Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine wasm binary filename based on CPU architecture #334

Open
larry0x opened this issue Oct 7, 2023 · 2 comments
Open

Determine wasm binary filename based on CPU architecture #334

larry0x opened this issue Oct 7, 2023 · 2 comments

Comments

@larry0x
Copy link
Contributor

larry0x commented Oct 7, 2023

In mars-integration-test, we load the wasm binary file the following way:

let path = format!("../{artifacts_dir}/{snaked_name}.wasm");

However, on ARM computers, the filename generated is instead contract_name-aarch64.wasm, which causes the test to fail.

I suggest we do something like this (untested, not sure if will work):

let path = {
    #[cfg(target_arch = "aarch64")]
    format!("../{artifacts_dir}/{snaked_name}-aarch64.wasm")
    #[cfg(not(target_arch = "aarch64"))]
    format!("../{artifacts_dir}/{snaked_name}.wasm")
};
@larry0x
Copy link
Contributor Author

larry0x commented Oct 7, 2023

The same case in the tests for mars-swapper-osmosis

@larry0x
Copy link
Contributor Author

larry0x commented Jan 17, 2024

This can be done using the cfg-if crate:

use cfg_if::cfg_if;
use std::{env, path::PathBuf};

let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
let wasm_file_path = manifest_dir.join({
    cfg_if! {
        if #[cfg(target_arch = "aarch64")] {
            "../../artifacts/cw_bank-aarch64.wasm"
        } else {
            "../../artifacts/cw_bank.wasm"
        }
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant