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

Add the example workspace to the CI #427

Closed
wants to merge 2 commits into from
Closed
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
18 changes: 14 additions & 4 deletions .github/workflows/example-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,32 @@ jobs:
run: |
cargo cbuild --verbose --release

- name: Build C API for example workspace
working-directory: example-workspace
run: |
cargo cbuild --verbose --release

- name: Run C API tests for example project
working-directory: example-project
run: |
cargo ctest --verbose --release

- name: Install into temporary location
- name: Install into temporary location the example project
working-directory: example-project
run: |
cargo cinstall --verbose --release --destdir=temp

- name: Install into temporary location the example workspace
working-directory: example-workspace
run: |
cargo cinstall --verbose --release --destdir=temp

- name: Copy installed files to /usr/local
if: startsWith(matrix.os, 'macos') || startsWith(matrix.os, 'ubuntu')
working-directory: example-project
run: |
sudo cp -r temp/usr/local/* /usr/local/

- name: Install into Cargo root
if: startsWith(matrix.os, 'windows')
shell: bash
Expand All @@ -82,13 +92,13 @@ jobs:
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: pkgconf

- name: Setup Meson + Ninja
if: startsWith(matrix.os, 'windows')
run: |
python3 -m pip install --upgrade pip setuptools wheel
python3 -m pip install meson ninja

- name: Setup MSVC for test
if: startsWith(matrix.os, 'windows')
uses: ilammy/msvc-dev-cmd@v1
Expand Down
1 change: 1 addition & 0 deletions example-workspace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
members = [
"api-a",
"api-b",
"api-c",
]
19 changes: 19 additions & 0 deletions example-workspace/api-c/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "api-c"
version = "0.1.0"
authors = ["Luca Barbato <[email protected]>"]
edition = "2021"

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

[features]
capi = ["libc"]

[dependencies]
libc = { version = "0.2", optional = true }

[package.metadata.capi.library]
name = "name_with_underscore-and-dashes"
version_suffix_components = 3
rustflags = "-Cmetadata=name_with_underscore-and-dashes"

15 changes: 15 additions & 0 deletions example-workspace/api-c/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#[cfg(feature = "capi")]
mod capi {
#[no_mangle]
extern "C" fn info() {
eprintln!("C-API");
}
}

#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}