Browse Source

Nix: source code filtering

staging
Emery Hemingway 2 years ago
parent
commit
b8e25c82da
  1. 0
      Tuprules.gcc
  2. 0
      Tuprules.llvm
  3. 4
      Tuprules.tup
  4. 72
      default.nix
  5. 2
      enter-shell.sh
  6. 4
      repos/base-nova/src/lib/ld/Tupfile
  7. 4
      repos/base/src/test/ds_ownership/Tupfile
  8. 4
      repos/base/src/test/log/Tupfile
  9. 4
      repos/base/src/test/mmio/Tupfile
  10. 4
      repos/base/src/test/new_delete/Tupfile
  11. 4
      repos/base/src/test/reconstructible/Tupfile
  12. 4
      repos/base/src/test/registry/Tupfile
  13. 4
      repos/base/src/test/rm_fault/Tupfile
  14. 4
      repos/base/src/test/rm_nested/Tupfile
  15. 4
      repos/base/src/test/segfault/Tupfile
  16. 4
      repos/base/src/test/smp/Tupfile
  17. 4
      repos/base/src/test/stack_smash/Tupfile
  18. 4
      repos/base/src/test/sub_rm/Tupfile
  19. 4
      repos/base/src/test/synced_interface/Tupfile
  20. 4
      repos/base/src/test/thread/Tupfile
  21. 4
      repos/base/src/test/timer/Tupfile
  22. 4
      repos/base/src/test/timer_accuracy/Tupfile
  23. 4
      repos/base/src/test/xml_node/Tupfile

0
tup-genode/gcc.tup → Tuprules.gcc

0
tup-genode/llvm.tup → Tuprules.llvm

4
Tuprules.tup

@ -13,11 +13,11 @@ DEV_DIR = $(TUP_CWD)/dev
DEV_LIB_DIR = $(DEV_DIR)/lib
ifdef IS_GCC
include tup-genode/gcc.tup
include Tuprules.gcc
endif
ifdef IS_LLVM
include tup-genode/llvm.tup
include Tuprules.llvm
endif
ifeq ($(TOOLCHAIN_CONFIGURED),)

72
default.nix

@ -24,9 +24,6 @@ let
nixpkgs'.stdenvAdapters.overrideCC nixpkgs'.stdenv sourceForgeToolchain;
in assert env.cc.isGNU; env;
src = self.outPath or (builtins.fetchGit ./.);
version = self.lastModified or "unstable";
inherit (stdenvLlvm) lib targetPlatform;
specs = with targetPlatform;
[ ]
@ -123,7 +120,6 @@ let
IS_GCC = "";
LINUX_HEADERS = buildPackages.glibc.dev;
VERSION = version;
};
in toTupConfig stdenvGcc (f stdenvGcc);
@ -148,16 +144,17 @@ let
llvmPackages.libunwind.override { isBaremetal = true; };
LIBUNWIND = llvmPackages.libunwind;
LINUX_HEADERS = buildPackages.glibc.dev;
VERSION = version;
};
in toTupConfig stdenvLlvm (f stdenvLlvm);
buildRepo = { env, repo, repoInputs }:
buildRepo = { env, repo, repoInputs, filter }:
let
in env.mkDerivation {
pname = "genode-" + repo;
inherit src repo specs version;
name = "genode-" + repo;
inherit repo specs;
src = builtins.filterSource filter ./.;
nativeBuildInputs = repoInputs;
# This is wrong, why does pkg-config not collect buildInputs?
@ -233,6 +230,8 @@ let
maintainers = [ maintainers.ehmry ];
};
} // {
version = self.lastModified;
};
buildRepo' = { ... }@args: buildRepo ({ env = stdenvGcc; } // args);
@ -240,33 +239,88 @@ let
#builtins.throw "create the tup config file in the stdenv environment, replacing CC/CXX with environmental variables"
in rec {
packages = rec {
packages = let
hasPrefix = pre:
with builtins;
let
pre' = "${toString ./.}/${pre}";
preLen = stringLength pre';
in path:
let pathLen = stringLength path;
in substring 0 preLen path == substring 0 pathLen pre';
hasSuffix = suf:
with builtins;
let sufLen = stringLength suf;
in path:
let pathLen = stringLength path;
in substring (pathLen - sufLen) pathLen path == suf;
filterBaseRepo = name:
with builtins;
let
match = [
(hasPrefix "Tup")
(hasPrefix "repos/Tup")
(hasPrefix "repos/base/")
(hasPrefix "repos/base-${name}")
];
skip = [
(hasSuffix "/run")
(hasSuffix "/recipes")
(hasSuffix ".gitignore")
];
in path: type: let f = f': f' path; in any f match && !any f skip;
filterRepo = repo:
with builtins;
let
reposDir = toString ./repos;
skip = [
(hasSuffix "/run")
(hasSuffix "/recipes")
(hasSuffix ".gitignore")
];
match = [
(hasPrefix "Tup")
(hasPrefix "repos/Tup")
(hasPrefix "repos/${repo}")
(hasPrefix "repos/base/src/ld")
];
in path: type: let f = f': f' path; in any f match && !any f skip;
in rec {
NOVA = nixpkgs.callPackage ./NOVA { };
base = buildRepo' {
repo = "base";
repoInputs = [ ];
filter = filterBaseRepo "-";
};
base-linux = buildRepo' {
repo = "base-linux";
repoInputs = [ base ];
filter = filterBaseRepo "linux";
};
base-nova = buildRepo' {
repo = "base-nova";
repoInputs = [ base ];
filter = filterBaseRepo "nova";
};
os = buildRepo' {
repo = "os";
repoInputs = [ base ];
filter = filterRepo "os";
};
gems = buildRepo' {
repo = "gems";
repoInputs = [ base os ];
filter = filterRepo "gems";
};
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;

