Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
/ jdk20 Public archive

Commit d624deb

Browse files
committed
8298459: Fix msys2 linking and handling out of tree build directory for source zip creation
Reviewed-by: erikj
1 parent a894649 commit d624deb

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

make/ZipSource.gmk

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@ include JavaCompilation.gmk
3131
include Modules.gmk
3232

3333
SRC_ZIP_WORK_DIR := $(SUPPORT_OUTPUTDIR)/src
34+
$(if $(filter $(TOPDIR)/%, $(SUPPORT_OUTPUTDIR)), $(eval SRC_ZIP_BASE := $(TOPDIR)), $(eval SRC_ZIP_BASE := $(SUPPORT_OUTPUTDIR)))
3435

3536
# Hook to include the corresponding custom file, if present.
3637
$(eval $(call IncludeCustomExtension, ZipSource.gmk))
@@ -45,10 +46,10 @@ ALL_MODULES := $(FindAllModules)
4546
# again to create src.zip.
4647
$(foreach m, $(ALL_MODULES), \
4748
$(foreach d, $(call FindModuleSrcDirs, $m), \
48-
$(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$d)/$m) \
49+
$(eval $d_TARGET := $(SRC_ZIP_WORK_DIR)/$(patsubst $(TOPDIR)/%,%,$(patsubst $(SUPPORT_OUTPUTDIR)/%,%,$d))/$m) \
4950
$(if $(SRC_GENERATED), , \
5051
$(eval $$($d_TARGET): $d ; \
51-
$$(if $(filter $(TOPDIR)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
52+
$$(if $(filter $(SRC_ZIP_BASE)/%, $d), $$(link-file-relative), $$(link-file-absolute)) \
5253
) \
5354
) \
5455
$(eval SRC_ZIP_SRCS += $$($d_TARGET)) \

make/common/MakeBase.gmk

+23-4
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,36 @@ endef
306306
# There are two versions, either creating a relative or an absolute link. Be
307307
# careful when using this on Windows since the symlink created is only valid in
308308
# the unix emulation environment.
309-
define link-file-relative
309+
# In msys2 we use mklink /J because its ln would perform a deep copy of the target.
310+
# This inhibits performance and can lead to issues with long paths. With mklink /J
311+
# relative linking does not work, so we handle the link as absolute path.
312+
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
313+
define link-file-relative
314+
$(call MakeTargetDir)
315+
$(RM) '$(call DecodeSpace, $@)'
316+
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
317+
endef
318+
else
319+
define link-file-relative
310320
$(call MakeTargetDir)
311321
$(RM) '$(call DecodeSpace, $@)'
312322
$(LN) -s '$(call DecodeSpace, $(call RelativePath, $<, $(@D)))' '$(call DecodeSpace, $@)'
313-
endef
323+
endef
324+
endif
314325

315-
define link-file-absolute
326+
ifeq ($(OPENJDK_BUILD_OS_ENV), windows.msys2)
327+
define link-file-absolute
328+
$(call MakeTargetDir)
329+
$(RM) '$(call DecodeSpace, $@)'
330+
cmd //c "mklink /J $(call FixPath, $(call DecodeSpace, $@)) $(call FixPath, $(call DecodeSpace, $<))"
331+
endef
332+
else
333+
define link-file-absolute
316334
$(call MakeTargetDir)
317335
$(RM) '$(call DecodeSpace, $@)'
318336
$(LN) -s '$(call DecodeSpace, $<)' '$(call DecodeSpace, $@)'
319-
endef
337+
endef
338+
endif
320339

321340
################################################################################
322341

0 commit comments

Comments
 (0)