< prev index next > make/ZipSource.gmk
Print this page
SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
$(if $(filter $(TOPDIR)/%, $(SUPPORT_OUTPUTDIR)), $(eval SRC_ZIP_BASE := $(TOPDIR)), $(eval SRC_ZIP_BASE := $(SUPPORT_OUTPUTDIR)))
################################################################################
# Create the directory structure for src.zip using symlinks.
- # <module>/<package>/<file>.java
+ # <module>/<package>/<file>.java
+ # or:
+ # <module>/META-INF/preview/<package>/<file>.java
+ # for preview enabled sources.
+ #
+ # Generate the src dirs in the first make invocation and then call this makefile
+ # again to create src.zip.
ALL_MODULES := $(FindAllModules)
- # Generate the src dirs in the first make invocation and then call this makefile
- # again to create src.zip.
+ # Module source directories ($d) are things like (but not limited to):
+ # - $TOPDIR/src/<module>/share/classes
+ # - $SUPPORT_OUTPUTDIR/gensrc/<module>
+ #
+ # A symbolic link is created for each directory. For example:
+ # - $TOPDIR/src/<module>/share/classes
+ # is linked from:
+ # - $SRC_ZIP_WORK_DIR/src/<module>/share/classes/<module>
+ #
+ # Each link has the form:
+ # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
+ # and always has the name of its module (even if the module already appears in <link-dir>.
+ #
+ # Then the contents of all link parent directories are given as ZIP includes:
+ # - $SRC_ZIP_WORK_DIR/<link-dir>
+ # results in ZIP file entries starting:
+ # - <module>/...
+ # where multiple source links/directories can contribute to the same module's sources.
+ #
$(foreach m, $(ALL_MODULES), \
$(foreach d, $(call FindModuleSrcDirs, $m), \
$(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d))/$m) \
$(if $(SRC_GENERATED), , \
$(eval $$($d_TARGET): $d ; \
$(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
$(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
) \
)
+ # Preview source directories are currently limited to:
+ # - $SUPPORT_OUTPUTDIR/gensrc-valueclasses/<module>
+ # If this is changed, the 'patsubst' rewriting will need updating.
+ #
+ # The difficulty with this case is that we need to have a directory of the form:
+ # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
+ # containing (either directly or via symbolic linking) a `META-INF/preview`
+ # subdirectory which then contains the sources.
+ #
+ # The easiest way to achieve this is to symbolically link:
+ # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>/META-INF/preview
+ # and then use the parent directory:
+ # - $SRC_ZIP_WORK_DIR/<link-dir>/<module>
+ # as the actual target for the ZIP file generation. However, this requires
+ # an extra rule to associate the symbolic link and the parent directory.
+ #
+ $(foreach m, $(ALL_MODULES), \
+ $(foreach d, $(call FindModuleValueClassSrcDirs, $m), \
+ $(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d)/$m) \
+ $(if $(SRC_GENERATED), , \
+ $(eval $$($d_TARGET)/META-INF/preview: $d ; \
+ $$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
+ ) \
+ $(eval $$($d_TARGET): $$($d_TARGET)/META-INF/preview) \
+ ) \
+ $(eval SRC_ZIP_SRCS += $$($d_TARGET)) \
+ $(eval SRC_ZIP_SRCS_$m += $$($d_TARGET)) \
+ ) \
+ )
+
TARGETS += $(SRC_ZIP_SRCS)
################################################################################
# Only evaluate the creation of src.zip in a sub make call when the symlinked
# src directory structure has been generated.
< prev index next >