ci: Add windows-installer job #163
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unix Cross Compile | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'next' | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: "[macOS] arm64 on [macOS] x86_64" | |
hostabi: darwin_x86_64 | |
os: macos-latest | |
targetabi: darwin_arm64 | |
targetbits: 64 | |
ocamlconfigure: vendor/dkml-compiler/env/standard-compiler-env-to-ocaml-configure-env.sh | |
expectfile: Mach-O 64-bit executable arm64 | |
- name: "[android] aarch64 on [linux] x86_64" | |
hostabi: linux_x86_64 | |
os: ubuntu-latest | |
targetabi: android_arm64v8a | |
targetbits: 64 | |
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh | |
expectfile: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped | |
- name: "[android] armv7a on [linux] x86" | |
hostabi: linux_x86 | |
os: ubuntu-latest | |
targetabi: android_arm32v7a | |
targetbits: 32 | |
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh | |
expectfile: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, with debug_info, not stripped | |
- name: "[android] x86_64 on [linux] x86_64" | |
hostabi: linux_x86_64 | |
os: ubuntu-latest | |
targetabi: android_x86_64 | |
targetbits: 64 | |
ocamlconfigure: vendor/dkml-compiler/env/github-actions-ci-to-ocaml-configure-env.sh | |
expectfile: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped | |
name: ${{ matrix.name }} | |
env: | |
BUILD_TYPE: Debug | |
# OCaml 4.12.1 | |
OCAML_GIT_REV: 46c947827ec2f6d6da7fe5e195ae5dda1d2ad0c5 | |
DKML_BUILD_TRACE: ON | |
DIST_DIR: dist/${{ matrix.targetabi }}-on-${{ matrix.hostabi }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
# =============== Checkout =============== | |
- uses: actions/checkout@v2 | |
with: | |
submodules: recursive | |
# =============== Cache =============== | |
- name: Cache builds | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-${{ matrix.hostabi }}-${{ matrix.targetabi }} | |
with: | |
path: | | |
dist/${{ matrix.targetabi }}-on-${{ matrix.hostabi }} | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('version.cmake') }} | |
restore-keys: | | |
${{ runner.os }}-dist-${{ env.cache-name }}- | |
# ================ Setup ================ | |
- name: Install compiler on Debian/Ubuntu | |
if: ${{ startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-') }} | |
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends build-essential | |
- name: Install bubblewrap for Opam sandboxing on Debian/Ubuntu | |
if: ${{ startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-') }} | |
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends bubblewrap | |
- name: Install 32-bit GCC on Debian/Ubuntu for 32-bit target ABIs | |
if: ${{ (startsWith(matrix.os, 'debian-') || startsWith(matrix.os, 'ubuntu-')) && matrix.targetbits == 32 }} | |
run: sudo env DEBIAN_FRONTEND="noninteractive" apt-get -q install -y --no-install-recommends gcc-multilib g++-multilib | |
# ================ Build ================ | |
- name: Setup ${{ env.BUILD_TYPE }} OCaml | |
run: | | |
vendor/dkml-compiler/src/r-c-ocaml-1-setup.sh \ | |
-d . \ | |
-t "${{ env.DIST_DIR }}" \ | |
-v "${{ env.OCAML_GIT_REV }}" \ | |
-e "${{ matrix.hostabi }}" \ | |
-a "${{ matrix.targetabi }}=${{ matrix.ocamlconfigure }}" \ | |
-k vendor/dkml-compiler/env/standard-compiler-env-to-ocaml-configure-env.sh | |
- name: Build ${{ env.BUILD_TYPE }} OCaml for host ${{ matrix.hostabi }} ABI | |
run: cd "${{ env.DIST_DIR }}" && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-2-build_host-noargs.sh | |
- name: Build ${{ env.BUILD_TYPE }} OCaml for host cross onto target ${{ matrix.targetabi }} ABI | |
run: cd "${{ env.DIST_DIR }}" && share/dkml/repro/100co/vendor/dkml-compiler/src/r-c-ocaml-3-build_cross-noargs.sh | |
- name: Audit file structure | |
# Use stderr since `set -x` goes to stderr and GitHub does not interleave stdout/stderr nicely | |
run: | | |
set "-x" | |
cd "${{ env.DIST_DIR }}" | |
find . -maxdepth 2 -type d >&2 | |
file bin/* >&2 | |
find opt/mlcross/ -maxdepth 2 -type d >&2 | |
file opt/mlcross/${{ matrix.targetabi }}/bin/* >&2 | |
- name: Test cross-compiling OCaml | |
run: | | |
echo 'let () = print_endline "Hello World!"' > hello_world.ml | |
"${{ env.DIST_DIR }}"/opt/mlcross/${{ matrix.targetabi }}/bin/ocamlopt.opt hello_world.ml -o hello_world.opt.exe -verbose | |
file hello_world.opt.exe | |
if [ ! "$(file hello_world.opt.exe)" = "hello_world.opt.exe: ${{ matrix.expectfile }}" ]; then | |
printf "FATAL: The archictecture of the OCaml compiled executable does not match the expected architecture: ${{ matrix.expectfile }}\n" | |
exit 1 | |
fi |