build wasm
This commit is contained in:
parent
0171ce2c7e
commit
9745267487
3 changed files with 30 additions and 3 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1 +1,4 @@
|
||||||
.direnv
|
.direnv
|
||||||
|
/triangle
|
||||||
|
/triangle.wasm
|
||||||
|
/result*
|
||||||
|
|
10
flake.nix
10
flake.nix
|
@ -5,10 +5,16 @@
|
||||||
flake-utils.lib.eachDefaultSystem (system:
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
flakePkgs = { triangle = pkgs.callPackage ./. { }; };
|
flakePkgs = {
|
||||||
|
triangle = pkgs.callPackage ./. { };
|
||||||
|
triangle-wasm = pkgs.callPackage ./wasm.nix { };
|
||||||
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
packages = flakePkgs;
|
packages = flakePkgs;
|
||||||
devShell = pkgs.mkShell { packages = with pkgs; [ nixfmt ]; };
|
devShell = pkgs.mkShell {
|
||||||
|
inputsFrom = with flakePkgs; [ triangle ];
|
||||||
|
packages = with pkgs; [ nixfmt emscripten ];
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
18
wasm.nix
Normal file
18
wasm.nix
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{ buildEmscriptenPackage }:
|
||||||
|
|
||||||
|
buildEmscriptenPackage {
|
||||||
|
name = "triangle";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
configurePhase = "";
|
||||||
|
buildPhase = ''
|
||||||
|
export EM_CACHE=/tmp/em-cache
|
||||||
|
emcc -o triangle triangle.c
|
||||||
|
'';
|
||||||
|
checkPhase = "";
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
ls -al
|
||||||
|
mv triangle triangle.wasm $out
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue