mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-21 19:29:49 -04:00
build: generate sourcemap info for stacktraces
hopefully anyway
This commit is contained in:
parent
fe181fb102
commit
1c55a315b0
1
Makefile
1
Makefile
@ -41,6 +41,7 @@ wasm: wasm-dist static-prep
|
|||||||
|
|
||||||
wasm-dist: web/src/*.rs web/src/components/*.rs
|
wasm-dist: web/src/*.rs web/src/components/*.rs
|
||||||
cd web; sh ../scripts/wasm-build.sh debug
|
cd web; sh ../scripts/wasm-build.sh debug
|
||||||
|
cd web; sh ../scripts/wasm-sourcemap.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf web/dist/*
|
rm -rf web/dist/*
|
||||||
|
50
flake.lock
generated
50
flake.lock
generated
@ -1,5 +1,21 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"cargo-wasm2map-src": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1693927731,
|
||||||
|
"narHash": "sha256-oqJ9ZZLvUK57A9Kf6L4pPrW6nHqb+18+JGKj9HfIaaM=",
|
||||||
|
"owner": "mtolmacs",
|
||||||
|
"repo": "wasm2map",
|
||||||
|
"rev": "c7d80748b7f3af37df24770b9330b17aa9599e3e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "mtolmacs",
|
||||||
|
"repo": "wasm2map",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -31,24 +47,6 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681202837,
|
|
||||||
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"gitignore": {
|
"gitignore": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
@ -114,6 +112,7 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"cargo-wasm2map-src": "cargo-wasm2map-src",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"gitignore": "gitignore",
|
"gitignore": "gitignore",
|
||||||
@ -142,21 +141,6 @@
|
|||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
14
flake.nix
14
flake.nix
@ -11,8 +11,9 @@
|
|||||||
};
|
};
|
||||||
naersk.url = "github:nix-community/naersk";
|
naersk.url = "github:nix-community/naersk";
|
||||||
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
|
||||||
|
cargo-wasm2map-src = { url = "github:mtolmacs/wasm2map"; flake = false; };
|
||||||
};
|
};
|
||||||
outputs = {nixpkgs, flake-utils, rust-overlay, naersk, ...}:
|
outputs = {nixpkgs, flake-utils, rust-overlay, naersk, cargo-wasm2map-src, ...}:
|
||||||
let
|
let
|
||||||
kitchenGen = (import ./nix/kitchen/default.nix);
|
kitchenGen = (import ./nix/kitchen/default.nix);
|
||||||
kitchenWasmGen = (import ./nix/kitchenWasm/default.nix);
|
kitchenWasmGen = (import ./nix/kitchenWasm/default.nix);
|
||||||
@ -42,9 +43,16 @@
|
|||||||
wasm-pack = wasm-packGen {
|
wasm-pack = wasm-packGen {
|
||||||
inherit rust-wasm naersk-lib pkgs;
|
inherit rust-wasm naersk-lib pkgs;
|
||||||
};
|
};
|
||||||
|
cargo-wasm2map = naersk-lib.buildPackage {
|
||||||
|
pname = "cargo-wasm2map";
|
||||||
|
version = "v0.1.0";
|
||||||
|
build-inputs = [ rust-wasm ];
|
||||||
|
src = cargo-wasm2map-src;
|
||||||
|
cargoBuildOptions = opts: opts ++ ["-p" "cargo-wasm2map" ];
|
||||||
|
};
|
||||||
wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; };
|
wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; };
|
||||||
kitchenWasm = kitchenWasmGen {
|
kitchenWasm = kitchenWasmGen {
|
||||||
inherit pkgs rust-wasm wasm-bindgen version;
|
inherit pkgs rust-wasm wasm-bindgen version cargo-wasm2map;
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
outputHashes = {
|
outputHashes = {
|
||||||
# I'm maintaining some patches for these so the lockfile hashes are a little
|
# I'm maintaining some patches for these so the lockfile hashes are a little
|
||||||
@ -89,7 +97,7 @@
|
|||||||
program = "${kitchen}/bin/kitchen";
|
program = "${kitchen}/bin/kitchen";
|
||||||
};
|
};
|
||||||
devShell = pkgs.callPackage ./nix/devShell/default.nix {
|
devShell = pkgs.callPackage ./nix/devShell/default.nix {
|
||||||
inherit rust-wasm wasm-bindgen;
|
inherit rust-wasm wasm-bindgen cargo-wasm2map;
|
||||||
wasm-pack-hermetic = wasm-pack;
|
wasm-pack-hermetic = wasm-pack;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
let
|
let
|
||||||
lib = import ../lib/lib.nix;
|
lib = import ../lib/lib.nix;
|
||||||
in
|
in
|
||||||
{ pkgs, rust-wasm, wasm-pack-hermetic, wasm-bindgen }:
|
{ pkgs, rust-wasm, wasm-pack-hermetic, wasm-bindgen, cargo-wasm2map }:
|
||||||
with pkgs;
|
with pkgs;
|
||||||
mkShell {
|
mkShell {
|
||||||
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen wasm-pack-hermetic llvm clang rust-wasm binaryen]);
|
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen wasm-pack-hermetic llvm clang rust-wasm binaryen cargo-wasm2map]);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
wasm-bindgen,
|
wasm-bindgen,
|
||||||
lockFile,
|
lockFile,
|
||||||
outputHashes,
|
outputHashes,
|
||||||
|
cargo-wasm2map,
|
||||||
}:
|
}:
|
||||||
with pkgs;
|
with pkgs;
|
||||||
let
|
let
|
||||||
@ -18,7 +19,7 @@ stdenv.mkDerivation {
|
|||||||
inherit src pname;
|
inherit src pname;
|
||||||
version = version;
|
version = version;
|
||||||
# we need wasmb-bindgen v0.2.83 exactly
|
# we need wasmb-bindgen v0.2.83 exactly
|
||||||
buildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen];
|
buildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen cargo-wasm2map];
|
||||||
propagatedBuildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen];
|
propagatedBuildInputs = [ rust-wasm wasm-bindgen wasm-pack binaryen];
|
||||||
phases = [ "postUnpackPhase" "buildPhase"];
|
phases = [ "postUnpackPhase" "buildPhase"];
|
||||||
postUnpackPhase = ''
|
postUnpackPhase = ''
|
||||||
@ -34,6 +35,7 @@ stdenv.mkDerivation {
|
|||||||
export project=kitchen
|
export project=kitchen
|
||||||
sh ../scripts/wasm-build.sh release
|
sh ../scripts/wasm-build.sh release
|
||||||
sh ../scripts/wasm-opt.sh release
|
sh ../scripts/wasm-opt.sh release
|
||||||
|
sh ../scripts/wasm-sourcemap.sh
|
||||||
rm -f $out/kitchen_wasm_bg.wasm
|
rm -f $out/kitchen_wasm_bg.wasm
|
||||||
cp -r index.html $out
|
cp -r index.html $out
|
||||||
cp -r favicon.ico $out
|
cp -r favicon.ico $out
|
||||||
|
3
scripts/wasm-sourcemap.sh
Normal file
3
scripts/wasm-sourcemap.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
set -x
|
||||||
|
|
||||||
|
cargo-wasm2map wasm2map --patch $out/${project}_wasm_bg.wasm --base-url=http://localhost:3030
|
Loading…
x
Reference in New Issue
Block a user