depot: add support for debug info files

Fixes #5015
This commit is contained in:
Christian Prochaska 2023-11-23 15:02:43 +01:00 committed by Christian Helmuth
parent ee8c76b42e
commit 801c4aa72f
6 changed files with 77 additions and 20 deletions

View File

@ -47,6 +47,9 @@ define HELP_MESSAGE
problems.
CCACHE=1 Compiler calls will use the C/C++ compiler cache.
DBG=1 Build 'dbg' archives containing debug info files
in addition to the corresponding 'bin' archives.
endef
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../..)
@ -94,10 +97,19 @@ endif
#
# Generate makefile for archive-build stage
#
# The target pattern rules are needed to make sure that 'build_bin_archive'
# is called only once for each bin/dbg archive pair.
#
# determine binary-archive path within the depot
_dst_bin_spec_path = $(call archive_user,$1)/bin/$(call bin_archive_spec,$1)/
dst_archive_path = $(call _dst_bin_spec_path,$1)$(call bin_archive_recipe,$1)/$(call bin_archive_version,$1)
dst_bin_archive_path = $(call _dst_bin_spec_path,$1)$(call bin_archive_recipe,$1)/$(call bin_archive_version,$1)
dst_bin_archive_path_pattern = $(call _dst_bin_spec_path,$1)$(call bin_archive_recipe,$1)/%
# determine debug-archive path within the depot
_dst_dbg_spec_path = $(call archive_user,$1)/dbg/$(call bin_archive_spec,$1)/
dst_dbg_archive_path = $(call _dst_dbg_spec_path,$1)$(call bin_archive_recipe,$1)/$(call bin_archive_version,$1)
dst_dbg_archive_path_pattern = $(call _dst_dbg_spec_path,$1)$(call bin_archive_recipe,$1)/%
BUILD_MK_FILE := $(DEPOT_DIR)/var/build.mk
@ -105,27 +117,38 @@ BUILD_MK_FILE := $(DEPOT_DIR)/var/build.mk
wipe_existing_archives:
$(VERBOSE)rm -rf $(addprefix $(DEPOT_DIR)/,\
$(foreach A,${ARCHIVES(bin)},$(call dst_archive_path,$A)))
$(foreach A,${ARCHIVES(bin)},$(call dst_bin_archive_path,$A)))
$(VERBOSE)rm -rf $(addprefix $(DEPOT_DIR)/,\
$(foreach A,${ARCHIVES(dbg)},$(call dst_dbg_archive_path,$A)))
$(BUILD_MK_FILE): checked_source_archives_exist checked_no_uncategorized
$(VERBOSE)mkdir -p $(dir $@)
$(VERBOSE)( echo -e "all:\n"; \
echo "TOOL_DIR := $(GENODE_DIR)/tool"; \
$(foreach A,${ARCHIVES(bin)},\
target=$(call dst_archive_path,$A); \
bin_target=$(call dst_bin_archive_path,$A); \
bin_target_pattern=$(call dst_bin_archive_path_pattern,$A); \
dbg_target=$(call dst_dbg_archive_path,$A); \
dbg_target_pattern=$(call dst_dbg_archive_path_pattern,$A); \
user=$(call archive_user,$A); \
recipe=$(call bin_archive_recipe,$A); \
version=$(call bin_archive_version,$A); \
spec=$(call bin_archive_spec,$A); \
echo ""; \
echo "TARGETS += $$target"; \
echo "TOOL($$target) := build_bin_archive"; \
echo "ARGS($$target) := $$recipe/$$version USER=$$user SPEC=$$spec"; \
echo "TARGETS += $$bin_target"; \
echo "TOOL($$bin_target) := build_bin_archive"; \
echo "ARGS($$bin_target) := $$recipe/$$version USER=$$user SPEC=$$spec"; \
echo ""; \
echo "ifneq (\$$(DBG),)"; \
echo "TARGETS += $$dbg_target"; \
echo "TOOL($$dbg_target) := build_bin_archive"; \
echo "ARGS($$dbg_target) := $$recipe/$$version USER=$$user SPEC=$$spec"; \
echo "endif"; \
echo -e "\n$$bin_target_pattern $$dbg_target_pattern:"; \
echo -e "\t\$$(MAKE) -f \$$(TOOL_DIR)/depot/mk/\$${TOOL(\$$@)}" \
"\$${ARGS(\$$@)} CCACHE=\$$(CCACHE) VERBOSE=\$$(VERBOSE)\n"; \
) \
echo -e "\nall: \$$(TARGETS)"; \
echo -e "\n\$$(TARGETS):"; \
echo -e "\t\$$(MAKE) -f \$$(TOOL_DIR)/depot/mk/\$${TOOL(\$$@)}" \
"\$${ARGS(\$$@)} CCACHE=\$$(CCACHE) VERBOSE=\$$(VERBOSE)\n"; \
) > $@

