Debian Codegraph @

tests/build.rs

raw symbols SCIP
1 #![allow(dead_code)]
2
3 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/;
4 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#;
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/;
6 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#;
9 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#;
10
11 use tempfilerust-analyzer cargo tempfile 3.27.0 crate/::TempDirrust-analyzer cargo tempfile 3.27.0 dir/TempDir#;
12
13 #[macro_use]
14 #[path = "../build/macros.rs"]
15 mod macrosrust-analyzer cargo clang-sys 1.8.1 macros/;
16
17 #[path = "../build/common.rs"]
18 mod commonrust-analyzer cargo clang-sys 1.8.1 common/;
19 #[path = "../build/dynamic.rs"]
20 mod dynamicrust-analyzer cargo clang-sys 1.8.1 dynamic/;
21 #[path = "../build/static.rs"]
22 mod r#staticrust-analyzer cargo clang-sys 1.8.1 `r#static`/;
23
24 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
25 struct RunCommandMockrust-analyzer cargo clang-sys 1.8.1 RunCommandMock# {
26 invocationsrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#invocations.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>)>,
27 responsesrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#responses.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
28 }
29
30
31 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
32 enum Archrust-analyzer cargo clang-sys 1.8.1 Arch# {
33 ARM64rust-analyzer cargo clang-sys 1.8.1 Arch#ARM64#,
34 X86rust-analyzer cargo clang-sys 1.8.1 Arch#X86#,
35 X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#,
36 }
37
38 impl Archrust-analyzer cargo clang-sys 1.8.1 Arch# {
39 fn pe_machine_typerust-analyzer cargo clang-sys 1.8.1 impl#[Arch]pe_machine_type().(self) -> u16 {
40 match self {
41 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::ARM64rust-analyzer cargo clang-sys 1.8.1 Arch#ARM64# => 0xAA64,
42 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86rust-analyzer cargo clang-sys 1.8.1 Arch#X86# => 0x014C,
43 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64# => 0x8664,
44 }
45 }
46 }
47
48 impl fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Archrust-analyzer cargo clang-sys 1.8.1 Arch# {
49 fn fmtrust-analyzer cargo clang-sys 1.8.1 impl#[Arch][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
50 match self {
51 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::ARM64rust-analyzer cargo clang-sys 1.8.1 Arch#ARM64# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "aarch64"),
52 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86rust-analyzer cargo clang-sys 1.8.1 Arch#X86# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "x86"),
53 Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "x86_64"),
54 }
55 }
56 }
57
58 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
59 struct Envrust-analyzer cargo clang-sys 1.8.1 Env# {
60 osrust-analyzer cargo clang-sys 1.8.1 Env#os.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
61 archrust-analyzer cargo clang-sys 1.8.1 Env#arch.: Archrust-analyzer cargo clang-sys 1.8.1 Arch#,
62 pointer_widthrust-analyzer cargo clang-sys 1.8.1 Env#pointer_width.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
63 envrust-analyzer cargo clang-sys 1.8.1 Env#env.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
64 varsrust-analyzer cargo clang-sys 1.8.1 Env#vars.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, (Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>)>,
65 cwdrust-analyzer cargo clang-sys 1.8.1 Env#cwd.: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
66 tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp.: TempDirrust-analyzer cargo tempfile 3.27.0 dir/TempDir#,
67 filesrust-analyzer cargo clang-sys 1.8.1 Env#files.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
68 commandsrust-analyzer cargo clang-sys 1.8.1 Env#commands.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#<RunCommandMockrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#>>,
69 }
70
71 impl Envrust-analyzer cargo clang-sys 1.8.1 Env# {
72 fn newrust-analyzer cargo clang-sys 1.8.1 impl#[Env]new().(os: &str, arch: Archrust-analyzer cargo clang-sys 1.8.1 Arch#, pointer_width: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
73 Envrust-analyzer cargo clang-sys 1.8.1 Env# {
74 osrust-analyzer cargo clang-sys 1.8.1 Env#os.: os.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
75 archrust-analyzer cargo clang-sys 1.8.1 Env#arch.,
76 pointer_widthrust-analyzer cargo clang-sys 1.8.1 Env#pointer_width.: pointer_width.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
77 envrust-analyzer cargo clang-sys 1.8.1 Env#env.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
78 varsrust-analyzer cargo clang-sys 1.8.1 Env#vars.: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(),
79 cwdrust-analyzer cargo clang-sys 1.8.1 Env#cwd.: envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::current_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/current_dir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
80 tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp.: tempfilerust-analyzer cargo tempfile 3.27.0 crate/::Builderrust-analyzer cargo tempfile 3.27.0 Builder#::newrust-analyzer cargo tempfile 3.27.0 impl#[`Builder<'a, 'b>`]new().().prefixrust-analyzer cargo tempfile 3.27.0 impl#[`Builder<'a, 'b>`]prefix().("clang_sys_test").tempdirrust-analyzer cargo tempfile 3.27.0 impl#[`Builder<'a, 'b>`]tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(),
81 filesrust-analyzer cargo clang-sys 1.8.1 Env#files.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
82 commandsrust-analyzer cargo clang-sys 1.8.1 Env#commands.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`][Default]default().(),
83 }
84 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("CLANG_PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
85 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("LD_LIBRARY_PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
86 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("LIBCLANG_PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
87 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("LIBCLANG_STATIC_PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
88 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("LLVM_CONFIG_PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
89 .varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().("PATH", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)
90 }
91
92 fn envrust-analyzer cargo clang-sys 1.8.1 impl#[Env]env().(mut self, env: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
93 self.envrust-analyzer cargo clang-sys 1.8.1 Env#env. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(env.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
94 self
95 }
96
97 fn varrust-analyzer cargo clang-sys 1.8.1 impl#[Env]var().(mut self, name: &str, value: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str>) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
98 let previous = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().(name).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().();
99 self.varsrust-analyzer cargo clang-sys 1.8.1 Env#vars..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), (value.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|v| v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), previous));
100 self
101 }
102
103 fn dirrust-analyzer cargo clang-sys 1.8.1 impl#[Env]dir().(mut self, path: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
104 self.filesrust-analyzer cargo clang-sys 1.8.1 Env#files..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(path.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
105 let path = self.tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp..pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(path);
106 fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::create_dir_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir_all().(path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
107 self
108 }
109
110 fn filerust-analyzer cargo clang-sys 1.8.1 impl#[Env]file().(mut self, path: &str, contents: &[u8]) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
111 self.filesrust-analyzer cargo clang-sys 1.8.1 Env#files..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(path.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
112 let path = self.tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp..pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(path);
113 fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::create_dir_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir_all().(path.parentrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]parent().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
114 fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(self.tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp..pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(path), contents).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
115 self
116 }
117
118 fn dllrust-analyzer cargo clang-sys 1.8.1 impl#[Env]dll().(self, path: &str, arch: Archrust-analyzer cargo clang-sys 1.8.1 Arch#, pointer_width: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
119 // PE header.
120 let mut contents = [0; 64];
121 contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().0x3C..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#0x3C rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&i32::to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]to_le_bytes().(10));
122 contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().10..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#14]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&[b'P', b'E', 0, 0]);
123 contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().14..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#16]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&u16::to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().(arch.pe_machine_typerust-analyzer cargo clang-sys 1.8.1 impl#[Arch]pe_machine_type().()));
124 let magic = if pointer_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."64" { 523 } else { 267 };
125 contents[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().34..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#36]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&u16::to_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u16]to_le_bytes().(magic));
126
127 self.filerust-analyzer cargo clang-sys 1.8.1 impl#[Env]file().(path, &contents)
128 }
129
130 fn sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().(self, path: &str, pointer_width: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
131 // ELF header.
132 let class = if pointer_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq()."64" { 2 } else { 1 };
133 let contents = [127, 69, 76, 70, class];
134
135 self.filerust-analyzer cargo clang-sys 1.8.1 impl#[Env]file().(path, &contents)
136 }
137
138 fn commandrust-analyzer cargo clang-sys 1.8.1 impl#[Env]command().(self, command: &str, args: &[&str], response: &str) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
139 let command = command.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
140 let args = args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|a| a.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
141
142 let mut key = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![command];
143 key.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(args);
144 self.commandsrust-analyzer cargo clang-sys 1.8.1 Env#commands..lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().responsesrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#responses..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(key, response.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
145
146 self
147 }
148
149 fn enablerust-analyzer cargo clang-sys 1.8.1 impl#[Env]enable().(self) -> Selfrust-analyzer cargo clang-sys 1.8.1 impl#[Env] {
150 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("_CLANG_SYS_TEST", "yep");
151 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("_CLANG_SYS_TEST_OS", &self.osrust-analyzer cargo clang-sys 1.8.1 Env#os.);
152 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("_CLANG_SYS_TEST_ARCH", &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{}", self.archrust-analyzer cargo clang-sys 1.8.1 Env#arch.));
153 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("_CLANG_SYS_TEST_POINTER_WIDTH", &self.pointer_widthrust-analyzer cargo clang-sys 1.8.1 Env#pointer_width.);
154 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(env) = &self.envrust-analyzer cargo clang-sys 1.8.1 Env#env. {
155 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().("_CLANG_SYS_TEST_ENV", env);
156 }
157
158 for (name, (value, _)) in &self.varsrust-analyzer cargo clang-sys 1.8.1 Env#vars. {
159 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value) = value {
160 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().(name, value);
161 } else {
162 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().(name);
163 }
164 }
165
166 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_current_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_current_dir().(&self.tmprust-analyzer cargo clang-sys 1.8.1 Env#tmp.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
167
168 let commands = self.commandsrust-analyzer cargo clang-sys 1.8.1 Env#commands..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().();
169 let mock = &mut *rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][DerefMut]deref_mut().commonrust-analyzer cargo clang-sys 1.8.1 common/::RUN_COMMAND_MOCKrust-analyzer cargo clang-sys 1.8.1 common/RUN_COMMAND_MOCK..lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
170 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().mock = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(move |command, path, args| {
171 let command = command.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
172 let path = path.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
173 let args = args.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|a| a.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>();
174
175 let mut commands = commands.lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
176 commands.invocationsrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#invocations..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().((command.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), path, args.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().()));
177
178 let mut key = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![command];
179 key.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(args);
180 commands.responsesrust-analyzer cargo clang-sys 1.8.1 RunCommandMock#responses..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&key).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().()
181 }));
182
183 self
184 }
185 }
186
187 impl Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for Envrust-analyzer cargo clang-sys 1.8.1 Env# {
188 fn droprust-analyzer cargo clang-sys 1.8.1 impl#[Env][Drop]drop().(&mut self) {
189 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("_CLANG_SYS_TEST");
190 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("_CLANG_SYS_TEST_OS");
191 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("_CLANG_SYS_TEST_ARCH");
192 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("_CLANG_SYS_TEST_POINTER_WIDTH");
193 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().("_CLANG_SYS_TEST_ENV");
194
195 for (name, (_, previous)) in &self.varsrust-analyzer cargo clang-sys 1.8.1 Env#vars. {
196 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(previous) = previous {
197 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_var().(name, previous);
198 } else {
199 envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::remove_varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/remove_var().(name);
200 }
201 }
202
203 if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(error) = envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::set_current_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/set_current_dir().(&self.cwdrust-analyzer cargo clang-sys 1.8.1 Env#cwd.) {
204 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Failed to reset working directory: {:?}", error);
205 }
206 }
207 }
208
209 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
210 fn test_allrust-analyzer cargo clang-sys 1.8.1 test_all().() {
211 // Run tests serially since they alter the environment.
212
213 test_linux_directory_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_directory_preference().();
214 test_linux_version_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_version_preference().();
215 test_linux_directory_and_version_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_directory_and_version_preference().();
216
217 #[cfg(target_os = "windows")]
218 {
219 test_windows_bin_sibling();
220 test_windows_mingw_gnu();
221 test_windows_mingw_msvc();
222 test_windows_arm64_on_x86_64();
223 test_windows_x86_64_on_arm64();
224 }
225 }
226
227 macro_rules! assert_errorrust-analyzer cargo clang-sys 1.8.1 assert_error! {
228 ($result:expr, $contents:expr $(,)?) => {
229 if let Err(error) = $result {
230 if !error.contains($contents) {
231 panic!("expected error to contain {:?}, received: {error:?}", $contents);
232 }
233 } else {
234 panic!("expected error, received: {:?}", $result);
235 }
236 };
237 }
238
239 //================================================
240 // Dynamic
241 //================================================
242
243 // Linux -----------------------------------------
244
245 fn test_linux_directory_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_directory_preference().() {
246 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::newrust-analyzer cargo clang-sys 1.8.1 impl#[Env]new().("linux", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
247 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/lib/libclang.so.1", "64")
248 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/local/lib/libclang.so.1", "64")
249 .enablerust-analyzer cargo clang-sys 1.8.1 impl#[Env]enable().();
250
251 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
252 dynamicrust-analyzer cargo clang-sys 1.8.1 dynamic/::findrust-analyzer cargo clang-sys 1.8.1 dynamic/find().(true),
253 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(("usr/local/lib".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "libclang.so.1".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())),
254 );
255 }
256
257 fn test_linux_version_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_version_preference().() {
258 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::newrust-analyzer cargo clang-sys 1.8.1 impl#[Env]new().("linux", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
259 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/lib/libclang-3.so", "64")
260 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/lib/libclang-3.5.so", "64")
261 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/lib/libclang-3.5.0.so", "64")
262 .enablerust-analyzer cargo clang-sys 1.8.1 impl#[Env]enable().();
263
264 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
265 dynamicrust-analyzer cargo clang-sys 1.8.1 dynamic/::findrust-analyzer cargo clang-sys 1.8.1 dynamic/find().(true),
266 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(("usr/lib".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "libclang-3.5.0.so".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())),
267 );
268 }
269
270 fn test_linux_directory_and_version_preferencerust-analyzer cargo clang-sys 1.8.1 test_linux_directory_and_version_preference().() {
271 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::newrust-analyzer cargo clang-sys 1.8.1 impl#[Env]new().("linux", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
272 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/local/llvm/lib/libclang-3.so", "64")
273 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/local/lib/libclang-3.5.so", "64")
274 .sorust-analyzer cargo clang-sys 1.8.1 impl#[Env]so().("usr/lib/libclang-3.5.0.so", "64")
275 .enablerust-analyzer cargo clang-sys 1.8.1 impl#[Env]enable().();
276
277 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
278 dynamicrust-analyzer cargo clang-sys 1.8.1 dynamic/::findrust-analyzer cargo clang-sys 1.8.1 dynamic/find().(true),
279 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(("usr/lib".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(), "libclang-3.5.0.so".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())),
280 );
281 }
282
283 // Windows ---------------------------------------
284
285 #[cfg(target_os = "windows")]
286 fn test_windows_bin_sibling() {
287 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::new("windows", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
288 .dir("Program Files\\LLVM\\lib")
289 .dll("Program Files\\LLVM\\bin\\libclang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
290 .enable();
291
292 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
293 dynamic::find(true),
294 Ok(("Program Files\\LLVM\\bin".into(), "libclang.dll".into())),
295 );
296 }
297
298 #[cfg(target_os = "windows")]
299 fn test_windows_mingw_gnu() {
300 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::new("windows", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
301 .env("gnu")
302 .dir("MSYS\\MinGW\\lib")
303 .dll("MSYS\\MinGW\\bin\\clang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
304 .dir("Program Files\\LLVM\\lib")
305 .dll("Program Files\\LLVM\\bin\\libclang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
306 .enable();
307
308 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
309 dynamic::find(true),
310 Ok(("MSYS\\MinGW\\bin".into(), "clang.dll".into())),
311 );
312 }
313
314 #[cfg(target_os = "windows")]
315 fn test_windows_mingw_msvc() {
316 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::new("windows", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
317 .env("msvc")
318 .dir("MSYS\\MinGW\\lib")
319 .dll("MSYS\\MinGW\\bin\\clang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
320 .dir("Program Files\\LLVM\\lib")
321 .dll("Program Files\\LLVM\\bin\\libclang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
322 .enable();
323
324 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
325 dynamic::find(true),
326 Ok(("Program Files\\LLVM\\bin".into(), "libclang.dll".into())),
327 );
328 }
329
330 #[cfg(target_os = "windows")]
331 fn test_windows_arm64_on_x86_64() {
332 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::new("windows", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
333 .env("msvc")
334 .dir("Program Files\\LLVM\\lib")
335 .dll("Program Files\\LLVM\\bin\\libclang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::ARM64rust-analyzer cargo clang-sys 1.8.1 Arch#ARM64#, "64")
336 .enable();
337
338 assert_errorrust-analyzer cargo clang-sys 1.8.1 assert_error!!(
339 dynamic::find(true),
340 "invalid: [(Program Files\\LLVM\\bin\\libclang.dll: invalid DLL (ARM64)",
341 );
342 }
343
344 #[cfg(target_os = "windows")]
345 fn test_windows_x86_64_on_arm64() {
346 let _env = Envrust-analyzer cargo clang-sys 1.8.1 Env#::new("windows", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::ARM64rust-analyzer cargo clang-sys 1.8.1 Arch#ARM64#, "64")
347 .env("msvc")
348 .dir("Program Files\\LLVM\\lib")
349 .dll("Program Files\\LLVM\\bin\\libclang.dll", Archrust-analyzer cargo clang-sys 1.8.1 Arch#::X86_64rust-analyzer cargo clang-sys 1.8.1 Arch#X86_64#, "64")
350 .enable();
351
352 assert_errorrust-analyzer cargo clang-sys 1.8.1 assert_error!!(
353 dynamic::find(true),
354 "invalid: [(Program Files\\LLVM\\bin\\libclang.dll: invalid DLL (x86-64)",
355 );
356 }