提交 f6b201a7 编写于 作者: E erikj

8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)

Reviewed-by: tbell
上级 b1f0a0f5
......@@ -473,15 +473,32 @@ EncodeSpace = \
$(subst $(SPACE),?,$(strip $1))
################################################################################
# Make directory without forking mkdir if not needed
# Make directory without forking mkdir if not needed.
#
# If a directory with an encoded space is provided, the wildcard function
# sometimes returns false answers (typically if the dir existed when the
# makefile was parsed, but was deleted by a previous rule). In that case, always
# call mkdir regardless of what wildcard says.
#
# 1: List of directories to create
MakeDir = \
$(strip \
$(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, $(if $(wildcard $d), , \
"$(call DecodeSpace, $d)")))) \
$(eval MakeDir_dirs_to_make := $(strip $(foreach d, $1, \
$(if $(findstring ?, $d), '$(call DecodeSpace, $d)', \
$(if $(wildcard $d), , $d) \
) \
))) \
$(if $(MakeDir_dirs_to_make), $(shell $(MKDIR) -p $(MakeDir_dirs_to_make))) \
)
# Make directory for target file. Should handle spaces in filenames. Just
# calling $(call MakeDir $(@D)) will not work if the directory contains a space
# and the target file already exists. In that case, the target file will have
# its wildcard ? resolved and the $(@D) will evaluate each space separated dir
# part on its own.
MakeTargetDir = \
$(call MakeDir, $(dir $(call EncodeSpace, $@)))
################################################################################
# Assign a variable only if it is empty
# Param 1 - Variable to assign
......@@ -499,7 +516,7 @@ ifeq ($(OPENJDK_TARGET_OS),solaris)
# If the source and target parent directories are the same, recursive copy doesn't work
# so we fall back on regular copy, which isn't preserving symlinks.
define install-file
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(RM) '$(call DecodeSpace, $@)'
if [ '$(call DecodeSpace, $(dir $@))' != \
'$(call DecodeSpace, $(dir $(call EncodeSpace, $<)))' ]; then \
......@@ -526,21 +543,21 @@ else ifeq ($(OPENJDK_TARGET_OS),macosx)
# If copying a soft link to a directory, need to delete the target first to avoid
# weird errors.
define install-file
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(RM) '$(call DecodeSpace, $@)'
$(CP) -fRP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
if [ -n "`$(XATTR) -ls '$(call DecodeSpace, $@)'`" ]; then $(XATTR) -cs '$(call DecodeSpace, $@)'; fi
endef
else
define install-file
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(CP) -fP '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
endef
endif
# Variant of install file that does not preserve symlinks
define install-file-nolink
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(CP) -f '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
endef
......@@ -590,13 +607,13 @@ RelativePath = \
# careful when using this on Windows since the symlink created is only valid in
# the unix emulation environment.
define link-file-relative
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(RM) '$(call DecodeSpace, $@)'
$(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
endef
define link-file-absolute
$(call MakeDir, $(@D))
$(call MakeTargetDir)
$(RM) '$(call DecodeSpace, $@)'
$(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
endef
......
......@@ -44,6 +44,7 @@ SRC_DIR := $(OUTPUT_DIR)/src
DEST_DIR := $(OUTPUT_DIR)/dest
$(OUTPUT_DIR)/_src_created: $(DEPS)
$(RM) -r $(DEST_DIR)
$(RM) -r $(SRC_DIR)
$(MKDIR) -p $(SRC_DIR)
$(MKDIR) -p $(SRC_DIR)/foo
......@@ -51,7 +52,7 @@ $(OUTPUT_DIR)/_src_created: $(DEPS)
$(TOUCH) $(SRC_DIR)/foo/foofile
$(TOUCH) "$(SRC_DIR)/foo/foo file"
# Spaces in directories only works with gnu make 4.0 or later
ifeq (4.0, $(firstword $(sort 4.0 $(MAKE_VERSION))))
ifeq (4.0dfd, $(firstword $(sort 4.0 $(MAKE_VERSION))))
$(MKDIR) -p "$(SRC_DIR)/foo bar"
$(TOUCH) "$(SRC_DIR)/foo bar/foobarfile"
$(TOUCH) "$(SRC_DIR)/foo bar/foo bar file"
......@@ -65,15 +66,32 @@ $(eval $(call SetupCopyFiles, COPY_1, \
FILES := $(call CacheFind, $(SRC_DIR)), \
))
# Optionally define a rule that deletes all the target files after the makefile
# has been parsed. GNU make has specific problems with this in combination with
# spaces in directory names.
ifeq ($(DELETE_FIRST), true)
delete-targets:
$(RM) -r $(DEST_DIR)
$(ECHO) '$(DEST_DIR)/foo' '$(wildcard $(DEST_DIR)/foo)'
$(COPY_1): delete-targets
endif
do-copy1: $(COPY_1)
run-test1: $(OUTPUT_DIR)/_src_created
$(ECHO) "Copy 1 first time"
+$(MAKE) -f $(THIS_FILE) do-copy1
$(DIFF) -r $(SRC_DIR) $(DEST_DIR)
# Rerun the copy a second time, with the targets present at make parse
# time, but then deleted by a prerequisite rule.
$(ECHO) "Copy 1 second time"
+$(MAKE) -f $(THIS_FILE) do-copy1 DELETE_FIRST=true
$(DIFF) -r $(SRC_DIR) $(DEST_DIR)
TEST_TARGETS += run-test1
.PHONY: do-copy1 run-test1
.PHONY: do-copy1 run-test1 delete-targets
################################################################################
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册