feat(zig): native Arboricx bundle parser and C ABI
This commit is contained in:
77
flake.nix
77
flake.nix
@@ -29,9 +29,82 @@
|
||||
customGHC = haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
|
||||
megaparsec
|
||||
]);
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Zig Arboricx host
|
||||
# ------------------------------------------------------------------
|
||||
tricuZig = pkgs.stdenv.mkDerivation {
|
||||
pname = "tricu-zig";
|
||||
version = "0.1.0";
|
||||
src = ./ext/zig;
|
||||
nativeBuildInputs = [ pkgs.zig ];
|
||||
buildPhase = ''
|
||||
export ZIG_GLOBAL_CACHE_DIR=$TMPDIR/zig-cache
|
||||
zig build
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/lib $out/include
|
||||
cp zig-out/bin/* $out/bin/ 2>/dev/null || true
|
||||
cp zig-out/lib/* $out/lib/ 2>/dev/null || true
|
||||
cp include/arboricx.h $out/include/
|
||||
'';
|
||||
};
|
||||
|
||||
# Separate test target — not included in `nix flake check`
|
||||
tricuZigTests = pkgs.stdenv.mkDerivation {
|
||||
pname = "tricu-zig-tests";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [ pkgs.gcc pkgs.python3 tricuZig ];
|
||||
buildPhase = "true";
|
||||
doCheck = true;
|
||||
checkPhase = ''
|
||||
export LD_LIBRARY_PATH=${tricuZig}/lib:$LD_LIBRARY_PATH
|
||||
ulimit -s 32768
|
||||
|
||||
cd ext/zig
|
||||
|
||||
# C ABI smoke test
|
||||
gcc -o /tmp/c_abi_test tests/c_abi_test.c \
|
||||
-I ${tricuZig}/include -L ${tricuZig}/lib -larboricx \
|
||||
-Wl,-rpath,${tricuZig}/lib
|
||||
/tmp/c_abi_test
|
||||
|
||||
# Kernel path append test
|
||||
gcc -o /tmp/c_abi_append_test tests/c_abi_append_test.c \
|
||||
-I ${tricuZig}/include -L ${tricuZig}/lib -larboricx \
|
||||
-Wl,-rpath,${tricuZig}/lib
|
||||
/tmp/c_abi_append_test
|
||||
|
||||
# Native bundle tests
|
||||
gcc -o /tmp/native_bundle_append_test tests/native_bundle_append_test.c \
|
||||
-I ${tricuZig}/include -L ${tricuZig}/lib -larboricx \
|
||||
-Wl,-rpath,${tricuZig}/lib
|
||||
/tmp/native_bundle_append_test
|
||||
|
||||
gcc -o /tmp/native_bundle_id_test tests/native_bundle_id_test.c \
|
||||
-I ${tricuZig}/include -L ${tricuZig}/lib -larboricx \
|
||||
-Wl,-rpath,${tricuZig}/lib
|
||||
/tmp/native_bundle_id_test
|
||||
|
||||
gcc -o /tmp/native_bundle_bools_test tests/native_bundle_bools_test.c \
|
||||
-I ${tricuZig}/include -L ${tricuZig}/lib -larboricx \
|
||||
-Wl,-rpath,${tricuZig}/lib
|
||||
/tmp/native_bundle_bools_test
|
||||
|
||||
# Python FFI test
|
||||
ARBORICX_LIB=${tricuZig}/lib/libarboricx.so \
|
||||
python3 tests/python_ffi_test.py
|
||||
|
||||
mkdir -p $out
|
||||
echo "All Zig tests passed" > $out/result
|
||||
'';
|
||||
};
|
||||
in {
|
||||
packages.${packageName} = tricuPackage;
|
||||
packages.default = tricuPackage;
|
||||
packages.tricu-zig = tricuZig;
|
||||
packages.tricu-zig-tests = tricuZigTests;
|
||||
|
||||
checks.${packageName} = tricuPackageTests;
|
||||
checks.default = tricuPackageTests;
|
||||
@@ -43,10 +116,14 @@
|
||||
haskellPackages.ghcid
|
||||
customGHC
|
||||
upx
|
||||
zig
|
||||
gcc
|
||||
python3
|
||||
];
|
||||
|
||||
inputsFrom = [
|
||||
tricuPackage
|
||||
tricuZig
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user