Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support intel macs #250

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .github/workflows/package-ffi-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/package-ffi-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 11 additions & 8 deletions build/ffi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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").
Expand Down
9 changes: 9 additions & 0 deletions flipt-client-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions flipt-client-go/evaluation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string.h>
Expand Down
9 changes: 9 additions & 0 deletions flipt-client-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ Add the dependency in your `pom.xml`:
</dependency>
```

## 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:
Expand Down
9 changes: 9 additions & 0 deletions flipt-client-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions flipt-client-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
9 changes: 9 additions & 0 deletions flipt-client-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 5 additions & 7 deletions flipt-client-python/flipt_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,20 @@ 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":
libfile = "linux_x86_64/libfliptengine.so"
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()}.")

Expand Down
6 changes: 6 additions & 0 deletions flipt-client-ruby/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Metrics/BlockLength:
- "spec/**/*"
- "test/**/*"

Metrics/MethodLength:
Max: 20
Exclude:
- "spec/**/*"
- "test/**/*"

Layout/LineLength:
Exclude:
- "spec/**/*"
Expand Down
11 changes: 10 additions & 1 deletion flipt-client-ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions flipt-client-ruby/lib/flipt_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
Loading