mirror of
https://github.com/zaerl/mojibake.git
synced 2026-12-01 16:56:40 +01:00
* Add precompiled NIFs and Windows support to the Elixir package Download a precompiled NIF with elixir_make and cc_precompiler from the GitHub release of the version, checked against checksum.exs, so that installing the package needs no compiler on Linux (x86_64 and aarch64, glibc), macOS (x86_64 and arm64), and Windows (x86_64). The NIFs target NIF version 2.16, which OTP 24 and later load. Other platforms, packages with fewer features, builds inside the repository, and MOJIBAKE_BUILD=1 compile from source; MOJIBAKE_PRECOMPILED_URL selects a mirror. A hex.publish alias refuses to publish without checksum.exs. Build the NIF on Windows with MSVC through Makefile.win and nmake. mix.exs passes it the sources and directories as Windows paths and keeps a flags file so that a flag or feature change rebuilds the NIF. Add an elixir-windows CI job, and an elixir-precompile workflow that builds the NIFs on Ubuntu 22.04, macOS, and Windows, checks with scripts/check_precompiled.exs that the package installs the runner's NIF without compiling, and uploads them to a published release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com> * Run the precompiled NIF smoke test from a file on Windows check_precompiled.exs passed the smoke test to `mix run -e` through `cmd /c`, which strips the quotes from the code, so the Windows precompile job failed with a syntax error after building and packaging the NIF. Write the test to a file in the unpacked package and run that instead, and log the mix command rather than the cmd.exe one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com> --------- Signed-off-by: Francesco Bigiarini <francesco.bigiarini@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
98 lines
3.2 KiB
YAML
98 lines
3.2 KiB
YAML
# The Mojibake library
|
|
#
|
|
# This file is distributed under the MIT License. See LICENSE for details.
|
|
|
|
# Build the precompiled NIFs of the Elixir package, check that the package installs them without
|
|
# a compiler, and, for a release, upload them to it. The Hex package downloads them from there;
|
|
# see "Packaging and publishing" under "Elixir package" in CONTRIBUTING.md.
|
|
|
|
name: Elixir precompiled NIFs
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: Release tag to build the NIFs from and upload them to, such as v0.7.0
|
|
required: true
|
|
pull_request:
|
|
paths:
|
|
- src/*.c
|
|
- src/*.h
|
|
- src/CMakeLists.txt
|
|
- src/elixir/**
|
|
- .github/workflows/elixir-precompile.yml
|
|
- .github/actions/setup-msvc/**
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
precompile:
|
|
name: Precompile (${{ matrix.os }})
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 30
|
|
permissions:
|
|
contents: write # gh release upload
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# ubuntu-22.04 sets the glibc the Linux NIFs need (2.35). macos-latest builds both macOS
|
|
# NIFs, and ubuntu-22.04 the aarch64 Linux one with a cross compiler; only the NIF of
|
|
# the runner itself can be checked.
|
|
os: [ubuntu-22.04, macos-latest, windows-latest]
|
|
env:
|
|
TAG: ${{ github.event.release.tag_name || inputs.tag }}
|
|
MACOSX_DEPLOYMENT_TARGET: '11.0'
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
|
|
with:
|
|
ref: ${{ github.event.release.tag_name || inputs.tag || '' }}
|
|
|
|
# OTP 25 has NIF version 2.16, the one in make_precompiler_nif_versions in
|
|
# src/elixir/mix.exs. A NIF built for it also loads on every later OTP.
|
|
- uses: erlef/setup-beam@54075bcc5e249e4758d363f27d099f55d843f124 # v1.24.1
|
|
with:
|
|
otp-version: '25'
|
|
elixir-version: '1.15'
|
|
|
|
- name: Install the aarch64 Linux cross compiler
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y gcc-aarch64-linux-gnu
|
|
|
|
- if: runner.os == 'Windows'
|
|
uses: ./.github/actions/setup-msvc
|
|
|
|
# PowerShell everywhere: Git Bash puts its own link.exe ahead of the MSVC linker.
|
|
- name: Precompile
|
|
shell: pwsh
|
|
working-directory: src/elixir
|
|
env:
|
|
MIX_ENV: prod
|
|
run: |
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
$env:ELIXIR_MAKE_CACHE_DIR = Join-Path $env:GITHUB_WORKSPACE "precompiled"
|
|
mix deps.get
|
|
mix elixir_make.precompile
|
|
Get-ChildItem $env:ELIXIR_MAKE_CACHE_DIR
|
|
|
|
- name: Check that the package installs the NIF without compiling
|
|
shell: pwsh
|
|
run: |
|
|
$PSNativeCommandUseErrorActionPreference = $true
|
|
elixir src/elixir/scripts/check_precompiled.exs precompiled
|
|
|
|
- name: Upload the NIFs to the release
|
|
if: env.TAG != ''
|
|
shell: bash
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: gh release upload "$TAG" precompiled/*.tar.gz --clobber
|