Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix: Make buildSysroot more broadly useful #171

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion hacking/nix/rust-utils/build-sysroot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
, std ? false
, compilerBuiltinsMem ? true
, compilerBuiltinsC ? rustEnvironment.compilerRTSource != null
, src ? null
, extraManifest ? {}
, extraConfig ? {}
}:
Expand All @@ -36,7 +37,7 @@ let
manifest = crateUtils.toTOMLFile "Cargo.toml" (crateUtils.clobber [
{
inherit package;
lib.path = crateUtils.dummyLibInSrc;
lib.path = crateUtils.dummyLibWithoutStdInSrc;
}
extraManifest
]);
Expand Down Expand Up @@ -89,6 +90,9 @@ in
} // lib.optionalAttrs compilerBuiltinsC {
"CC_${targetTriple.name}" = "${stdenv.cc.targetPrefix}gcc";
RUST_COMPILER_RT_ROOT = rustEnvironment.compilerRTSource;
} // lib.optionalAttrs (src != null) {
# HACK
__CARGO_TESTS_ONLY_SRC_ROOT = src;
}) ''
cargo build \
-Z unstable-options \
Expand Down
9 changes: 5 additions & 4 deletions hacking/nix/rust-utils/crate-utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ rec {
###

dummyLibInSrc = dummyInSrc "lib.rs" dummyLib;
dummyLibWithoutStdInSrc = dummyInSrc "lib.rs" dummyLibWithoutStd;
dummyMainWithStdInSrc = dummyInSrc "main.rs" dummyMainWithStd;
dummyMainWithOrWithoutStdInSrc = dummyInSrc "main.rs" dummyMainWithOrWithoutStd;

Expand All @@ -39,14 +40,14 @@ rec {
in
"${src}/${name}";

dummyLibWithoutStd = writeText "lib.rs" ''
#![no_std]
'';

dummyMainWithStd = writeText "main.rs" ''
fn main() {}
'';

# dummyLib = writeText "lib.rs" ''
# #![no_std]
# '';

# HACK for cargo test (required by harness = "false")
dummyLib = dummyMainOrLibWithOrWithoutStd;

Expand Down
3 changes: 2 additions & 1 deletion hacking/nix/scope/world/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ mkShell (seL4RustEnvVars // kernelLoaderConfigEnvVars // capdlEnvVars // bindgen
];

shellHook = ''
# abbreviation
export h=$HOST_CARGO_FLAGS
export t="--target $RUST_SEL4_TARGET"
export bt="--target $RUST_BARE_METAL_TARGET"
'';
})
Loading