From 10f39becdfd787c091cc7e65bfde822ca15533b3 Mon Sep 17 00:00:00 2001 From: Arkadiusz Hiler Date: Wed, 20 Sep 2023 17:10:05 +0300 Subject: [PATCH] make: Collect compile_commands.json in $(OBJ)/compile_commands/ All compile_commands.json from the build directories will be copied to the compile_commands subdirectory adjusting the paths of the source to point to the real (not the rsynced) one. NOTE: it still may point to the build dir for things like generated config.h --- make/rules-common.mk | 8 ++++++++ make/rules-source.mk | 2 ++ 2 files changed, 10 insertions(+) diff --git a/make/rules-common.mk b/make/rules-common.mk index b057bb72..00a1b4ff 100644 --- a/make/rules-common.mk +++ b/make/rules-common.mk @@ -49,6 +49,10 @@ $$(OBJ)/.$(1)-dist$(3): $$(OBJ)/.$(1)-post-build$(3) ifneq ($(UNSTRIPPED_BUILD),) $$(OBJ)/.$(1)-dist$(3): @echo ":: installing $(3)bit $(1)..." >&2 + if [ -f "$$($(2)_OBJ$(3))/compile_commands.json" ]; then \ + mkdir -p "$$(OBJ)/compile_commands/$(1)$(3)/"; \ + sed "s#$$($(2)_SRC)#$$($(2)_ORIGIN)#g" "$$($(2)_OBJ$(3))/compile_commands.json" > "$$(OBJ)/compile_commands/$(1)$(3)/compile_commands.json"; \ + fi mkdir -p $$($(2)_LIBDIR$(3))/ $$(DST_LIBDIR$(3))/ cd $$($(2)_LIBDIR$(3)) && find -type f -printf '$$(DST_LIBDIR$(3))/%h\0' | sort -z | uniq -z | xargs $(--verbose?) -0 -r -P$$(J) mkdir -p cd $$($(2)_LIBDIR$(3)) && find -type l -printf '%p\0$$(DST_LIBDIR$(3))/%p\0' | xargs $(--verbose?) -0 -r -P$$(J) -n2 cp -a @@ -62,6 +66,10 @@ $$(OBJ)/.$(1)-dist$(3): else $$(OBJ)/.$(1)-dist$(3): @echo ":: installing $(3)bit $(1)..." >&2 + if [ -f "$$($(2)_OBJ$(3))/compile_commands.json" ]; then \ + mkdir -p "$$(OBJ)/compile_commands/$(1)$(3)/"; \ + sed "s#$$($(2)_SRC)#$$($(2)_ORIGIN)#g" "$$($(2)_OBJ$(3))/compile_commands.json" > "$$(OBJ)/compile_commands/$(1)$(3)/compile_commands.json"; \ + fi mkdir -p $$($(2)_LIBDIR$(3))/ $$(DST_LIBDIR$(3))/ cd $$($(2)_LIBDIR$(3)) && find -type f -printf '$$(DST_LIBDIR$(3))/%h\0' | sort -z | uniq -z | xargs $(--verbose?) -0 -r -P$$(J) mkdir -p cd $$($(2)_LIBDIR$(3)) && find -type l -printf '%p\0$$(DST_LIBDIR$(3))/%p\0' | xargs $(--verbose?) -0 -r -P$$(J) -n2 cp -a diff --git a/make/rules-source.mk b/make/rules-source.mk index 4903de0b..4f8cd8fa 100644 --- a/make/rules-source.mk +++ b/make/rules-source.mk @@ -8,12 +8,14 @@ # # outputs: # $($(2)_SRC): variable, absolute rsynced source folder +# $($(2)_ORIGIN): variable, absolute origin source folder # $(1)-rebuild: target, call it to force package rebuild # $(1)-source: target, tracking package source changes # $(1)-clean: target, clean package and force rebuild # define create-rules-source $(2)_SRC = $$(OBJ)/src-$(1) +$(2)_ORIGIN = $(3) $(1)-rebuild: .PHONY: $(1)-rebuild