From c5817f347a983cac89faf6d68181cb3a77de1c5b Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 19 Apr 2019 09:56:43 +0200 Subject: [PATCH] Finalize binary packages using "include $(BIN_RULES)" Rather than call a small macro without inputs or outputs, ": |> !bin |>", include a file that will perform some metadata checks and invoke the !bin macro. In this way checks are extensible across packages by simply adding them to the common $(BIN_RULES) file. --- Tuprules.tup | 13 ++++++++++++- errata/bin.tup | 14 ++++++++++++++ nim/binaries.tup | 1 - src/server/fs_block/Tupfile | 2 +- src/server/nic_bus/Tupfile | 3 ++- src/server/nic_bus/runtime | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 errata/bin.tup diff --git a/Tuprules.tup b/Tuprules.tup index dbcbe24..78e637a 100644 --- a/Tuprules.tup +++ b/Tuprules.tup @@ -29,15 +29,26 @@ PUBLIC_BIN_DIR = $(PUBLIC_DIR)/bin PUBLIC_PKG_DIR = $(PUBLIC_DIR)/pkg RAW_DIR = $(DEPOT_RAW_DIR)/$(RAW_NAME)/current + # Destination for locally defined raw package + +BIN_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current + # Destination for locally defined binary package + +PKG_DIR = $(DEPOT_BIN_DIR)/$(BIN_NAME)/current + # Destination for locally defined runtime package !raw = |> ^ COLLECT %o^ \ echo $(RAW_DEPENDS) local/raw/$(RAW_NAME)/$(RAW_VERSION) | tr ' ' '\n' > %o; \ echo local/raw/$(RAW_NAME)/$(RAW_VERSION) > %o \ |> $(RAW_DIR)/.ARCHIVES $(DEPOT_DIR)/ +BIN_RULES = $(TUP_CWD)/errata/bin.tup + # Rules for finalizing a locally defined binary package + !bin = |> ^ COLLECT %o^ \ echo $(BIN_DEPENDS) local/src/$(BIN_NAME)/$(BIN_VERSION) | tr ' ' '\n' > %o; \ -|> $(DEPOT_BIN_DIR)/$(BIN_NAME)/current/.ARCHIVES $(DEPOT_DIR)/ +|> $(BIN_DIR)/.ARCHIVES $(DEPOT_DIR)/ + # Macro invoked in BIN_RULES AWK_LOCAL_ARCHIVES = awk -F '/' \ '{if ($1 != "local") {print $0} \ diff --git a/errata/bin.tup b/errata/bin.tup new file mode 100644 index 0000000..30af60f --- /dev/null +++ b/errata/bin.tup @@ -0,0 +1,14 @@ +ifeq ($(BIN_NAME),) +error BIN_NAME is empty +endif + +ifeq ($(BIN_VERSION),) +error BIN_VERSION is empty +endif + +: |> !bin |> + # Finalize the metadata with the macro defined in the + # ../Tuprules.tup. The macro cannot be defined here + # because the "include" directive is not available for + # relative paths during "include_rules" so this file + # cannot be included by intermediate Tuprules.tup. diff --git a/nim/binaries.tup b/nim/binaries.tup index 79d2ffe..c1acdc8 100644 --- a/nim/binaries.tup +++ b/nim/binaries.tup @@ -4,4 +4,3 @@ : foreach $(NIM_SRC_DIR)/*.nim |> !nim_build |> {binary} : foreach {binary} |> !collect_bin |> -: |> !bin |> diff --git a/src/server/fs_block/Tupfile b/src/server/fs_block/Tupfile index 2855c82..7756e37 100644 --- a/src/server/fs_block/Tupfile +++ b/src/server/fs_block/Tupfile @@ -10,4 +10,4 @@ PKGS = genode-os genode-prg $(LD) `pkg-config --libs $(PKGS)` %f -o %o |> %d {binary} : {binary} |> !collect_bin |> -: |> !bin |> +include $(BIN_RULES) diff --git a/src/server/nic_bus/Tupfile b/src/server/nic_bus/Tupfile index e6bf0e5..cfbc10b 100644 --- a/src/server/nic_bus/Tupfile +++ b/src/server/nic_bus/Tupfile @@ -10,7 +10,8 @@ PKGS = genode-os genode-prg $(LD) `pkg-config --libs $(PKGS)` %f -o %o |> %d {binary} : {binary} |> !collect_bin |> -: |> !bin |> + +include $(BIN_RULES) PKG_DEPENDS += _/src/$(TARGET_NAME) : runtime |> !collect_pkg_runtime |> diff --git a/src/server/nic_bus/runtime b/src/server/nic_bus/runtime index 47921e5..63ecce9 100644 --- a/src/server/nic_bus/runtime +++ b/src/server/nic_bus/runtime @@ -1,5 +1,5 @@ - +