Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
1e1b7bc
Add test workflow
Nov 2, 2023
246bc74
Create main.yml
Nov 2, 2023
e913382
Update PR run
Nov 2, 2023
4b98025
Use x86 target
Nov 2, 2023
fc81af4
remove flags
Nov 2, 2023
edcc2b7
install musl-tools
Nov 2, 2023
06f8ca0
Add aarch
Nov 2, 2023
67a0063
Build for cross
Nov 2, 2023
502202e
Fix quotes
Nov 2, 2023
22f3c1b
Add glibc
Nov 2, 2023
3deb403
Try using older image
Nov 2, 2023
4b10e33
Make sure we separate caches
Nov 2, 2023
388e69a
Build for linux
Nov 2, 2023
4406bdc
Update yaml
Nov 2, 2023
eea585c
Add packaging for aarch64
Nov 3, 2023
61b8be0
Add short SHA
Nov 3, 2023
93cdae8
Add tests
Nov 5, 2023
5470996
Merge branch 'main' into gh-actions
Nov 6, 2023
7732df5
Add RUSTFLAGS
Nov 6, 2023
9aab7df
Update test paths
Nov 6, 2023
d641cca
Add LD_LIBRARY_PATH
Nov 6, 2023
86fe57e
Try gnu instead
Nov 6, 2023
556690b
Use cross-rs for all builds
Nov 6, 2023
74e83d3
Update c2pa
Nov 6, 2023
acaf455
Update prefix key
Nov 6, 2023
8a7f4f7
Add tmate
Nov 6, 2023
8c8f6c9
Limit tmate access
Nov 6, 2023
62b75c1
Parse exit code
Nov 6, 2023
28d0e59
Fix target name
Nov 6, 2023
425bf3c
Try building static lib
Nov 6, 2023
1557c78
Update binstall, build staticlib
Nov 6, 2023
ddadf1f
Revert binstall
Nov 6, 2023
81a1793
Try gnu instead
Nov 6, 2023
1bb66c6
Remove rustflags
Nov 6, 2023
80b2f41
Revert changes
Nov 6, 2023
cf588cf
Update release.yml
Feb 1, 2024
0a4277a
Merge branch 'main' into gh-actions
Feb 1, 2024
8283eec
Update release.yml
Feb 1, 2024
99289eb
Update release.yml
Feb 1, 2024
274d762
Update release.yml
Feb 1, 2024
c6032f0
Update release.yml
Feb 1, 2024
bea4575
Update release.yml
Feb 1, 2024
35df133
Update release.yml
Feb 1, 2024
68210b3
Update release.yml
Feb 1, 2024
fde0033
Update release.yml
Feb 1, 2024
4113bfa
Update release.yml
Feb 1, 2024
3de4a5b
Update release.yml
Feb 1, 2024
892a635
Update Makefile
Feb 1, 2024
f3165ee
Update release.yml
Feb 1, 2024
3090a8c
Remove Linux gnu build
Feb 1, 2024
7a6fb0d
Add target var
Feb 1, 2024
884e563
Update make test paths
Feb 1, 2024
90c436a
Add musl-specific compilers for testing
Feb 1, 2024
ce471c9
Update makefile
Feb 1, 2024
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
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build releases

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]

jobs:
build:
strategy:
matrix:
include:
- os: macos-latest-large
target: aarch64-apple-darwin
- os: macos-latest-large
target: aarch64-apple-ios
- os: macos-latest-large
# cross-compile for Linux ARM using Apple Silicon until we have ARM runners
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, that's clever. Might have to steal that one elsewhere …

target: aarch64-unknown-linux-musl
- os: macos-latest
target: x86_64-apple-darwin
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
# - os: windows-latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is Windows disabled? That seems like a blocker.

# target: x86_64-pc-windows-msvc
name: Build ${{matrix.target}}
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get short SHA
id: sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Install build tools (Linux)
if: ${{matrix.os == 'ubuntu-latest'}}
run: |
sudo apt-get update
sudo apt-get install musl-tools

