triangle/wasm.nix
2023-11-20 21:31:16 -06:00

31 lines
538 B
Nix

{ stdenv, clang, pkgsCross }:
stdenv.mkDerivation {
name = "triangle";
src = ./.;
nativeBuildInputs = [ clang ];
configurePhase = "";
buildPhase = ''
clang \
--target=wasm32-unknown-wasi \
--sysroot ${pkgsCross.wasi32.wasilibc} \
-O3 \
-flto \
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--lto-O3 \
-o triangle.wasm \
triangle.c
'';
checkPhase = "";
installPhase = ''
mkdir -p $out
ls -al
mv triangle.js triangle.wasm $out
'';
}