MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / build

Method build

crates/test-programs/artifacts/build.rs:41–172  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

39
40impl Artifacts {
41 fn build(&mut self) {
42 let mut generated_code = String::new();
43 // Build adapters used below for componentization.
44 let reactor_adapter = self.build_adapter(&mut generated_code, "reactor", &[]);
45 let command_adapter = self.build_adapter(
46 &mut generated_code,
47 "command",
48 &["--no-default-features", "--features=command"],
49 );
50 let proxy_adapter = self.build_adapter(
51 &mut generated_code,
52 "proxy",
53 &["--no-default-features", "--features=proxy"],
54 );
55
56 // Build all test programs both in Rust and C/C++.
57 let mut tests = Vec::new();
58 self.build_rust_tests(&mut tests);
59 self.build_non_rust_tests(&mut tests);
60
61 // With all our `tests` now compiled generate various macos for each
62 // test along with constants pointing to various paths. Note that
63 // components are created here as well from core modules.
64 let mut kinds = BTreeMap::new();
65 let missing_sdk_path =
66 PathBuf::from("Asset not compiled, WASI_SDK_PATH missing at compile time");
67 let mut components = Vec::new();
68 for test in tests.iter() {
69 let shouty_snake = test.name.to_shouty_snake_case();
70 let snake = test.name.to_snake_case();
71
72 let core_wasm = test.core_wasm.as_deref().unwrap_or(&missing_sdk_path);
73 generated_code +=
74 &format!("pub const {shouty_snake}: &'static str = {core_wasm:?};\n",);
75 generated_code += &format!(
76 "#[macro_export] macro_rules! {snake}_bytes {{
77 () => {{ include_bytes!({core_wasm:?}) }}
78 }}",
79 );
80
81 // Bucket, based on the name of the test, into a "kind" which
82 // generates a `foreach_*` macro below.
83 let kind = match test.name.as_str() {
84 s if s.starts_with("p1_cli_")
85 || s.starts_with("p2_cli_")
86 || s.starts_with("p3_cli_") =>
87 {
88 "cli"
89 }
90 s if s.starts_with("p1_") => "p1",
91 s if s.starts_with("p2_http_") => "p2_http",
92 s if s.starts_with("p2_api_") => "p2_api",
93 s if s.starts_with("p2_tls_") => "p2_tls",
94 s if s.starts_with("p2_") => "p2",
95 s if s.starts_with("p3_http_") => "p3_http",
96 s if s.starts_with("p3_api_") => "p3_api",
97 s if s.starts_with("p3_tls_") => "p3_tls",
98 s if s.starts_with("p3_") => "p3",

Callers 1

mainFunction · 0.45

Calls 15

fromFunction · 0.85
build_adapterMethod · 0.80
build_rust_testsMethod · 0.80
build_non_rust_testsMethod · 0.80
or_insertMethod · 0.80
to_strMethod · 0.80
newFunction · 0.50
writeFunction · 0.50
iterMethod · 0.45
as_strMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected