Skip to content

Commit

Permalink
Change the build to use Example instead of c-example as the output dir
Browse files Browse the repository at this point in the history
Change the action so that steps run in parallel. This also makes it easier to add more builds and do the tests... if I can figure out to compile for different archetectures.
  • Loading branch information
NSoiffer committed Nov 6, 2024
1 parent 30fd596 commit 840b4ca
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 51 deletions.
203 changes: 153 additions & 50 deletions .github/workflows/automaticRelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,64 +4,170 @@ on:
push:
branches:
- main
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * 6'
# schedule:
# # * is a special character in YAML so you have to quote this string
# - cron: '0 0 * * 6'

jobs:
zip-rules:
name: zip up the rules directory
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Rust Library
run: |
cargo build --target x86_64-unknown-linux-gnu # doesn't need a release build since all that we want is the Rules dir
- name: create rules.zip
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: 'Rules.zip'
directory: 'addon/globalPlugins/MathCAT'
path: 'Rules'
- name: Upload Rules.zip
uses: actions/upload-artifact@v4
with:
name: 'Rules.zip'
path: 'addon/globalPlugins/MathCAT/Rules.zip'
compression-level: 0
retention-days: 1

rust-32-win:
name: Build 32 bit windows dll
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build 32 bit version
run: cargo build --target i686-pc-windows-msvc --release
# HOW DO GET A 32 BIT GCC TO RUN?
# - name: Setup Example dir and test build
# run: |
# cp target/i686-pc-windows-msvc/release/libmathcat_c.dll Example/
# cd Example
# gcc -m32 test.cpp -o test -L. -llibmathcat_c
# ./test.exe
# gcc test.c -o test -L. -llibmathcat_c
# ./test.exe
- name: create zip file for dll file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_c.dll-32-win.zip'
directory: 'Example'
path: 'libmathcat_c.dll'
- name: Upload 32 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_c.dll-32-win.zip
path: libmathcat_c.dll-32-win.zip
compression-level: 0
retention-days: 1
- name: Upload Example Dir
uses: actions/upload-artifact@v4
with:
name: Example
path: Example
compression-level: 0
retention-days: 1

rust-64-win:
name: Build 64 bit windows dll
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build 64 bit version
run: cargo build --target x86_64-pc-windows-msvc --release
#
- name: Setup Example dir and test build
run: |
cp target/x86_64-pc-windows-msvc/release/libmathcat_c.dll Example/
cd Example
gcc test.cpp -o test -L. -llibmathcat_c
./test.exe
gcc test.c -o test -L. -llibmathcat_c
./test.exe
- name: create zip file for dll file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_c.dll-64-win.zip'
directory: 'Example'
path: 'libmathcat_c.dll'
- name: Upload 64 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_c.dll-64-win.zip
path: libmathcat_c.dll-64-win.zip
compression-level: 0
retention-days: 1

rust-64-arm-win:
name: Build 64 bit arm windows dll
runs-on: windows-latest # needs to run on windows because of bzip2
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build 64 bit version
run: |
rustup target add aarch64-pc-windows-msvc
cargo build --target aarch64-pc-windows-msvc --release
# HOW DO GET A ARM GCC TO RUN?
- name: Setup Example dir and test build
run: |
cp target/aarch64-pc-windows-msvc/release/libmathcat_c.dll Example/
cd Example
gcc test.cpp -o test -L. -llibmathcat_c
./test.exe
gcc test.c -o test -L. -llibmathcat_c
./test.exe
- name: create zip file for dll file -- this allows the name to indicate arch, python version, etc., but unzipped it is correctly named
uses: thedoctor0/zip-release@0.7.5
with:
type: 'zip'
filename: '../libmathcat_c.dll-64-arm.zip'
directory: 'Example'
path: 'libmathcat_c.dll'
- name: Upload 64 bit pyd file
uses: actions/upload-artifact@v4
with:
name: libmathcat_c.dll-64-armn.zip
path: libmathcat_c.dll-64-arm.zip
compression-level: 0
retention-days: 1

pre-release:
name: Pre Release
runs-on: windows-latest
continue-on-error: false
needs: [zip-rules, rust-32-win, rust-64-win, rust-64-arm-win]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build 64 bit version
run: cargo build --target x86_64-pc-windows-msvc --release
- name: create libmathcat64
uses: thedoctor0/zip-release@0.7.5
# download the previous build artifacts and put them in their proper places
- name: Download Rules.zip
uses: actions/download-artifact@v4
with:
type: 'zip'
filename: '../../../libmathcat64.zip'
directory: target/x86_64-pc-windows-msvc/release
path: libmathcat_c*
- name: create rules.zip
uses: thedoctor0/zip-release@0.7.5
name: Rules.zip
- name: Download Example Dir
uses: actions/download-artifact@v4
with:
type: 'zip'
filename: '../Rules.zip'
directory: 'c-example'
path: 'Rules'
# build the test after zipping up "Rules" because the test will unzip the files needed for the test
- name: test build
run: |
cp target/x86_64-pc-windows-msvc/release/libmathcat_c.dll c-example/
cd c-example
gcc test.cpp -o test -L. -llibmathcat_c
./test.exe
- name: Build 32 bit version
run: cargo build --target i686-pc-windows-msvc --release
- name: create libmathcat32
uses: thedoctor0/zip-release@0.7.5
name: Example
- name: Download 32 bit build
uses: actions/download-artifact@v4
with:
type: 'zip'
filename: '../../../libmathcat32.zip'
directory: target/i686-pc-windows-msvc/release
path: libmathcat_c*

- name: Build ARM 64 bit version
run: |
rustup target add aarch64-pc-windows-msvc
cargo build --target aarch64-pc-windows-msvc --release
- name: create arm libmathcat64
uses: thedoctor0/zip-release@0.7.5
name: libmathcat_c.dll-32-win.zip
- name: Download 64 bit build
uses: actions/download-artifact@v4
with:
type: 'zip'
filename: '../../../libmathcat-arm64-untested.zip'
directory: target/aarch64-pc-windows-msvc/release
path: libmathcat_c*

name: libmathcat_c.dll-64-win.zip
- name: Download 64 bit linux build
uses: actions/download-artifact@v4
with:
name: libmathcat_c.dll-64-armn.zip
- name: Automatic release
uses: marvinpinto/action-automatic-releases@latest
with:
Expand All @@ -72,7 +178,4 @@ jobs:
files: |
libmathcat*.zip
Rules.zip
c-example/mathcat.h
c-example/mathcat-c.h
c-example/test.cpp
c-example/test.c
Example
2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::env;
use cbindgen::*;

fn main() {
let c_examples_dir = PathBuf::from("c-example");
let c_examples_dir = PathBuf::from("Example");
unzip_rules(&c_examples_dir);
write_headers(&c_examples_dir, "mathcat-c.h", Language::C);
write_headers(&c_examples_dir, "mathcat.h", Language::Cxx);
Expand Down

0 comments on commit 840b4ca

Please sign in to comment.