18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29
30 include Modules.gmk
31 include ZipArchive.gmk
32
33 SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
34 $(if $(filter $(TOPDIR)/%, $(SUPPORT_OUTPUTDIR)), $(eval SRC_ZIP_BASE := $(TOPDIR)), $(eval SRC_ZIP_BASE := $(SUPPORT_OUTPUTDIR)))
35
36 ################################################################################
37 # Create the directory structure for src.zip using symlinks.
38 # <module>/<package>/<file>.java
39
40 ALL_MODULES := $(FindAllModules)
41
42 # Generate the src dirs in the first make invocation and then call this makefile
43 # again to create src.zip.
44 $(foreach m, $(ALL_MODULES), \
45 $(foreach d, $(call FindModuleSrcDirs, $m), \
46 $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d))/$m) \
47 $(if $(SRC_GENERATED), , \
48 $(eval $$($d_TARGET): $d ; \
49 $$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
50 ) \
51 ) \
52 $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
53 $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
54 ) \
55 )
56
57 TARGETS += $(SRC_ZIP_SRCS)
58
59 ################################################################################
60 # Only evaluate the creation of src.zip in a sub make call when the symlinked
61 # src directory structure has been generated.
62 ifeq ($(SRC_GENERATED), true)
63
64 # Rewrite the EXCLUDE_TRANSLATIONS locales as exclude patters for java files
65 TRANSLATIONS_PATTERN := $(addprefix %_, $(addsuffix .java, $(EXCLUDE_TRANSLATIONS)))
66
67 # Add excludes for translations for all modules except jdk.localedata
68 $(foreach s, $(SRC_ZIP_SRCS), \
69 $(if $(filter $(notdir $s), jdk.localedata), , \
70 $(eval BUILD_SRC_ZIP_EXCLUDE_PATTERNS_$(dir $s) := $$(TRANSLATIONS_PATTERN)) \
71 ) \
72 )
73
74 $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
75 SRC := $(dir $(SRC_ZIP_SRCS)), \
76 INCLUDES := $(SRC_ZIP_INCLUDES), \
|
18 # 2 along with this work; if not, write to the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 # or visit www.oracle.com if you need additional information or have any
23 # questions.
24 #
25
26 include MakeFileStart.gmk
27
28 ################################################################################
29
30 include Modules.gmk
31 include ZipArchive.gmk
32
33 SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
34 $(if $(filter $(TOPDIR)/%, $(SUPPORT_OUTPUTDIR)), $(eval SRC_ZIP_BASE := $(TOPDIR)), $(eval SRC_ZIP_BASE := $(SUPPORT_OUTPUTDIR)))
35
36 ################################################################################
37 # Create the directory structure for src.zip using symlinks.
38 # <module>/<package>/<file>.java
39 # or:
40 # <module>/META-INF/preview/<package>/<file>.java
41 # for preview enabled sources.
42 #
43 # Generate the src dirs in the first make invocation and then call this makefile
44 # again to create src.zip.
45
46 ALL_MODULES := $(FindAllModules)
47
48 # Module source directories ($d) are things like (but not limited to):
49 # - $TOPDIR/src/<module>/share/classes
50 # - $SUPPORT_OUTPUTDIR/gensrc/<module>
51 #
52 # A symbolic link is created for each directory. For example:
53 # - $TOPDIR/src/<module>/share/classes
54 # is linked from:
55 # - $SRC_ZIP_WORK_DIR/src/<module>/share/classes/<module>
56 #
57 # Each link has the form:
58 # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
59 # and always has the name of its module (even if the module already appears in <link-dir>.
60 #
61 # Then the contents of all link parent directories are given as ZIP includes:
62 # - $SRC_ZIP_WORK_DIR/<link-dir>
63 # results in ZIP file entries starting:
64 # - <module>/...
65 # where multiple source links/directories can contribute to the same module's sources.
66 #
67 $(foreach m, $(ALL_MODULES), \
68 $(foreach d, $(call FindModuleSrcDirs, $m), \
69 $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d))/$m) \
70 $(if $(SRC_GENERATED), , \
71 $(eval $$($d_TARGET): $d ; \
72 $$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
73 ) \
74 ) \
75 $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
76 $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
77 ) \
78 )
79
80 # Preview source directories are currently limited to:
81 # - $SUPPORT_OUTPUTDIR/gensrc-valueclasses/<module>
82 # If this is changed, the 'patsubst' rewriting will need updating.
83 #
84 # The difficulty with this case is that we need to have a directory of the form:
85 # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
86 # containing (either directly or via symbolic linking) a `META-INF/preview`
87 # subdirectory which then contains the sources.
88 #
89 # The easiest way to achieve this is to symbolically link:
90 # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>/META-INF/preview
91 # and then use the parent directory:
92 # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
93 # as the actual target for the ZIP file generation. However, this requires
94 # an extra rule to associate the symbolic link and the parent directory.
95 #
96 $(foreach m, $(ALL_MODULES), \
97 $(foreach d, $(call FindModuleValueClassSrcDirs, $m), \
98 $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d)/$m) \
99 $(if $(SRC_GENERATED), , \
100 $(eval $$($d_TARGET)/META-INF/preview: $d ; \
101 $$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
102 ) \
103 $(eval $$($d_TARGET): $$($d_TARGET)/META-INF/preview) \
104 ) \
105 $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
106 $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
107 ) \
108 )
109
110 TARGETS += $(SRC_ZIP_SRCS)
111
112 ################################################################################
113 # Only evaluate the creation of src.zip in a sub make call when the symlinked
114 # src directory structure has been generated.
115 ifeq ($(SRC_GENERATED), true)
116
117 # Rewrite the EXCLUDE_TRANSLATIONS locales as exclude patters for java files
118 TRANSLATIONS_PATTERN := $(addprefix %_, $(addsuffix .java, $(EXCLUDE_TRANSLATIONS)))
119
120 # Add excludes for translations for all modules except jdk.localedata
121 $(foreach s, $(SRC_ZIP_SRCS), \
122 $(if $(filter $(notdir $s), jdk.localedata), , \
123 $(eval BUILD_SRC_ZIP_EXCLUDE_PATTERNS_$(dir $s) := $$(TRANSLATIONS_PATTERN)) \
124 ) \
125 )
126
127 $(eval $(call SetupZipArchive, BUILD_SRC_ZIP, \
128 SRC := $(dir $(SRC_ZIP_SRCS)), \
129 INCLUDES := $(SRC_ZIP_INCLUDES), \
|