Skip to content

Commit 44da05b

Browse files
authored
Use minimum NIF version for each target (#279)
* use single nif version * use Erlang/OTP 24 (NIF 2.16) for macOS * updated to elixir_make v0.8.2
1 parent 4d1b518 commit 44da05b

File tree

3 files changed

+51
-45
lines changed

3 files changed

+51
-45
lines changed

.github/workflows/precompile.yml

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,57 @@ permissions:
1010

1111
jobs:
1212
precompile:
13-
runs-on: ${{ matrix.os }}
13+
runs-on: ${{ matrix.job.os }}
1414
env:
1515
MIX_ENV: "prod"
1616

17-
name: Precompile for Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}, OS ${{ matrix.os }}
17+
name: Precompile for Elixir ${{ matrix.job.elixir }}, OTP ${{ matrix.job.otp }}, OS ${{ matrix.job.os }}
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
os: ["ubuntu-20.04", "windows-2019", "macos-11"]
22-
elixir: ["1.14"]
23-
otp: ["26", "25", "23"]
24-
exclude:
25-
- os: "windows-2019"
26-
otp: "23"
21+
job:
22+
- { os: "ubuntu-20.04", otp: "23", elixir: "1.14" }
23+
- { os: "macos-11", otp: "24.3.4.16", elixir: "1.14.3"}
24+
- { os: "windows-2019", otp: "25", elixir: "1.14"}
2725
steps:
2826
- uses: actions/checkout@v3
2927
- uses: erlef/setup-beam@v1
30-
if: matrix.os != 'macos-11'
28+
if: matrix.job.os != 'macos-11'
3129
with:
32-
otp-version: ${{ matrix.otp }}
33-
elixir-version: ${{ matrix.elixir }}
30+
otp-version: ${{ matrix.job.otp }}
31+
elixir-version: ${{ matrix.job.elixir }}
3432
- name: Install erlang and elixir
35-
if: matrix.os == 'macos-11'
33+
if: matrix.job.os == 'macos-11'
3634
run: |
37-
if [ "${{ matrix.otp }}" = "23" ]; then
38-
brew install "erlang@${{ matrix.otp }}"
39-
brew link --overwrite "erlang@${{ matrix.otp }}"
35+
export ROOT_DIR=$(pwd)
36+
37+
mkdir -p ./cache/otp
38+
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
39+
cd ./cache/otp
40+
tar -xzf otp-v${{ matrix.job.otp }}-x86_64-apple-darwin.tar.gz
41+
cd ${ROOT_DIR}
42+
43+
export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
44+
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
45+
46+
mkdir -p ./cache/elixir
47+
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
48+
cd ./cache/elixir
49+
tar -xzf elixir-${{ matrix.job.elixir }}.tar.gz
50+
cd elixir-${{ matrix.job.elixir }}
51+
make compile
52+
make -j$(sysctl -n hw.ncpu) install
4053
41-
export ELIXIR_VER=1.14.3
42-
mkdir -p "${HOME}/.elixir/v${ELIXIR_VER}"
43-
cd "${HOME}/.elixir/v${ELIXIR_VER}"
44-
wget "https://github.com/elixir-lang/elixir/releases/download/v${ELIXIR_VER}/elixir-otp-${{ matrix.otp }}.zip" -O "elixir-${ELIXIR_VER}.zip"
45-
unzip "elixir-${ELIXIR_VER}.zip"
46-
rm -f "elixir-${ELIXIR_VER}.zip"
47-
export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}"
48-
else
49-
brew install erlang elixir
50-
fi
5154
mix local.hex --force
5255
mix local.rebar --force
5356
5457
- uses: ilammy/msvc-dev-cmd@v1
55-
if: matrix.os == 'windows-2019'
58+
if: matrix.job.os == 'windows-2019'
5659
with:
5760
arch: x64
5861

