Skip to content

Commit

Permalink
chore: tweak refs (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen authored Jul 25, 2024
1 parent 3b3a34b commit 4e91b43
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
12 changes: 8 additions & 4 deletions crates/moon/src/cli/generate_test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,12 @@ pub fn generate_test_driver(
pkgname
)
}
let generated_content =
generate_driver(&mbts_test_data, pkgname, &filter_file, &filter_index);
let generated_content = generate_driver(
&mbts_test_data,
pkgname,
filter_file.as_deref(),
filter_index,
);
let generated_file = target_dir.join(pkg.rel.fs_full_name()).join(driver_name);

if !generated_file.parent().unwrap().exists() {
Expand All @@ -186,8 +190,8 @@ pub fn generate_test_driver(
fn generate_driver(
data: &str,
pkgname: &str,
file_filter: &Option<String>,
index_filter: &Option<u32>,
file_filter: Option<&str>,
index_filter: Option<u32>,
) -> String {
let test_driver_template = {
let template = include_str!(concat!(
Expand Down
30 changes: 15 additions & 15 deletions crates/moonbuild/src/gen/gen_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ pub fn gen_link_command(
heap_start_address.unwrap().to_string(),
]
})
.lazy_args_with_cond(link_flags.is_some(), || link_flags.unwrap())
.lazy_args_with_cond(link_flags.is_some(), || link_flags.unwrap().into())
.lazy_args_with_cond(
moonc_opt.link_opt.target_backend == moonutil::common::TargetBackend::Js
&& item.link.is_some()
Expand Down Expand Up @@ -450,36 +450,36 @@ pub fn gen_n2_build_state(

#[rustfmt::skip]
impl LinkDepItem {
pub fn wasm_exports(&self) -> Option<&Vec<String>> { self.link.as_ref()?.wasm.as_ref()?.exports.as_ref() }
pub fn wasm_export_memory_name(&self) -> Option<&String> { self.link.as_ref()?.wasm.as_ref()?.export_memory_name.as_ref() }
pub fn wasm_exports(&self) -> Option<&[String]> { self.link.as_ref()?.wasm.as_ref()?.exports.as_deref() }
pub fn wasm_export_memory_name(&self) -> Option<&str> { self.link.as_ref()?.wasm.as_ref()?.export_memory_name.as_deref() }
pub fn wasm_import_memory(&self) -> Option<&moonutil::package::ImportMemory> { self.link.as_ref()?.wasm.as_ref()?.import_memory.as_ref() }
pub fn wasm_heap_start_address(&self) -> Option<&u32> { self.link.as_ref()?.wasm.as_ref()?.heap_start_address.as_ref() }
pub fn wasm_link_flags(&self) -> Option<&Vec<String>> { self.link.as_ref()?.wasm.as_ref()?.flags.as_ref() }
pub fn wasm_heap_start_address(&self) -> Option<u32> { self.link.as_ref()?.wasm.as_ref()?.heap_start_address }
pub fn wasm_link_flags(&self) -> Option<&[String]> { self.link.as_ref()?.wasm.as_ref()?.flags.as_deref() }

pub fn wasm_gc_exports(&self) -> Option<&Vec<String>> { self.link.as_ref()?.wasm_gc.as_ref()?.exports.as_ref() }
pub fn wasm_gc_export_memory_name(&self) -> Option<&String> { self.link.as_ref()?.wasm_gc.as_ref()?.export_memory_name.as_ref() }
pub fn wasm_gc_exports(&self) -> Option<&[String]> { self.link.as_ref()?.wasm_gc.as_ref()?.exports.as_deref() }
pub fn wasm_gc_export_memory_name(&self) -> Option<&str> { self.link.as_ref()?.wasm_gc.as_ref()?.export_memory_name.as_deref() }
pub fn wasm_gc_import_memory(&self) -> Option<&moonutil::package::ImportMemory> { self.link.as_ref()?.wasm_gc.as_ref()?.import_memory.as_ref() }
pub fn wasm_gc_link_flags(&self) -> Option<&Vec<String>> { self.link.as_ref()?.wasm_gc.as_ref()?.flags.as_ref() }
pub fn wasm_gc_link_flags(&self) -> Option<&[String]> { self.link.as_ref()?.wasm_gc.as_ref()?.flags.as_deref() }

pub fn js_exports(&self) -> Option<&Vec<String>> { self.link.as_ref()?.js.as_ref()?.exports.as_ref() }
pub fn js_exports(&self) -> Option<&[String]> { self.link.as_ref()?.js.as_ref()?.exports.as_deref() }

pub fn exports(&self, b: TargetBackend) -> Option<&Vec<String>> {
pub fn exports(&self, b: TargetBackend) -> Option<&[String]> {
match b {
Wasm => self.wasm_exports(),
WasmGC => self.wasm_gc_exports(),
Js => self.js_exports(),
}
}

pub fn export_memory_name(&self, b: TargetBackend) -> Option<&String> {
pub fn export_memory_name(&self, b: TargetBackend) -> Option<&str> {
match b {
Wasm => self.wasm_export_memory_name(),
WasmGC => self.wasm_gc_export_memory_name(),
Js => None,
}
}

pub fn heap_start_address(&self, b: TargetBackend) -> Option<&u32> {
pub fn heap_start_address(&self, b: TargetBackend) -> Option<u32> {
match b {
Wasm => self.wasm_heap_start_address(),
WasmGC => None,
Expand All @@ -495,10 +495,10 @@ impl LinkDepItem {
}
}

pub fn link_flags(&self, b: TargetBackend) -> Option<Vec<String>> {
pub fn link_flags(&self, b: TargetBackend) -> Option<&[String]> {
match b {
Wasm => self.wasm_link_flags().cloned(),
WasmGC => self.wasm_gc_link_flags().cloned(),
Wasm => self.wasm_link_flags(),
WasmGC => self.wasm_gc_link_flags(),
Js => None,
}
}
Expand Down

0 comments on commit 4e91b43

Please sign in to comment.