-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add rustler_precompiled support for prebuilt NIF binaries #70
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| name: Build Precompiled NIFs | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - "native/**" | ||
| - ".github/workflows/release.yml" | ||
| tags: | ||
| - "v*" | ||
| pull_request: | ||
| paths: | ||
| - ".github/workflows/release.yml" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| jobs: | ||
| build_release: | ||
| name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }}) | ||
| runs-on: ${{ matrix.job.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| nif: ["2.15"] | ||
| job: | ||
| - { target: aarch64-apple-darwin, os: macos-14 } | ||
| - { target: x86_64-apple-darwin, os: macos-13 } | ||
| - { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04, use-cross: true } | ||
| - { target: aarch64-unknown-linux-musl, os: ubuntu-22.04, use-cross: true } | ||
| - { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04 } | ||
| - { target: x86_64-unknown-linux-musl, os: ubuntu-22.04, use-cross: true } | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Extract project version | ||
| shell: bash | ||
| run: | | ||
| # Extract version from mix.exs @version attribute | ||
| VERSION=$(sed -n 's/^[[:space:]]*@version "\(.*\)"/\1/p' mix.exs | head -n1) | ||
| if [ -z "$VERSION" ]; then | ||
| echo "::error::Failed to extract version from mix.exs" | ||
| exit 1 | ||
| fi | ||
| echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV | ||
|
|
||
| - name: Install Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Build the project | ||
| id: build-crate | ||
| uses: philss/rustler-precompiled-action@v1.1.4 | ||
| with: | ||
| project-name: ecto_libsql | ||
| project-version: ${{ env.PROJECT_VERSION }} | ||
| target: ${{ matrix.job.target }} | ||
| nif-version: ${{ matrix.nif }} | ||
| use-cross: ${{ matrix.job.use-cross }} | ||
| cross-version: "from-source" | ||
| project-dir: "native/ecto_libsql" | ||
|
|
||
| - name: Artifact upload | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ steps.build-crate.outputs.file-name }} | ||
| path: ${{ steps.build-crate.outputs.file-path }} | ||
|
|
||
| - name: Publish archives and packages | ||
| uses: softprops/action-gh-release@v2 | ||
| with: | ||
| files: | | ||
| ${{ steps.build-crate.outputs.file-path }} | ||
| if: startsWith(github.ref, 'refs/tags/') | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ defmodule EctoLibSql.MixProject do | |
|
|
||
| @version "0.8.9" | ||
| @source_url "https://github.com/ocean/ecto_libsql" | ||
| @dev? String.ends_with?(@version, "-dev") | ||
| @force_build? System.get_env("ECTO_LIBSQL_BUILD") in ["1", "true"] | ||
|
|
||
|
Comment on lines
+6
to
8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: fd -e "mix.exs" --max-one-resultRepository: ocean/ecto_libsql Length of output: 294 🏁 Script executed: head -100 mix.exsRepository: ocean/ecto_libsql Length of output: 2798 🏁 Script executed: sed -n '55,75p' mix.exsRepository: ocean/ecto_libsql Length of output: 824 🌐 Web query:
💡 Result: If 1) Add
|
||
| def project do | ||
| [ | ||
|
|
@@ -55,7 +57,8 @@ defmodule EctoLibSql.MixProject do | |
| {:ecto_sql, "~> 3.11"}, | ||
| {:ex_doc, "~> 0.31", only: :dev, runtime: false}, | ||
| {:jason, "~> 1.4"}, | ||
| {:rustler, "~> 0.37.1"}, | ||
| {:rustler, "~> 0.37.1", optional: not (@dev? or @force_build?)}, | ||
| {:rustler_precompiled, "~> 0.8"}, | ||
| {:sobelow, "~> 0.13", only: [:dev, :test], runtime: false}, | ||
| {:stream_data, "~> 1.0", only: [:dev, :test]} | ||
| ] | ||
|
|
@@ -64,7 +67,8 @@ defmodule EctoLibSql.MixProject do | |
| defp package() do | ||
| [ | ||
| name: "ecto_libsql", | ||
| files: ~w(lib priv .formatter.exs mix.exs README.md LICENSE CHANGELOG.md USAGE.md native), | ||
| files: | ||
| ~w(lib priv .formatter.exs mix.exs README.md LICENSE CHANGELOG.md USAGE.md ECTO_MIGRATION_GUIDE.md SECURITY.md native checksum-*.exs), | ||
| licenses: ["Apache-2.0"], | ||
| links: %{ | ||
| "GitHub" => @source_url, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Cross-compilation configuration for rustler_precompiled NIF builds. | ||
| # | ||
| # macOS: Use dynamic lookup for Erlang NIF symbols (resolved at load time). | ||
| # musl: Disable static CRT linking for compatibility with BEAM's dynamic loader. | ||
|
|
||
| [target.'cfg(target_os = "macos")'] | ||
| rustflags = [ | ||
| "-C", "link-arg=-undefined", | ||
| "-C", "link-arg=dynamic_lookup", | ||
| ] | ||
|
|
||
| [target.x86_64-unknown-linux-musl] | ||
| rustflags = [ | ||
| "-C", "target-feature=-crt-static", | ||
| ] | ||
|
|
||
| [target.aarch64-unknown-linux-musl] | ||
| rustflags = [ | ||
| "-C", "target-feature=-crt-static", | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.