5962
- name: Install system dependencies
60-
if: matrix.os == 'ubuntu-20.04'
63+
if: matrix.job.os == 'ubuntu-20.04'
6164
run: |
6265
sudo apt-get update
6366
sudo apt-get install -y build-essential automake autoconf pkg-config bc m4 unzip zip wget \
@@ -70,7 +73,7 @@ jobs:
7073
gcc-s390x-linux-gnu g++-s390x-linux-gnu
7174
7275
- name: Get musl cross-compilers
73-
if: matrix.os == 'ubuntu-20.04'
76+
if: matrix.job.os == 'ubuntu-20.04'
7477
run: |
7578
for musl_arch in x86_64 aarch64 riscv64
7679
do
@@ -81,10 +84,10 @@ jobs:
8184
- name: Create precompiled library
8285
shell: bash
8386
run: |
84-
if [ "${{ matrix.os }}" = "macos-11" ]; then
85-
export ELIXIR_VER=1.14.3
86-
export PATH="${HOME}/.elixir/v${ELIXIR_VER}/bin:${PATH}"
87-
elif [ "${{ matrix.os }}" = "ubuntu-20.04" ]; then
87+
if [ "${{ matrix.job.os }}" = "macos-11" ]; then
88+
export PATH=$(pwd)/cache/otp/usr/local/bin:$(pwd)/./cache/elixir/elixir-${{ matrix.job.elixir }}/bin:${PATH}
89+
export ERL_ROOTDIR=$(pwd)/cache/otp/usr/local/lib/erlang
90+
elif [ "${{ matrix.job.os }}" = "ubuntu-20.04" ]; then
8891
for musl_arch in x86_64 aarch64 riscv64
8992
do
9093
export PATH="$(pwd)/${musl_arch}-linux-musl-cross/bin:${PATH}"

mix.exs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ defmodule Exqlite.MixProject do
1818
"https://github.com/elixir-sqlite/exqlite/releases/download/v#{@version}/@{artefact_filename}",
1919
make_precompiler_filename: "sqlite3_nif",
2020
make_precompiler_nif_versions: [
21-
versions: ["2.15", "2.16", "2.17"],
22-
availability: &target_available_for_nif_version?/2
21+
versions: &nif_versions/1,
22+
fallback_version: fn opts ->
23+
hd(nif_versions(opts))
24+
end
2325
],
2426
make_env: Application.get_env(:exqlite, :make_env, %{}),
2527
cc_precompiler: cc_precompiler(),
@@ -54,7 +56,7 @@ defmodule Exqlite.MixProject do
5456
[
5557
{:db_connection, "~> 2.1"},
5658
{:ex_sqlean, "~> 0.8.5", only: [:dev, :test]},
57-
{:elixir_make, "~> 0.7", runtime: false},
59+
{:elixir_make, "~> 0.8", runtime: false},
5860
{:cc_precompiler, "~> 0.1", runtime: false},
5961
{:ex_doc, "~> 0.27", only: :dev, runtime: false},
6062
{:temp, "~> 0.4", only: [:dev, :test]},
@@ -82,14 +84,6 @@ defmodule Exqlite.MixProject do
8284
end
8385
end
8486

85-
def target_available_for_nif_version?(target, nif_version) do
86-
if String.contains?(target, "windows") do
87-
Enum.member?(["2.16", "2.17"], nif_version)
88-
else
89-
true
90-
end
91-
end
92-
9387
defp package do
9488
[
9589
files: ~w(
@@ -142,6 +136,15 @@ defmodule Exqlite.MixProject do
142136
]
143137
end
144138

139+
defp nif_versions(opts) do
140+
if String.contains?(opts.target, "windows") or
141+
String.contains?(opts.target, "darwin") do
142+
["2.16"]
143+
else
144+
["2.15"]
145+
end
146+
end
147+
145148
defp cc_precompiler do
146149
[
147150
cleanup: "clean",

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
%{
22
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
3-
"cc_precompiler": {:hex, :cc_precompiler, "0.1.9", "e8d3364f310da6ce6463c3dd20cf90ae7bbecbf6c5203b98bf9b48035592649b", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9dcab3d0f3038621f1601f13539e7a9ee99843862e66ad62827b0c42b2f58a54"},
3+
"cc_precompiler": {:hex, :cc_precompiler, "0.1.10", "47c9c08d8869cf09b41da36538f62bc1abd3e19e41701c2cea2675b53c704258", [:mix], [{:elixir_make, "~> 0.7", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "f6e046254e53cd6b41c6bacd70ae728011aa82b2742a80d6e2214855c6e06b22"},
44
"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"},
55
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},
66
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
77
"earmark_parser": {:hex, :earmark_parser, "1.4.39", "424642f8335b05bb9eb611aa1564c148a8ee35c9c8a8bba6e129d51a3e3c6769", [:mix], [], "hexpm", "06553a88d1f1846da9ef066b87b57c6f605552cfbe40d20bd8d59cc6bde41944"},
8-
"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"},
8+
"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"},
99
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
1010
"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"},
1111
"ex_sqlean": {:hex, :ex_sqlean, "0.8.8", "be03d0aa4ee2955b59b386743ccaccbf0cc56f9635f701f185fe2d962b2ab214", [:mix], [], "hexpm", "de3644787ee736880597886decdf86f104c1778398401615c37d1ec4563146fa"},

0 commit comments

Comments
 (0)