diff --git a/.github/workflows/package-ffi-engine.yml b/.github/workflows/package-ffi-engine.yml index 937438ff..4c15d17e 100644 --- a/.github/workflows/package-ffi-engine.yml +++ b/.github/workflows/package-ffi-engine.yml @@ -47,6 +47,16 @@ jobs: target: x86_64-apple-darwin use_cross: false + - name: iOS-arm64 + os: macos-latest + target: aarch64-apple-ios + use_cross: false + + - name: Android-arm64 + os: ubuntu-latest + target: aarch64-linux-android + use_cross: true + runs-on: ${{ matrix.platform.os }} env: @@ -77,6 +87,10 @@ jobs: run: | echo "RUSTFLAGS=-C target-feature=-crt-static" >> $GITHUB_ENV + - name: Install cross from GitHub + run: | + which cross || cargo install cross --git https://github.com/cross-rs/cross + - name: Build ${{ matrix.platform.name }} uses: actions-rs/cargo@v1 with: diff --git a/Cargo.toml b/Cargo.toml index 0b45d555..c7456769 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,3 +8,6 @@ rpath = true [profile.release.package.flipt-engine-wasm] opt-level = "s" + +[profile.release.package.flipt-engine-ffi] +opt-level = "z" \ No newline at end of file diff --git a/flipt-engine-ffi/Cargo.toml b/flipt-engine-ffi/Cargo.toml index 50cf4cd0..2887a298 100644 --- a/flipt-engine-ffi/Cargo.toml +++ b/flipt-engine-ffi/Cargo.toml @@ -26,4 +26,4 @@ mockito = "1.4.0" [lib] name = "fliptengine" -crate-type = ["rlib", "dylib"] +crate-type = ["rlib", "dylib", "staticlib"] \ No newline at end of file diff --git a/package/ffi/main.go b/package/ffi/main.go index e25f7bd6..e6af5803 100644 --- a/package/ffi/main.go +++ b/package/ffi/main.go @@ -30,6 +30,10 @@ var ( "dart": dartBuild, } sema = make(chan struct{}, 5) + // defaultExclude is the default exclude for all builds to prevent + // unneccessary architecture support files from being copied into the + // build directory + defaultExclude = []string{"**/*.rlib", "**/*.a", "**/*.d", "*musl*", "*iOS*", "*Android*", "*wasm*"} ) func init() { @@ -249,16 +253,13 @@ func goBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger.D WithWorkdir("/src"). WithFile("/tmp/ext/flipt_engine.h", hostDirectory.File("flipt-engine-ffi/include/flipt_engine.h")) - defaultExclude := []string{"*.rlib"} - if buildOpts.libc == glibc { - exclude := append(defaultExclude, "*_musl") repository = repository. - WithDirectory("/tmp/ext", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{Exclude: exclude}) + WithDirectory("/tmp/ext", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{Exclude: defaultExclude}) } else { repository = repository. - WithDirectory("/tmp/ext/linux_arm64", hostDirectory.Directory("tmp/linux_arm64_musl"), dagger.ContainerWithDirectoryOpts{Exclude: defaultExclude}). - WithDirectory("/tmp/ext/linux_x86_64", hostDirectory.Directory("tmp/linux_x86_64_musl"), dagger.ContainerWithDirectoryOpts{Exclude: defaultExclude}) + WithDirectory("/tmp/ext/linux_arm64", hostDirectory.Directory("tmp/linux_arm64_musl"), dagger.ContainerWithDirectoryOpts{Exclude: []string{"**/*.rlib", "**/*.a", "**/*.d"}}). + WithDirectory("/tmp/ext/linux_x86_64", hostDirectory.Directory("tmp/linux_x86_64_musl"), dagger.ContainerWithDirectoryOpts{Exclude: []string{"**/*.rlib", "**/*.a", "**/*.d"}}) } filtered := repository. @@ -314,7 +315,7 @@ func nodeBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger Exclude: []string{"./node_modules/"}, }). WithDirectory("/src/ext", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{ - Exclude: []string{"**/*.rlib", "*_musl"}, + Exclude: defaultExclude, }). WithFile("/src/ext/flipt_engine.h", hostDirectory.File("flipt-engine-ffi/include/flipt_engine.h")). WithWorkdir("/src"). @@ -348,7 +349,7 @@ func rubyBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger WithWorkdir("/src"). WithDirectory("/src", hostDirectory.Directory("flipt-client-ruby")). WithDirectory("/src/lib/ext", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{ - Exclude: []string{"**/*.rlib", "*_musl"}, + Exclude: defaultExclude, }). WithFile("/src/lib/ext/flipt_engine.h", hostDirectory.File("flipt-engine-ffi/include/flipt_engine.h")). WithExec([]string{"bundle", "install"}). @@ -408,7 +409,7 @@ func javaBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger container := client.Container().From("gradle:8.5.0-jdk11"). WithDirectory("/src", hostDirectory.Directory("flipt-client-java")). WithDirectory("/src/src/main/resources", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{ - Exclude: []string{"**/*.rlib", "*_musl"}, + Exclude: defaultExclude, }). WithFile("/src/main/resources/flipt_engine.h", hostDirectory.File("flipt-engine-ffi/include/flipt_engine.h")). WithWorkdir("/src"). @@ -462,7 +463,7 @@ func dartBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger Exclude: []string{".gitignore", ".dart_tool/"}, }). WithDirectory("/src/lib/src/ffi", hostDirectory.Directory("tmp"), dagger.ContainerWithDirectoryOpts{ - Exclude: []string{"**/*.rlib", "*_musl"}, + Exclude: defaultExclude, }). WithWorkdir("/src"). WithExec([]string{"dart", "pub", "get"})