Skip to content

Commit

Permalink
Share workspace build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Jun 18, 2024
1 parent 9bbc0bb commit 6aa89c7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
crate = "holochain";
package = "holochain";
};

holochain_cli_x86_64-windows = import ./modules/holochain-windows.nix {
inherit localSystem inputs;
crate = "hc";
package = "holochain_cli";
};
} // (if localSystem == "aarch64-darwin" then {
holochain_aarch64-apple = import ./modules/holochain-cross.nix {
inherit localSystem inputs;
Expand Down
61 changes: 37 additions & 24 deletions modules/holochain-windows.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,50 @@ let
cp -r libsodium-win64/* $out
'';
};
in
craneLib.buildPackage {
pname = package;
version = crateInfo.version;

# Load source with a custom filter so we can include non-cargo files that get used during the build
src = holochainCommon.src;
commonArgs = {
# Just used for building the workspace, will be replaced when building a specific crate
pname = "default";
version = "0.0.0";

strictDeps = true;
doCheck = false;
# Load source with a custom filter so we can include non-cargo files that get used during the build
src = holochainCommon.src;

CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";
strictDeps = true;
doCheck = false;

# fixes issues related to libring
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
CARGO_BUILD_TARGET = "x86_64-pc-windows-gnu";

# Otherwise tx5-go-pion-sys picks up the host linker instead of the cross linker
RUSTC_LINKER = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";
# fixes issues related to libring
TARGET_CC = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";

SODIUM_LIB_DIR = "${libsodium}/lib";
# Otherwise tx5-go-pion-sys picks up the host linker instead of the cross linker
RUSTC_LINKER = "${pkgs.pkgsCross.mingwW64.stdenv.cc}/bin/${pkgs.pkgsCross.mingwW64.stdenv.cc.targetPrefix}cc";

nativeBuildInputs = with pkgs; [
go
perl
];
SODIUM_LIB_DIR = "${libsodium}/lib";

depsBuildBuild = with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
nativeBuildInputs = with pkgs; [
go
perl
];

cargoExtraArgs = "--package ${package}";
}
depsBuildBuild = with pkgs; [
pkgsCross.mingwW64.stdenv.cc
pkgsCross.mingwW64.windows.pthreads
];
};

# Build *just* the Cargo dependencies (of the entire workspace),
# so we can reuse all of that work (e.g. via cachix) when running in CI
# It is *highly* recommended to use something like cargo-hakari to avoid
# cache misses when building individual top-level-crates
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in
craneLib.buildPackage (commonArgs // {
pname = package;
version = crateInfo.version;

inherit cargoArtifacts;

cargoExtraArgs = "--package ${package}";
})

0 comments on commit 6aa89c7

Please sign in to comment.