View File

@ -53,6 +53,7 @@ include $(DEPOT_TOOL_DIR)/mk/dependencies.inc
# select function for determining the archive version depending on archive type
_archive_version(bin) = bin_archive_version
_archive_version(dbg) = bin_archive_version
_archive_version(src) = archive_version
_archive_version(api) = archive_version
_archive_version(raw) = archive_version
@ -60,7 +61,7 @@ _archive_version(pkg) = archive_version
_version_defined = ${call ${_archive_version(${call archive_type,$1})},$1}
NEEDED_ARCHIVES := $(foreach TYPE,pkg src raw api bin,${ARCHIVES(${TYPE})})
NEEDED_ARCHIVES := $(foreach TYPE,pkg src raw api bin dbg,${ARCHIVES(${TYPE})})
# check for completeness of archive-path arguments
NO_VERSION_ARCHIVES := $(sort $(foreach A,$(NEEDED_ARCHIVES),\

View File

@ -12,7 +12,10 @@ define HELP_MESSAGE
usage:
$(firstword $(MAKEFILE_LIST)) <archive-path> {PUBLIC=<public>}
$(firstword $(MAKEFILE_LIST)) <archive-path> {PUBLIC=<public>} {DBG=1}
With the optional 'DBG=1' argument, 'dbg' archives are downloaded
in addition to the corresponding 'bin' archives.
endef

View File

@ -12,12 +12,14 @@ define HELP_MESSAGE
usage:
$(firstword $(MAKEFILE_LIST)) <src-name> SPEC=<spec> USER=<user> CCACHE=<ccache>
$(firstword $(MAKEFILE_LIST)) <src-name> SPEC=<spec> USER=<user> CCACHE=<ccache> DBG=<dbg>
<src-name> name of the source archive to build
<spec> build spec, e.g., x86_32, x86_64
<user> identity of the archive creator
<ccache> compiler calls will use the C/C++ compiler cache if this is 1
<dbg> build 'dbg' archives containing debug info files in addition
to the corresponding 'bin' archives if this is 1
endef
@ -52,6 +54,7 @@ REP_DIR := $(RECIPE_DIR:/recipes/src/$(ARCHIVE)=)
DEPOT_API_DIR := $(DEPOT_DIR)/$(USER)/api
DEPOT_SRC_DIR := $(DEPOT_DIR)/$(USER)/src
DEPOT_BIN_DIR := $(DEPOT_DIR)/$(USER)/bin
DEPOT_DBG_DIR := $(DEPOT_DIR)/$(USER)/dbg
#
@ -119,8 +122,9 @@ endif
# Define build-directory location
#
DEPOT_ARCHIVE_DIR := $(DEPOT_BIN_DIR)/$(SPEC)/$(VERSIONED_ARCHIVE)
DEPOT_ARCHIVE_BUILD_DIR := $(addsuffix .build,$(DEPOT_ARCHIVE_DIR))
DEPOT_BIN_ARCHIVE_DIR := $(DEPOT_BIN_DIR)/$(SPEC)/$(VERSIONED_ARCHIVE)
DEPOT_DBG_ARCHIVE_DIR := $(DEPOT_DBG_DIR)/$(SPEC)/$(VERSIONED_ARCHIVE)
DEPOT_ARCHIVE_BUILD_DIR := $(addsuffix .build,$(DEPOT_BIN_ARCHIVE_DIR))
#
@ -209,18 +213,28 @@ $(DEPOT_ARCHIVE_BUILD_DIR)/bin: $(BUILD_CONF) $(SPECS_CONF) $(TOOLS_CONF) $(BUIL
$(VERBOSE)$(MAKE) -C $(DEPOT_ARCHIVE_BUILD_DIR) $(BUILD_ARG) ||\
( $(RM_BUILD_DIR_CMD); false )
$(DEPOT_ARCHIVE_BUILD_DIR)/debug: $(DEPOT_ARCHIVE_BUILD_DIR)/bin
#
# Extract build results from build directory into binary-archive directory
# Extract build results from build directory into binary-archive and
# debug-archive directories
#
$(DEPOT_ARCHIVE_DIR): $(DEPOT_ARCHIVE_BUILD_DIR)/bin
$(DEPOT_BIN_ARCHIVE_DIR): $(DEPOT_ARCHIVE_BUILD_DIR)/bin
$(VERBOSE)mkdir -p $@
$(VERBOSE)find $< -maxdepth 0 -not -empty -exec cp -rL $</* $@/ \;
$(TARGET): $(DEPOT_ARCHIVE_DIR)
@$(ECHO) "$(DARK_COL)created$(DEFAULT_COL) $(USER)/bin/$(SPEC)/$(VERSIONED_ARCHIVE)"
$(DEPOT_DBG_ARCHIVE_DIR): $(DEPOT_ARCHIVE_BUILD_DIR)/debug
$(VERBOSE)mkdir -p $@
$(VERBOSE)find $< -name *.debug -exec cp {} $@/ \;
@$(ECHO) "$(DARK_COL)created$(DEFAULT_COL) $(USER)/dbg/$(SPEC)/$(VERSIONED_ARCHIVE)"
$(TARGET): $(DEPOT_BIN_ARCHIVE_DIR)
ifneq ($(DBG),)
$(TARGET): $(DEPOT_DBG_ARCHIVE_DIR)
endif
#
# Remove intermediate build artifacts
@ -228,8 +242,11 @@ $(TARGET): $(DEPOT_ARCHIVE_DIR)
ifeq ($(KEEP_BUILD_DIR),)
$(TARGET): remove_build_dir_when_done
remove_build_dir_when_done: $(DEPOT_ARCHIVE_DIR)
remove_build_dir_when_done: $(DEPOT_BIN_ARCHIVE_DIR)
$(VERBOSE)$(RM_BUILD_DIR_CMD)
ifneq ($(DBG),)
remove_build_dir_when_done: $(DEPOT_DBG_ARCHIVE_DIR)
endif
endif

View File

@ -76,6 +76,15 @@ _binpkg_bin_archives = $(foreach S,$(call _binpkg_src_archives,$1),\
ARCHIVES(bin) := $(sort ${ARCHIVES(bin)} $(foreach P,${ARCHIVES(binpkg)},\
$(call _binpkg_bin_archives,$P)))
#
# Populate ARCHIVES(dbg) with debug-packages
#
ifneq ($(DBG),)
_dbg_from_bin = $(call archive_user,$1)/dbg/$(call bin_archive_spec,$1)/$(call bin_archive_recipe,$1)/$(call bin_archive_version,$1)
ARCHIVES(dbg) := $(foreach A,${ARCHIVES(bin)},$(call _dbg_from_bin,$A))
endif
#
# Extend ARCHIVES(src) with package dependencies
#

View File

@ -12,7 +12,7 @@ define HELP_MESSAGE
usage:
$(firstword $(MAKEFILE_LIST)) <archive-path> {PUBLIC_DIR=<public>}
$(firstword $(MAKEFILE_LIST)) <archive-path> {PUBLIC_DIR=<public>} {DBG=1}
The <archive-path> denotes the archives (and implicitly their
dependencies) to publish from the depot to the public directory.
@ -24,6 +24,9 @@ define HELP_MESSAGE
The optional 'PUBLIC_DIR' argument defines the location of the public
directory. If not specified, '<genode-dir>/public/' is used.
With the optional 'DBG=1' argument, 'dbg' archives are published
in addition to the corresponding 'bin' archives.
endef
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../..)
@ -43,6 +46,7 @@ include $(DEPOT_TOOL_DIR)/mk/front_end.inc
ifneq ($(MAKECMDGOALS),)
DEPENDENCIES_CMD := $(DEPOT_TOOL_DIR)/dependencies DEPOT_DIR="$(DEPOT_DIR)" \
DEPOT_TOOL_DIR="$(DEPOT_TOOL_DIR)" \
DBG="$(DBG)" \
$(MAKECMDGOALS)
DEPENDENCIES_RESULT := $(shell $(DEPENDENCIES_CMD) 2> /dev/null || true)
endif