Compare commits
No commits in common. "f55209223537bae6172e2edfb3852ef22c04c3be" and "8a68a2c2cac25fed107cffb0f8f2c1c66fa30bb2" have entirely different histories.
f552092235
...
8a68a2c2ca
6 changed files with 32 additions and 228 deletions
|
|
@ -1,11 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Build hate-no-d inside a FreeBSD VM and copy the binary and the static
|
# Build hate-no-d inside a FreeBSD VM and copy the binary back.
|
||||||
# library back.
|
|
||||||
#
|
#
|
||||||
# freebsd-build.sh <output-file> [source-dir]
|
# freebsd-build.sh <output-file> [source-dir]
|
||||||
#
|
#
|
||||||
# The archive lands next to <output-file> as libhate-no-d.a.
|
|
||||||
#
|
|
||||||
# Needs qemu-system-x86, cloud-image-utils, openssh-client, xz and curl, plus
|
# 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
|
# /dev/kvm (act_runner: options: "--device /dev/kvm"); under TCG the boot takes
|
||||||
# many minutes. The guest runs with -snapshot, so nothing persists.
|
# many minutes. The guest runs with -snapshot, so nothing persists.
|
||||||
|
|
@ -128,12 +125,10 @@ ssh_vm 'set -e
|
||||||
tar xzf /root/src.tar.gz -C /root/src
|
tar xzf /root/src.tar.gz -C /root/src
|
||||||
cd /root/src
|
cd /root/src
|
||||||
gmake CC=cc clean >/dev/null 2>&1 || true
|
gmake CC=cc clean >/dev/null 2>&1 || true
|
||||||
gmake CC=cc all lib'
|
gmake CC=cc all'
|
||||||
|
|
||||||
log "fetching artifacts"
|
log "fetching binary"
|
||||||
mkdir -p "$OUT_DIR"
|
mkdir -p "$(dirname "$OUT")"
|
||||||
scp $SCP_OPTS "root@127.0.0.1:/root/src/hate-no-d" "$OUT"
|
scp $SCP_OPTS "root@127.0.0.1:/root/src/hate-no-d" "$OUT"
|
||||||
scp $SCP_OPTS "root@127.0.0.1:/root/src/libhate-no-d.a" "$OUT_DIR/libhate-no-d.a"
|
|
||||||
|
|
||||||
log "built $OUT ($(wc -c < "$OUT") bytes)"
|
log "built $OUT ($(wc -c < "$OUT") bytes)"
|
||||||
log "built $OUT_DIR/libhate-no-d.a ($(wc -c < "$OUT_DIR/libhate-no-d.a") bytes)"
|
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Stage one release asset into a directory and pack it, so every download is a
|
|
||||||
# self-contained "folder" instead of a bare binary.
|
|
||||||
#
|
|
||||||
# make-archive.sh <asset-name> <tar.gz|zip> <payload>...
|
|
||||||
#
|
|
||||||
# asset-name e.g. hate-no-d-linux-x86_64; also the directory inside the
|
|
||||||
# archive, so unpacking never scatters files
|
|
||||||
# format tar.gz for Unix payloads (keeps the executable bit), zip for
|
|
||||||
# Windows ones
|
|
||||||
# payload files to pack, each keeping its basename
|
|
||||||
#
|
|
||||||
# LICENSE and README.md are added from the working directory when present.
|
|
||||||
# Writes ./<asset-name>.<format> and leaves the staging directory behind.
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
if [ $# -lt 3 ]; then
|
|
||||||
echo "usage: $0 <asset-name> <tar.gz|zip> <payload>..." >&2
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
name=$1
|
|
||||||
format=$2
|
|
||||||
shift 2
|
|
||||||
|
|
||||||
# Guard the rm -rf below.
|
|
||||||
case "$name" in
|
|
||||||
'' | */*) echo "make-archive: bad asset name: '$name'" >&2; exit 2 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$format" in
|
|
||||||
tar.gz | zip) ;;
|
|
||||||
*) echo "make-archive: unknown format: '$format'" >&2; exit 2 ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
for f in "$@"; do
|
|
||||||
[ -f "$f" ] || { echo "make-archive: no such file: $f" >&2; exit 1; }
|
|
||||||
done
|
|
||||||
|
|
||||||
rm -rf "$name"
|
|
||||||
mkdir -p "$name"
|
|
||||||
|
|
||||||
# The first payload is the binary: make its mode deterministic instead of
|
|
||||||
# trusting whatever the build/copy path produced.
|
|
||||||
first=1
|
|
||||||
for f in "$@"; do
|
|
||||||
cp "$f" "$name/$(basename "$f")"
|
|
||||||
if [ "$first" = 1 ]; then
|
|
||||||
chmod 755 "$name/$(basename "$f")"
|
|
||||||
first=0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
for f in LICENSE README.md; do
|
|
||||||
if [ -f "$f" ]; then
|
|
||||||
cp "$f" "$name/"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
case "$format" in
|
|
||||||
tar.gz) tar -czf "$name.tar.gz" "$name" ;;
|
|
||||||
zip) zip -qr -X "$name.zip" "$name" >/dev/null ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "make-archive: wrote $name.$format"
|
|
||||||
ls -l "$name" | sed 's/^/make-archive: /'
|
|
||||||
|
|
@ -45,7 +45,7 @@ jobs:
|
||||||
make \
|
make \
|
||||||
CFLAGS="-O2 -Wall -arch ${{ matrix.arch }}" \
|
CFLAGS="-O2 -Wall -arch ${{ matrix.arch }}" \
|
||||||
LUAJIT_EXTRA="TARGET_FLAGS=-arch ${{ matrix.arch }}" \
|
LUAJIT_EXTRA="TARGET_FLAGS=-arch ${{ matrix.arch }}" \
|
||||||
all lib
|
all
|
||||||
|
|
||||||
- name: Verify architecture
|
- name: Verify architecture
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -53,13 +53,9 @@ jobs:
|
||||||
file ./hate-no-d
|
file ./hate-no-d
|
||||||
file ./hate-no-d | grep -q '${{ matrix.arch }}'
|
file ./hate-no-d | grep -q '${{ matrix.arch }}'
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-macos-${{ matrix.arch }}" tar.gz \
|
|
||||||
./hate-no-d ./libhate-no-d.a
|
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
if: github.event.inputs.tag != ''
|
if: github.event.inputs.tag != ''
|
||||||
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-macos-${{ matrix.arch }}.tar.gz"
|
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. Builds only the archive (JIT compiled out) for an Xcode app target.
|
||||||
|
|
@ -76,21 +72,15 @@ jobs:
|
||||||
- name: Fetch submodules
|
- name: Fetch submodules
|
||||||
run: git submodule update --init --recursive
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
- name: Build static library
|
- name: Build libluajit.a
|
||||||
run: make PLATFORM=iOS IOS_ARCH=arm64 all lib
|
run: make PLATFORM=iOS IOS_ARCH=arm64 all
|
||||||
|
|
||||||
- name: Verify archive
|
- name: Verify archive
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
# libhate-no-d.a is what ships; it must be single-arch arm64 Mach-O.
|
lipo -info submodules/luajit/src/libluajit.a
|
||||||
lipo -info ./libhate-no-d.a
|
lipo -info submodules/luajit/src/libluajit.a | grep -q arm64
|
||||||
lipo -info ./libhate-no-d.a | grep -q arm64
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
# Only a static archive ships here: iOS forbids JIT, so libhate-no-d.a is
|
|
||||||
# the deliverable to link into an Xcode target. There is no binary.
|
|
||||||
run: sh .forgejo/scripts/make-archive.sh hate-no-d-ios-arm64 tar.gz ./libhate-no-d.a
|
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
if: github.event.inputs.tag != ''
|
if: github.event.inputs.tag != ''
|
||||||
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d-ios-arm64.tar.gz
|
run: sh .forgejo/scripts/release-asset.sh submodules/luajit/src/libluajit.a hate-no-d-ios-arm64-luajit.a
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,7 @@
|
||||||
# push / pull_request -> build only
|
# push / pull_request -> build only
|
||||||
# tag 'v*' -> build + release assets
|
# tag 'v*' -> build + release assets
|
||||||
#
|
#
|
||||||
# Assets: one archive per target, named hate-no-d-<os>-<arch>.tar.gz (zip on
|
# Assets: hate-no-d-linux-*, -android-*, -windows_mingw_w64-*.exe, -freebsd-x86_64.
|
||||||
# Windows), each unpacking to a directory of the same name holding the binary
|
|
||||||
# plus LICENSE and README.md. Release attachments are a flat list with no
|
|
||||||
# folders, so the archive is what groups a target's files together.
|
|
||||||
# macOS/iOS live in apple.yml; everything here builds on the Linux runner.
|
# macOS/iOS live in apple.yml; everything here builds on the Linux runner.
|
||||||
name: release
|
name: release
|
||||||
|
|
||||||
|
|
@ -90,7 +87,7 @@ jobs:
|
||||||
make gcc libc6-dev binutils jq curl ca-certificates ${{ matrix.packages }}
|
make gcc libc6-dev binutils jq curl ca-certificates ${{ matrix.packages }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make ${{ matrix.make_args }} all lib
|
run: make ${{ matrix.make_args }} all
|
||||||
|
|
||||||
# A mis-set CC silently yields a host binary, so check the ELF machine.
|
# A mis-set CC silently yields a host binary, so check the ELF machine.
|
||||||
- name: Verify architecture
|
- name: Verify architecture
|
||||||
|
|
@ -99,12 +96,9 @@ jobs:
|
||||||
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}'
|
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -F '${{ matrix.machine }}'
|
||||||
echo "architecture ok: ${{ matrix.machine }}"
|
echo "architecture ok: ${{ matrix.machine }}"
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-linux-${{ matrix.arch }}" tar.gz ./hate-no-d ./libhate-no-d.a
|
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-linux-${{ matrix.arch }}.tar.gz"
|
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
|
# Android. One job for all ABIs so the ~630 MB NDK is downloaded once. The
|
||||||
|
|
@ -155,23 +149,13 @@ jobs:
|
||||||
make clean >/dev/null 2>&1 || true
|
make clean >/dev/null 2>&1 || true
|
||||||
if [ "$abi" = armeabi-v7a ]; then
|
if [ "$abi" = armeabi-v7a ]; then
|
||||||
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
||||||
ANDROID_ABI="$abi" HOST_CC="gcc -m32" all lib
|
ANDROID_ABI="$abi" HOST_CC="gcc -m32" all
|
||||||
else
|
else
|
||||||
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
make PLATFORM=Android ANDROID_NDK="$ANDROID_NDK" ANDROID_API="$ANDROID_API" \
|
||||||
ANDROID_ABI="$abi" HOST_CC=gcc all lib
|
ANDROID_ABI="$abi" HOST_CC=gcc all
|
||||||
fi
|
fi
|
||||||
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -E 'AArch64|ARM|X86-64'
|
readelf -h ./hate-no-d | grep -F 'Machine:' | grep -E 'AArch64|ARM|X86-64'
|
||||||
mkdir -p "dist/$abi"
|
cp ./hate-no-d "dist/hate-no-d-android-$abi"
|
||||||
cp ./hate-no-d "dist/$abi/hate-no-d"
|
|
||||||
cp ./libhate-no-d.a "dist/$abi/libhate-no-d.a"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: |
|
|
||||||
set -eu
|
|
||||||
for abi in arm64-v8a armeabi-v7a x86_64; do
|
|
||||||
sh .forgejo/scripts/make-archive.sh "hate-no-d-android-$abi" tar.gz \
|
|
||||||
"dist/$abi/hate-no-d" "dist/$abi/libhate-no-d.a"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
|
|
@ -179,7 +163,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
for abi in arm64-v8a armeabi-v7a x86_64; do
|
for abi in arm64-v8a armeabi-v7a x86_64; do
|
||||||
sh .forgejo/scripts/release-asset.sh "hate-no-d-android-$abi.tar.gz"
|
sh .forgejo/scripts/release-asset.sh "dist/hate-no-d-android-$abi" "hate-no-d-android-$abi"
|
||||||
done
|
done
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
@ -213,21 +197,16 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d .
|
sh .forgejo/scripts/freebsd-build.sh dist/hate-no-d-freebsd-x86_64 .
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: sh .forgejo/scripts/make-archive.sh hate-no-d-freebsd-x86_64 tar.gz \
|
|
||||||
dist/hate-no-d dist/libhate-no-d.a
|
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d-freebsd-x86_64.tar.gz
|
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.
|
# Windows. Cross-compiled with mingw-w64; no Windows machine or MSVC involved.
|
||||||
# i686 needs a 32-bit host compiler for the native buildvm. The asset is a zip
|
# i686 needs a 32-bit host compiler for the native buildvm. The build stays
|
||||||
# (Windows convention) holding hate-no-d.exe; the toolchain is not part of the
|
# hate-no-d.exe -- only the release asset name carries the toolchain.
|
||||||
# name because it is not a compatibility axis for anyone downloading it.
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
windows:
|
windows:
|
||||||
name: windows/${{ matrix.arch }}
|
name: windows/${{ matrix.arch }}
|
||||||
|
|
@ -239,8 +218,10 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- arch: x86_64
|
- arch: x86_64
|
||||||
|
tag: windows_mingw_w64-x64
|
||||||
host_cc: gcc
|
host_cc: gcc
|
||||||
- arch: i686
|
- arch: i686
|
||||||
|
tag: windows_mingw_w64-x86
|
||||||
host_cc: gcc -m32
|
host_cc: gcc -m32
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
|
@ -252,16 +233,15 @@ jobs:
|
||||||
run: git submodule update --init --recursive
|
run: git submodule update --init --recursive
|
||||||
|
|
||||||
# --no-install-recommends omits libc6-dev, and minilua needs limits.h.
|
# --no-install-recommends omits libc6-dev, and minilua needs limits.h.
|
||||||
# zip: the release asset is a .zip, matching the Windows convention.
|
|
||||||
- name: Install toolchain
|
- name: Install toolchain
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
apt-get install -y --no-install-recommends \
|
apt-get install -y --no-install-recommends \
|
||||||
make gcc libc6-dev gcc-multilib mingw-w64 jq zip
|
make gcc libc6-dev gcc-multilib mingw-w64 jq
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all lib
|
run: make PLATFORM=Windows WIN_ARCH=${{ matrix.arch }} HOST_CC="${{ matrix.host_cc }}" all
|
||||||
|
|
||||||
- name: Verify executable
|
- name: Verify executable
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -273,10 +253,6 @@ jobs:
|
||||||
bad=$(printf '%s\n' "$deps" | grep -v -E '^(KERNEL32|msvcrt)\.dll$' || true)
|
bad=$(printf '%s\n' "$deps" | grep -v -E '^(KERNEL32|msvcrt)\.dll$' || true)
|
||||||
[ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; }
|
[ -z "$bad" ] || { echo "unexpected runtime DLL dependency: $bad" >&2; exit 1; }
|
||||||
|
|
||||||
- name: Package
|
|
||||||
run: sh .forgejo/scripts/make-archive.sh "hate-no-d-windows-${{ matrix.arch }}" zip \
|
|
||||||
./hate-no-d.exe ./libhate-no-d.a
|
|
||||||
|
|
||||||
- name: Attach to release
|
- name: Attach to release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
run: sh .forgejo/scripts/release-asset.sh "./hate-no-d-windows-${{ matrix.arch }}.zip"
|
run: sh .forgejo/scripts/release-asset.sh ./hate-no-d.exe hate-no-d-${{ matrix.tag }}.exe
|
||||||
|
|
|
||||||
10
.gitignore
vendored
10
.gitignore
vendored
|
|
@ -1,13 +1,3 @@
|
||||||
hate-no-d
|
hate-no-d
|
||||||
hate-no-d.exe
|
hate-no-d.exe
|
||||||
quick-start.lua
|
quick-start.lua
|
||||||
|
|
||||||
# Release staging dirs and archives (.forgejo/scripts/make-archive.sh).
|
|
||||||
hate-no-d-*/
|
|
||||||
hate-no-d-*.tar.gz
|
|
||||||
hate-no-d-*.zip
|
|
||||||
|
|
||||||
# Build artifacts (make lib).
|
|
||||||
*.o
|
|
||||||
*.mri
|
|
||||||
libhate-no-d.a
|
|
||||||
|
|
|
||||||
91
Makefile
91
Makefile
|
|
@ -6,11 +6,6 @@
|
||||||
# make PLATFORM=Android ANDROID_NDK=... ANDROID_ABI=armeabi-v7a ANDROID_API=21
|
# make PLATFORM=Android ANDROID_NDK=... ANDROID_ABI=armeabi-v7a ANDROID_API=21
|
||||||
# make PLATFORM=iOS IOS_ARCH=arm64 IOS_MIN=12.0
|
# make PLATFORM=iOS IOS_ARCH=arm64 IOS_MIN=12.0
|
||||||
# make PLATFORM=Windows WIN_ARCH=x86_64 (cross build with mingw-w64)
|
# make PLATFORM=Windows WIN_ARCH=x86_64 (cross build with mingw-w64)
|
||||||
#
|
|
||||||
# Targets:
|
|
||||||
# make the CLI (hate-no-d, or hate-no-d.exe / libluajit.a on iOS)
|
|
||||||
# make lib libhate-no-d.a, for embedding into another program
|
|
||||||
# make help every target and option
|
|
||||||
|
|
||||||
# luajit requires GNU Make (use `gmake` on FreeBSD/OpenBSD/NetBSD).
|
# luajit requires GNU Make (use `gmake` on FreeBSD/OpenBSD/NetBSD).
|
||||||
ifndef .FEATURES
|
ifndef .FEATURES
|
||||||
|
|
@ -22,22 +17,7 @@ endif
|
||||||
LUAJIT_DIR := submodules/luajit
|
LUAJIT_DIR := submodules/luajit
|
||||||
LUAJIT_SRC := $(LUAJIT_DIR)/src
|
LUAJIT_SRC := $(LUAJIT_DIR)/src
|
||||||
LUAJIT_AR := $(LUAJIT_SRC)/libluajit.a
|
LUAJIT_AR := $(LUAJIT_SRC)/libluajit.a
|
||||||
OBJ := hate-no-d.o
|
|
||||||
BIN := hate-no-d
|
BIN := hate-no-d
|
||||||
LIB := libhate-no-d.a
|
|
||||||
|
|
||||||
# Everything that goes into $(LIB) besides LuaJIT itself. Empty today: the only
|
|
||||||
# C in the tree is the CLI driver, and its main() belongs to the executable an
|
|
||||||
# embedder already has, not to a library (a -all_load/--whole-archive link would
|
|
||||||
# collide). Runtime modules added later get listed here, e.g.
|
|
||||||
# LIB_OBJS += hnod.o
|
|
||||||
# and are merged into the archive automatically -- that is why the archive has
|
|
||||||
# a name of its own instead of just being LuaJIT's.
|
|
||||||
LIB_OBJS :=
|
|
||||||
|
|
||||||
# Archiver used to merge $(LIB). Cross toolchains ship their own; Apple has no
|
|
||||||
# `ar -M`, so those targets use libtool instead (see the $(LIB) rule).
|
|
||||||
AR ?= ar
|
|
||||||
|
|
||||||
LUAJIT_XCFLAGS := -DLUAJIT_ENABLE_LUA52COMPAT
|
LUAJIT_XCFLAGS := -DLUAJIT_ENABLE_LUA52COMPAT
|
||||||
LUAJIT_EXTRA :=
|
LUAJIT_EXTRA :=
|
||||||
|
|
@ -102,7 +82,6 @@ ifeq ($(OS_KIND),windows)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CC := $(WIN_ARCH)-w64-mingw32-gcc
|
CC := $(WIN_ARCH)-w64-mingw32-gcc
|
||||||
AR := $(WIN_ARCH)-w64-mingw32-ar
|
|
||||||
HOST_CC ?= gcc
|
HOST_CC ?= gcc
|
||||||
PLAT_LIBS := -lm
|
PLAT_LIBS := -lm
|
||||||
BIN := $(BIN).exe
|
BIN := $(BIN).exe
|
||||||
|
|
@ -173,7 +152,6 @@ ifeq ($(OS_KIND),android)
|
||||||
ANDROID_CC := $(ANDROID_BIN)/$(ANDROID_TRIPLET)$(ANDROID_API)-clang
|
ANDROID_CC := $(ANDROID_BIN)/$(ANDROID_TRIPLET)$(ANDROID_API)-clang
|
||||||
|
|
||||||
CC := $(ANDROID_CC)
|
CC := $(ANDROID_CC)
|
||||||
AR := $(ANDROID_BIN)/llvm-ar
|
|
||||||
EXPORT_LDFLAGS := -Wl,-E
|
EXPORT_LDFLAGS := -Wl,-E
|
||||||
PLAT_LIBS := -lm
|
PLAT_LIBS := -lm
|
||||||
LINK_TARGET := $(BIN)
|
LINK_TARGET := $(BIN)
|
||||||
|
|
@ -223,84 +201,25 @@ $(LUAJIT_AR):
|
||||||
$(MAKE) -C $(LUAJIT_SRC) $(LUAJIT_MAKE_ARGS) "LJCORE_O=ljamalg.o" libluajit.a
|
$(MAKE) -C $(LUAJIT_SRC) $(LUAJIT_MAKE_ARGS) "LJCORE_O=ljamalg.o" libluajit.a
|
||||||
|
|
||||||
# Targets
|
# Targets
|
||||||
help:
|
|
||||||
@echo "hate-no-d -- LuaJIT-based Lua runtime"
|
|
||||||
@echo ""
|
|
||||||
@echo "Targets:"
|
|
||||||
@echo " make [all] CLI for the auto-detected platform (hate-no-d,"
|
|
||||||
@echo " hate-no-d.exe, or libluajit.a on iOS)"
|
|
||||||
@echo " make lib libhate-no-d.a: LuaJIT plus LIB_OBJS, for embedding"
|
|
||||||
@echo " make luajit LuaJIT static archive only"
|
|
||||||
@echo " make print-config resolved configuration for the current target"
|
|
||||||
@echo " make clean remove build artifacts, LuaJIT's included"
|
|
||||||
@echo " make help this text"
|
|
||||||
@echo ""
|
|
||||||
@echo "Options (pass as VAR=value):"
|
|
||||||
@echo " PLATFORM= Linux | Android | Darwin | iOS | Windows | a BSD"
|
|
||||||
@echo " (default: uname -s)"
|
|
||||||
@echo " WIN_ARCH= x86_64 | i686 [Windows]"
|
|
||||||
@echo " ANDROID_NDK= NDK root, or export ANDROID_NDK_HOME [Android]"
|
|
||||||
@echo " ANDROID_ABI= arm64-v8a | armeabi-v7a | x86_64 | x86 [Android]"
|
|
||||||
@echo " ANDROID_API= target API level, default 21 [Android]"
|
|
||||||
@echo " IOS_ARCH= IOS_MIN= arm64 / 12.0 [iOS]"
|
|
||||||
@echo " IOS_SDK= IOS_CC= Xcode paths, default from xcrun [iOS]"
|
|
||||||
@echo " MACOSX_HRT= hardened-runtime JIT, default 1 [macOS]"
|
|
||||||
@echo " MACOSX_DEPLOYMENT_TARGET= default 11.0 [macOS]"
|
|
||||||
@echo " HOST_CC= host compiler for minilua/buildvm; needed"
|
|
||||||
@echo " when the target is 32-bit and the host is not"
|
|
||||||
@echo " CFLAGS= default -O2 -Wall"
|
|
||||||
@echo " LDFLAGS= extra linker flags"
|
|
||||||
@echo " LIB_OBJS= extra objects merged into libhate-no-d.a"
|
|
||||||
@echo " AR= archiver used to merge libhate-no-d.a"
|
|
||||||
|
|
||||||
all: $(LINK_TARGET)
|
all: $(LINK_TARGET)
|
||||||
|
|
||||||
$(OBJ): hate-no-d.c
|
$(BIN): hate-no-d.c $(LUAJIT_AR)
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ hate-no-d.c
|
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ hate-no-d.c \
|
||||||
|
|
||||||
$(BIN): $(OBJ) $(LUAJIT_AR)
|
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(OBJ) \
|
|
||||||
$(LUAJIT_AR) $(EXPORT_LDFLAGS) $(LDFLAGS) $(PLAT_LIBS)
|
$(LUAJIT_AR) $(EXPORT_LDFLAGS) $(LDFLAGS) $(PLAT_LIBS)
|
||||||
|
|
||||||
luajit: $(LUAJIT_AR)
|
luajit: $(LUAJIT_AR)
|
||||||
|
|
||||||
# Static library for embedding: $(LIB_OBJS) plus LuaJIT, merged into one archive
|
|
||||||
# so a host program links a single file, and modules added to $(LIB_OBJS) later
|
|
||||||
# join it without the host's link line changing.
|
|
||||||
lib: $(LIB)
|
|
||||||
|
|
||||||
# Apple's ar (cctools) has no MRI script mode, so archives are merged with
|
|
||||||
# libtool there. Everywhere else GNU ar, binutils ar and llvm-ar all parse MRI
|
|
||||||
# scripts (ADDMOD for objects, ADDLIB for another archive).
|
|
||||||
APPLE := $(filter macos ios,$(OS_KIND))
|
|
||||||
|
|
||||||
$(LIB): $(LIB_OBJS) $(LUAJIT_AR)
|
|
||||||
ifeq ($(APPLE),)
|
|
||||||
@rm -f $@ $@.mri
|
|
||||||
@{ echo "CREATE $@"; \
|
|
||||||
for o in $(LIB_OBJS); do echo "ADDMOD $$o"; done; \
|
|
||||||
echo "ADDLIB $(LUAJIT_AR)"; \
|
|
||||||
echo "SAVE"; echo "END"; } > $@.mri
|
|
||||||
$(AR) -M < $@.mri
|
|
||||||
@rm -f $@.mri
|
|
||||||
else
|
|
||||||
@rm -f $@
|
|
||||||
libtool -static -o $@ $(LIB_OBJS) $(LUAJIT_AR)
|
|
||||||
endif
|
|
||||||
@echo "lib: built $@ ($$($(AR) t $@ | wc -l | tr -d ' ') members)"
|
|
||||||
|
|
||||||
# Show the resolved configuration for the current (or selected) platform.
|
# Show the resolved configuration for the current (or selected) platform.
|
||||||
# Useful for checking a cross build before committing to it.
|
# Useful for checking a cross build before committing to it.
|
||||||
print-config:
|
print-config:
|
||||||
@echo "PLATFORM = $(PLATFORM)"
|
@echo "PLATFORM = $(PLATFORM)"
|
||||||
@echo "OS_KIND = $(OS_KIND)"
|
@echo "OS_KIND = $(OS_KIND)"
|
||||||
@echo "CC / AR = $(CC) / $(AR)"
|
@echo "CC = $(CC)"
|
||||||
@echo "CFLAGS = $(CFLAGS)"
|
@echo "CFLAGS = $(CFLAGS)"
|
||||||
@echo "CPPFLAGS = $(CPPFLAGS)"
|
@echo "CPPFLAGS = $(CPPFLAGS)"
|
||||||
@echo "EXPORT_LDFLAGS = $(EXPORT_LDFLAGS)"
|
@echo "EXPORT_LDFLAGS = $(EXPORT_LDFLAGS)"
|
||||||
@echo "PLAT_LIBS = $(PLAT_LIBS)"
|
@echo "PLAT_LIBS = $(PLAT_LIBS)"
|
||||||
@echo "LINK_TARGET = $(LINK_TARGET)"
|
@echo "LINK_TARGET = $(LINK_TARGET)"
|
||||||
@echo "OBJ / LIB = $(OBJ) / $(LIB) [$(LIB_OBJS)]"
|
|
||||||
@echo "LUAJIT_MAKE_ARGS = $(LUAJIT_MAKE_ARGS)"
|
@echo "LUAJIT_MAKE_ARGS = $(LUAJIT_MAKE_ARGS)"
|
||||||
@echo "MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET) (HRT=$(MACOSX_HRT))"
|
@echo "MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET) (HRT=$(MACOSX_HRT))"
|
||||||
@echo "ANDROID_ABI / API = $(ANDROID_ABI) / $(ANDROID_API)"
|
@echo "ANDROID_ABI / API = $(ANDROID_ABI) / $(ANDROID_API)"
|
||||||
|
|
@ -309,6 +228,6 @@ print-config:
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C $(LUAJIT_DIR) clean
|
$(MAKE) -C $(LUAJIT_DIR) clean
|
||||||
rm -f $(BIN) $(OBJ) $(LIB) $(LIB).mri
|
rm -f $(BIN)
|
||||||
|
|
||||||
.PHONY: all clean luajit print-config lib help
|
.PHONY: all clean luajit print-config
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue