getting mize to build as a module
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
@@ -1133,7 +1133,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mize"
|
name = "mize"
|
||||||
version = "0.0.0"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
|
|||||||
5
lib.nix
5
lib.nix
@@ -75,7 +75,7 @@ rec {
|
|||||||
buildMizeForSystem = system: let
|
buildMizeForSystem = system: let
|
||||||
hostSystem = getCrossSystem system;
|
hostSystem = getCrossSystem system;
|
||||||
|
|
||||||
pkgsCross = import nixpkgs { inherit buildSystem hostSystem; overlays = [ rust-overlay.overlays.default ]; };
|
pkgsCross = import nixpkgs { inherit buildSystem hostSystem; localSystem = buildSystem; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
|
||||||
pkgsNative = import nixpkgs { inherit buildSystem; overlays = [ rust-overlay.overlays.default ]; };
|
pkgsNative = import nixpkgs { inherit buildSystem; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
|
||||||
@@ -161,11 +161,12 @@ rec {
|
|||||||
cp $build_dir/target/${hostSystem.nameRust}/$debugOrRelease/libmize_module_${attrs.modName}.so $out/lib/
|
cp $build_dir/target/${hostSystem.nameRust}/$debugOrRelease/libmize_module_${attrs.modName}.so $out/lib/
|
||||||
'';
|
'';
|
||||||
mizeBuildPhase = attrs.mizeBuildPhase or ''
|
mizeBuildPhase = attrs.mizeBuildPhase or ''
|
||||||
cargo --color always build --target ${hostSystem.nameRust} --manifest-path $build_dir/Cargo.toml --lib
|
cargo --color always build --target ${hostSystem.nameRust} ${if builtins.hasAttr "cargoExtraArgs" attrs then attrs.cargoExtraArgs else ""} --manifest-path $build_dir/Cargo.toml --lib
|
||||||
'';
|
'';
|
||||||
selector_string = mkSelString (attrs.select or {} // {
|
selector_string = mkSelString (attrs.select or {} // {
|
||||||
inherit (attrs) modName;
|
inherit (attrs) modName;
|
||||||
});
|
});
|
||||||
|
devShell = if builtins.hasAttr "devShell" attrs then attrs.devShell else mkMizeRustShell {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
module = { mkMizeRustModule, mkMizeRustShell, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
||||||
|
|
||||||
mkMizeRustModule (
|
mkMizeRustModule (
|
||||||
|
|
||||||
@@ -18,6 +18,10 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
// (lib.attrsets.optionalAttrs (hostSystem.kernel.name == "linux") {
|
// (lib.attrsets.optionalAttrs (hostSystem.kernel.name == "linux") {
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
cargoExtraArgs = "--bin mize --features os-target";
|
cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
mizeInstallPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp $build_dir/target/${hostSystem.nameRust}/$debugOrRelease/mize $out/
|
||||||
|
'';
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -25,7 +29,7 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
|
|
||||||
|
|
||||||
# x86_64-linux stuff
|
# x86_64-linux stuff
|
||||||
// (lib.attrsets.optionalAttrs (hostSystem.name == "x86_64-linux-gnu") {
|
// (lib.attrsets.optionalAttrs (hostSystem.name == "x86_64-linux-gnu") rec {
|
||||||
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
@@ -35,9 +39,13 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
|
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
(if hostSystem.nameFull == "x86_64-unknown-linux-gnu" then pkgs.openssl else pkgsCross.openssl)
|
pkgs.openssl
|
||||||
];
|
];
|
||||||
|
|
||||||
|
devShell = mkMizeRustShell {
|
||||||
|
inherit buildInputs nativeBuildInputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
# patch the interpreter to run on most linux-gnu distros
|
# patch the interpreter to run on most linux-gnu distros
|
||||||
# postBuild = "patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /build/source/target/release/mize";
|
# postBuild = "patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /build/source/target/release/mize";
|
||||||
@@ -80,7 +88,7 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
|
|
||||||
|
|
||||||
#browser stuff
|
#browser stuff
|
||||||
// (lib.attrsets.optionalAttrs (hostSystem.name == "wasm32-none-unknown") {
|
// (lib.attrsets.optionalAttrs (hostSystem.name == "wasm32-none-unknown") rec {
|
||||||
|
|
||||||
cargoArtifacts = craneLib.buildDepsOnly ({
|
cargoArtifacts = craneLib.buildDepsOnly ({
|
||||||
src = ./.;
|
src = ./.;
|
||||||
@@ -91,6 +99,12 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
buildInputs = with pkgs; [ cargo-binutils lld ];
|
buildInputs = with pkgs; [ cargo-binutils lld ];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mizeBuildPhase = ''
|
||||||
|
cd $build_dir
|
||||||
|
RUST_LOG=off wasm-pack build --target no-modules --dev --out-dir $out -- --features wasm-target --no-default-features
|
||||||
|
'';
|
||||||
|
mizeInstallPhase = "";
|
||||||
|
|
||||||
doInstallCargoArtifacts = false;
|
doInstallCargoArtifacts = false;
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
@@ -107,7 +121,11 @@ module = { mkMizeRustModule, hostSystem, pkgsCross, pkgs, lib, craneLib, ... }:
|
|||||||
cat $src/src/platform/wasm/init.js >> $out/pkg/mize.js
|
cat $src/src/platform/wasm/init.js >> $out/pkg/mize.js
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildInputs = with pkgs; [ wasm-bindgen-cli binaryen wasm-pack ];
|
nativeBuildInputs = with pkgs; [ wasm-bindgen-cli binaryen wasm-pack ];
|
||||||
|
|
||||||
|
devShell = mkMizeRustShell {
|
||||||
|
inherit nativeBuildInputs;
|
||||||
|
};
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user