add_workflow #1
7 changed files with 592 additions and 8 deletions
134
.forgejo/scripts/freebsd-build.sh
Normal file
134
.forgejo/scripts/freebsd-build.sh
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
#!/bin/sh
|
||||
# Build hate-no-d inside a FreeBSD VM and copy the binary back.
|
||||
#
|
||||
# freebsd-build.sh <output-file> [source-dir]
|
||||
#
|
||||
# Needs qemu-system-x86, cloud-image-utils, openssh-client, xz and curl, plus
|
||||
# /dev/kvm (act_runner: options: "--device /dev/kvm"); under TCG the boot takes
|
||||
# many minutes. The guest runs with -snapshot, so nothing persists.
|
||||
set -eu
|
||||
|
||||
VERSION="${FREEBSD_VERSION:-15.1}"
|
||||
ARCH=amd64
|
||||
BASE="https://download.freebsd.org/releases/VM-IMAGES/${VERSION}-RELEASE/${ARCH}/Latest"
|
||||
IMAGE="FreeBSD-${VERSION}-RELEASE-${ARCH}-BASIC-CLOUDINIT-ufs.qcow2.xz"
|
||||
SSH_PORT="${FREEBSD_SSH_PORT:-2222}"
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "usage: $0 <output-file> [source-dir]" >&2
|
||||
exit 2
|
||||
fi
|
||||
OUT_DIR=$(dirname "$1")
|
||||
mkdir -p "$OUT_DIR"
|
||||
OUT=$(cd "$OUT_DIR" && pwd)/$(basename "$1")
|
||||
SRC=$(cd "${2:-.}" && pwd)
|
||||
|
||||
WORK="${FBSD_WORK:-${TMPDIR:-/tmp}/fbsd-ci}"
|
||||
|
||||
log() { echo "freebsd-build: $*"; }
|
||||
die() { echo "freebsd-build: $*" >&2; exit 1; }
|
||||
|
||||
[ -r /dev/kvm ] && [ -w /dev/kvm ] || die "/dev/kvm is not usable; the runner must expose it (container options: --device /dev/kvm)"
|
||||
|
||||
mkdir -p "$WORK"
|
||||
cd "$WORK"
|
||||
|
||||
# --- guest credentials -------------------------------------------------------
|
||||
[ -f id_ci ] || ssh-keygen -t ed25519 -N '' -f id_ci -q
|
||||
chmod 600 id_ci
|
||||
PUB=$(cat id_ci.pub)
|
||||
|
||||
cat > user-data <<EOF
|
||||
#cloud-config
|
||||
hostname: fbsd-ci
|
||||
disable_root: false
|
||||
ssh_pwauth: false
|
||||
users:
|
||||
- name: root
|
||||
ssh_authorized_keys:
|
||||
- $PUB
|
||||
runcmd:
|
||||
- sed -i '' -e 's/^#*PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
|
||||
- sysrc sshd_enable=YES
|
||||
- service sshd restart
|
||||
EOF
|
||||
|
||||
cat > meta-data <<'EOF'
|
||||
instance-id: fbsd-ci-1
|
||||
local-hostname: fbsd-ci
|
||||
EOF
|
||||
|
||||
# --- disk image --------------------------------------------------------------
|
||||
if [ ! -f disk.qcow2 ]; then
|
||||
[ -f "$IMAGE" ] || { log "downloading $IMAGE"; curl -fsSL -o "$IMAGE" "$BASE/$IMAGE"; }
|
||||
log "decompressing"
|
||||
xz -dc -T0 "$IMAGE" > disk.qcow2
|
||||
fi
|
||||
|
||||
log "building cloud-init seed"
|
||||
cloud-localds seed.iso user-data meta-data
|
||||
|
||||
# --- boot --------------------------------------------------------------------
|
||||
SSH_OPTS="-i $WORK/id_ci -p $SSH_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o BatchMode=yes -o ConnectTimeout=3"
|
||||
SCP_OPTS="-i $WORK/id_ci -P $SSH_PORT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o BatchMode=yes"
|
||||
|
||||
rm -f console.log qemu.pid
|
||||
qemu_pid=""
|
||||
|
||||
cleanup() {
|
||||
if [ -n "$qemu_pid" ] && kill -0 "$qemu_pid" 2>/dev/null; then
|
||||
kill "$qemu_pid" 2>/dev/null || true
|
||||
wait "$qemu_pid" 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT INT TERM
|
||||
|
||||
log "booting FreeBSD $VERSION"
|
||||
qemu-system-x86_64 \
|
||||
-M q35 -cpu host -smp 2 -m 2048 \
|
||||
-enable-kvm \
|
||||
-drive file=disk.qcow2,if=virtio,format=qcow2,snapshot=on \
|
||||
-drive file=seed.iso,if=virtio,media=cdrom,readonly=on \
|
||||
-netdev "user,id=n0,hostfwd=tcp:127.0.0.1:${SSH_PORT}-:22" \
|
||||
-device virtio-net-pci,netdev=n0 \
|
||||
-display none -serial file:console.log \
|
||||
-daemonize -pidfile qemu.pid
|
||||
qemu_pid=$(cat qemu.pid)
|
||||
|
||||
ssh_vm() { ssh $SSH_OPTS "root@127.0.0.1" "$@"; }
|
||||
|
||||
i=0
|
||||
until ssh_vm true 2>/dev/null; do
|
||||
i=$((i + 1))
|
||||
if [ "$i" -gt 90 ]; then
|
||||
tail -40 console.log >&2 || true
|
||||
die "guest did not become reachable over SSH"
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
log "guest up after ~$((i * 2))s: $(ssh_vm 'uname -sr')"
|
||||
|
||||
# --- build -------------------------------------------------------------------
|
||||
log "installing gmake in guest"
|
||||
ssh_vm 'set -e; env ASSUME_ALWAYS_YES=yes pkg install -y gmake >/dev/null 2>&1; gmake --version | head -1'
|
||||
|
||||
log "transferring source"
|
||||
tar czf "$WORK/src.tar.gz" -C "$SRC" \
|
||||
--exclude=.git --exclude=.build --exclude=hate-no-d \
|
||||
--exclude='*.o' --exclude='*.a' --exclude='*.so' .
|
||||
scp $SCP_OPTS "$WORK/src.tar.gz" "root@127.0.0.1:/root/src.tar.gz"
|
||||
|
||||
# FreeBSD has no gcc: CC must be on the command line to reach the sub-make.
|
||||
log "building"
|
||||
ssh_vm 'set -e
|
||||
rm -rf /root/src && mkdir -p /root/src
|
||||
tar xzf /root/src.tar.gz -C /root/src
|
||||
cd /root/src
|
||||
gmake CC=cc clean >/dev/null 2>&1 || true
|
||||
gmake CC=cc all'
|
||||
|
||||
log "fetching binary"
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
scp $SCP_OPTS "root@127.0.0.1:/root/src/hate-no-d" "$OUT"
|
||||
|
||||
log "built $OUT ($(wc -c < "$OUT") bytes)"
|
||||
68
.forgejo/scripts/release-asset.sh
Normal file
68
.forgejo/scripts/release-asset.sh
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/sh
|
||||
# Attach one file to the release for $TAG, creating the release if needed.
|
||||
#
|
||||
# release-asset.sh <file> [asset-name]
|
||||
#
|
||||
# Idempotent: a re-run replaces the asset, and jobs racing to create the same
|
||||
# release converge. Env: FORGEJO_API_URL, FORGEJO_TOKEN, REPO, TAG.
|
||||
set -eu
|
||||
|
||||
api="${FORGEJO_API_URL:?FORGEJO_API_URL is not set}"
|
||||
repo="${REPO:?REPO is not set}"
|
||||
tag="${TAG:?TAG is not set}"
|
||||
token="${FORGEJO_TOKEN:?FORGEJO_TOKEN is not set}"
|
||||
|
||||
case "$api" in
|
||||
http*) ;;
|
||||
*)
|
||||
# An unexpanded github.server_url leaves a bare "/api/v1"; fail loudly.
|
||||
echo "release-asset: FORGEJO_API_URL is not a URL: '$api'" >&2
|
||||
echo " set github.server_url support or override the env var" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
file="$1"
|
||||
name="${2:-$(basename "$file")}"
|
||||
|
||||
[ -f "$file" ] || { echo "release-asset: no such file: $file" >&2; exit 1; }
|
||||
|
||||
auth="Authorization: token $token"
|
||||
get_rid() {
|
||||
curl -fsS -H "$auth" "$api/repos/$repo/releases/tags/$tag" | jq -r '.id // empty'
|
||||
}
|
||||
|
||||
rid="$(get_rid || true)"
|
||||
|
||||
if [ -z "$rid" ]; then
|
||||
echo "release-asset: creating release $tag"
|
||||
curl -sS -o /dev/null -H "$auth" -H 'Content-Type: application/json' \
|
||||
-X POST "$api/repos/$repo/releases" \
|
||||
--data "$(jq -nc --arg t "$tag" '{tag_name: $t, name: $t}')" || true
|
||||
|
||||
# A parallel job may have created it between our GET and POST.
|
||||
i=0
|
||||
while [ -z "$rid" ] && [ "$i" -lt 5 ]; do
|
||||
sleep 1
|
||||
rid="$(get_rid || true)"
|
||||
i=$((i + 1))
|
||||
done
|
||||
fi
|
||||
|
||||
[ -n "$rid" ] || { echo "release-asset: cannot resolve release for $tag" >&2; exit 1; }
|
||||
|
||||
# Replace a same-named asset so a re-run does not accumulate duplicates.
|
||||
old="$(curl -fsS -H "$auth" "$api/repos/$repo/releases/$rid/assets" \
|
||||
| jq -r --arg n "$name" '.[] | select(.name == $n) | .id' | head -1)"
|
||||
|
||||
if [ -n "$old" ]; then
|
||||
echo "release-asset: replacing existing asset $name"
|
||||
curl -fsS -o /dev/null -H "$auth" \
|
||||
-X DELETE "$api/repos/$repo/releases/$rid/assets/$old"
|
||||
fi
|
||||
|
||||
curl -fsS -H "$auth" -X POST \
|
||||
"$api/repos/$repo/releases/$rid/assets?name=$name" \
|
||||
-F "attachment=@$file" >/dev/null
|
||||
|
||||
echo "release-asset: uploaded $name to $tag"
|
||||
86
.forgejo/workflows/apple.yml
Normal file
86
.forgejo/workflows/apple.yml
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# Apple targets (macOS + iOS), kept out of release.yml: they need a `macos`
|
||||
# runner. Gating them there with `if: vars.*` does not work -- Forgejo does not
|
||||
# evaluate `vars` in `if:`, so the jobs queued forever and the run never
|
||||
# finished. Manual dispatch only, until a Mac runner exists.
|
||||
name: apple
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Release tag to attach artifacts to (empty = build only)'
|
||||
required: false
|
||||
default: ''
|
||||
|
||||
env:
|
||||
FORGEJO_API_URL: ${{ github.server_url }}/api/v1
|
||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ github.event.inputs.tag }}
|
||||
|
||||
jobs:
|
||||
# ---------------------------------------------------------------------------
|
||||
# macOS. The SDKs are universal: only target objects get -arch.
|
||||
# ---------------------------------------------------------------------------
|
||||
macos:
|
||||
name: macos/${{ matrix.arch }}
|
||||
runs-on: macos
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
arch: [arm64, x86_64]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
# luajit.org is dumb HTTP and rejects the --depth that checkout's
|
||||
# submodule support always passes, so clone it here in full.
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
make \
|
||||
CFLAGS="-O2 -Wall -arch ${{ matrix.arch }}" \
|
||||
LUAJIT_EXTRA="TARGET_FLAGS=-arch ${{ matrix.arch }}" \
|
||||
all
|
||||
|
||||
- name: Verify architecture
|
||||
run: |
|
||||
set -eu
|
||||
file ./hate-no-d
|
||||
file ./hate-no-d | grep -q '${{ matrix.arch }}'
|
||||
|
||||
- name: Attach to release
|
||||
if: github.event.inputs.tag != ''
|
||||
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d "hate-no-d-macos-${{ matrix.arch }}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# iOS. Builds only the archive (JIT compiled out) for an Xcode app target.
|
||||
# ---------------------------------------------------------------------------
|
||||
ios:
|
||||
name: ios/arm64
|
||||
runs-on: macos
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Build libluajit.a
|
||||
run: make PLATFORM=iOS IOS_ARCH=arm64 all
|
||||
|
||||
- name: Verify archive
|
||||
run: |
|
||||
set -eu
|
||||
lipo -info submodules/luajit/src/libluajit.a
|
||||
lipo -info submodules/luajit/src/libluajit.a | grep -q arm64
|
||||
|
||||
- name: Attach to release
|
||||
if: github.event.inputs.tag != ''
|
||||
run: sh .forgejo/scripts/release-asset.sh submodules/luajit/src/libluajit.a hate-no-d-ios-arm64-luajit.a
|
||||
258
.forgejo/workflows/release.yml
Normal file
258
.forgejo/workflows/release.yml
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
# Build every supported target and attach the binaries to a Forgejo release.
|
||||
#
|
||||
# push / pull_request -> build only
|
||||
# tag 'v*' -> build + release assets
|
||||
#
|
||||
# Assets: hate-no-d-linux-*, -android-*, -windows_mingw_w64-*.exe, -freebsd-x86_64.
|
||||
# macOS/iOS live in apple.yml; everything here builds on the Linux runner.
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
tags: ['v*']
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Forgejo ignores `permissions:`; the workflow token already has write access
|
||||
# to its own repo, and fork PRs never reach the tag-gated upload steps.
|
||||
|
||||
env:
|
||||
FORGEJO_API_URL: ${{ github.server_url }}/api/v1
|
||||
FORGEJO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REPO: ${{ github.repository }}
|
||||
TAG: ${{ github.ref_name }}
|
||||
|
||||
jobs:
|
||||
# ---------------------------------------------------------------------------
|
||||
# Linux. bookworm sets the glibc 2.36 floor (Debian 12, Ubuntu 24.04+) and is
|
||||
# shared with the android/windows jobs. Do not fall back to bullseye: its LTS
|
||||
# ended 2026-08 and deb.debian.org no longer serves bullseye-security.
|
||||
# ---------------------------------------------------------------------------
|
||||
linux:
|
||||
name: linux/${{ matrix.arch }}
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-bookworm # node + git: actions/checkout is a JS action
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
machine: X86-64
|
||||
make_args: ''
|
||||
packages: ''
|
||||
# 32-bit target: leaving HOST_CC unset keeps minilua/buildvm 32-bit
|
||||
# too. Host and target pointer sizes must match -- do not use HOST_CC=gcc.
|
||||
- arch: i686
|
||||
machine: 'Intel 80386'
|
||||
make_args: 'CC="gcc -m32"'
|
||||
packages: 'gcc-multilib libc6-dev-i386'
|
||||
# 64-bit host -> 64-bit target, so host tools stay native.
|
||||
- arch: aarch64
|
||||
machine: AArch64
|
||||
make_args: 'CC=aarch64-linux-gnu-gcc HOST_CC=gcc'
|
||||
packages: 'gcc-aarch64-linux-gnu libc6-dev-arm64-cross qemu-user-static'
|
||||
# 32-bit target, so the host tools must be 32-bit too. gcc-multilib
|
||||
# cannot be installed (gcc-12-arm-linux-gnueabihf conflicts with it);
|
||||
# lib32gcc-12-dev + libc6-dev-i386 replace it, and linux-libc-dev:i386
|
||||
# adds the 32-bit asm/ headers.
|
||||
- arch: armv7
|
||||
machine: ARM
|
||||
make_args: 'CC=arm-linux-gnueabihf-gcc HOST_CC="gcc -m32"'
|
||||
packages: 'gcc-arm-linux-gnueabihf libc6-dev-armhf-cross lib32gcc-12-dev libc6-dev-i386 linux-libc-dev:i386 qemu-user-static'
|
||||
multiarch_i386: true
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
set -eu
|
||||
# Only armv7: linux-libc-dev:i386 provides its 32-bit asm/ headers.
|
||||
if [ '${{ matrix.multiarch_i386 }}' = 'true' ]; then
|
||||
dpkg --add-architecture i386
|
||||
fi
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends \
|
||||
make gcc libc6-dev binutils jq curl ca-certificates ${{ matrix.packages }}
|
||||
|
||||
- name: Build
|
||||
run: make ${{ matrix.make_args }} all
|
||||
|
||||
# A mis-set CC silently yields a host binary, so check the ELF machine.
|
||||
- name: Verify architecture
|
||||
run: |
|
||||
set -eu
|
||||
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}'
|
||||
echo "architecture ok: ${{ matrix.machine }}"
|
||||
|
||||
- name: Attach to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d "hate-no-d-linux-${{ matrix.arch }}"
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Android. One job for all ABIs so the ~630 MB NDK is downloaded once. The
|
||||
# binaries are Bionic ELF, so only the ELF header can be checked here.
|
||||
# ---------------------------------------------------------------------------
|
||||
android:
|
||||
name: android
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
env:
|
||||
ANDROID_NDK_VERSION: r27c
|
||||
ANDROID_NDK: /opt/android-ndk-r27c
|
||||
ANDROID_API: '21'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Install toolchain
|
||||
# gcc-multilib: armeabi-v7a needs 32-bit host tools.
|
||||
run: |
|
||||
set -eu
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends \
|
||||
make gcc libc6-dev binutils jq curl ca-certificates unzip \
|
||||
gcc-multilib libc6-dev-i386
|
||||
|
||||
- name: Install NDK r27c
|
||||
run: |
|
||||
set -eu
|
||||
url="https://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux.zip"
|
||||
curl -fsSL -o /tmp/ndk.zip "$url"
|
||||
mkdir -p /opt
|
||||
unzip -q /tmp/ndk.zip -d /opt
|
||||
rm -f /tmp/ndk.zip
|
||||
test -d "$ANDROID_NDK"
|
||||
|
||||
- name: Build all ABIs
|
||||
run: |
|
||||
set -eu
|
||||
mkdir -p dist
|
||||
for abi in arm64-v8a armeabi-v7a x86_64; do
|
||||
make clean >/dev/null 2>&1 || true
|
||||
if [ "$abi" = armeabi-v7a ]; then
|
||||
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
||||
ANDROID_ABI="$abi" HOST_CC="gcc -m32" all
|
||||
else
|
||||
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
||||
ANDROID_ABI="$abi" HOST_CC=gcc all
|
||||
fi
|
||||
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -E 'AArch64|ARM|X86-64'
|
||||
cp ./hate-no-d "dist/hate-no-d-android-$abi"
|
||||
done
|
||||
|
||||
- name: Attach to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: |
|
||||
set -eu
|
||||
for abi in arm64-v8a armeabi-v7a x86_64; do
|
||||
sh .forgejo/scripts/release-asset.sh "dist/hate-no-d-android-$abi" "hate-no-d-android-$abi"
|
||||
done
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# FreeBSD. Compiled inside a QEMU/KVM guest, so no FreeBSD runner is needed.
|
||||
# The container must expose /dev/kvm (act_runner: options: "--device /dev/kvm"),
|
||||
# otherwise QEMU falls back to TCG and the boot crawls. ~1m40s end to end.
|
||||
# ---------------------------------------------------------------------------
|
||||
bsd:
|
||||
name: freebsd/x86_64
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Install QEMU
|
||||
run: |
|
||||
set -eu
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends \
|
||||
qemu-system-x86 cloud-image-utils openssh-client xz-utils jq
|
||||
|
||||
- name: Build in FreeBSD VM
|
||||
run: |
|
||||
set -eu
|
||||
mkdir -p dist
|
||||
sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d-freebsd-x86_64 .
|
||||
|
||||
- name: Attach to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: sh .forgejo/scripts/release-asset.sh dist/hate-no-d-freebsd-x86_64 hate-no-d-freebsd-x86_64
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Windows. Cross-compiled with mingw-w64; no Windows machine or MSVC involved.
|
||||
# i686 needs a 32-bit host compiler for the native buildvm. The build stays
|
||||
# hate-no-d.exe -- only the release asset name carries the toolchain.
|
||||
# ---------------------------------------------------------------------------
|
||||
windows:
|
||||
name: windows/${{ matrix.arch }}
|
||||
runs-on: docker
|
||||
container:
|
||||
image: node:20-bookworm
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
tag: windows_mingw_w64-x64
|
||||
host_cc: gcc
|
||||
- arch: i686
|
||||
tag: windows_mingw_w64-x86
|
||||
host_cc: gcc -m32
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://data.forgejo.org/actions/checkout@v4
|
||||
with:
|
||||
submodules: false
|
||||
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
# --no-install-recommends omits libc6-dev, and minilua needs limits.h.
|
||||
- name: Install toolchain
|
||||
run: |
|
||||
set -eu
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends \
|
||||
make gcc libc6-dev gcc-multilib mingw-w64 jq
|
||||
|
||||
- name: Build
|
||||
run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all
|
||||
|
||||
- name: Verify executable
|
||||
run: |
|
||||
set -eu
|
||||
bin=hate-no-d.exe
|
||||
file "./$bin" | grep -q 'for MS Windows'
|
||||
deps=$(${{ matrix.arch }}-w64-mingw32-objdump -p "./$bin" | awk '/DLL Name/{print $3}')
|
||||
echo "$deps"
|
||||
bad=$(printf '%s\n' "$deps" | grep -v -E '^(KERNEL32|msvcrt)\.dll$' || true)
|
||||
[ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; }
|
||||
|
||||
- name: Attach to release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d.exe hate-no-d-${{ matrix.tag }}.exe
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,2 +1,3 @@
|
|||
hate-no-d
|
||||
hate-no-d.exe
|
||||
quick-start.lua
|
||||
|
|
|
|||
33
Makefile
33
Makefile
|
|
@ -5,6 +5,7 @@
|
|||
# make PLATFORM=Android ANDROID_NDK=/opt/android-ndk
|
||||
# make PLATFORM=Android ANDROID_NDK=... ANDROID_ABI=armeabi-v7a ANDROID_API=21
|
||||
# make PLATFORM=iOS IOS_ARCH=arm64 IOS_MIN=12.0
|
||||
# make PLATFORM=Windows WIN_ARCH=x86_64 (cross build with mingw-w64)
|
||||
|
||||
# luajit requires GNU Make (use `gmake` on FreeBSD/OpenBSD/NetBSD).
|
||||
ifndef .FEATURES
|
||||
|
|
@ -32,6 +33,8 @@ else ifeq ($(PLATFORM),Darwin)
|
|||
OS_KIND := macos
|
||||
else ifeq ($(PLATFORM),iOS)
|
||||
OS_KIND := ios
|
||||
else ifeq ($(PLATFORM),Windows)
|
||||
OS_KIND := windows
|
||||
else ifneq (,$(filter $(PLATFORM),FreeBSD OpenBSD NetBSD DragonFly GNU/kFreeBSD))
|
||||
OS_KIND := bsd
|
||||
else
|
||||
|
|
@ -60,6 +63,35 @@ ifeq ($(OS_KIND),posix)
|
|||
LINK_TARGET := $(BIN)
|
||||
endif
|
||||
|
||||
# Windows (PE, cross-compiled from a POSIX host with mingw-w64)
|
||||
#
|
||||
# Native builds use build.bat.
|
||||
#
|
||||
# 64-bit targets build on any 64-bit host. i686 also needs a 32-bit host
|
||||
# compiler, because LuaJIT's buildvm runs natively and its pointer size must
|
||||
# match the target:
|
||||
# make PLATFORM=Windows WIN_ARCH=i686 HOST_CC="gcc -m32"
|
||||
#
|
||||
# No export table: ffi.C resolves through msvcrt/kernel32 handles on Windows,
|
||||
# unlike ELF where the Lua API has to be exported with -Wl,-E.
|
||||
ifeq ($(OS_KIND),windows)
|
||||
WIN_ARCH ?= x86_64
|
||||
|
||||
ifeq ($(filter $(WIN_ARCH),x86_64 i686),)
|
||||
$(error WIN_ARCH must be x86_64 or i686)
|
||||
endif
|
||||
|
||||
CC := $(WIN_ARCH)-w64-mingw32-gcc
|
||||
HOST_CC ?= gcc
|
||||
PLAT_LIBS := -lm
|
||||
BIN := $(BIN).exe
|
||||
LINK_TARGET := $(BIN)
|
||||
|
||||
# LuaJIT derives HOST_CC from CC, so label both to the sub-make: otherwise
|
||||
# the host tools (minilua, buildvm) are compiled with the cross compiler.
|
||||
LUAJIT_EXTRA := "CC=$(CC)" "HOST_CC=$(HOST_CC)" TARGET_SYS=Windows
|
||||
endif
|
||||
|
||||
# macOS (Mach-O)
|
||||
#
|
||||
# ld64 exports main-executable globals by default; -export_dynamic only stops
|
||||
|
|
@ -192,6 +224,7 @@ print-config:
|
|||
@echo "MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET) (HRT=$(MACOSX_HRT))"
|
||||
@echo "ANDROID_ABI / API = $(ANDROID_ABI) / $(ANDROID_API)"
|
||||
@echo "IOS_ARCH / MIN = $(IOS_ARCH) / $(IOS_MIN)"
|
||||
@echo "WIN_ARCH = $(WIN_ARCH) (HOST_CC=$(HOST_CC))"
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(LUAJIT_DIR) clean
|
||||
|
|
|
|||
20
README.md
20
README.md
|
|
@ -4,27 +4,31 @@ A [Love2D](https://www.love2d.org/) antagonist.
|
|||
|
||||
## Quick Start
|
||||
|
||||
### On Linux, macOS, BSD, POSIX or Windows-MinGW
|
||||
|
||||
```sh
|
||||
echo -e 'print("Hey! I am hate-no-d!")' > quick-start.lua
|
||||
./hate-no-d quick-start.lua
|
||||
```
|
||||
|
||||
### On Windows MSVC
|
||||
|
||||
```bat
|
||||
echo print("Hey! I am hate-no-d!") > quick-start.lua
|
||||
hate-no-d.exe quick-start.lua
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
### On Linux, macOS, BSD, POSIX or Windows-MinGW
|
||||
|
||||
```sh
|
||||
git clone --recurse-submodules https://git.pbento.pt/pedro-bento/hate-no-d.git
|
||||
cd hate-no-d
|
||||
make
|
||||
```
|
||||
|
||||
## Quick Start (Windows)
|
||||
|
||||
```bat
|
||||
echo print("Hey! I am hate-no-d!") > quick-start.lua
|
||||
hate-no-d.exe quick-start.lua
|
||||
```
|
||||
|
||||
## Build (Windows)
|
||||
### On Windows MSVC
|
||||
|
||||
```bat
|
||||
git clone --recurse-submodules https://git.pbento.pt/pedro-bento/hate-no-d.git
|
||||
|
|
|
|||
Loading…
Reference in a new issue