From ff10687a6c07cd3ba2650ef9cc3b4005bd08561d Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 4 Feb 2016 12:20:03 +0100 Subject: [PATCH] toolchain: report missing ports at once Previously, ports that were needed for a scenario and that were not prepared or outdated, triggered one assertion each during the second build stage. The commit slots a mechanism in ahead that gathers all these ports during the first build stage and reports them in form of a list before the second build stage is entered. This list can be used directly as argument for tool/ports/prepare_port to prepare respectively update the ports. If, however, this mechanism is not available, for example because a target is build without the first build stage, the old assertion still prevents the target from running into troubles with a missing port. Fixes #1872 --- repos/base-foc/lib/mk/platform.inc | 8 ++++++-- repos/base-nova/mk/spec/nova.mk | 8 ++++++++ repos/base-nova/src/kernel/target.mk | 3 ++- repos/base-okl4/mk/spec/okl4.mk | 10 ++++++++-- repos/base-sel4/lib/mk/spec/x86_32/platform.mk | 8 ++++++-- repos/base/mk/dep_lib.mk | 8 +++++++- repos/base/mk/dep_prg.mk | 8 +++++++- repos/base/mk/util.inc | 14 +++++++++++++- tool/builddir/build.mk | 15 +++++++++++++++ 9 files changed, 72 insertions(+), 10 deletions(-) diff --git a/repos/base-foc/lib/mk/platform.inc b/repos/base-foc/lib/mk/platform.inc index f70d84d7c..90a9cd4ea 100644 --- a/repos/base-foc/lib/mk/platform.inc +++ b/repos/base-foc/lib/mk/platform.inc @@ -6,6 +6,12 @@ # userland (L4re) that comes with Fiasco.OC. # +# +# We do this also in the first build stage to ensure that the kernel +# port, if missing, is added to the missing-ports list of this stage. +# +FOC_CONTRIB_DIR := $(call select_from_ports,foc)/src/kernel/foc + # # Execute the rules in this file only at the second build stage when we know # about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'. @@ -26,8 +32,6 @@ $(BUILD_BASE_DIR)/include/%: $(VERBOSE)mkdir -p $(dir $@) $(VERBOSE)ln -sf $(L4_BUILD_DIR)/include/$* $@ -FOC_CONTRIB_DIR := $(call select_from_ports,foc)/src/kernel/foc - # # Create L4 build directory # diff --git a/repos/base-nova/mk/spec/nova.mk b/repos/base-nova/mk/spec/nova.mk index 298770d41..ff778d9c5 100644 --- a/repos/base-nova/mk/spec/nova.mk +++ b/repos/base-nova/mk/spec/nova.mk @@ -9,3 +9,11 @@ SPECS += pci ps2 vesa framebuffer # Linker options that are specific for x86 # LD_TEXT_ADDR ?= 0x01000000 + +# +# We would normally have to do this only in the kernel lib. We do it in +# general nonetheless to ensure that the kernel port, if missing, is added to +# the missing-ports list of the first build stage. The kernel lib is evaluated +# only at a later build stage. +# +NOVA_SRC_DIR := $(call select_from_ports,nova)/src/kernel/nova diff --git a/repos/base-nova/src/kernel/target.mk b/repos/base-nova/src/kernel/target.mk index 1e1d95de1..385bee12c 100644 --- a/repos/base-nova/src/kernel/target.mk +++ b/repos/base-nova/src/kernel/target.mk @@ -1,6 +1,7 @@ +include $(call select_from_repositories,mk/spec/nova.mk) + TARGET = hypervisor REQUIRES = x86 nova -NOVA_SRC_DIR = $(call select_from_ports,nova)/src/kernel/nova NOVA_BUILD_DIR = $(BUILD_BASE_DIR)/kernel STARTUP_LIB = SRC_CC = $(sort $(notdir $(wildcard $(NOVA_SRC_DIR)/src/*.cpp))) diff --git a/repos/base-okl4/mk/spec/okl4.mk b/repos/base-okl4/mk/spec/okl4.mk index b24e71be2..0770a7bf0 100644 --- a/repos/base-okl4/mk/spec/okl4.mk +++ b/repos/base-okl4/mk/spec/okl4.mk @@ -9,9 +9,15 @@ -include $(BUILD_BASE_DIR)/etc/okl4.conf # -# If no OKL4 source directory is set, we use the standard contrib directory +# If no OKL4 source directory is set, we use the standard contrib directory. +# We do this with ifeq and := as ?= would be done lazy. Forcing the +# evaluation of $(call select_from_ports,okl4) ensures that the kernel +# port, if missing, is added to the missing-ports list of the first build +# stage. # -OKL4_DIR ?= $(call select_from_ports,okl4)/src/kernel/okl4 +ifeq ($(OKL4_DIR),) +OKL4_DIR := $(call select_from_ports,okl4)/src/kernel/okl4 +endif # # Make sure that symlink modification times are handled correctly. diff --git a/repos/base-sel4/lib/mk/spec/x86_32/platform.mk b/repos/base-sel4/lib/mk/spec/x86_32/platform.mk index 6de4daf66..de121b64b 100644 --- a/repos/base-sel4/lib/mk/spec/x86_32/platform.mk +++ b/repos/base-sel4/lib/mk/spec/x86_32/platform.mk @@ -5,14 +5,18 @@ # symlinked to the build directory. # +# +# We do this also in the first build stage to ensure that the kernel +# port, if missing, is added to the missing-ports list of this stage. +# +LIBSEL4_DIR := $(call select_from_ports,sel4)/src/kernel/sel4/libsel4 + # # Execute the rules in this file only at the second build stage when we know # about the complete build settings, e.g., the 'CROSS_DEV_PREFIX'. # ifeq ($(called_from_lib_mk),yes) -LIBSEL4_DIR := $(call select_from_ports,sel4)/src/kernel/sel4/libsel4 - # # Make seL4 kernel API headers available to the Genode build system # diff --git a/repos/base/mk/dep_lib.mk b/repos/base/mk/dep_lib.mk index c2b0a2a33..0b6390e2f 100644 --- a/repos/base/mk/dep_lib.mk +++ b/repos/base/mk/dep_lib.mk @@ -16,6 +16,8 @@ # INSTALL_DIR - destination directory for installing shared libraries # +ACCUMULATE_MISSING_PORTS = 1 + # # Include common utility functions # @@ -132,7 +134,11 @@ ifneq ($(LIBS),) @(echo "$(DEP_VAR_NAME) = $(foreach l,$(LIBS),$l.lib \$$(DEP_$l.lib))"; \ echo "") >> $(LIB_DEP_FILE) endif - @(echo "$(LIB).lib: $(addsuffix .lib,$(LIBS))"; \ +ifneq ($(DEP_MISSING_PORTS),) + @(echo "MISSING_PORTS += $(DEP_MISSING_PORTS)"; \ + echo "") >> $(LIB_DEP_FILE) +endif + @(echo "$(LIB).lib: check_ports $(addsuffix .lib,$(LIBS))"; \ echo " @\$$(MKDIR) -p \$$(LIB_CACHE_DIR)/$(LIB)"; \ echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C \$$(LIB_CACHE_DIR)/$(LIB) -f \$$(BASE_DIR)/mk/lib.mk \\"; \ echo " REP_DIR=$(REP_DIR) \\"; \ diff --git a/repos/base/mk/dep_prg.mk b/repos/base/mk/dep_prg.mk index 34e1d5895..d92913c1d 100644 --- a/repos/base/mk/dep_prg.mk +++ b/repos/base/mk/dep_prg.mk @@ -3,6 +3,8 @@ # all: +ACCUMULATE_MISSING_PORTS = 1 + # # Include common utility functions # @@ -53,7 +55,11 @@ ifneq ($(LIBS),) @(echo "DEP_$(TARGET).prg = $(foreach l,$(LIBS),$l.lib \$$(DEP_$l.lib))"; \ echo "") >> $(LIB_DEP_FILE) endif - @(echo "$(TARGET).prg: $(addsuffix .lib,$(LIBS))"; \ +ifneq ($(DEP_MISSING_PORTS),) + @(echo "MISSING_PORTS += $(DEP_MISSING_PORTS)"; \ + echo "") >> $(LIB_DEP_FILE) +endif + @(echo "$(TARGET).prg: check_ports $(addsuffix .lib,$(LIBS))"; \ echo " @\$$(MKDIR) -p $(PRG_REL_DIR)"; \ echo " \$$(VERBOSE_MK)\$$(MAKE) $(VERBOSE_DIR) -C $(PRG_REL_DIR) -f \$$(BASE_DIR)/mk/prg.mk \\"; \ echo " REP_DIR=$(REP_DIR) \\"; \ diff --git a/repos/base/mk/util.inc b/repos/base/mk/util.inc index 9e37beb7e..9377a95d3 100644 --- a/repos/base/mk/util.inc +++ b/repos/base/mk/util.inc @@ -40,6 +40,18 @@ _lookup_port_hash_file = $(wildcard $(addsuffix /ports/$1.hash,$(REPOSITORIES)) _capture_port_hash_file = $(call _capture,$(call _lookup_port_hash_file,$1),PORT_HASH_FILES) _hash_of_port = $(shell echo | cat $(call _capture_port_hash_file,$1)) _port_dir = $(wildcard $(CONTRIB_DIR)/$1-$(call _hash_of_port,$1)) -_checked_port_dir = $(call _assert,$(call _port_dir,$1),$1 is not prepared or outdated) + +# +# We accumulate missing ports instead of stopping only if the environment +# explicitely states that it is aware of it. This ensures that environments +# that are not aware can't run into troubles with missing ports. +# +ifeq (ACCUMULATE_MISSING_PORTS,) +_checked_port_dir = $(call _assert,$(call _port_dir,$1),$1 is not prepared or outdated) +else +_port_missing = $(eval DEP_MISSING_PORTS += $1) +_checked_port = $(if $2,$2,$(call _port_missing,$1)) +_checked_port_dir = $(call _checked_port,$1,$(call _port_dir,$1)) +endif select_from_ports = $(call _checked_port_dir,$1) diff --git a/tool/builddir/build.mk b/tool/builddir/build.mk index 798cc0079..3ca95d0c0 100644 --- a/tool/builddir/build.mk +++ b/tool/builddir/build.mk @@ -221,6 +221,21 @@ $(INSTALL_DIR): .PHONY: gen_deps_and_build_targets gen_deps_and_build_targets: $(INSTALL_DIR) $(LIB_DEP_FILE) + @(echo ""; \ + echo "ifneq (\$$(MISSING_PORTS),)"; \ + echo "check_ports:"; \ + echo " @echo \"\""; \ + echo " @echo \"Error: Ports not prepared or outdated:\""; \ + echo " @echo \" \$$(sort \$$(MISSING_PORTS))\""; \ + echo " @echo \"\""; \ + echo " @echo \"You can prepare respectively update them as follows:\""; \ + echo " @echo \" /tool/ports/prepare_port \$$(sort \$$(MISSING_PORTS))\""; \ + echo " @echo \"\""; \ + echo " @false"; \ + echo "else"; \ + echo "check_ports:"; \ + echo "endif"; \ + echo "") >> $(LIB_DEP_FILE) @$(VERBOSE_MK)$(MAKE) $(VERBOSE_DIR) -f $(LIB_DEP_FILE) all .PHONY: again