lots of stuff
This commit is contained in:
@@ -6,6 +6,9 @@ license = "GPL-3.0"
|
|||||||
description = 'A strongly typed "filesystem" for the age of connectivity.'
|
description = 'A strongly typed "filesystem" for the age of connectivity.'
|
||||||
repository = "https://github.com/c2vi/mize"
|
repository = "https://github.com/c2vi/mize"
|
||||||
|
|
||||||
|
[package.metadata.wasm-pack.profile.dev]
|
||||||
|
wasm-opt = false
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "mize"
|
name = "mize"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
@@ -17,6 +20,7 @@ path = "src/platform/os/main.rs"
|
|||||||
required-features = [ "os-target" ]
|
required-features = [ "os-target" ]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = [ "os-target" ]
|
||||||
os-target = [ "clap", "home", "nix", "sysinfo", "ciborium/default", "tracing-subscriber", "async", "tracing-subscriber/env-filter", "libloading", "ciborium-io", "tracing-core" ]
|
os-target = [ "clap", "home", "nix", "sysinfo", "ciborium/default", "tracing-subscriber", "async", "tracing-subscriber/env-filter", "libloading", "ciborium-io", "tracing-core" ]
|
||||||
wasm-target = [ "wasm-bindgen", "console_error_panic_hook", "wasm-bindgen-cli" ]
|
wasm-target = [ "wasm-bindgen", "console_error_panic_hook", "wasm-bindgen-cli" ]
|
||||||
async = ["tokio/net", "tokio", "tokio/rt-multi-thread", "tokio/io-util"]
|
async = ["tokio/net", "tokio", "tokio/rt-multi-thread", "tokio/io-util"]
|
||||||
|
|||||||
2
deploy
2
deploy
@@ -2,7 +2,7 @@
|
|||||||
if [[ "$1" == "a" ]]
|
if [[ "$1" == "a" ]]
|
||||||
then
|
then
|
||||||
ssh acern mkdir -p /tmp/victorinix
|
ssh acern mkdir -p /tmp/victorinix
|
||||||
rsync -rv --exclude="target" ./* acern:/tmp/victorinix/
|
rsync -rv --exclude="target" --exclude="gitignore" ./* acern:/tmp/victorinix/
|
||||||
path=$(ssh acern nix build /tmp/victorinix#webfiles -L --print-out-paths)
|
path=$(ssh acern nix build /tmp/victorinix#webfiles -L --print-out-paths)
|
||||||
|
|
||||||
echo doneeeeeeeeeeeeeee
|
echo doneeeeeeeeeeeeeee
|
||||||
|
|||||||
27
flake.lock
generated
27
flake.lock
generated
@@ -1,17 +1,12 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"crane": {
|
"crane": {
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1715274763,
|
"lastModified": 1725125250,
|
||||||
"narHash": "sha256-3Iv1PGHJn9sV3HO4FlOVaaztOxa9uGLfOmUWrH7v7+A=",
|
"narHash": "sha256-CB20rDD5eHikF6mMTTJdwPP1qvyoiyyw1RDUzwIaIF8=",
|
||||||
"owner": "ipetkov",
|
"owner": "ipetkov",
|
||||||
"repo": "crane",
|
"repo": "crane",
|
||||||
"rev": "27025ab71bdca30e7ed0a16c88fd74c5970fc7f5",
|
"rev": "96fd12c7100e9e05fa1a0a5bd108525600ce282f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -62,14 +57,18 @@
|
|||||||
"mize_modules": {
|
"mize_modules": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725174598,
|
"dirtyRev": "fa3b462cbe3e63fc9ecada6c4445d366e58a6f86-dirty",
|
||||||
"narHash": "sha256-jB5YUArfAiwYwZ7qLwWMHCAY4DMWmLp7F3hzEG5mezk=",
|
"dirtyShortRev": "fa3b462-dirty",
|
||||||
"path": "/home/me/work/modules",
|
"lastModified": 1725362504,
|
||||||
"type": "path"
|
"narHash": "sha256-uL7SRKxrCpS/9sXVOdClijqdxXNLIuiHZ54YYZck42E=",
|
||||||
|
"submodules": true,
|
||||||
|
"type": "git",
|
||||||
|
"url": "file:///home/me/work/modules"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"path": "/home/me/work/modules",
|
"submodules": true,
|
||||||
"type": "path"
|
"type": "git",
|
||||||
|
"url": "file:///home/me/work/modules"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
|
|||||||
141
flake.nix
141
flake.nix
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
crane = {
|
crane = {
|
||||||
url = "github:ipetkov/crane";
|
url = "github:ipetkov/crane";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
@@ -19,7 +18,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
mize_modules = {
|
mize_modules = {
|
||||||
url = "github:c2vi/mize-modules";
|
#url = "github:c2vi/mize-modules";
|
||||||
|
url = "git+file:///home/me/work/modules?submodules=1";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -34,9 +34,22 @@ let
|
|||||||
fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.toolchain
|
fenix.packages.${system}.targets.wasm32-unknown-unknown.latest.toolchain
|
||||||
fenix.packages.${system}.latest.toolchain
|
fenix.packages.${system}.latest.toolchain
|
||||||
];
|
];
|
||||||
|
wasmCrane = (crane.mkLib pkgs).overrideToolchain wasmToolchain;
|
||||||
|
|
||||||
osToolchain = fenix.packages.${system}.latest.toolchain;
|
osToolchain = fenix.packages.${system}.latest.toolchain;
|
||||||
wasmCrane = crane.lib.${system}.overrideToolchain wasmToolchain;
|
osCrane = (crane.mkLib pkgs).overrideToolchain osToolchain;
|
||||||
osCrane = crane.lib.${system}.overrideToolchain osToolchain;
|
|
||||||
|
#winToolchain = fenix.packages.${system}.combine [
|
||||||
|
#fenix.packages.${system}.targets.x86_64-pc-windows-gnu.latest.toolchain
|
||||||
|
#fenix.packages.${system}.latest.toolchain
|
||||||
|
#];
|
||||||
|
winToolchain = with fenix.packages.${system};
|
||||||
|
combine [
|
||||||
|
minimal.rustc
|
||||||
|
minimal.cargo
|
||||||
|
targets.x86_64-pc-windows-gnu.latest.rust-std
|
||||||
|
];
|
||||||
|
winCrane = (crane.mkLib pkgs).overrideToolchain winToolchain;
|
||||||
|
|
||||||
wasmArtifacts = wasmCrane.buildDepsOnly ({
|
wasmArtifacts = wasmCrane.buildDepsOnly ({
|
||||||
src = self;
|
src = self;
|
||||||
@@ -51,21 +64,55 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#systems = [ "aarch64-linux" "x86_64-linux" "x86_64-pc-windows-gnu" "wasm32-unknown-none-unknown" "x86_64-apple-darwin" "aarch64-apple-darwin" ];
|
||||||
|
systems = [ "aarch64-unknown-linux-gnu" "x86_64-unknown-linux-gnu" "x86_64-pc-windows-gnu" "wasm32-unknown-none-unknown" ];
|
||||||
|
|
||||||
mizeLib = import ./lib.nix {
|
mizeLib = import ./lib.nix {
|
||||||
inherit inputs nixpkgs self osCrane defaultMizeConfig mize_modules;
|
inherit inputs nixpkgs pkgs self osCrane defaultMizeConfig mize_modules;
|
||||||
inherit rust-overlay crane;
|
inherit rust-overlay crane fenix;
|
||||||
localSystem = system;
|
localSystem = system;
|
||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
############################## PACKAGES ##############################
|
############################## PACKAGES ##############################
|
||||||
|
|
||||||
packages = {
|
packages = rec {
|
||||||
|
|
||||||
osCrane = osCrane;
|
inherit osCrane;
|
||||||
|
#test = mizeLib.buildMizeForSystem "wasm32-unknown-none-unknown";
|
||||||
|
test = mizeLib.buildMizeForSystem "aarch64-linux";
|
||||||
|
#test = mizeLib.buildMizeForSystem "x86_64-pc-windows-gnu";
|
||||||
|
|
||||||
|
mizeFor = let
|
||||||
|
mizes = map mizeLib.buildMizeForSystem systems;
|
||||||
|
in builtins.listToAttrs ( map ( mize: { name = mize.system.name; value = mize; } ) mizes );
|
||||||
|
|
||||||
|
#pkgsCross = import nixpkgs { localSystem = system; crossSystem = { config = "x86_64-pc-windows-gnu"; }; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
|
||||||
|
pkgsTest = pkgs;
|
||||||
|
|
||||||
|
#pkgsCross = import nixpkgs { localSystem = system; crossSystem = { config = "x86_64-w64-windows-mingw"; }; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
pkgsCross = import nixpkgs { localSystem = system; crossSystem = { config = "x86_64-unknown-linux-gnu"; }; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
craneLib = (crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default);
|
||||||
|
|
||||||
|
|
||||||
|
one = craneLib.buildPackage {
|
||||||
|
src = "${self}";
|
||||||
|
#cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
cargoExtraArgs = "--bin mize";
|
||||||
|
doCheck = false; # tests does not work in wasm
|
||||||
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||||
|
MIZE_BUILD_CONFIG = pkgs.writeTextFile {
|
||||||
|
name = "mize-build-config";
|
||||||
|
text = builtins.toJSON (defaultMizeConfig // {
|
||||||
|
mize_version = one.version;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
webfiles = pkgs.callPackage ./webfiles.nix {
|
webfiles = pkgs.callPackage ./webfiles.nix {
|
||||||
inherit (mizeLib) buildMizeForSystem mkInstallPhase;
|
inherit (mizeLib) buildMizeForSystem mkInstallPhase;
|
||||||
|
inherit systems;
|
||||||
};
|
};
|
||||||
|
|
||||||
default = osCrane.buildPackage {
|
default = osCrane.buildPackage {
|
||||||
@@ -76,6 +123,7 @@ in {
|
|||||||
wasm = wasmCrane.buildPackage {
|
wasm = wasmCrane.buildPackage {
|
||||||
src = "${self}";
|
src = "${self}";
|
||||||
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
||||||
|
cargoExtraArgs = "--bin mize --features wasm-target";
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -105,19 +153,74 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
############################## DEV SHELLS ##############################
|
############################## DEV SHELLS ##############################
|
||||||
devShells.default = pkgs.mkShell {
|
devShells = {
|
||||||
|
|
||||||
|
one = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "hiiiiiiii";
|
||||||
|
nativeBuildInputs = [
|
||||||
|
(fenix.packages.${system}.combine [ wasmToolchain osToolchain winToolchain ])
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.pkgsCross.mingwW64.stdenv.cc.cc
|
||||||
|
pkgs.pkgsCross.mingwW64.windows.pthreads
|
||||||
|
(fenix.packages.${system}.combine [ wasmToolchain osToolchain winToolchain ])
|
||||||
|
];
|
||||||
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
||||||
|
pkgs.pkgsCross.mingwW64.windows.pthreads
|
||||||
|
];
|
||||||
|
|
||||||
|
RUSTFLAGS="-L ${pkgs.pkgsCross.mingwW64.windows.pthreads}/lib";
|
||||||
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||||
|
|
||||||
|
|
||||||
|
#fixes issues related to openssl
|
||||||
|
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
||||||
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
||||||
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
||||||
|
|
||||||
|
depsBuildBuild = with pkgs; [
|
||||||
|
pkgsCross.mingwW64.stdenv.cc
|
||||||
|
pkgsCross.mingwW64.windows.pthreads
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
win = winCrane.buildPackage {
|
||||||
|
#src = winCrane.cleanCargoSource ./testing;
|
||||||
|
#pname = "testing";
|
||||||
|
src = ./testing;
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
|
||||||
|
|
||||||
|
# fixes issues related to libring
|
||||||
|
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
|
||||||
|
|
||||||
|
#fixes issues related to openssl
|
||||||
|
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
||||||
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
||||||
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
||||||
|
|
||||||
|
depsBuildBuild = with pkgs; [
|
||||||
|
pkgsCross.mingwW64.stdenv.cc
|
||||||
|
pkgsCross.mingwW64.windows.pthreads
|
||||||
|
];
|
||||||
|
shellHook = ''
|
||||||
|
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
||||||
|
'';
|
||||||
|
MIZE_BUILD_CONFIG = pkgs.writeTextFile {
|
||||||
|
name = "vic-build-config";
|
||||||
|
text = builtins.toJSON defaultMizeConfig;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
default = pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
|
|
||||||
wasm-pack #pkg-config openssl #cargo rustc
|
wasm-pack #pkg-config openssl #cargo rustc
|
||||||
cargo-generate
|
cargo-generate
|
||||||
/*
|
|
||||||
(fenix.packages.${system}.complete.withComponents [
|
|
||||||
"cargo"
|
|
||||||
"clippy"
|
|
||||||
"rust-src"
|
|
||||||
"rustc"
|
|
||||||
"rustfmt"
|
|
||||||
])
|
|
||||||
*/
|
|
||||||
(fenix.packages.${system}.combine [ wasmToolchain osToolchain ])
|
(fenix.packages.${system}.combine [ wasmToolchain osToolchain ])
|
||||||
lldb gdb
|
lldb gdb
|
||||||
];
|
];
|
||||||
@@ -131,11 +234,13 @@ in {
|
|||||||
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
export MIZE_CONFIG_FILE=${self}/test-config.toml
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}) // {
|
}) // {
|
||||||
|
|
||||||
############################## SOME GLOBAL OUTPUTS ##############################
|
############################## SOME GLOBAL OUTPUTS ##############################
|
||||||
inherit inputs self;
|
inherit inputs self;
|
||||||
|
rustPkgs = import nixpkgs { overlays = [rust-overlay.overlays.default]; system = "x86_64-linux"; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
265
lib.nix
265
lib.nix
@@ -1,5 +1,4 @@
|
|||||||
{ stdenv
|
{ pkgs
|
||||||
, pkgs
|
|
||||||
, osCrane
|
, osCrane
|
||||||
, self
|
, self
|
||||||
, defaultMizeConfig
|
, defaultMizeConfig
|
||||||
@@ -8,11 +7,14 @@
|
|||||||
, nixpkgs
|
, nixpkgs
|
||||||
, rust-overlay
|
, rust-overlay
|
||||||
, crane
|
, crane
|
||||||
|
, fenix
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
rec {
|
rec {
|
||||||
# get a list of all modules, that have a mize_module.nix in their folder
|
|
||||||
module_list_drv = pkgs.stdenv.mkDerivation {
|
# get a list of all modules
|
||||||
|
# aka folders with a mize_module.nix in them
|
||||||
|
module_list_drv = path: pkgs.stdenv.mkDerivation {
|
||||||
name = "mize_module_list";
|
name = "mize_module_list";
|
||||||
dontUnpack = true;
|
dontUnpack = true;
|
||||||
configurePhase = "";
|
configurePhase = "";
|
||||||
@@ -20,17 +22,76 @@ rec {
|
|||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
touch $out/modules_to_build
|
touch $out/modules_to_build
|
||||||
|
|
||||||
for d in ${mize_modules}/modules/*; do
|
for d in ${path}/modules/*; do
|
||||||
[[ -f $d/mize_module.nix ]] && echo "$d/mize_module.nix" >> $out/modules_to_build
|
[[ -f $d/mize_module.nix ]] && (echo "$d/mize_module.nix" >> $out/modules_to_build; echo found module $d/mize_module.nix)
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
module_list_string = builtins.readFile "${module_list_drv}/modules_to_build";
|
findModules = path: let
|
||||||
|
module_list_string = builtins.readFile "${module_list_drv path}/modules_to_build";
|
||||||
module_list = pkgs.lib.lists.remove "" (pkgs.lib.strings.splitString "\n" module_list_string);
|
module_list = pkgs.lib.lists.remove "" (pkgs.lib.strings.splitString "\n" module_list_string);
|
||||||
|
in module_list;
|
||||||
|
|
||||||
|
|
||||||
|
findModulesNix = path: let
|
||||||
|
dirs = builtins.readDir path;
|
||||||
|
filtered_dirs = map (dir: builtins.trace "dir: ${dir}" (dir));
|
||||||
|
module_list = filtered_dirs;
|
||||||
|
in module_list;
|
||||||
|
|
||||||
|
|
||||||
|
getCrossSystem = system: let
|
||||||
|
crossSystem = (if builtins.isString system then (pkgs.lib.systems.parse.mkSystemFromString system) else system)
|
||||||
|
// rec {
|
||||||
|
name = if crossSystem.vendor != "unknown"
|
||||||
|
then "${crossSystem.cpu.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}"
|
||||||
|
else "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
|
||||||
|
nameFull = "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
|
||||||
|
config = nameFull;
|
||||||
|
};
|
||||||
|
in crossSystem;
|
||||||
|
|
||||||
|
|
||||||
|
buildMizeForSystem = system: let
|
||||||
|
crossSystem = getCrossSystem system;
|
||||||
|
|
||||||
|
pkgsCross = import nixpkgs { inherit localSystem crossSystem; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
|
||||||
|
pkgsNative = import nixpkgs { inherit localSystem; overlays = [ rust-overlay.overlays.default ]; };
|
||||||
|
|
||||||
|
craneLib =
|
||||||
|
if crossSystem.kernel.name == "windows"
|
||||||
|
then
|
||||||
|
(crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [
|
||||||
|
fenix.packages.${localSystem}.minimal.rustc
|
||||||
|
fenix.packages.${localSystem}.minimal.cargo
|
||||||
|
fenix.packages.${localSystem}.targets."${crossSystem.cpu.name}-pc-windows-gnu".latest.rust-std
|
||||||
|
])
|
||||||
|
|
||||||
|
else if crossSystem.cpu.name == "wasm32"
|
||||||
|
then
|
||||||
|
(crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [
|
||||||
|
fenix.packages.${localSystem}.targets.wasm32-unknown-unknown.latest.toolchain
|
||||||
|
fenix.packages.${localSystem}.latest.toolchain
|
||||||
|
])
|
||||||
|
else if crossSystem.name == "x86_64-linux-gnu"
|
||||||
|
then
|
||||||
|
builtins.trace "x86_64-linux-gnu hackfix...."
|
||||||
|
(crane.mkLib pkgs).overrideToolchain (fenix.packages.${localSystem}.combine [
|
||||||
|
fenix.packages.${localSystem}.latest.toolchain
|
||||||
|
])
|
||||||
|
|
||||||
|
else
|
||||||
|
(crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default)
|
||||||
|
;
|
||||||
|
|
||||||
|
mkSelString = attrs: builtins.toJSON (attrs // {
|
||||||
|
inherit toolchain_version;
|
||||||
|
system = crossSystem.nameFull;
|
||||||
|
mize_version = main-default.version;
|
||||||
|
});
|
||||||
|
|
||||||
toolchain_version_drv = pkgs.stdenv.mkDerivation {
|
toolchain_version_drv = pkgs.stdenv.mkDerivation {
|
||||||
name = "toolchain_version_drv";
|
name = "toolchain_version_drv";
|
||||||
@@ -40,92 +101,184 @@ rec {
|
|||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
touch $out/rustc-version
|
touch $out/rustc-version
|
||||||
|
|
||||||
${osCrane.rustc}/bin/rustc --version > $out/rustc-version
|
echo hiiiiiiiiiiiiiiiiiiiiiiii
|
||||||
|
echo 'rustc 1.80.1 (3f5fd8dd4 2024-08-06)' > $out/rustc-version
|
||||||
|
${craneLib.cargo}/bin/rustc --version > $out/rustc-version
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
toolchain_version_string = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile "${toolchain_version_drv}/rustc-version");
|
toolchain_version = pkgs.lib.strings.removeSuffix "\n" (builtins.readFile "${toolchain_version_drv}/rustc-version");
|
||||||
|
|
||||||
|
mkMizeModule = attrs: pkgsCross.stdenv.mkDerivation (attrs // {
|
||||||
|
selector_string = mkSelString attrs.select;
|
||||||
buildMizeForSystem = system: let
|
|
||||||
crossSystem = (if builtins.isString system then pkgs.lib.systems.mkSystemFrommString system else system)
|
|
||||||
// {
|
|
||||||
name = if crossSystem.vendor == "unknown"
|
|
||||||
then "${crossSystem.cpu.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}"
|
|
||||||
else "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
|
|
||||||
nameFull = "${crossSystem.cpu.name}-${crossSystem.vendor.name}-${crossSystem.kernel.name}-${crossSystem.abi.name}";
|
|
||||||
};
|
|
||||||
pkgsCross = import nixpkgs { inherit crossSystem localSystem; overlays = [ rust-overlay ]; };
|
|
||||||
|
|
||||||
craneLib = (crane.mkLib pkgsCross).overrideToolchain (p: p.rust-bin.stable.latest.default);
|
|
||||||
|
|
||||||
mkSelString = attrs: builtins.toJSON (attrs // {
|
|
||||||
toolchain_version = toolchain_version_string;
|
|
||||||
mize_version = main.version;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mkMizeModule = attrs: {
|
mkMizeRustModule = attrs: craneLib.buildPackage (attrs // {
|
||||||
a = builtins.error "todo!()";
|
MIZE_BUILD_CONFIG = mizeBildConfig;
|
||||||
};
|
selector_string = mkSelString (attrs.select or {} // {
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
mkMizeRustModule = attrs: craneLib.buildPackage attrs // {
|
# linux specific stuff
|
||||||
cargoExtraArgs = "--target ${crossSystem.nameFull} " + attrs.cargoExtraArgs or "";
|
// (if crossSystem.kernel.name == "linux" then {
|
||||||
"CARGO_TARGET_${pkgsCross.lib.strings.toUpper crossSystem.nameFull}_LINKER" = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
"CARGO_TARGET_${builtins.replaceStrings ["-"] ["_"] (pkgsCross.lib.strings.toUpper crossSystem.nameFull)}_LINKER" = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||||
HOST_CC = "${pkgsCross.stdenv.cc.nativePrefix}cc";
|
HOST_CC = "${pkgsCross.stdenv.cc.nativePrefix}cc";
|
||||||
TARGET_CC = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
TARGET_CC = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||||
};
|
CARGO_BUILD_TARGET = crossSystem.nameFull;
|
||||||
|
nativeBuildInputs = attrs.nativeBuildInputs or [] ++ [
|
||||||
|
pkgsCross.stdenv.cc
|
||||||
|
];
|
||||||
|
} else {})
|
||||||
|
|
||||||
buildModule = path: (pkgsCross.callPackage path {
|
# add wasm stuff
|
||||||
inherit mkSelString craneLib;
|
// (if crossSystem.cpu.name == "wasm32" then {
|
||||||
inherit mkMizeModule mkMizeRustModule;
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
||||||
toolchain_version = toolchain_version_string;
|
|
||||||
mize_version = main.version;
|
|
||||||
});
|
|
||||||
|
|
||||||
main = craneLib.buildPackage {
|
# checks fail on wasm
|
||||||
src = "${self}";
|
doCheck = false;
|
||||||
cargoExtraArgs = "--bin mize --features os-target";
|
} else {})
|
||||||
|
|
||||||
MIZE_BUILD_CONFIG = pkgs.writeTextFile {
|
# add windows stuff
|
||||||
|
// (if crossSystem.kernel.name == "windows" then {
|
||||||
|
strictDeps = true;
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
CARGO_BUILD_TARGET = "${crossSystem.cpu.name}-pc-windows-gnu";
|
||||||
|
|
||||||
|
# fixes issues related to libring
|
||||||
|
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
|
||||||
|
|
||||||
|
#fixes issues related to openssl
|
||||||
|
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
||||||
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
||||||
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
||||||
|
|
||||||
|
depsBuildBuild = [
|
||||||
|
pkgs.pkgsCross.mingwW64.stdenv.cc
|
||||||
|
pkgs.pkgsCross.mingwW64.windows.pthreads
|
||||||
|
];
|
||||||
|
} else {})
|
||||||
|
);
|
||||||
|
|
||||||
|
buildModule = path: extraArgs: (pkgs.callPackage path {
|
||||||
|
inherit mkSelString craneLib toolchain_version;
|
||||||
|
inherit mkMizeModule mkMizeRustModule buildModule findModules crossSystem pkgsCross pkgsNative;
|
||||||
|
mize_version = main-default.version;
|
||||||
|
} // extraArgs );
|
||||||
|
|
||||||
|
mizeBildConfig = pkgs.writeTextFile {
|
||||||
name = "mize-build-config";
|
name = "mize-build-config";
|
||||||
text = builtins.toJSON (defaultMizeConfig // {
|
text = builtins.toJSON (defaultMizeConfig // {
|
||||||
toolchain_version = toolchain_version_string;
|
inherit toolchain_version;
|
||||||
mize_version = main.version;
|
mize_version = main-default.version;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
main-default = craneLib.buildPackage ({
|
||||||
|
src = "${self}";
|
||||||
|
cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
MIZE_BUILD_CONFIG = mizeBildConfig;
|
||||||
|
|
||||||
# patch the interpreter to run on most linux-gnu distros
|
# patch the interpreter to run on most linux-gnu distros
|
||||||
postBuild = ''
|
postBuild =
|
||||||
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /build/source/target/release/mize
|
if crossSystem.cpu.name == "x86_64"
|
||||||
'';
|
then "patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 /build/source/target/release/mize"
|
||||||
|
else if crossSystem.cpu.name == "aarch64"
|
||||||
|
then "patchelf --set-interpreter /lib64/ld-linux-aarch64.so.2 /build/source/target/${crossSystem.nameFull}/release/mize"
|
||||||
|
else ""
|
||||||
|
;
|
||||||
|
|
||||||
|
}
|
||||||
|
// (if crossSystem.name == "x86_64-linux-gnu" then builtins.trace "another x86_64-linux hackfix..." {} else {
|
||||||
|
CARGO_BUILD_TARGET = crossSystem.nameFull;
|
||||||
|
"CARGO_TARGET_${builtins.replaceStrings ["-"] ["_"] (pkgsCross.lib.strings.toUpper crossSystem.nameFull)}_LINKER" = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||||
|
HOST_CC = "${pkgsCross.stdenv.cc.nativePrefix}cc";
|
||||||
|
TARGET_CC = "${pkgsCross.stdenv.cc.targetPrefix}cc";
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
main-win = craneLib.buildPackage {
|
||||||
|
src = craneLib.cleanCargoSource ./.;
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
cargoExtraArgs = "--bin mize --features os-target";
|
||||||
|
|
||||||
|
CARGO_BUILD_TARGET = "${crossSystem.cpu.name}-pc-windows-gnu";
|
||||||
|
|
||||||
|
MIZE_BUILD_CONFIG = mizeBildConfig;
|
||||||
|
|
||||||
|
# fixes issues related to libring
|
||||||
|
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
|
||||||
|
|
||||||
|
#fixes issues related to openssl
|
||||||
|
OPENSSL_DIR = "${pkgs.openssl.dev}";
|
||||||
|
OPENSSL_LIB_DIR = "${pkgs.openssl.out}/lib";
|
||||||
|
OPENSSL_INCLUDE_DIR = "${pkgs.openssl.dev}/include/";
|
||||||
|
|
||||||
|
depsBuildBuild = [
|
||||||
|
pkgs.pkgsCross.mingwW64.stdenv.cc
|
||||||
|
pkgs.pkgsCross.mingwW64.windows.pthreads
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
main-wasm = craneLib.buildPackage {
|
||||||
|
src = "${self}";
|
||||||
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
||||||
|
doCheck = false;
|
||||||
|
cargoExtraArgs = "--features wasm-target";
|
||||||
|
MIZE_BUILD_CONFIG = mizeBildConfig;
|
||||||
|
};
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
inherit main;
|
inherit toolchain_version_drv pkgsCross craneLib;
|
||||||
|
main =
|
||||||
|
if crossSystem.kernel.name == "windows"
|
||||||
|
then main-win
|
||||||
|
else if crossSystem.cpu.name == "wasm32"
|
||||||
|
then main-wasm
|
||||||
|
else main-default
|
||||||
|
;
|
||||||
|
|
||||||
system = crossSystem;
|
system = crossSystem;
|
||||||
|
|
||||||
modules = pkgs.lib.lists.flatten (map buildModule module_list);
|
modulesListDrv = module_list_drv mize_modules;
|
||||||
};
|
modulesFileList = pkgs.lib.lists.flatten (findModules mize_modules);
|
||||||
|
modulesList = map (mod: (buildModule mod {})) modulesFileList;
|
||||||
|
|
||||||
|
modules = builtins.listToAttrs ( map ( mod: { name = mod.modName; value = mod; } ) modulesList );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
mkInstallPhase = mize: ''
|
mkInstallPhase = mize: ''
|
||||||
# install mize
|
# install mize
|
||||||
mkdir -p $out/mize/${mize.system.name}
|
mkdir -p $out/mize/${mize.system.name}
|
||||||
cp ${mize.main}/bin/mize $out/mize/${mize.system.name}/
|
|
||||||
|
${
|
||||||
|
if mize.system.kernel.name == "windows"
|
||||||
|
then "cp ${mize.main}/bin/mize.exe $out/mize/${mize.system.name}/"
|
||||||
|
else if mize.system.cpu.name == "wasm32"
|
||||||
|
then "cp ${mize.main}/lib/mize.wasm $out/mize/${mize.system.name}/"
|
||||||
|
else "cp ${mize.main}/bin/mize $out/mize/${mize.system.name}/"
|
||||||
|
}
|
||||||
|
|
||||||
# intall the modules
|
# intall the modules
|
||||||
${mkModulesInstallPhase mize.modules}
|
${mkModulesInstallPhase mize.modulesList}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mkModulesInstallPhase = modules: pkgs.lib.concatStringsSep "\n" (map (module: ''
|
mkModulesInstallPhase = modules: pkgs.lib.concatStringsSep "\n" (map mkModuleInstallPhase modules);
|
||||||
|
|
||||||
|
mkModuleInstallPhase = module: ''
|
||||||
echo got module: ${module.name}
|
echo got module: ${module.name}
|
||||||
hash=$(echo ${module.selector_string} | sha256sum | cut -c -32)
|
hash=$(echo ${module.selector_string} | sha256sum | cut -c -32)
|
||||||
mkdir -p $out/mize/dist/$hash
|
mkdir -p $out/mize/dist/$hash
|
||||||
cp -r ${module}/* $out/mize/dist/$hash
|
cp -r ${module}/* $out/mize/dist/$hash
|
||||||
echo '${module.selector_string}' > $out/mize/dist/$hash/selector_string
|
echo '${module.selector_string}' > $out/mize/dist/$hash/selector
|
||||||
'')) modules;
|
'';
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ pub struct Instance {
|
|||||||
// TODO: set to a random uuid
|
// TODO: set to a random uuid
|
||||||
pub self_namespace: Arc<Mutex<Namespace>>,
|
pub self_namespace: Arc<Mutex<Namespace>>,
|
||||||
pub op_tx: channel::Sender<Operation>,
|
pub op_tx: channel::Sender<Operation>,
|
||||||
context: Vec<MizeId>,
|
threads: Arc<Mutex<Vec<(u32, String)>>>,
|
||||||
threads: Vec<String>,
|
next_thread_id: Arc<Mutex<u32>>,
|
||||||
give_msg_wait: Arc<Mutex<HashMap<MizeId, Vec<Sender<ItemData>>>>>,
|
give_msg_wait: Arc<Mutex<HashMap<MizeId, Vec<Sender<ItemData>>>>>,
|
||||||
create_msg_wait: Arc<Mutex<Option<Sender<MizeId>>>>,
|
create_msg_wait: Arc<Mutex<Option<Sender<MizeId>>>>,
|
||||||
update_thread_busy: Arc<Mutex<bool>>,
|
update_thread_busy: Arc<Mutex<bool>>,
|
||||||
@@ -100,8 +100,8 @@ impl Instance {
|
|||||||
namespace, self_namespace, op_tx,
|
namespace, self_namespace, op_tx,
|
||||||
namespace_pool: Arc::new(Mutex::new(namespace_pool_raw)),
|
namespace_pool: Arc::new(Mutex::new(namespace_pool_raw)),
|
||||||
modules: Arc::new(Mutex::new(HashMap::new())),
|
modules: Arc::new(Mutex::new(HashMap::new())),
|
||||||
context: vec![],
|
threads: Arc::new(Mutex::new(Vec::new())),
|
||||||
threads: vec![],
|
next_thread_id: Arc::new(Mutex::new(0)),
|
||||||
next_con_id: Arc::new(Mutex::new(1)),
|
next_con_id: Arc::new(Mutex::new(1)),
|
||||||
give_msg_wait, create_msg_wait,
|
give_msg_wait, create_msg_wait,
|
||||||
update_thread_busy: Arc::new(Mutex::new(false)),
|
update_thread_busy: Arc::new(Mutex::new(false)),
|
||||||
@@ -151,16 +151,15 @@ impl Instance {
|
|||||||
crate::platform::any::instance_init(self);
|
crate::platform::any::instance_init(self);
|
||||||
|
|
||||||
// end of platform specific init code
|
// end of platform specific init code
|
||||||
self.load_module("Blob")?;
|
|
||||||
|
|
||||||
let mut modules_inner = self.modules.lock()?;
|
|
||||||
|
|
||||||
let module = modules_inner.get_mut("Blob").unwrap();
|
self.load_module("String")?;
|
||||||
|
|
||||||
println!("right before segfault");
|
//let mut modules_inner = self.modules.lock()?;
|
||||||
module.init(&self);
|
//let module = modules_inner.get_mut("String").unwrap();
|
||||||
|
//println!("right before segfault");
|
||||||
|
//module.init(&self);
|
||||||
|
|
||||||
//self.load_module("String")?;
|
|
||||||
|
|
||||||
debug!("INSTANCE INIT DONE");
|
debug!("INSTANCE INIT DONE");
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -398,8 +397,33 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn(&mut self, name: &str, func: impl FnOnce() -> MizeResult<()> + Send + 'static) -> MizeResult<()> {
|
pub fn spawn(&mut self, name: &str, func: impl FnOnce() -> MizeResult<()> + Send + 'static) -> MizeResult<()> {
|
||||||
self.threads.push(name.to_owned());
|
let threads_inner = self.threads.lock()?;
|
||||||
thread::spawn(move || func());
|
let mut next_thread_id = self.next_thread_id.lock()?;
|
||||||
|
|
||||||
|
threads_inner.push((next_thread_id, name.to_owned()));
|
||||||
|
|
||||||
|
let to_spawn = move || {
|
||||||
|
debug!("spawning thread: {}", name);
|
||||||
|
let my_thread_id = next_thread_id;
|
||||||
|
|
||||||
|
func()?;
|
||||||
|
|
||||||
|
let mut threads_inner = self.threads.lock()?;
|
||||||
|
threads_inner = threads_inner.into_iter().filter(|el| match el {
|
||||||
|
(my_thread_id, _) => false,
|
||||||
|
(_, _) => true,
|
||||||
|
});
|
||||||
|
debug!("thread '{}' stopped", name);
|
||||||
|
};
|
||||||
|
|
||||||
|
*next_thread_id += 1;
|
||||||
|
|
||||||
|
#[cfg(feature = "os-target")]
|
||||||
|
thread::spawn(move || to_spawn());
|
||||||
|
|
||||||
|
#[cfg(feature = "wasm-target")]
|
||||||
|
crate::platform::wasm::wasm_spawn(move || to_spawn())?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
|
|
||||||
#![ allow( warnings ) ]
|
#![ allow( warnings ) ]
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub fn main() {
|
||||||
|
println!("hello from main fn");
|
||||||
|
}
|
||||||
|
|
||||||
static PROTO_VERSION: u8 = 1;
|
static PROTO_VERSION: u8 = 1;
|
||||||
|
|
||||||
// the core part has the code that can run on any platform
|
// the core part has the code that can run on any platform
|
||||||
@@ -43,6 +48,9 @@ pub mod platform {
|
|||||||
#[cfg(feature = "os-target")]
|
#[cfg(feature = "os-target")]
|
||||||
pub use super::os::load_module;
|
pub use super::os::load_module;
|
||||||
|
|
||||||
|
#[cfg(feature = "wasm-target")]
|
||||||
|
pub use super::super::load_module;
|
||||||
|
|
||||||
#[cfg(not(any(feature = "os-target", feature = "wasm-target")))]
|
#[cfg(not(any(feature = "os-target", feature = "wasm-target")))]
|
||||||
pub use super::super::load_module;
|
pub use super::super::load_module;
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,25 @@
|
|||||||
mod utils;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
use std::ptr::NonNull;
|
||||||
|
use std::panic;
|
||||||
|
|
||||||
use crate::instance::Instance;
|
use crate::instance::{self, Instance};
|
||||||
use crate::error::MizeResult;
|
use crate::error::MizeResult;
|
||||||
|
use crate::Module;
|
||||||
|
|
||||||
|
|
||||||
|
// console_log macro
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern "C" {
|
||||||
|
#[wasm_bindgen(js_namespace = console)]
|
||||||
|
fn log(s: &str);
|
||||||
|
}
|
||||||
|
macro_rules! console_log {
|
||||||
|
// Note that this is using the `log` function imported above during
|
||||||
|
// `bare_bones`
|
||||||
|
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||||
|
}
|
||||||
|
//end of console_log macro
|
||||||
|
|
||||||
|
|
||||||
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
||||||
// allocator.
|
// allocator.
|
||||||
@@ -11,19 +27,71 @@ use crate::error::MizeResult;
|
|||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
extern {
|
|
||||||
fn alert(s: &str);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
// A function imitating `std::thread::spawn`.
|
||||||
pub fn greet() {
|
// thanks to: https://www.tweag.io/blog/2022-11-24-wasm-threads-and-messages/
|
||||||
alert("Hello, wasm-game-of-life!");
|
pub fn wasm_spawn(f: impl FnOnce() + Send + 'static) -> MizeResult<()> {
|
||||||
}
|
let worker = web_sys::Worker::new("./worker.js")?;
|
||||||
|
// Double-boxing because `dyn FnOnce` is unsized and so `Box<dyn FnOnce()>` is a fat pointer.
|
||||||
pub fn wasm_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
// But `Box<Box<dyn FnOnce()>>` is just a plain pointer, and since wasm has 32-bit pointers,
|
||||||
println!("Hello world from wasm_instance_init!!!!!!!!!!");
|
// we can cast it to a `u32` and back.
|
||||||
alert("Hello world from wasm_instance_init!!!!!!!!!!");
|
let ptr = Box::into_raw(Box::new(Box::new(f) as Box<dyn FnOnce()>));
|
||||||
|
let msg = js_sys::Array::new();
|
||||||
|
// Send the worker a reference to our memory chunk, so it can initialize a wasm module
|
||||||
|
// using the same memory.
|
||||||
|
msg.push(&wasm_bindgen::memory());
|
||||||
|
// Also send the worker the address of the closure we want to execute.
|
||||||
|
msg.push(&JsValue::from(ptr as u32));
|
||||||
|
worker.post_message(&msg);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
// This function is here for `worker.js` to call.
|
||||||
|
pub fn worker_entry_point(addr: u32) {
|
||||||
|
// Interpret the address we were given as a pointer to a closure to call.
|
||||||
|
let closure = unsafe { Box::from_raw(ptr as *mut Box<dyn FnOnce()>) };
|
||||||
|
(*closure)();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn wasm_instance_init(instance: &mut Instance) -> MizeResult<()> {
|
||||||
|
console_log!("Hello world from wasm_instance_init!!!!!!!!!!");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct JsInstance {
|
||||||
|
inner: NonNull<Instance>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub struct JsModule {
|
||||||
|
inner: NonNull<Box<dyn Module + Send + Sync>>,
|
||||||
|
//inner: *mut Mme,
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
impl JsInstance {
|
||||||
|
#[wasm_bindgen(constructor)]
|
||||||
|
pub fn new() -> JsInstance {
|
||||||
|
panic::set_hook(Box::new(console_error_panic_hook::hook));
|
||||||
|
|
||||||
|
let instance = match Instance::new() {
|
||||||
|
Ok(val) => val,
|
||||||
|
Err(e) => {
|
||||||
|
console_log!("Instance::new() failed with: {:?}", e);
|
||||||
|
panic!()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
let mut js_instance = JsInstance { inner: NonNull::from(Box::leak(Box::new(instance))) };
|
||||||
|
return js_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#[wasm_bindgen]
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
, pkgs
|
, pkgs
|
||||||
, mkInstallPhase
|
, mkInstallPhase
|
||||||
, buildMizeForSystem
|
, buildMizeForSystem
|
||||||
|
, systems
|
||||||
, ...
|
, ...
|
||||||
}: let
|
}: let
|
||||||
|
|
||||||
# list of systems, we build mize for for webfiles
|
# list of systems, we build mize for for webfiles
|
||||||
systems = [ "x86_64-linux" "aarch64-linux" "wasm32" ];
|
#systems = [ "x86_64-linux" "aarch64-linux" "wasm32" ];
|
||||||
|
#systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
|
|
||||||
list_of_mizes = map buildMizeForSystem systems;
|
list_of_mizes = map buildMizeForSystem systems;
|
||||||
|
|
||||||
@@ -18,9 +20,10 @@ stdenv.mkDerivation {
|
|||||||
# so that /bin/sh does not get patched to a nix store path in victorinix-s
|
# so that /bin/sh does not get patched to a nix store path in victorinix-s
|
||||||
dontPatchShebangs = true;
|
dontPatchShebangs = true;
|
||||||
|
|
||||||
buildPhase = "";
|
buildPhase = ''
|
||||||
|
'';
|
||||||
|
|
||||||
InstallPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
mkdir -p $out/mize
|
mkdir -p $out/mize
|
||||||
mkdir -p $out/mize/dist
|
mkdir -p $out/mize/dist
|
||||||
|
|||||||
Reference in New Issue
Block a user