diff --git a/binding.gyp b/binding.gyp index f85ba7bc..80b6ad26 100644 --- a/binding.gyp +++ b/binding.gyp @@ -70,7 +70,7 @@ } ], [ - "OS==\"linux\"", + "OS==\"linux\" and target_arch ==\"x64\"", { "link_settings": { "libraries": [ @@ -80,6 +80,18 @@ ] } } + ], + [ + "OS==\"linux\" and target_arch ==\"arm64\"", + { + "link_settings": { + "libraries": [ + "-lpact_ffi", + "-L<(module_root_dir)/ffi/linuxaarch64", + "-Wl,-rpath,'$$ORIGIN'/linuxaarch64" + ] + } + } ] ], "library_dirs": [ @@ -113,6 +125,12 @@ "<(module_root_dir)/ffi/osxaarch64/libpact_ffi.dylib", ], "destination": "<(PRODUCT_DIR)/osxaarch64" + }, + { + "files": [ + "<(module_root_dir)/ffi/linuxaarch64/libpact_ffi.so", + ], + "destination": "<(PRODUCT_DIR)/linuxaarch64" } ] }, diff --git a/script/lib/download-ffi.sh b/script/lib/download-ffi.sh index 3c36c365..f4bc48a3 100755 --- a/script/lib/download-ffi.sh +++ b/script/lib/download-ffi.sh @@ -19,6 +19,7 @@ fi warn "Cleaning ffi directory $FFI_DIR" rm -rf "${FFI_DIR:?}/*" mkdir -p "$FFI_DIR/osxaarch64" +mkdir -p "$FFI_DIR/linuxaarch64" function download_ffi_file { if [ -z "${1:-}" ]; then @@ -56,6 +57,7 @@ function download_ffi { if [ -z "${ONLY_DOWNLOAD_PACT_FOR_WINDOWS:-}" ]; then download_ffi "linux-x86_64.so.gz" "lib" "libpact_ffi.so.gz" + download_ffi "linux-aarch64.so.gz" "lib" "linuxaarch64/libpact_ffi.so.gz" download_ffi "osx-x86_64.dylib.gz" "lib" "libpact_ffi.dylib.gz" download_ffi "osx-aarch64-apple-darwin.dylib.gz" "lib" "osxaarch64/libpact_ffi.dylib.gz" else diff --git a/src/ffi/internals/index.spec.ts b/src/ffi/internals/index.spec.ts index f05c4e79..6391f6c2 100644 --- a/src/ffi/internals/index.spec.ts +++ b/src/ffi/internals/index.spec.ts @@ -10,11 +10,16 @@ describe('ffi names', () => { 'v0.0.1-pact_ffi-windows-x86_64.dll' ); }); - it('has the correct name for linux', () => { + it('has the correct name for linux intel', () => { expect(libName('pact_ffi', 'v0.0.1', 'x64', 'linux')).to.be.equal( 'v0.0.1-libpact_ffi-linux-x86_64.so' ); }); + it('has the correct name for linux arm', () => { + expect(libName('pact_ffi', 'v0.0.1', 'arm64', 'linux')).to.be.equal( + 'v0.0.1-libpact_ffi-linux-aarch64.so' + ); + }); it('has the correct name for osx intel', () => { expect(libName('pact_ffi', 'v0.0.1', 'x64', 'darwin')).to.be.equal( 'v0.0.1-libpact_ffi-osx-x86_64.dylib' @@ -22,7 +27,7 @@ describe('ffi names', () => { }); it('has the correct name for osx arm', () => { expect(libName('pact_ffi', 'v0.0.1', 'arm64', 'darwin')).to.be.equal( - 'v0.0.1-libpact_ffi-osx-aarch64-apple-darwin.dylib' + 'v0.0.1-libpact_ffi-osx-aarch64.dylib' ); }); }); diff --git a/src/ffi/internals/index.ts b/src/ffi/internals/index.ts index a962c6f7..0b34f6d2 100644 --- a/src/ffi/internals/index.ts +++ b/src/ffi/internals/index.ts @@ -16,14 +16,15 @@ const LIBNAME_PREFIX_LOOKUP = { // This is a lookup between process.arch and // the architecture names used in pact-reference -const ARCH_LOOKUP = { x64: 'x86_64', arm64: 'aarch64-apple-darwin' }; +const ARCH_LOOKUP = { x64: 'x86_64', arm64: 'aarch64' }; // This is a lookup between "${platform}-${arch}" and // the file extensions to link on that platform/arch combination const EXTENSION_LOOKUP = { 'osx-x86_64': 'dylib', - 'osx-aarch64-apple-darwin': 'dylib', + 'osx-aarch64': 'dylib', 'linux-x86_64': 'so', + 'linux-aarch64': 'so', 'windows-x86_64': 'dll', };