1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#![feature(backtrace)]
mod compilation;
mod compilation_utils;
mod database;
mod queries;
mod sources_list;
mod top_crates;
use self::compilation::CompileManager;
use self::database::DatabaseManager;
use self::sources_list::CratesList;
use log_derive::logfn;
use std::path::Path;
use std::time::Duration;
#[logfn(Trace)]
pub fn initialise_with_top(sources_list_path: &Path, top_count: usize, all_versions: bool) {
let crates_list = CratesList::top_crates_by_download_count(top_count, all_versions);
crates_list.save(sources_list_path);
}
pub fn initialise_with_all(sources_list_path: &Path, all_versions: bool) {
let crates_list = CratesList::all_crates(all_versions);
crates_list.save(sources_list_path);
}
#[logfn(Trace)]
pub fn compile(
sources_list_path: &Path,
workspace: &Path,
toolchain: String,
max_log_size: usize,
memory_limit: Option<usize>,
timeout: Option<Duration>,
enable_networking: bool,
output_json: bool,
use_original_rustc: bool,
purge_build_dir: bool,
custom_registry: Option<String>,
) {
let crates_list = CratesList::load(sources_list_path);
let manager = CompileManager::new(
crates_list,
workspace,
toolchain,
max_log_size,
memory_limit,
timeout,
enable_networking,
output_json,
use_original_rustc,
purge_build_dir,
custom_registry,
);
manager
.compile_all()
.map_err(|e| panic!("Error: {}, {:?}", e, e.backtrace().map(|bt| bt.to_string())))
.unwrap();
}
#[logfn(Trace)]
pub fn check_compilation(workspace: &Path, delete_failures: bool) {
self::compilation_utils::check_compilation(workspace, delete_failures);
}
#[logfn(Trace)]
pub fn move_extracted(workspace: &Path, target_dir: &Path) {
self::compilation_utils::move_extracted(workspace, target_dir);
}
#[logfn(Trace)]
pub fn update_database(workspace: &Path, database_root: &Path) {
let mut manager = DatabaseManager::new(database_root);
manager.update_database(workspace);
}
#[logfn(Trace)]
pub fn run_query(
query_name: &str,
database_root: &Path,
report_path: &Path,
workspace_path: &Path,
sources_list_path: &Path,
) {
if !report_path.exists() {
std::fs::create_dir_all(&report_path).unwrap();
}
queries::run_query(
query_name,
database_root,
report_path,
workspace_path,
sources_list_path,
);
}