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

32 bit target and library build in CI #4

Merged
merged 2 commits into from
Aug 16, 2024
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
46 changes: 34 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
matrix:
target:
- x86_64-unknown-linux-gnu
- i686-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-gnu
- i686-pc-windows-gnu

steps:
- name: Checkout code
Expand All @@ -43,6 +45,9 @@ jobs:
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" ]; then
sudo apt-get install -y mingw-w64
fi
if [ "${{ matrix.target }}" = "i686-pc-windows-gnu" ]; then
sudo apt-get install -y gcc-mingw-w64-i686
fi
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
fi
Expand All @@ -52,25 +57,42 @@ jobs:
# build target for rust
echo "TARGET=${{ matrix.target }}" >> $GITHUB_ENV

- name: Build Binary
if [ "${{ matrix.target }}" = "x86_64-pc-windows-gnu" -o "${{ matrix.target }}" = "i686-pc-windows-gnu" ]; then
# windows 64+32
echo "DEBUG_BINARY_NAME=target/${{ matrix.target }}/debug/ifstat-rs.exe" >> $GITHUB_ENV
echo "DEBUG_LIBRARY_NAME=target/${{ matrix.target }}/debug/ifstat_rs.dll" >> $GITHUB_ENV
echo "RELEASE_BINARY_NAME=target/${{ matrix.target }}/release/ifstat-rs.exe" >> $GITHUB_ENV
echo "RELEASE_LIBRARY_NAME=target/${{ matrix.target }}/release/ifstat_rs.dll" >> $GITHUB_ENV
else
echo "DEBUG_BINARY_NAME=target/${{ matrix.target }}/debug/ifstat-rs" >> $GITHUB_ENV
echo "DEBUG_LIBRARY_NAME=target/${{ matrix.target }}/debug/libifstat_rs.so" >> $GITHUB_ENV
echo "RELEASE_BINARY_NAME=target/${{ matrix.target }}/release/ifstat-rs" >> $GITHUB_ENV
echo "RELEASE_LIBRARY_NAME=target/${{ matrix.target }}/release/libifstat_rs.so" >> $GITHUB_ENV
fi

mkdir -p build_output/{debug,release}

- name: Build Binary (Debug)
run: |
cargo build --target "${{ matrix.target }}"
mkdir -p build_output
cp target/${{ matrix.target }}/debug/ifstat-rs${{ matrix.target == 'x86_64-pc-windows-gnu' && '.exe' || '' }} build_output/
cp ${{ env.DEBUG_BINARY_NAME }} build_output/debug/

- name: Build Library
- name: Build Binary (Release)
run: |
cargo build --target "${{ matrix.target }}" --release
cp ${{ env.RELEASE_BINARY_NAME }} build_output/release/

- name: Build Library (Debug)
run: |
cargo build --target "${{ matrix.target }}" --lib
mkdir -p build_output
cp ${{ env.DEBUG_LIBRARY_NAME }} build_output/debug/

# handle different name under windows
if [ "${{ matrix.target }}" != "x86_64-pc-windows-gnu" ]; then
cp target/${{ matrix.target }}/debug/libifstat_rs${{ matrix.target == 'x86_64-pc-windows-gnu' && '.dll' || '.so' }} build_output/
else
cp target/${{ matrix.target }}/debug/ifstat_rs.dll build_output/
fi
- name: Build Library (Release)
run: |
cargo build --target "${{ matrix.target }}" --lib --release
cp ${{ env.RELEASE_LIBRARY_NAME }} build_output/release/

- name: Upload built Binary + Library
- name: Upload built (Binary + Library)x(Debug + Release) bundle
uses: actions/upload-artifact@v4
with:
path: build_output/
Expand Down
2 changes: 1 addition & 1 deletion src/net_stats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub extern "C" fn GetNetDevStats() -> *mut c_char {
pub extern "C" fn FreeCString(s: *mut c_char) {
if !s.is_null() {
unsafe {
let _ = CString::from_raw(s); // This will automatically free the memory
drop(CString::from_raw(s));
}
}
}
Loading