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

Use minimum NIF version for each target #279

Merged
merged 3 commits into from
Mar 11, 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
67 changes: 35 additions & 32 deletions .github/workflows/precompile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,57 @@ permissions:

jobs:
precompile:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.job.os }}
env:
MIX_ENV: "prod"

name: Precompile for Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, OS ${{ matrix.os }}
name: Precompile for Elixir ${{ matrix.job.elixir }}, OTP ${{ matrix.job.otp }}, OS ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-20.04", "windows-2019", "macos-11"]
elixir: ["1.14"]
otp: ["26", "25", "23"]
exclude:
- os: "windows-2019"
otp: "23"
job:
- { os: "ubuntu-20.04", otp: "23", elixir: "1.14" }
- { os: "macos-11", otp: "24.3.4.16", elixir: "1.14.3"}
- { os: "windows-2019", otp: "25", elixir: "1.14"}
steps:
- uses: actions/checkout@v3
- uses: erlef/setup-beam@v1
if: matrix.os != 'macos-11'
if: matrix.job.os != 'macos-11'
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.job.otp }}
elixir-version: ${{ matrix.job.elixir }}
- name: Install erlang and elixir
if: matrix.os == 'macos-11'
if: matrix.job.os == 'macos-11'
run: |
if [ "${{ matrix.otp }}" = "23" ]; then
brew install "erlang@${{ matrix.otp }}"
brew link --overwrite "erlang@${{ matrix.otp }}"
export ROOT_DIR=$(pwd)

mkdir -p ./cache/otp
curl -fSL https://github.com/cocoa-xu/otp-build/releases/download/v${{ matrix.job.otp }}/otp-x86_64-apple-darwin.tar.gz -o ./cache/otp/otp-v${{ matrix.job.otp }}-x86_64-apple-darwin.tar.gz
cd ./cache/otp
tar -xzf otp-v${{ matrix.job.otp }}-x86_64-apple-darwin.tar.gz
cd ${ROOT_DIR}

export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang

mkdir -p ./cache/elixir
curl -fSL https://github.com/elixir-lang/elixir/archive/refs/tags/v${{ matrix.job.elixir }}.tar.gz -o ./cache/elixir/elixir-${{ matrix.job.elixir }}.tar.gz
cd ./cache/elixir
tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
cd elixir-${{ matrix.job.elixir }}
make compile
make -j$(sysctl -n hw.ncpu) install

export ELIXIR_VER=1.14.3
mkdir -p "${HOME}/.elixir/v${ELIXIR_VER}"
cd "${HOME}/.elixir/v${ELIXIR_VER}"
wget "https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VER}/elixir-otp-${{ matrix.otp }}.zip" -O "elixir-${ELIXIR_VER}.zip"
unzip "elixir-${ELIXIR_VER}.zip"
rm -f "elixir-${ELIXIR_VER}.zip"
export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}"
else
brew install erlang elixir
fi
mix local.hex --force
mix local.rebar --force

- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-2019'
if: matrix.job.os == 'windows-2019'
with:
arch: x64

- name: Install system dependencies
if: matrix.os == 'ubuntu-20.04'
if: matrix.job.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip wget \
Expand All @@ -70,7 +73,7 @@ jobs:
gcc-s390x-linux-gnu g++-s390x-linux-gnu

