Skip to content

Commit

Permalink
refactor(gear-wasm-builder): put *.meta.txts along with other WASM…
Browse files Browse the repository at this point in the history
… binaries

Co-authored-by: Shamil <[email protected]>
  • Loading branch information
fluiderson and shamilsan authored Jul 26, 2023
1 parent 3eeea24 commit 3ae048d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gcli/tests/cmd/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Metadata {

#[test]
fn test_command_program_metadata_works() -> Result<()> {
let meta = env::example_path("new-meta/demo_new_meta.meta.txt");
let meta = env::wasm_bin("demo_new_meta.meta.txt");
let args = Args::new("program").action("meta").meta(meta);
let result = common::gcli(Vec::<String>::from(args)).expect("run gcli failed");

Expand All @@ -109,7 +109,7 @@ fn test_command_program_metadata_works() -> Result<()> {

#[test]
fn test_command_program_metadata_derive_works() -> Result<()> {
let meta = env::example_path("new-meta/demo_new_meta.meta.txt");
let meta = env::wasm_bin("demo_new_meta.meta.txt");
let args = Args::new("program")
.action("meta")
.meta(meta)
Expand Down
5 changes: 0 additions & 5 deletions gcli/tests/common/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,3 @@ pub fn bin(name: &str) -> String {
pub fn wasm_bin(name: &str) -> String {
bin_path(name, true)
}

/// path of `example/binaries` folders
pub fn example_path(name: &str) -> String {
ROOT.clone() + "/examples/" + name
}
2 changes: 1 addition & 1 deletion gcli/tests/gear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn paths() {
env::bin("gear"),
env::bin("gcli"),
env::wasm_bin("demo_new_meta.opt.wasm"),
env::example_path("new-meta/demo_new_meta.meta.txt"),
env::wasm_bin("demo_new_meta.meta.txt"),
]
.into_iter()
.for_each(|path| {
Expand Down
5 changes: 3 additions & 2 deletions utils/wasm-builder/src/wasm_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ impl WasmProject {

let mut source_code = "#![no_std] pub use orig_project::*;\n".to_owned();

fs::create_dir_all(&self.wasm_target_dir)?;

// Write metadata
if let Some(metadata) = &self.project_type.metadata() {
let file_base_name = self
Expand All @@ -222,7 +224,7 @@ impl WasmProject {
.expect("Run `WasmProject::create_project()` first");

let wasm_meta_path = self
.original_dir
.wasm_target_dir
.join([file_base_name, ".meta.txt"].concat());

smart_fs::write_metadata(wasm_meta_path, metadata)
Expand Down Expand Up @@ -397,7 +399,6 @@ extern "C" fn metahash() {{
.join(format!("{}.wasm", &file_base_name));

fs::create_dir_all(&self.target_dir)?;
fs::create_dir_all(&self.wasm_target_dir)?;

if self.project_type.is_metawasm() {
self.postprocess_meta(&original_wasm_path, file_base_name)?;
Expand Down

0 comments on commit 3ae048d

Please sign in to comment.