Optimize base-hw tests, include dhall config with build
parent
b4ee16345f
commit
e48de48711
|
@ -7,18 +7,21 @@ let
|
|||
inherit (nixpkgs) buildPackages;
|
||||
testPkgs = thisSystem genodepkgs.packages;
|
||||
|
||||
dhallCachePrelude = ''
|
||||
export XDG_CACHE_HOME=$NIX_BUILD_TOP
|
||||
export DHALL_GENODE="${testPkgs.dhallGenode}/binary.dhall";
|
||||
${buildPackages.xorg.lndir}/bin/lndir -silent \
|
||||
${testPkgs.dhallGenode}/.cache \
|
||||
$XDG_CACHE_HOME
|
||||
'';
|
||||
|
||||
in rec {
|
||||
|
||||
runDhallCommand = name: env: script:
|
||||
nixpkgs.runCommand name
|
||||
({ nativeBuildInputs = [ buildPackages.dhall ]; } // env) ''
|
||||
export XDG_CACHE_HOME=$NIX_BUILD_TOP
|
||||
export DHALL_GENODE="${testPkgs.dhallGenode}/binary.dhall";
|
||||
${buildPackages.xorg.lndir}/bin/lndir -silent \
|
||||
${testPkgs.dhallGenode}/.cache \
|
||||
$XDG_CACHE_HOME
|
||||
|
||||
${script}
|
||||
${dhallCachePrelude}
|
||||
${script}
|
||||
'';
|
||||
|
||||
linuxScript = name: env: bootDhall:
|
||||
|
@ -31,16 +34,72 @@ in rec {
|
|||
runDhallCommand name env ''
|
||||
dhall to-directory-tree --output $out \
|
||||
<<< "${./compile-boot.dhall} (${bootDhall}) \"$out\""
|
||||
dhall <<< "(${bootDhall}).config" \
|
||||
| dhall encode \
|
||||
> $out/config.dhall.bin
|
||||
'';
|
||||
|
||||
novaImage = name: env: boot:
|
||||
let inherit (nixpkgs.stdenv) cc;
|
||||
in nixpkgs.stdenv.mkDerivation {
|
||||
hwImage = name: env: boot:
|
||||
nixpkgs.stdenv.mkDerivation {
|
||||
name = name + ".image.elf";
|
||||
# buildInputs = with buildPackages; [ stdenv.cc ];
|
||||
build = compileBoot name env boot;
|
||||
nativeBuildInputs = [ buildPackages.dhall ];
|
||||
buildCommand = let
|
||||
bootstrapDhall =
|
||||
# snippet used to nest core.elf into image.elf
|
||||
builtins.toFile "boostrap.dall" ''
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
# CC="${cc}/bin/${cc.targetPrefix}cc"
|
||||
in { config = Genode.Init.default
|
||||
, rom =
|
||||
Genode.BootModules.toRomPaths
|
||||
[ { mapKey = "core.elf", mapValue = "./core.elf" } ]
|
||||
}
|
||||
'';
|
||||
in ''
|
||||
${dhallCachePrelude}
|
||||
|
||||
build_core() {
|
||||
local lib="$1"
|
||||
local modules="$2"
|
||||
local link_address="$3"
|
||||
local out="$4"
|
||||
|
||||
# compile the boot modules into one object file
|
||||
$CC -c -x assembler -o "boot_modules.o" "$modules"
|
||||
|
||||
# link final image
|
||||
LD="${buildPackages.binutils}/bin/${buildPackages.binutils.targetPrefix}ld"
|
||||
$LD \
|
||||
--strip-all \
|
||||
-T${testPkgs.genodeSources}/repos/base/src/ld/genode.ld \
|
||||
-z max-page-size=0x1000 \
|
||||
-Ttext=$link_address -gc-sections \
|
||||
"$lib" "boot_modules.o" \
|
||||
-o $out
|
||||
}
|
||||
|
||||
build_core \
|
||||
"${testPkgs.base-hw-pc.coreObj}" \
|
||||
"$build/modules_asm" \
|
||||
0xffffffc000000000 \
|
||||
core.elf
|
||||
|
||||
dhall to-directory-tree --output bootstrap \
|
||||
<<< "${./compile-boot.dhall} ${bootstrapDhall} \"bootstrap\""
|
||||
|
||||
build_core \
|
||||
"${testPkgs.base-hw-pc.bootstrapObj}" \
|
||||
bootstrap/modules_asm \
|
||||
0x00200000 \
|
||||
$out
|
||||
'';
|
||||
};
|
||||
|
||||
novaImage = name: env: boot:
|
||||
nixpkgs.stdenv.mkDerivation {
|
||||
name = name + ".image.elf";
|
||||
build = compileBoot name env boot;
|
||||
|
||||
buildCommand = ''
|
||||
# compile the boot modules into one object file
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
-- SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
let Genode = env:DHALL_GENODE
|
||||
|
||||
let sumRam =
|
||||
λ(boot : Genode.Boot.Type)
|
||||
→ let sum = Genode.Init.resources boot.config in sum.ram
|
||||
|
||||
in sumRam
|
|
@ -48,7 +48,7 @@ let
|
|||
XDG_CACHE_HOME = "/tmp";
|
||||
} // testEnv;
|
||||
|
||||
image = apps.hw-image.function testEnv' testConfig';
|
||||
image = lib.hwImage name testEnv' testConfig';
|
||||
|
||||
baseSetup = ''
|
||||
##
|
||||
|
@ -114,13 +114,13 @@ let
|
|||
mkdir -p $out/bin
|
||||
echo "$testScript" > $out/test-script
|
||||
echo "$baseSetup" > $out/base-setup
|
||||
eval $(${apps.dhall-to-bash.program} --declare "TEST_RAM" \
|
||||
<<< "${./boot-ram.dhall} (${testConfig'})")
|
||||
source ${image.build}/stats
|
||||
|
||||
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
|
||||
wrapProgram $out/bin/genode-test-driver \
|
||||
--set testScript "$testScript" \
|
||||
--set baseSetup "$baseSetup" \
|
||||
--set TEST_RAM $TEST_RAM \
|
||||
--set TEST_RAM $RAM \
|
||||
'';
|
||||
|
||||
passMeta = drv:
|
||||
|
|
|
@ -116,7 +116,7 @@ let
|
|||
mkdir -p $out/bin
|
||||
echo "$testScript" > $out/test-script
|
||||
echo "$baseSetup" > $out/base-setup
|
||||
source ${build}/stats
|
||||
source ${image.build}/stats
|
||||
|
||||
ln -s ${testDriver}/bin/genode-test-driver $out/bin/
|
||||
wrapProgram $out/bin/genode-test-driver \
|
||||
|
@ -132,7 +132,8 @@ let
|
|||
test = passMeta (runTests driver);
|
||||
|
||||
in test // {
|
||||
inherit build driver image test manifest;
|
||||
inherit driver image test manifest;
|
||||
inherit (image) build;
|
||||
|
||||
config = buildPackages.runCommand (name + ".dhall") testEnv' ''
|
||||
${apps.dhall.program} <<< "${testConfig'}" > $out
|
||||
|
|
Loading…
Reference in New Issue