- name: Get musl cross-compilers
if: matrix.os == 'ubuntu-20.04'
if: matrix.job.os == 'ubuntu-20.04'
run: |
for musl_arch in x86_64 aarch64 riscv64
do
Expand All @@ -81,10 +84,10 @@ jobs:
- name: Create precompiled library
shell: bash
run: |
if [ "${{ matrix.os }}" = "macos-11" ]; then
export ELIXIR_VER=1.14.3
export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}"
elif [ "${{ matrix.os }}" = "ubuntu-20.04" ]; then
if [ "${{ matrix.job.os }}" = "macos-11" ]; then
export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
elif [ "${{ matrix.job.os }}" = "ubuntu-20.04" ]; then
for musl_arch in x86_64 aarch64 riscv64
do
export PATH="$(pwd)/${musl_arch}-linux-musl-cross/bin:${PATH}"
Expand Down
25 changes: 14 additions & 11 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ defmodule Exqlite.MixProject do
"https://github.com/elixir-sqlite/exqlite/releases/download/v#{@version}/@{artefact_filename}",
make_precompiler_filename: "sqlite3_nif",
make_precompiler_nif_versions: [
versions: ["2.15", "2.16", "2.17"],
availability: &target_available_for_nif_version?/2
versions: &nif_versions/1,
fallback_version: fn opts ->
hd(nif_versions(opts))
end
],
make_env: Application.get_env(:exqlite, :make_env, %{}),
cc_precompiler: cc_precompiler(),
Expand Down Expand Up @@ -54,7 +56,7 @@ defmodule Exqlite.MixProject do
[
{:db_connection, "~> 2.1"},
{:ex_sqlean, "~> 0.8.5", only: [:dev, :test]},
{:elixir_make, "~> 0.7", runtime: false},
{:elixir_make, "~> 0.8", runtime: false},
{:cc_precompiler, "~> 0.1", runtime: false},
{:ex_doc, "~> 0.27", only: :dev, runtime: false},
{:temp, "~> 0.4", only: [:dev, :test]},
Expand Down Expand Up @@ -82,14 +84,6 @@ defmodule Exqlite.MixProject do
end
end

def target_available_for_nif_version?(target, nif_version) do
if String.contains?(target, "windows") do
Enum.member?(["2.16", "2.17"], nif_version)
else
true
end
end

defp package do
[
files: ~w(
Expand Down Expand Up @@ -142,6 +136,15 @@ defmodule Exqlite.MixProject do
]
end

defp nif_versions(opts) do
if String.contains?(opts.target, "windows") or
String.contains?(opts.target, "darwin") do
["2.16"]
else
["2.15"]
end
end

defp cc_precompiler do
[
cleanup: "clean",
Expand Down
4 changes: 2 additions & 2 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
%{
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"cc_precompiler": {:hex, :cc_precompiler, "0.1.9", "e8d3364f310da6ce6463c3dd20cf90ae7bbecbf6c5203b98bf9b48035592649b", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9dcab3d0f3038621f1601f13539e7a9ee99843862e66ad62827b0c42b2f58a54"},
"cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"},
"credo": {:hex, :credo, "1.7.3", "05bb11eaf2f2b8db370ecaa6a6bda2ec49b2acd5e0418bc106b73b07128c0436", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "35ea675a094c934c22fb1dca3696f3c31f2728ae6ef5a53b5d648c11180a4535"},
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
"elixir_make": {:hex, :elixir_make, "0.7.8", "505026f266552ee5aabca0b9f9c229cbb496c689537c9f922f3eb5431157efc7", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "7a71945b913d37ea89b06966e1342c85cfe549b15e6d6d081e8081c493062c07"},
"elixir_make": {:hex, :elixir_make, "0.8.2", "cd4a5a75891362e9207adaac7e66223fd256ec2518ae013af7f10c9c85b50b5c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.0", [hex: :certifi, repo: "hexpm", optional: true]}], "hexpm", "9d9607d640c372a7291e5a56ce655aa2351897929be20bd211648fdb79e725dc"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"ex_doc": {:hex, :ex_doc, "0.31.1", "8a2355ac42b1cc7b2379da9e40243f2670143721dd50748bf6c3b1184dae2089", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.1", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "3178c3a407c557d8343479e1ff117a96fd31bafe52a039079593fb0524ef61b0"},
"ex_sqlean": {:hex, :ex_sqlean, "0.8.8", "be03d0aa4ee2955b59b386743ccaccbf0cc56f9635f701f185fe2d962b2ab214", [:mix], [], "hexpm", "de3644787ee736880597886decdf86f104c1778398401615c37d1ec4563146fa"},
Expand Down
Loading