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

build: fix missing libatomic on armv7 Linux #20

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
target: armv7-unknown-linux-gnueabihf
setup: |
sudo apt-get update
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y
sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libatomic1-armhf-cross -y
build: |
yarn build --target armv7-unknown-linux-gnueabihf --zig --zig-link-only
arm-linux-gnueabihf-strip *.node
Expand Down
17 changes: 15 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@ extern crate napi_build;
fn main() {
napi_build::setup();
let compile_target = std::env::var("TARGET").unwrap();
if compile_target == "x86_64-unknown-linux-gnu" {
println!("cargo:rustc-link-search=/usr/x86_64-unknown-linux-gnu/lib");
match compile_target.as_str() {
"x86_64-unknown-linux-gnu" => {
println!("cargo:rustc-link-search=/usr/x86_64-unknown-linux-gnu/lib");
}
"armv7-unknown-linux-gnueabihf" => {
const CROSS_LIB_PATH: &str = "/usr/lib/gcc-cross/arm-linux-gnueabihf";
if let Ok(version) = std::process::Command::new("ls")
.arg(CROSS_LIB_PATH)
.output()
.map(|o| String::from_utf8(o.stdout).unwrap().trim().to_string())
{
println!("cargo:rustc-link-search={CROSS_LIB_PATH}/{version}");
};
}
_ => {}
}
}