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

Install with cargo #29

Closed
wants to merge 7 commits into from
Closed

Install with cargo #29

wants to merge 7 commits into from

Conversation

ainozaki
Copy link
Contributor

@ainozaki ainozaki commented Mar 19, 2024

This PR enables installing Wasker with cargo.
In build.rs , LLVM is downloaded and installed into $HOME/.wasker .

@ainozaki
Copy link
Contributor Author

I'll update Dockerfile later..

@ainozaki ainozaki removed the request for review from saza-ku March 20, 2024 02:16

fn main() {
let llvm_version = "15.0.0";
let target = format!("clang+llvm-{}-x86_64-linux-gnu-rhel-8.4", llvm_version);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could automatically detect the platform, and remove the need to edit it.

Comment on lines +21 to +32
std::process::Command::new("wget")
.arg(&url)
.arg("-O")
.arg(format!("/tmp/{}.tar.xz", target))
.output()
.expect("Failed to download LLVM");

// Create directory
if !std::path::Path::new(&wasker_dir).exists() {
println!("Creating directory {:?}", wasker_dir);
std::fs::create_dir(&wasker_dir).expect("Failed to create directory");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could directly download the file, instead of using wget.

Comment on lines +35 to +42
println!("Extracting tar file to {:?}", wasker_dir);
std::process::Command::new("tar")
.arg("-xf")
.arg(format!("/tmp/{}.tar.xz", target))
.arg("-C")
.arg(wasker_dir)
.output()
.expect("Failed to extract tar file");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could directly extract tar files, instead of using tar command.

5: let target = format!("clang+llvm-{}-aarch64-linux-gnu-rhel-8.4", llvm_version);

# shell
export LLVM_SYS_150_PREFIX=~/.wasker/clang+llvm-15.0.0-aarch64-linux-gnu/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to automatically set the environment variable? By something like build.rs or cargo.toml?

https://stackoverflow.com/questions/57017066/how-do-i-set-environment-variables-with-cargo
https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-env

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it would be helpful if build.rs renames the LLVM directory to clang+llvm regardless of the platforms.

git clone [email protected]:mewz-project/wasker.git
cd Wasker
export LLVM_SYS_150_PREFIX=~/.wasker/clang+llvm-15.0.0-x86_64-linux-gnu-rhel-8.4/
cargo install wasker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cargo install wasker
cargo build

@saza-ku
Copy link
Contributor

saza-ku commented Mar 20, 2024

@ainozaki Oh sorry, it's still not ready for review.

@saza-ku saza-ku marked this pull request as draft March 20, 2024 08:36
@ainozaki
Copy link
Contributor Author

Thank you for comments 🙏
I realize cargo install is too heavy for just installing wasker CLI tool, because compiling wasker requires LLVM.
I would like to close this PR and move to #29

@ainozaki ainozaki closed this Mar 26, 2024
@saza-ku
Copy link
Contributor

saza-ku commented Mar 26, 2024

Sounds good

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

Successfully merging this pull request may close these issues.

2 participants