* [Buildroot] [PATCH v2 1/1] package/pkg-generic.mk: fix absolute paths in per-package config files
2022-01-04 17:48 [Buildroot] [PATCH v2 0/1] Fix per-package builds with qt5 submodule packages Adam Duskett
@ 2022-01-04 17:48 ` Adam Duskett
0 siblings, 0 replies; 2+ messages in thread
From: Adam Duskett @ 2022-01-04 17:48 UTC (permalink / raw)
To: buildroot; +Cc: Adam Duskett, Thomas Petazzoni
Some packages (notably qmake packages) generate .cmake, .pc, and .pri files
with absolute paths. Unfortunately, doing so breaks per-package builds because
the paths in those files point outside the per-package sysroot for packages
that have rsynced those same files.
Add the new pre-configure hook "FIXUP_CONFIG_FILES_ABSOLUTE_PATHS" in
package/pkg-generic.mk which searches for .cmake, .pc, and .pri files in a
given per-package host and staging directory and replaces the old
$(PER_PACKAGE_DIR) directory with the correct directory for the given package.
This simple fix allows qt5 submodule packages to build with per-package enabled.
Based off of Louis-Paul's earlier work found here:
https://lore.kernel.org/buildroot/a339f273-33f3-f232-eac4-6e50427abf6d@cordier.org/
And Yann Morin's feedback found here:
https://patchwork.ozlabs.org/project/buildroot/patch/20200217212350.29750-21-anaumann@ultratronik.de/
Signed-off-by: Adam Duskett <aduskett@gmail.com>
---
changes v1 -> v2
- Drop patches 2 and 3 and combine them into a single macro in pkg-generic.mk
- Move the PRE_CONFIGURE_HOOK to inner-generic-package so it actually runs
- Rename FIXUP_PC_FILES_ABSOLUTE_PATHS to FIXUP_CONFIG_FILES_ABSOLUTE_PATHS
- Use $(HOST_DIR) instead of $(STAGING_DIR) to cover both stagin and host
directories in a single step.
package/pkg-generic.mk | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 5626af1d87..5a2b4ccaf8 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -103,6 +103,21 @@ define fixup-libtool-files
endef
endif
+# When per-package is enabled, packages may generate files with absolute paths
+# that point to the given sysroot. However, after the rsync step for another
+# package that uses those files, per-package isolation is broken because the
+# hard-coded paths point to directories outside the per-package sysroot.
+# As a pre-configure step, sed all .cmake, .pc, and .pri files in a given
+# package sysroot containing the word "per-package" and replace the line with
+# the appropriate per-package directory.
+ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
+define FIXUP_CONFIG_FILES_ABSOLUTE_PATHS
+ $(Q)find $(HOST_DIR)/ -name "*.pc" -o -name "*.cmake" -o -name "*.pri" \
+ | xargs --no-run-if-empty \
+ $(SED) "s:$(PER_PACKAGE_DIR)/[^/]\+/:$(PER_PACKAGE_DIR)/$(NAME)/:g"
+endef
+endif
+
# Make sure python _sysconfigdata*.py files only reference the current
# per-package directory.
#
@@ -837,6 +852,7 @@ $(2)_EXTRACT_CMDS ?= \
# pre/post-steps hooks
$(2)_POST_PREPARE_HOOKS += FIXUP_PYTHON_SYSCONFIGDATA
+$(2)_PRE_CONFIGURE_HOOKS += FIXUP_CONFIG_FILES_ABSOLUTE_PATHS
ifeq ($$($(2)_TYPE),target)
ifneq ($$(HOST_$(2)_KCONFIG_VAR),)
--
2.33.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 2+ messages in thread