mirror of
https://github.com/zaphar/kitchen.git
synced 2025-07-22 19:40:14 -04:00
refactor: make the wasm builder a little more configurable.
This commit is contained in:
parent
e1735e4243
commit
e3c4a01648
@ -45,6 +45,14 @@
|
|||||||
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;
|
||||||
|
lockFile = ./Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
# I'm maintaining some patches for these so the lockfile hashes are a little
|
||||||
|
# incorrect. We override those here.
|
||||||
|
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
||||||
|
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
||||||
|
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
kitchen = (kitchenGen {
|
kitchen = (kitchenGen {
|
||||||
inherit pkgs version naersk-lib kitchenWasm rust-wasm;
|
inherit pkgs version naersk-lib kitchenWasm rust-wasm;
|
||||||
|
@ -3,23 +3,18 @@
|
|||||||
features ? "",
|
features ? "",
|
||||||
rust-wasm,
|
rust-wasm,
|
||||||
wasm-bindgen,
|
wasm-bindgen,
|
||||||
|
lockFile,
|
||||||
|
outputHashes,
|
||||||
}:
|
}:
|
||||||
with pkgs;
|
with pkgs;
|
||||||
let
|
let
|
||||||
pname = "kitchen-wasm";
|
pname = "kitchen-wasm";
|
||||||
src = ./../..;
|
src = ./../..;
|
||||||
lockFile = ./../../Cargo.lock;
|
|
||||||
# NOTE(jwall): Because we use wasm-pack directly below we need
|
# NOTE(jwall): Because we use wasm-pack directly below we need
|
||||||
# the cargo dependencies to already be installed.
|
# the cargo dependencies to already be installed.
|
||||||
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile; outputHashes = {
|
cargoDeps = (pkgs.rustPlatform.importCargoLock { inherit lockFile outputHashes; });
|
||||||
# I'm maintaining some patches for these so the lockfile hashes are a little
|
|
||||||
# incorrect. We override those here.
|
|
||||||
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
|
||||||
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
|
||||||
"sqlx-0.6.2" = "sha256-X/LFvtzRfiOIEZJiVzmFvvULPpjhqvI99pSwH7a//GM=";
|
|
||||||
};
|
|
||||||
});
|
|
||||||
in
|
in
|
||||||
|
# TODO(zaphar): I should actually be leveraging naersklib.buildPackage with a postInstall for the optimization and bindgen
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
inherit src pname;
|
inherit src pname;
|
||||||
version = version;
|
version = version;
|
||||||
@ -34,13 +29,10 @@ stdenv.mkDerivation {
|
|||||||
'';
|
'';
|
||||||
# TODO(jwall): Build this from the root rather than the src.
|
# TODO(jwall): Build this from the root rather than the src.
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
set -x
|
|
||||||
echo building with wasm-pack
|
|
||||||
wasm-pack --version
|
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
cd web
|
cd web
|
||||||
cp -r static $out
|
cp -r static $out
|
||||||
cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out --offline
|
cargo build --lib --release --target wasm32-unknown-unknown --target-dir $out ${features} --offline
|
||||||
wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
|
wasm-bindgen $out/wasm32-unknown-unknown/release/kitchen_wasm.wasm --out-dir $out --typescript --target web
|
||||||
wasm-opt $out/kitchen_wasm_bg.wasm -o $out/kitchen_wasm_bg-opt.wasm -O
|
wasm-opt $out/kitchen_wasm_bg.wasm -o $out/kitchen_wasm_bg-opt.wasm -O
|
||||||
rm -f $out/kitchen_wasm_bg.wasm
|
rm -f $out/kitchen_wasm_bg.wasm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user