From fe2b4043fec9294d8994753f8bd75507393f14a0 Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:19:11 -0400 Subject: [PATCH 1/2] chore: update readme's and clients --- .github/workflows/package-ffi-engine.yml | 6 +++++- .github/workflows/package-ffi-sdks.yml | 9 +++++++++ README.md | 9 +++++++++ build/ffi/main.go | 19 +++++++++++-------- flipt-client-go/README.md | 9 +++++++++ flipt-client-go/evaluation.go | 1 + flipt-client-java/README.md | 9 +++++++++ flipt-client-node/README.md | 9 +++++++++ flipt-client-node/src/index.ts | 3 +++ flipt-client-python/README.md | 9 +++++++++ flipt-client-python/flipt_client/__init__.py | 12 +++++------- flipt-client-ruby/README.md | 11 ++++++++++- flipt-client-ruby/lib/flipt_client.rb | 2 ++ 13 files changed, 91 insertions(+), 17 deletions(-) diff --git a/.github/workflows/package-ffi-engine.yml b/.github/workflows/package-ffi-engine.yml index 32096550..5e0d2513 100644 --- a/.github/workflows/package-ffi-engine.yml +++ b/.github/workflows/package-ffi-engine.yml @@ -28,6 +28,10 @@ jobs: os: macos-latest target: aarch64-apple-darwin use_cross: false + - name: Darwin-x86_64 + os: macos-latest + target: x86_64-apple-darwin + use_cross: false runs-on: ${{ matrix.platform.os }} steps: @@ -57,7 +61,7 @@ jobs: args: --target ${{ matrix.platform.target }} --release use-cross: ${{ matrix.platform.use_cross }} - - if: matrix.platform.name == 'Darwin-arm64' + - if: startsWith(matrix.platform.name, 'Darwin') run: | strip -x target/${{ matrix.platform.target }}/release/libfliptengine.dylib diff --git a/.github/workflows/package-ffi-sdks.yml b/.github/workflows/package-ffi-sdks.yml index fc54092d..5137acf1 100644 --- a/.github/workflows/package-ffi-sdks.yml +++ b/.github/workflows/package-ffi-sdks.yml @@ -65,6 +65,15 @@ jobs: tar -xzf /tmp/flipt-engine-ffi-Darwin-arm64.tar.gz -C /tmp/darwin_arm64 && \ mv /tmp/darwin_arm64/target/aarch64-apple-darwin/release/* tmp/darwin_arm64 + - name: Download Mac x86_64 Engine + run: | + mkdir -p tmp/darwin_x86_64 && \ + wget "https://github.com/flipt-io/flipt-client-sdks/releases/download/flipt-engine-ffi-${ENGINE_TAG}/flipt-engine-ffi-Darwin-x86_64.tar.gz" -O /tmp/ + flipt-engine-ffi-Darwin-x86_64.tar.gz && \ + mkdir -p /tmp/darwin_x86_64 && \ + tar -xzf /tmp/flipt-engine-ffi-Darwin-x86_64.tar.gz -C /tmp/darwin_x86_64 && \ + mv /tmp/darwin_x86_64/target/x86_64-apple-darwin/release/* tmp/darwin_x86_64 + - name: Download Linux ARM64 Engine run: | mkdir -p tmp/linux_arm64 && \ diff --git a/README.md b/README.md index 64ec1ea6..6511af7a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,15 @@ The [Foreign Function Interface (FFI)](https://en.wikipedia.org/wiki/Foreign_fun > [!IMPORTANT] > Our FFI SDKs currently only work with OSes that use the `glibc` C library. We are working on adding support for other OSes that use `musl` such as Alpine Linux. See [this issue](https://github.com/flipt-io/flipt-client-sdks/issues/141) for more information. +### Supported Architectures + +The FFI based SDKs are currently supported on the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + ### WASM The WebAssembly (WASM) version of the client SDKs is currently in beta. This version allows you to evaluate flags in the browser using WebAssembly which is OS and architecture agnostic. diff --git a/build/ffi/main.go b/build/ffi/main.go index 52b1305c..9e9bc348 100644 --- a/build/ffi/main.go +++ b/build/ffi/main.go @@ -273,27 +273,30 @@ func javaBuild(ctx context.Context, client *dagger.Client, hostDirectory *dagger // the directory structure of the tmp directory is as follows: // tmp/linux_x86_64/ // tmp/linux_arm64/ + // tmp/darwin_x86_64/ // tmp/darwin_arm64/ // we need to convert it to the following structure: // tmp/linux-x86-64/ // tmp/linux-arm/ + // tmp/darwin-x86-64/ // tmp/darwin-aarch64/ // this is because JNA expects the library to be in a specific directory structure based on host OS and architecture // see: https://github.com/java-native-access/jna/blob/master/test/com/sun/jna/PlatformTest.java // we can do this on the host and then copy the files into the container - if err := os.Rename("tmp/linux_x86_64", "tmp/linux-x86-64"); err != nil { - return err - } - - if err := os.Rename("tmp/linux_arm64", "tmp/linux-arm"); err != nil { - return err + rename := map[string]string{ + "linux_x86_64": "linux-x86-64", + "linux_arm64": "linux-arm", + "darwin_x86_64": "darwin-x86-64", + "darwin_arm64": "darwin-aarch64", } - if err := os.Rename("tmp/darwin_arm64", "tmp/darwin-aarch64"); err != nil { - return err + for old, new := range rename { + if err := os.Rename(fmt.Sprintf("tmp/%s", old), fmt.Sprintf("tmp/%s", new)); err != nil { + return err + } } container := client.Container().From("gradle:8.5.0-jdk11"). diff --git a/flipt-client-go/README.md b/flipt-client-go/README.md index d90fcbb8..06e332d6 100644 --- a/flipt-client-go/README.md +++ b/flipt-client-go/README.md @@ -11,6 +11,15 @@ The `flipt-client-go` library contains the Go source code for the Flipt [client- go get go.flipt.io/flipt-client ``` +## Supported Architectures + +This SDK currently supports the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + ## Usage In your Go code you can import this client and use it as so: diff --git a/flipt-client-go/evaluation.go b/flipt-client-go/evaluation.go index 070652de..8c6a89a0 100644 --- a/flipt-client-go/evaluation.go +++ b/flipt-client-go/evaluation.go @@ -3,6 +3,7 @@ package evaluation /* #cgo CFLAGS: -I./ext #cgo darwin,arm64 LDFLAGS: -L${SRCDIR}/ext/darwin_arm64 -lfliptengine -Wl,-rpath,${SRCDIR}/ext/darwin_arm64 +#cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/ext/darwin_x86_64 -lfliptengine -Wl,-rpath,${SRCDIR}/ext/darwin_x86_64 #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/ext/linux_arm64 -lfliptengine -Wl,-rpath,${SRCDIR}/ext/linux_arm64 #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/ext/linux_x86_64 -lfliptengine -Wl,-rpath,${SRCDIR}/ext/linux_x86_64 #include diff --git a/flipt-client-java/README.md b/flipt-client-java/README.md index 8f4c0a61..7f00eed1 100644 --- a/flipt-client-java/README.md +++ b/flipt-client-java/README.md @@ -28,6 +28,15 @@ Add the dependency in your `pom.xml`: ``` +## Supported Architectures + +This SDK currently supports the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + ## Usage In your Java code you can import this client and use it as so: diff --git a/flipt-client-node/README.md b/flipt-client-node/README.md index 350a452e..38a2781d 100644 --- a/flipt-client-node/README.md +++ b/flipt-client-node/README.md @@ -10,6 +10,15 @@ The `flipt-client-node` library contains the JavaScript/TypeScript source code f npm install @flipt-io/flipt-client ``` +## Supported Architectures + +This SDK currently supports the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + ## Usage In your Node code you can import this client and use it as so: diff --git a/flipt-client-node/src/index.ts b/flipt-client-node/src/index.ts index 84399e00..62d95f9e 100644 --- a/flipt-client-node/src/index.ts +++ b/flipt-client-node/src/index.ts @@ -21,6 +21,9 @@ switch (os.platform()) { if (os.arch() === 'arm64') { libfile = 'darwin_arm64/libfliptengine.dylib'; break; + } else if (os.arch() === 'x64') { + libfile = 'darwin_x86_64/libfliptengine.dylib'; + break; } throw new Error('Unsupported platform: ' + os.platform() + '/' + os.arch()); case 'linux': diff --git a/flipt-client-python/README.md b/flipt-client-python/README.md index e49535e9..fabc670a 100644 --- a/flipt-client-python/README.md +++ b/flipt-client-python/README.md @@ -10,6 +10,15 @@ The `flipt-client-python` library contains the Python source code for the Flipt pip install flipt-client ``` +## Supported Architectures + +This SDK currently supports the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + ## Usage In your Python code you can import this client and use it as so: diff --git a/flipt-client-python/flipt_client/__init__.py b/flipt-client-python/flipt_client/__init__.py index 505a2e81..5fa00cbb 100644 --- a/flipt-client-python/flipt_client/__init__.py +++ b/flipt-client-python/flipt_client/__init__.py @@ -29,12 +29,12 @@ def __init__( # get dynamic library extension for the current platform if platform.system() == "Darwin": arch = platform.machine() - if arch == "arm64" or arch == "aarch64": + if arch == "x86_64": + libfile = "darwin_x86_64/libfliptengine.dylib" + elif arch == "arm64" or arch == "aarch64": libfile = "darwin_arm64/libfliptengine.dylib" else: - raise Exception( - f"Unsupported processor: {platform.processor()}. Please use an arm64 Mac." - ) + raise Exception(f"Unsupported processor: {platform.processor()}") elif platform.system() == "Linux": arch = platform.machine() if arch == "x86_64": @@ -42,9 +42,7 @@ def __init__( elif arch == "arm64" or arch == "aarch64": libfile = "linux_arm64/libfliptengine.so" else: - raise Exception( - f"Unsupported processor: {platform.processor()}. Please use an x86_64 or arm64 Linux machine." - ) + raise Exception(f"Unsupported processor: {platform.processor()}") else: raise Exception(f"Unsupported platform: {platform.system()}.") diff --git a/flipt-client-ruby/README.md b/flipt-client-ruby/README.md index 24499d0e..dd4def37 100644 --- a/flipt-client-ruby/README.md +++ b/flipt-client-ruby/README.md @@ -10,7 +10,16 @@ The `flipt-client-ruby` library contains the Ruby source code for the Flipt [cli gem install flipt_client ``` -## Using System Libffi +## Supported Architectures + +This SDK currently supports the following OSes/architectures: + +- Linux x86_64 +- Linux arm64 +- MacOS x86_64 +- MacOS arm64 + +### Using System Libffi If you are experiencing segfaults when using this gem, you may need to configure `ffi` to use the system libffi instead of the bundled one. diff --git a/flipt-client-ruby/lib/flipt_client.rb b/flipt-client-ruby/lib/flipt_client.rb index 843d45a0..2b024292 100644 --- a/flipt-client-ruby/lib/flipt_client.rb +++ b/flipt-client-ruby/lib/flipt_client.rb @@ -18,6 +18,8 @@ def self.libfile case RbConfig::CONFIG['arch'] when /arm64-darwin/ "ext/darwin_arm64/#{FLIPTENGINE}.dylib" + when /x86_64-darwin/ + "ext/darwin_x86_64/#{FLIPTENGINE}.dylib" when /arm64-linux|aarch64-linux/ "ext/linux_arm64/#{FLIPTENGINE}.so" when /x86_64-linux/ From a39f370519ac395c7ad729a4058986091fadfbce Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:23:13 -0400 Subject: [PATCH 2/2] chore: bump rubocop line length --- flipt-client-ruby/.rubocop.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/flipt-client-ruby/.rubocop.yml b/flipt-client-ruby/.rubocop.yml index fab9441c..460a64d9 100644 --- a/flipt-client-ruby/.rubocop.yml +++ b/flipt-client-ruby/.rubocop.yml @@ -12,6 +12,12 @@ Metrics/BlockLength: - "spec/**/*" - "test/**/*" +Metrics/MethodLength: + Max: 20 + Exclude: + - "spec/**/*" + - "test/**/*" + Layout/LineLength: Exclude: - "spec/**/*"