mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-25 08:21:08 +00:00
base-hw: streamline extraction of depot archives
This patch simplifies the packaging of the base-hw kernel for a given board, in particular when the board support is hosted as an external repository such as genode-world. Regardless of where the board-support is hosted, the content.mk file becomes as simple as: include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc The board name is automatically inferred from the path of the src recipe. The architecture is determined from board/<name>/arch files, following the pattern of the image_link_address. The attempt to build a base-hw-<board> binary archive for the wrong architecture is now gracefully handled by skipping all targets (using the REQUIRES mechanism). Besides the improved convenience, the patch results in depot archives that are much closer tailored to the actual board by omitting files for architectures that are not used by the board. E.g., the src/base-hw-pc archive does not contain any ARM-related content. The patch also restores the package builds for core/bootstrap object files as a follow-up fix of "base: remove SPEC variables of boards", which happened to left 'BOARD' undefined in the src archives. Fixes #4019
This commit is contained in:
parent
1b77cb3832
commit
fa68325a57
1
repos/base-hw/board/imx53_qsb/arch
Normal file
1
repos/base-hw/board/imx53_qsb/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/imx53_qsb_tz/arch
Normal file
1
repos/base-hw/board/imx53_qsb_tz/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/imx6q_sabrelite/arch
Normal file
1
repos/base-hw/board/imx6q_sabrelite/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/imx7d_sabre/arch
Normal file
1
repos/base-hw/board/imx7d_sabre/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/imx8q_evk/arch
Normal file
1
repos/base-hw/board/imx8q_evk/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v8a
|
1
repos/base-hw/board/nit6_solox/arch
Normal file
1
repos/base-hw/board/nit6_solox/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/pbxa9/arch
Normal file
1
repos/base-hw/board/pbxa9/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/pc/arch
Normal file
1
repos/base-hw/board/pc/arch
Normal file
@ -0,0 +1 @@
|
||||
x86_64
|
1
repos/base-hw/board/riscv_qemu/arch
Normal file
1
repos/base-hw/board/riscv_qemu/arch
Normal file
@ -0,0 +1 @@
|
||||
riscv
|
1
repos/base-hw/board/rpi/arch
Normal file
1
repos/base-hw/board/rpi/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v6
|
1
repos/base-hw/board/rpi3/arch
Normal file
1
repos/base-hw/board/rpi3/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v8a
|
1
repos/base-hw/board/usb_armory/arch
Normal file
1
repos/base-hw/board/usb_armory/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/virt_qemu/arch
Normal file
1
repos/base-hw/board/virt_qemu/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/wand_quad/arch
Normal file
1
repos/base-hw/board/wand_quad/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
1
repos/base-hw/board/zynq_qemu/arch
Normal file
1
repos/base-hw/board/zynq_qemu/arch
Normal file
@ -0,0 +1 @@
|
||||
arm_v7a
|
@ -1,3 +1 @@
|
||||
BOARD = imx53_qsb
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1,4 @@
|
||||
BOARD = imx53_qsb_tz
|
||||
CONTENT += src/core/board/imx53_qsb \
|
||||
src/bootstrap/board/imx53_qsb
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = imx6q_sabrelite
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = imx7d_sabre
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = imx8q_evk
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = nit6_solox
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = pbxa9
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = pc
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = rpi
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = rpi3
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = virt_qemu
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,3 +1 @@
|
||||
BOARD = zynq_qemu
|
||||
|
||||
include $(GENODE_DIR)/repos/base-hw/recipes/src/base-hw_content.inc
|
||||
|
@ -1,19 +1,182 @@
|
||||
include $(GENODE_DIR)/repos/base/recipes/src/base_content.inc
|
||||
#
|
||||
# Before including this file, the CONTENT variable may contain a list of
|
||||
# repository-relative paths of content to include in the src archive in
|
||||
# addition to the default content inferred for the given board.
|
||||
#
|
||||
|
||||
content: src/bootstrap
|
||||
|
||||
src/bootstrap:
|
||||
#
|
||||
# Determine board name from the path to the src recipe's content.mk file
|
||||
#
|
||||
|
||||
# obtain directory name of src recipe w/o trailing slash
|
||||
_BOARD := $(CONTENT_MK:/content.mk=)
|
||||
|
||||
# strip all leading path elements, keeping only the src-recipe name
|
||||
_BOARD := $(notdir $(_BOARD))
|
||||
|
||||
# remove "base-hw-" part of the src-recipe name, keeping only the board name
|
||||
BOARD := $(patsubst base-hw-%,%,$(_BOARD))
|
||||
|
||||
|
||||
#
|
||||
# Selection of ARCH-specific subdirectories and files
|
||||
#
|
||||
|
||||
LIB_MK_SPECS(arm_v6) := arm arm_v6
|
||||
LIB_MK_SPECS(arm_v7a) := arm arm_v7 cortex_a8 cortex_a9 cortex_a15
|
||||
LIB_MK_SPECS(arm_v8a) := arm_64 arm_v8
|
||||
LIB_MK_SPECS(x86_64) := x86_64
|
||||
LIB_MK_SPECS(riscv) := riscv
|
||||
|
||||
SRC_BOOTSTRAP_SPECS(arm_v6) := arm
|
||||
SRC_BOOTSTRAP_SPECS(arm_v7a) := arm
|
||||
SRC_BOOTSTRAP_SPECS(arm_v8a) := arm_64 arm
|
||||
SRC_BOOTSTRAP_SPECS(x86_64) := x86_64
|
||||
SRC_BOOTSTRAP_SPECS(riscv) := riscv
|
||||
|
||||
SRC_CORE_SPECS(arm_v6) := arm arm_v6
|
||||
SRC_CORE_SPECS(arm_v7a) := arm arm_v7 cortex_a8 cortex_a9 cortex_a15
|
||||
SRC_CORE_SPECS(arm_v8a) := arm arm_v8
|
||||
SRC_CORE_SPECS(x86_64) := x86 x86_64
|
||||
SRC_CORE_SPECS(riscv) := riscv
|
||||
|
||||
SRC_INCLUDE_HW_SPECS(arm_v6) := arm
|
||||
SRC_INCLUDE_HW_SPECS(arm_v7a) := arm
|
||||
SRC_INCLUDE_HW_SPECS(arm_v8a) := arm arm_64
|
||||
SRC_INCLUDE_HW_SPECS(x86_64) := x86_64
|
||||
SRC_INCLUDE_HW_SPECS(riscv) := riscv
|
||||
|
||||
SRC_LIB_BASE_SPECS(arm_v6) := arm
|
||||
SRC_LIB_BASE_SPECS(arm_v7a) := arm
|
||||
SRC_LIB_BASE_SPECS(arm_v8a) := arm_64
|
||||
SRC_LIB_BASE_SPECS(x86_64) := x86_64
|
||||
SRC_LIB_BASE_SPECS(riscv) := riscv
|
||||
|
||||
SRC_LIB_STARTUP_SPECS(arm_v6) := arm
|
||||
SRC_LIB_STARTUP_SPECS(arm_v7a) := arm
|
||||
SRC_LIB_STARTUP_SPECS(arm_v8a) := arm_64
|
||||
SRC_LIB_STARTUP_SPECS(x86_64) := x86_64
|
||||
SRC_LIB_STARTUP_SPECS(riscv) := riscv
|
||||
|
||||
# location of hw-ld.mk file
|
||||
LD_MK_DIR(arm_v6) := lib/mk/spec/arm
|
||||
LD_MK_DIR(arm_v7a) := lib/mk/spec/arm
|
||||
LD_MK_DIR(arm_v8a) := lib/mk/spec/arm_v8
|
||||
LD_MK_DIR(x86_64) := lib/mk/spec/x86_64
|
||||
LD_MK_DIR(riscv) := lib/mk/spec/riscv
|
||||
|
||||
|
||||
#
|
||||
# Defermine CPU architecture for the given BOARD
|
||||
#
|
||||
|
||||
BOARD_ARCH_PATH := $(REP_DIR)/board/$(BOARD)/arch
|
||||
|
||||
ifeq ($(wildcard $(BOARD_ARCH_PATH)),)
|
||||
content: arch_undefined
|
||||
arch_undefined:
|
||||
echo -n "\nError: CPU architecure for board $(BOARD) undefined\n\n" \
|
||||
" missing file $(BOARD_ARCH_PATH)\n\n"
|
||||
false
|
||||
else
|
||||
ARCH := $(firstword $(shell cat $(BOARD_ARCH_PATH)))
|
||||
endif
|
||||
|
||||
|
||||
#
|
||||
# Enumeration of package content
|
||||
#
|
||||
|
||||
BASE_DIR := $(GENODE_DIR)/repos/base
|
||||
BASE_HW_DIR := $(GENODE_DIR)/repos/base-hw
|
||||
|
||||
SRC_TIMER := target.inc include hw main.cc
|
||||
|
||||
SRC_INCLUDE_HW += $(notdir $(wildcard $(BASE_HW_DIR)/src/include/hw/*.h)) \
|
||||
$(addprefix spec/,${SRC_INCLUDE_HW_SPECS(${ARCH})}) \
|
||||
uart
|
||||
|
||||
SRC_BOOTSTRAP += hw env.cc init.cc lock.cc log.cc thread.cc \
|
||||
platform.cc platform.h \
|
||||
$(addprefix spec/,${SRC_BOOTSTRAP_SPECS(${ARCH})}) \
|
||||
$(addprefix board/,$(BOARD))
|
||||
|
||||
SRC_LIB_BASE += $(notdir $(wildcard $(BASE_HW_DIR)/src/lib/base/*.cc)) \
|
||||
$(notdir $(wildcard $(BASE_DIR)/src/lib/base/*.cc)) \
|
||||
${SRC_LIB_BASE_SPECS(${ARCH})}
|
||||
|
||||
SRC_LIB_STARTUP += init_main_thread.cc _main.cc \
|
||||
$(addprefix spec/,${SRC_LIB_STARTUP_SPECS(${ARCH})})
|
||||
|
||||
SRC_CORE += $(notdir $(wildcard $(BASE_HW_DIR)/src/core/*.cc)) \
|
||||
$(notdir $(wildcard $(BASE_HW_DIR)/src/core/*.h)) \
|
||||
$(notdir $(wildcard $(BASE_DIR)/src/core/*.cc)) \
|
||||
$(addprefix spec/,${SRC_CORE_SPECS(${ARCH})}) \
|
||||
$(addprefix board/,$(BOARD)) \
|
||||
version.inc target.inc include hw kernel
|
||||
|
||||
LIB_MK := base-hw-common.mk base-hw.mk bootstrap-hw.inc core-hw.inc \
|
||||
timeout-hw.mk cxx.mk base.inc base-common.inc startup.inc \
|
||||
$(addprefix spec/,${LIB_MK_SPECS(${ARCH})})
|
||||
|
||||
CONTENT += $(addprefix src/timer/,$(SRC_TIMER)) \
|
||||
$(addprefix src/include/hw/,$(SRC_INCLUDE_HW)) \
|
||||
$(addprefix src/bootstrap/,$(SRC_BOOTSTRAP)) \
|
||||
$(addprefix lib/mk/,$(LIB_MK)) \
|
||||
$(addprefix src/lib/base/,$(SRC_LIB_BASE)) \
|
||||
$(addprefix src/lib/startup/,$(SRC_LIB_STARTUP)) \
|
||||
$(addprefix src/core/,$(SRC_CORE)) \
|
||||
src/lib/hw src/lib/ld src/lib/cxx \
|
||||
src/include/base/internal src/include/pager \
|
||||
include/drivers/uart
|
||||
|
||||
# remove duplicates
|
||||
CONTENT := $(sort $(CONTENT))
|
||||
|
||||
|
||||
#
|
||||
# Utilities to aggregate content from base, base-hw, and rep directories
|
||||
#
|
||||
|
||||
_try_mirror_from = $(if $(wildcard $1/$2),mkdir -p $(dir $2); cp -r $1/$2 $(dir $2))
|
||||
|
||||
mirror_from_base_dir = $(call _try_mirror_from,$(GENODE_DIR)/repos/base,$@)
|
||||
mirror_from_base_hw_dir = $(call _try_mirror_from,$(GENODE_DIR)/repos/base-hw,$@)
|
||||
mirror_from_rep_dir = $(call _try_mirror_from,$(REP_DIR),$@)
|
||||
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
|
||||
content: $(CONTENT)
|
||||
|
||||
$(CONTENT):
|
||||
$(mirror_from_base_dir)
|
||||
$(mirror_from_base_hw_dir)
|
||||
$(mirror_from_rep_dir)
|
||||
|
||||
content: generalize_target_names remove_other_board_libs
|
||||
content: LICENSE
|
||||
LICENSE:
|
||||
cp $(GENODE_DIR)/LICENSE $@
|
||||
|
||||
generalize_target_names: lib/mk src/lib src/timer
|
||||
for spec in arm riscv x86_64; do \
|
||||
mv lib/mk/spec/$$spec/ld-hw.mk lib/mk/spec/$$spec/ld.mk; \
|
||||
done;
|
||||
content: etc/specs.conf
|
||||
etc/specs.conf:
|
||||
$(mirror_from_base_hw_dir)
|
||||
|
||||
content: generalize_target_names
|
||||
generalize_target_names: $(CONTENT)
|
||||
# apply kernel-agnostic convention of naming the timer and ld.lib.so
|
||||
mv ${LD_MK_DIR(${ARCH})}/ld-hw.mk ${LD_MK_DIR(${ARCH})}/ld.mk
|
||||
sed -i "s/ld-hw/ld/" src/lib/ld/hw/target.mk
|
||||
sed -i "s/hw_timer_drv/timer/" src/timer/hw/target.mk
|
||||
# supplement BOARD definition that normally comes form the build dir
|
||||
sed -i "s/\?= unknown/:= $(BOARD)/" src/core/hw/target.mk
|
||||
sed -i "s/\?= unknown/:= $(BOARD)/" src/bootstrap/hw/target.mk
|
||||
# discharge targets when building for mismatching architecture
|
||||
sed -i "1aREQUIRES := $(ARCH)" src/core/hw/target.mk
|
||||
sed -i "1aREQUIRES := $(ARCH)" src/bootstrap/hw/target.mk
|
||||
sed -i "/REQUIRES/s/hw/hw $(ARCH)/" src/timer/hw/target.mk
|
||||
sed -i "1aREQUIRES := $(ARCH)" src/lib/ld/hw/target.mk
|
||||
|
||||
remove_other_board_libs: lib/mk
|
||||
find lib/mk/spec -name core-hw-*.mk -o -name bootstrap-hw-*.mk |\
|
||||
grep -v "hw-$(BOARD).mk" | xargs rm -rf
|
||||
|
Loading…
Reference in New Issue
Block a user