-
Notifications
You must be signed in to change notification settings - Fork 117
/
Copy pathCopySupport.gmk
129 lines (112 loc) · 4.3 KB
/
CopySupport.gmk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# ===========================================================================
# (c) Copyright IBM Corp. 2020, 2025 All Rights Reserved
# ===========================================================================
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# IBM designates this particular file as subject to the "Classpath" exception
# as provided by IBM in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
ifeq ($(origin LIB_DST_DIR),undefined)
include CopyCommon.gmk
endif
EXE_DST_DIR := $(call FindExecutableDirForModule, $(MODULE))
# openj9_debuginfo_sources
# ------------------------
# $1 - representative path
ifeq (macosx,$(OPENJDK_TARGET_OS))
openj9_debuginfo_sources = $(wildcard $1.dSYM/Contents/Info.plist $1.dSYM/Contents/Resources/DWARF/$(notdir $1))
else ifeq (windows,$(OPENJDK_TARGET_OS))
openj9_debuginfo_sources = $(wildcard $(addprefix $(basename $1),.map .pdb))
else
openj9_debuginfo_sources = $(wildcard $(basename $1).debuginfo)
endif
ifeq (true,$(ZIP_EXTERNAL_DEBUG_SYMBOLS))
# openj9_copy_debuginfos
# ----------------------
# $1 - sequence of file paths
openj9_copy_debuginfos = \
$(if $(call openj9_debuginfo_sources,$(firstword $1)), \
$(eval $(call openj9_zip_files,$(dir $(firstword $1)),$(call openj9_debuginfo_sources,$(firstword $1)),$(basename $(word 2,$1)).diz)) \
$(if $(word 3,$1),$(call openj9_copy_files,,$(addsuffix .diz,$(basename $(wordlist 2,$(words $1),$1))))))
# openj9_zip_files
# ----------------
# $1 - working directory
# $2 - source file paths
# $3 - target file path
define openj9_zip_files
TARGETS += $3
$3 : $2
$(call MakeTargetDir)
($(CD) $1 && $(ZIPEXE) -Dq $$@ $(patsubst $1%,%,$2))
endef
else # ZIP_EXTERNAL_DEBUG_SYMBOLS
# openj9_copy_debuginfos
# ----------------------
# $1 - sequence of file paths
openj9_copy_debuginfos = \
$(foreach suffix, $(call openj9_debuginfo_suffixes,$(firstword $1)), \
$(call openj9_copy_files,,$(addsuffix $(suffix),$(basename $1))))
# openj9_debuginfo_suffixes
# -------------------------
# $1 - sequence of file paths
openj9_debuginfo_suffixes = $(patsubst $(basename $1)%,%,$(call openj9_debuginfo_sources,$1))
endif # ZIP_EXTERNAL_DEBUG_SYMBOLS
define openj9_copy_only
$(call install-file)
endef
define openj9_copy_and_sign
$(openj9_copy_only)
$(call CodesignFile,"$@")
endef
# openj9_copy_rule
# ----------------
# $1 - suffix of install action macro ('only' or 'and_sign')
# $2 - source file path
# $3 - target file path
define openj9_copy_rule
TARGETS += $3
$3 : $2
$$(openj9_copy_$1)
endef
# openj9_copy_files
# -----------------
# $1 - suffix of install action macro ('only' or 'and_sign'; default is 'only')
# $2 - sequence of file paths
openj9_copy_files = \
$(eval $(call openj9_copy_rule,$(if $1,$(strip $1),only),$(firstword $2),$(word 2,$2))) \
$(if $(word 3,$2),$(call openj9_copy_files,,$(wordlist 2,$(words $2),$2)))
# openj9_copy_files_and_debuginfos
# --------------------------------
# $1 - sequence of file paths
openj9_copy_files_and_debuginfos = \
$(call openj9_copy_files,and_sign,$1) \
$(call openj9_copy_debuginfos,$1)
# openj9_copy_exes
# ----------------
# $1 = list of executable names without $(EXECUTABLE_SUFFIX)
openj9_copy_exes = \
$(foreach file, $1, \
$(call openj9_copy_files_and_debuginfos, \
$(addsuffix /$(file)$(EXECUTABLE_SUFFIX), \
$(OPENJ9_VM_BUILD_DIR) \
$(EXE_DST_DIR))))
# openj9_copy_shlibs
# ------------------
# $1 = list of shared library names without $(LIBRARY_PREFIX) or $(SHARED_LIBRARY_SUFFIX)
openj9_copy_shlibs = \
$(foreach name, $1, \
$(call openj9_copy_files_and_debuginfos, \
$(addsuffix /$(call SHARED_LIBRARY,$(name)), \
$(OPENJ9_VM_BUILD_DIR) \
$(LIB_DST_DIR)/$(OPENJ9_LIBS_SUBDIR))))