triangle/wasm.nix

31 lines
499 B
Nix
Raw Normal View History

2023-11-12 18:56:53 +00:00
{ stdenv, clang, wasilibc }:
2023-11-11 01:21:37 +00:00
2023-11-12 18:56:53 +00:00
stdenv.mkDerivation {
2023-11-11 01:21:37 +00:00
name = "triangle";
src = ./.;
2023-11-12 18:56:53 +00:00
nativeBuildInputs = [ clang wasilibc ];
2023-11-11 01:21:37 +00:00
configurePhase = "";
buildPhase = ''
2023-11-12 18:56:53 +00:00
clang \
--target=wasm32-unknown-wasi \
-O3 \
-flto \
-nostdlib \
-Wl,--no-entry \
-Wl,--export-all \
-Wl,--lto-O3 \
-o triangle.wasm \
triangle.c
2023-11-11 01:21:37 +00:00
'';
2023-11-12 18:56:53 +00:00
2023-11-11 01:21:37 +00:00
checkPhase = "";
installPhase = ''
mkdir -p $out
ls -al
2023-11-12 18:56:53 +00:00
mv triangle.js triangle.wasm $out
2023-11-11 01:21:37 +00:00
'';
}