2
enter-shell.sh

@ -1,6 +1,6 @@
#! /bin/sh
set -e
nix build .#packages.x86_64-linux-x86_64-genode.tupConfigGcc -o tup.config
nix build .#packages.x86_64-linux-x86_64-genode.tupConfigGcc -o build-gcc/tup.config
export SHELL=bash
exec nix dev-shell

4
repos/base-nova/src/lib/ld/Tupfile

@ -26,7 +26,7 @@ endif
LDFLAGS += -z max-page-size=0x1000
LDFLAGS += -T$(BASE_DIR)/src/ld/genode_rel.ld
LDFLAGS += -L$(DEV_DIR)/lib
PKG_LIBS = -L$(DEV_DIR)/lib `$(PKG_CONFIG) --libs alarm cxx ldso-startup timeout`
: {obj} | \
$(DEV_DIR)/<lib> \
@ -35,7 +35,7 @@ LDFLAGS += -L$(DEV_DIR)/lib
$(REP_DIR)/<base-nova> \
$(REP_DIR)/<startup> \
symbol.map \
|> $(LD) -o %o $(LD_MARCH) $(LDFLAGS) --whole-archive --start-group -l:alarm.a %<base-common> %<base-nova> -l:cxx.a %<startup> -l:timeout.a %f --end-group --no-whole-archive $(LIBGCC) \
|> $(LD) -o %o $(LD_MARCH) $(LDFLAGS) --whole-archive --start-group $(PKG_LIBS) %<base-common> %<base-nova> %<startup> %f --end-group --no-whole-archive $(LIBGCC) \
|> ld-nova.lib.so $(REP_DIR)/<ld> {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/ds_ownership/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/log/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/mmio/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/new_delete/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/reconstructible/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/registry/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/rm_fault/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/rm_nested/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/segfault/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/smp/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/stack_smash/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/sub_rm/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/synced_interface/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/thread/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/timer/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/timer_accuracy/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>

4
repos/base/src/test/xml_node/Tupfile

@ -1,4 +0,0 @@
include_rules
: foreach *.cc |> !cxx |> %B.o {obj}
: {obj} | |> !prg |> test-%d {bin}
: {bin} |> !collect_bin |>
Loading…
Cancel
Save