Skip to content

Commit

Permalink
Add a shared library building test
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Feb 17, 2022
1 parent 995edd6 commit 4dd4a22
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
rustup target add aarch64-unknown-linux-gnu
cargo run zigbuild --target aarch64-unknown-linux-gnu
cargo run zigbuild --target aarch64-unknown-linux-gnu.2.17
# Test building shared library
cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/libhello/Cargo.toml
- name: Linux - Test musl libc build
run: |
rustup target add aarch64-unknown-linux-musl
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/target
target/
6 changes: 5 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ impl Build {
let target_dir = self
.target_dir
.clone()
.or_else(|| self.manifest_path.as_ref().map(|m| m.join("target")))
.or_else(|| {
self.manifest_path
.as_ref()
.map(|m| m.parent().unwrap().join("target"))
})
.unwrap_or_else(|| {
env::current_dir()
.expect("Failed to get current working directory")
Expand Down
7 changes: 7 additions & 0 deletions tests/libhello/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/libhello/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "hello"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib"]

[dependencies]
4 changes: 4 additions & 0 deletions tests/libhello/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[no_mangle]
pub extern "C" fn hello() {
println!("hello");
}

0 comments on commit 4dd4a22

Please sign in to comment.