- name: Install Rust toolchain
uses: dtolnay/[email protected]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why fix on a specific Rust version? IMHO should matrix the MSRV version and stable.

with:
components: llvm-tools-preview
target: ${{matrix.target}}

- name: Install cbindgen
run: cargo install cbindgen

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{matrix.target}}

- name: Install musl for mac -> linux cross compilation
if: ${{matrix.target == 'aarch64-unknown-linux-musl'}}
run: brew install filosottile/musl-cross/musl-cross

- name: Build library
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc
run: make TARGET=${{matrix.target}} release

- name: Run C tests
if: ${{matrix.os != 'windows-latest'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again … why is Windows disabled? See also lines 70 and 74.

run: make TARGET=${{matrix.target}} test-c

- name: Run C++ tests
if: ${{matrix.os != 'windows-latest'}}
run: make TARGET=${{matrix.target}} test-cpp

- name: Show Windows warning
if: ${{matrix.os == 'windows-latest'}}
run: echo "::warning::C/C++ tests did NOT run in Windows"

- name: Move files to main folder
run: mv target/release/libc2pa_c* .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not work on Windows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC Windows uses rename instead of mv for this purpose. I think the conditionals used above if: ... 'windows-latest' ... should work to separate Windows from Unix/Mac build hosts.


- name: Add files to archive
uses: actions/upload-artifact@v4
with:
name: c2pa-c_${{matrix.target}}-${{ steps.sha.outputs.sha_short }}.zip
path: |
README.md
include/**
examples/**
libc2pa_c*
retention-days: 3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/target
/dist
/include
/Cargo.lock

.vscode
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ c2pa = {version="0.28.4", features = ["file_io", "add_thumbnails", "fetch_remote
serde = { version = "1.0", features = ["derive"] }
serde_derive = "1.0"
serde_json = "1.0"
thiserror = "1.0.49"
thiserror = "1.0.49"
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ ifeq ($(OS), Linux)
CFLAGS = -pthread -Wl,--no-as-needed -ldl -lm
ENV = LD_LIBRARY_PATH=target/release
endif
ifneq (,$(findstring musl,$(TARGET)))
CC = musl-gcc
GCC = musl-g++
else
GCC = g++
endif

check-format:
cargo fmt -- --check
Expand All @@ -19,19 +25,19 @@ test-rust:
cargo test --all-features

release:
cargo build --release
cargo build --release --target $(TARGET)
cbindgen --config cbindgen.toml --crate c2pa-c --output include/c2pa.h --lang c

test-c: release
$(CC) $(CFLAGS) tests/test.c -o target/ctest -lc2pa_c -L./target/release
$(ENV) target/ctest
test-c:
$(CC) $(CFLAGS) tests/test.c -o target/$(TARGET)/ctest -lc2pa_c -L./target/$(TARGET)/release
LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:./target/$(TARGET)/release target/$(TARGET)/ctest

test-cpp: release
g++ $(CFLAGS) -std=c++17 tests/test.cpp -o target/cpptest -lc2pa_c -L./target/release
$(ENV) target/cpptest
test-cpp:
$(GCC) $(CFLAGS) -std=c++11 tests/test.cpp -o target/$(TARGET)/cpptest -lc2pa_c -L./target/$(TARGET)/release
LD_LIBRARY_PATH=$$LD_LIBRARY_PATH:./target/$(TARGET)/release target/$(TARGET)/cpptest

example: release
g++ $(CFLAGS) -std=c++17 examples/training.cpp -o target/training -lc2pa_c -L./target/release
$(GCC) $(CFLAGS) -std=c++17 examples/training.cpp -o target/training -lc2pa_c -L./target/release
$(ENV) target/training

# Creates a folder wtih c2patool bin, samples and readme
Expand All @@ -45,4 +51,4 @@ package:

test: check-format clippy test-rust test-c test-cpp

all: test example
all: test example