triangle/wasm.nix

32 lines
538 B
Nix
Raw Normal View History

2023-11-21 03:31:16 +00:00
{ stdenv, clang, pkgsCross }:
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-21 03:31:16 +00:00
nativeBuildInputs = [ clang ];
2023-11-12 18:56:53 +00:00
2023-11-11 01:21:37 +00:00
configurePhase = "";
buildPhase = ''
2023-11-12 18:56:53 +00:00
clang \
--target=wasm32-unknown-wasi \
2023-11-21 03:31:16 +00:00
--sysroot ${pkgsCross.wasi32.wasilibc} \
2023-11-12 18:56:53 +00:00
-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
'';
}