@@ -24,76 +24,54 @@ endif
2424
2525EXE_DST_DIR := $(call FindExecutableDirForModule, $(MODULE))
2626
27+ # openj9_debuginfo_sources
28+ # ------------------------
29+ # $1 - representative path
2730ifeq (macosx,$(OPENJDK_TARGET_OS))
28- DEBUGINFO_SRC_SUFFIX := .dSYM
31+ openj9_debuginfo_sources = $(wildcard $1 .dSYM/Contents/Info.plist $1.dSYM/Contents/Resources/DWARF/$(notdir $1))
2932else ifeq (windows,$(OPENJDK_TARGET_OS))
30- DEBUGINFO_SRC_SUFFIX := . pdb
33+ openj9_debuginfo_sources = $(wildcard $(addprefix $(basename $1),.map . pdb))
3134else
32- DEBUGINFO_SRC_SUFFIX := .debuginfo
35+ openj9_debuginfo_sources = $(wildcard $(basename $1) .debuginfo)
3336endif
3437
3538ifeq (true,$(ZIP_EXTERNAL_DEBUG_SYMBOLS))
36- DEBUGINFO_DST_SUFFIX := .diz
37- else
38- DEBUGINFO_DST_SUFFIX := $(DEBUGINFO_SRC_SUFFIX)
39- endif
4039
41- # openj9_make_debuginfo_paths
42- # ---------------------------
43- # $1 - required suffix
44- # $2 - input paths
45- openj9_make_debuginfo_paths = \
46- $(if $(filter .dSYM, $1), \
47- $(addsuffix .dSYM, $2), \
48- $(foreach path, $2, $(path:$(suffix $(path))=$1)))
49-
50- # openj9_copy_debuginfo_rule
51- # --------------------------
52- # $1 - source file path
53- # $2 - target file path
54- define openj9_copy_debuginfo_rule
55- TARGETS += $2
56- $2 : $1
57- ifneq (,$(and $(filter %$(DEBUGINFO_SRC_SUFFIX),$1),$(filter %.diz,$2)))
40+ # openj9_copy_debuginfos
41+ # ----------------------
42+ # $1 - sequence of file paths
43+ openj9_copy_debuginfos = \
44+ $(if $(call openj9_debuginfo_sources,$(word 1,$1)), \
45+ $(eval $(call openj9_zip_files,$(dir $(word 1,$1)),$(call openj9_debuginfo_sources,$(word 1,$1)),$(basename $(word 2,$1)).diz)) \
46+ $(if $(word 3,$1),$(call openj9_copy_files,,$(addsuffix .diz,$(basename $(wordlist 2,$(words $1),$1))))))
47+
48+ # openj9_zip_files
49+ # ----------------
50+ # $1 - working directory
51+ # $2 - source file paths
52+ # $3 - target file path
53+ define openj9_zip_files
54+ TARGETS += $3
55+ $3 : $2
5856 $(call MakeTargetDir)
59- ($(CD) $$(<D) && $(ZIPEXE) -Dqr $$@ $$(<F))
60- else
61- $$(call install-file)
62- endif
57+ ($(CD) $1 && $(ZIPEXE) -Dq $$@ $(patsubst $1%,%,$2))
6358endef
6459
65- # openj9_copy_debuginfo_helper
66- # ----------------------------
67- # $1 - sequence of file paths
68- openj9_copy_debuginfo_helper = \
69- $(eval $(call openj9_copy_debuginfo_rule,$(word 1,$1),$(word 2,$1))) \
70- $(if $(word 3,$1),$(call openj9_copy_debuginfo_helper,$(wordlist 2,$(words $1),$1)))
71-
72- # openj9_copy_debuginfo_paths*
73- # ----------------------------
74- # $1 - source suffix
75- # $2 - sequence of file paths
76- ifeq (macosx/.dSYM,$(OPENJDK_TARGET_OS)/$(DEBUGINFO_DST_SUFFIX))
77- # When not zipping on MacOSX, there are multiple files to copy; openj9_copy_debuginfo_paths_list
78- # names the functions that produce the sequence for each file.
79- openj9_copy_debuginfo_paths_list = openj9_copy_debuginfo_paths_a openj9_copy_debuginfo_paths_b
80- openj9_copy_debuginfo_paths_a = $(foreach path, $2, $(path).dSYM/Contents/Info.plist)
81- openj9_copy_debuginfo_paths_b = $(foreach path, $2, $(path).dSYM/Contents/Resources/DWARF/$(notdir $(path)))
82- else
83- openj9_copy_debuginfo_paths_list = openj9_copy_debuginfo_paths
84- openj9_copy_debuginfo_paths = \
85- $(call openj9_make_debuginfo_paths,$(DEBUGINFO_SRC_SUFFIX),$(word 1,$2)) \
86- $(call openj9_make_debuginfo_paths,$(DEBUGINFO_DST_SUFFIX),$(wordlist 2,$(words $2),$2))
87- endif # macosx
60+ else # ZIP_EXTERNAL_DEBUG_SYMBOLS
8861
8962# openj9_copy_debuginfos
9063# ----------------------
91- # $1 - source suffix
92- # $2 - sequence of file paths
64+ # $1 - sequence of file paths
9365openj9_copy_debuginfos = \
94- $(if $(wildcard $(call openj9_make_debuginfo_paths,$(DEBUGINFO_SRC_SUFFIX),$(word 1,$2))), \
95- $(foreach paths, $(openj9_copy_debuginfo_paths_list), \
96- $(call openj9_copy_debuginfo_helper, $(call $(paths),$1,$2))))
66+ $(foreach suffix, $(call openj9_debuginfo_suffixes,$(word 1,$1)), \
67+ $(call openj9_copy_files,,$(addsuffix $(suffix),$(basename $1))))
68+
69+ # openj9_debuginfo_suffixes
70+ # -------------------------
71+ # $1 - sequence of file paths
72+ openj9_debuginfo_suffixes = $(patsubst $(basename $1)%,%,$(call openj9_debuginfo_sources,$1))
73+
74+ endif # ZIP_EXTERNAL_DEBUG_SYMBOLS
9775
9876define openj9_copy_only
9977 $(call install-file)
@@ -128,7 +106,7 @@ openj9_copy_files = \
128106# $1 - sequence of file paths
129107openj9_copy_files_and_debuginfos = \
130108 $(call openj9_copy_files,and_sign,$1) \
131- $(call openj9_copy_debuginfos,$(suffix $(word 1,$1)),$ 1)
109+ $(call openj9_copy_debuginfos,$1)
132110
133111# openj9_copy_exes
134112# ----------------
0 commit comments