Nix: source code filtering
This commit is contained in:
parent
955e95272c
commit
b8e25c82da
|
@ -13,11 +13,11 @@ DEV_DIR = $(TUP_CWD)/dev
|
||||||
DEV_LIB_DIR = $(DEV_DIR)/lib
|
DEV_LIB_DIR = $(DEV_DIR)/lib
|
||||||
|
|
||||||
ifdef IS_GCC
|
ifdef IS_GCC
|
||||||
include tup-genode/gcc.tup
|
include Tuprules.gcc
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef IS_LLVM
|
ifdef IS_LLVM
|
||||||
include tup-genode/llvm.tup
|
include Tuprules.llvm
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(TOOLCHAIN_CONFIGURED),)
|
ifeq ($(TOOLCHAIN_CONFIGURED),)
|
||||||
|
|
72
default.nix
72
default.nix
|
@ -24,9 +24,6 @@ let
|
||||||
nixpkgs'.stdenvAdapters.overrideCC nixpkgs'.stdenv sourceForgeToolchain;
|
nixpkgs'.stdenvAdapters.overrideCC nixpkgs'.stdenv sourceForgeToolchain;
|
||||||
in assert env.cc.isGNU; env;
|
in assert env.cc.isGNU; env;
|
||||||
|
|
||||||
src = self.outPath or (builtins.fetchGit ./.);
|
|
||||||
version = self.lastModified or "unstable";
|
|
||||||
|
|
||||||
inherit (stdenvLlvm) lib targetPlatform;
|
inherit (stdenvLlvm) lib targetPlatform;
|
||||||
specs = with targetPlatform;
|
specs = with targetPlatform;
|
||||||
[ ]
|
[ ]
|
||||||
|
@ -123,7 +120,6 @@ let
|
||||||
|
|
||||||
IS_GCC = "";
|
IS_GCC = "";
|
||||||
LINUX_HEADERS = buildPackages.glibc.dev;
|
LINUX_HEADERS = buildPackages.glibc.dev;
|
||||||
VERSION = version;
|
|
||||||
};
|
};
|
||||||
in toTupConfig stdenvGcc (f stdenvGcc);
|
in toTupConfig stdenvGcc (f stdenvGcc);
|
||||||
|
|
||||||
|
@ -148,16 +144,17 @@ let
|
||||||
llvmPackages.libunwind.override { isBaremetal = true; };
|
llvmPackages.libunwind.override { isBaremetal = true; };
|
||||||
LIBUNWIND = llvmPackages.libunwind;
|
LIBUNWIND = llvmPackages.libunwind;
|
||||||
LINUX_HEADERS = buildPackages.glibc.dev;
|
LINUX_HEADERS = buildPackages.glibc.dev;
|
||||||
VERSION = version;
|
|
||||||
};
|
};
|
||||||
in toTupConfig stdenvLlvm (f stdenvLlvm);
|
in toTupConfig stdenvLlvm (f stdenvLlvm);
|
||||||
|
|
||||||
buildRepo = { env, repo, repoInputs }:
|
buildRepo = { env, repo, repoInputs, filter }:
|
||||||
let
|
let
|
||||||
|
|
||||||
in env.mkDerivation {
|
in env.mkDerivation {
|
||||||
pname = "genode-" + repo;
|
name = "genode-" + repo;
|
||||||
inherit src repo specs version;
|
inherit repo specs;
|
||||||
|
|
||||||
|
src = builtins.filterSource filter ./.;
|
||||||
|
|
||||||
nativeBuildInputs = repoInputs;
|
nativeBuildInputs = repoInputs;
|
||||||
# This is wrong, why does pkg-config not collect buildInputs?
|
# This is wrong, why does pkg-config not collect buildInputs?
|
||||||
|
@ -233,6 +230,8 @@ let
|
||||||
maintainers = [ maintainers.ehmry ];
|
maintainers = [ maintainers.ehmry ];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // {
|
||||||
|
version = self.lastModified;
|
||||||
};
|
};
|
||||||
|
|
||||||
buildRepo' = { ... }@args: buildRepo ({ env = stdenvGcc; } // args);
|
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"
|
#builtins.throw "create the tup config file in the stdenv environment, replacing CC/CXX with environmental variables"
|
||||||
|
|
||||||
in rec {
|
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 { };
|
NOVA = nixpkgs.callPackage ./NOVA { };
|
||||||
|
|
||||||
base = buildRepo' {
|
base = buildRepo' {
|
||||||
repo = "base";
|
repo = "base";
|
||||||
repoInputs = [ ];
|
repoInputs = [ ];
|
||||||
|
filter = filterBaseRepo "-";
|
||||||
};
|
};
|
||||||
|
|
||||||
base-linux = buildRepo' {
|
base-linux = buildRepo' {
|
||||||
repo = "base-linux";
|
repo = "base-linux";
|
||||||
repoInputs = [ base ];
|
repoInputs = [ base ];
|
||||||
|
filter = filterBaseRepo "linux";
|
||||||
};
|
};
|
||||||
|
|
||||||
base-nova = buildRepo' {
|
base-nova = buildRepo' {
|
||||||
repo = "base-nova";
|
repo = "base-nova";
|
||||||
repoInputs = [ base ];
|
repoInputs = [ base ];
|
||||||
|
filter = filterBaseRepo "nova";
|
||||||
};
|
};
|
||||||
|
|
||||||
os = buildRepo' {
|
os = buildRepo' {
|
||||||
repo = "os";
|
repo = "os";
|
||||||
repoInputs = [ base ];
|
repoInputs = [ base ];
|
||||||
|
filter = filterRepo "os";
|
||||||
};
|
};
|
||||||
|
|
||||||
gems = buildRepo' {
|
gems = buildRepo' {
|
||||||
repo = "gems";
|
repo = "gems";
|
||||||
repoInputs = [ base os ];
|
repoInputs = [ base os ];
|
||||||
|
filter = filterRepo "gems";
|
||||||
};
|
};
|
||||||
|
|
||||||
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;
|
inherit stdenvGcc stdenvLlvm tupConfigGcc tupConfigLlvm;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
set -e
|
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
|
export SHELL=bash
|
||||||
exec nix dev-shell
|
exec nix dev-shell
|
||||||
|
|
|
@ -26,7 +26,7 @@ endif
|
||||||
LDFLAGS += -z max-page-size=0x1000
|
LDFLAGS += -z max-page-size=0x1000
|
||||||
LDFLAGS += -T$(BASE_DIR)/src/ld/genode_rel.ld
|
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} | \
|
: {obj} | \
|
||||||
$(DEV_DIR)/<lib> \
|
$(DEV_DIR)/<lib> \
|
||||||
|
@ -35,7 +35,7 @@ LDFLAGS += -L$(DEV_DIR)/lib
|
||||||
$(REP_DIR)/<base-nova> \
|
$(REP_DIR)/<base-nova> \
|
||||||
$(REP_DIR)/<startup> \
|
$(REP_DIR)/<startup> \
|
||||||
symbol.map \
|
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}
|
|> ld-nova.lib.so $(REP_DIR)/<ld> {bin}
|
||||||
|
|
||||||
: {bin} |> !collect_bin |>
|
: {bin} |> !collect_bin |>
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
|
@ -1,4 +0,0 @@
|
||||||
include_rules
|
|
||||||
: foreach *.cc |> !cxx |> %B.o {obj}
|
|
||||||
: {obj} | |> !prg |> test-%d {bin}
|
|
||||||
: {bin} |> !collect_bin |>
|
|
Loading…
Reference in New Issue