Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
guillemcordoba committed Mar 6, 2024
1 parent 55ea85f commit ee0dd86
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nix/fixture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ serde = "1"
[profile.release]
opt-level = "z"
trim-paths = true
remap-debuginfo = true
# remap-debuginfo = true
2 changes: 1 addition & 1 deletion nix/fixture/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion nix/fixture/zome/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use hdk::prelude::*;


#[hdk_extern]
pub fn hello(_: ()) -> ExternResult<String> {
Ok(String::from("hello"))
Expand Down
21 changes: 21 additions & 0 deletions nix/rustc-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e

file="/build/source/zome/src/lib.rs"
# for arg in "$@"; do
# if [[ ${arg} == ${CARGO_HOME}/* && -z ${file} ]]; then
# file=${arg##${CARGO_HOME}}
# fi
# done
# echo "heyy"
# echo $file
args=()
for arg in "$@"; do
if [[ ${arg} == metadata=* ]]; then
args+=(metadata="${file}")
else
args+=("${arg}")
fi
done

exec "${args[@]}"
7 changes: 7 additions & 0 deletions nix/zome.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
craneLib,
workspacePath,
crateCargoToml,
writeShellScript,
excludedCrates
}:

Expand All @@ -14,12 +15,15 @@ let
cargoToml = builtins.fromTOML (builtins.readFile crateCargoToml);
crate = cargoToml.package.name;

# rustcWrapper = writeShellScript "rustc-wrapper.sh" (builtins.readFile ./rustc-wrapper.sh);

commonArgs = {
strictDeps = true;
doCheck = false;
src = craneLib.cleanCargoSource (craneLib.path workspacePath);
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
# CARGO_BUILD_RUSTFLAGS = "";
# RUSTC_WRAPPER = rustcWrapper;
};

wasmDeps = craneLib.buildDepsOnly (commonArgs // {
Expand All @@ -32,6 +36,9 @@ let
cargoLock = workspacePath + /Cargo.lock;
cargoArtifacts = wasmDeps;
cargoExtraArgs = "-p ${crate} --locked -v";
# cargoBuildCommand = "cargo rustc --profile release -- -C metadata=${cratePath}/src/lib.rs";
# cargoBuildCommand = "rustc -vv --crate-name ${crate} --edition=2021 ${workspacePath}/zome/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type cdylib --crate-type rlib --emit=dep-info,link -C opt-level=z -C embed-bitcode=no -Zunstable-options -Zremap-path-scope=all --remap-path-prefix=/build/source=. --out-dir /build/source/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/build/source/target/wasm32-unknown-unknown/release/deps -L dependency=/build/source/target/release/deps --extern hdk=/build/source/target/wasm32-unknown-unknown/release/deps/libhdk-958f0c3891df457c.rlib --extern serde=/build/source/target/wasm32-unknown-unknown/release/deps/libserde-7c4f086b3ce3ca72.rlib";
# installPhaseCommand = "";
pname = crate;
version = cargoToml.package.version;
});
Expand Down

0 comments on commit ee0dd86

Please sign in to comment.