make/common/CopyFiles.gmk
author herrick
Thu, 28 Mar 2019 13:49:38 -0400
branchJDK-8200758-branch
changeset 57292 7a683c461b80
parent 53484 8c296eedfb04
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     1
#
53484
8c296eedfb04 8217730: Split up MakeBase.gmk
ihse
parents: 52186
diff changeset
     2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     4
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    10
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    15
# accompanied this code).
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    16
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    20
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    23
# questions.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    24
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    25
53484
8c296eedfb04 8217730: Split up MakeBase.gmk
ihse
parents: 52186
diff changeset
    26
ifeq (,$(_MAKEBASE_GMK))
8c296eedfb04 8217730: Split up MakeBase.gmk
ihse
parents: 52186
diff changeset
    27
  $(error You must include MakeBase.gmk prior to including CopyFiles.gmk)
32807
20386e6d858f 8136385: Various build speed improvements for windows
erikj
parents: 32553
diff changeset
    28
endif
20386e6d858f 8136385: Various build speed improvements for windows
erikj
parents: 32553
diff changeset
    29
35008
ef0cd710989f 8146403: Windows build can be faster
erikj
parents: 34596
diff changeset
    30
################################################################################
47751
f7e430cbfe34 8190702: JMC packaging causing errors in JDK 10 consolidated repo (macOS)
erikj
parents: 47715
diff changeset
    31
#
53484
8c296eedfb04 8217730: Split up MakeBase.gmk
ihse
parents: 52186
diff changeset
    32
# Code for handling the SetupCopyFiles macro.
41260
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40241
diff changeset
    33
#
15051
d32ad37472e6 8005540: build-infra: Improve incremental build speed on windows by caching find results
erikj
parents: 14279
diff changeset
    34
################################################################################
d32ad37472e6 8005540: build-infra: Improve incremental build speed on windows by caching find results
erikj
parents: 14279
diff changeset
    35
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    36
define AddFileToCopy
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    37
  # Helper macro for SetupCopyFiles
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    38
  # 1 : Source file
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    39
  # 2 : Dest file
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    40
  # 3 : Variable to add targets to
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    41
  # 4 : Macro to call for copy operation
42983
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    42
  # 5 : Action text to log
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    43
  $2: $1
47334
09d386ddaa42 8189095: Import JMC from artifactory using Jib and main makefiles
erikj
parents: 47314
diff changeset
    44
	$$(call LogInfo, $(strip $5) $$(patsubst $(OUTPUTDIR)/%,%,$$(call DecodeSpace, $$@)))
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    45
	$$($$(strip $4))
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    46
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    47
  $3 += $2
47435
80fd2dab3805 8187974: Merge Java Mission Control 6.1 3rdpartyreame with the JDK 18.3 3rdpartyreadme
erikj
parents: 47364
diff changeset
    48
  $3_SOURCES += $1
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    49
endef
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    50
32811
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    51
# Returns the value of the first argument
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    52
identity = \
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    53
    $(strip $1)
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    54
28902
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    55
# Setup make rules for copying files, with an option to do more complex
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    56
# processing instead of copying.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    57
#
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    58
# Parameter 1 is the name of the rule. This name is used as variable prefix,
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    59
# and the targets generated are listed in a variable by that name.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    60
#
47435
80fd2dab3805 8187974: Merge Java Mission Control 6.1 3rdpartyreame with the JDK 18.3 3rdpartyreadme
erikj
parents: 47364
diff changeset
    61
# The list of all source files is returned in $1_SOURCES.
80fd2dab3805 8187974: Merge Java Mission Control 6.1 3rdpartyreame with the JDK 18.3 3rdpartyreadme
erikj
parents: 47364
diff changeset
    62
#
28902
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    63
# Remaining parameters are named arguments. These include:
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    64
#   SRC     : Source root dir (defaults to dir of first file)
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    65
#   DEST    : Dest root dir
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    66
#   FILES   : List of files to copy with absolute paths, or path relative to SRC.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    67
#             Must be in SRC.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    68
#   FLATTEN : Set to flatten the directory structure in the DEST dir.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    69
#   MACRO   : Optionally override the default macro used for making the copy.
0c09b47449c8 8069064: Various improvements and fixes in build system
ihse
parents: 28901
diff changeset
    70
#             Default is 'install-file'
32811
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    71
#   NAME_MACRO : Optionally supply a macro that rewrites the target file name
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    72
#                based on the source file name
42983
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    73
#   LOG_ACTION : Optionally specify a different action text for log messages
29312
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 29304
diff changeset
    74
SetupCopyFiles = $(NamedParamsMacroTemplate)
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 29304
diff changeset
    75
define SetupCopyFilesBody
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    76
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    77
  ifeq ($$($1_MACRO), )
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    78
    $1_MACRO := install-file
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    79
  endif
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
    80
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    81
  # Default SRC to the dir of the first file.
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    82
  ifeq ($$($1_SRC), )
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    83
    $1_SRC := $$(dir $$(firstword $$($1_FILES)))
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    84
  endif
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    85
32811
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    86
  ifeq ($$($1_NAME_MACRO), )
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    87
    $1_NAME_MACRO := identity
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    88
  endif
df82db312e58 8135060: Stop building Xcode projects in install build
erikj
parents: 32553
diff changeset
    89
42983
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    90
  ifeq ($$($1_LOG_ACTION), )
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    91
    $1_LOG_ACTION := Copying
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    92
  endif
7bf4468cdbc4 8172037: Change log message of SetupCopyFiles
erikj
parents: 42530
diff changeset
    93
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 33394
diff changeset
    94
  # Remove any trailing slash from SRC and DEST
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    95
  $1_SRC := $$(patsubst %/,%,$$($1_SRC))
34596
e8328ce5b64e 8142907: Integration of minor fixes from the build-infra project
ihse
parents: 33394
diff changeset
    96
  $1_DEST := $$(patsubst %/,%,$$($1_DEST))
28901
5acc0ec03d06 8042707: Source changes needed to build JDK 9 with Visual Studio 2013 (VS2013)
erikj
parents: 27595
diff changeset
    97
47354
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
    98
  # Need to wrap arguments in DoubleDollar because of the eval nested inside an
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
    99
  # eval macro body.
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
   100
  $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
47354
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   101
    $$(eval $$(call AddFileToCopy, \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   102
        $$(call DoubleDollar, $$($1_SRC)/$$f), \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   103
        $$(call DoubleDollar, \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   104
            $$($1_DEST)/$$(call $$(strip $$($1_NAME_MACRO)),$$(if $$($1_FLATTEN),$$(notdir $$f),$$f)) \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   105
        ), \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   106
        $1, \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   107
        $$($1_MACRO), \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   108
        $$($1_LOG_ACTION) \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   109
    )) \
e8bda13da40b 8189434: SetupCopyFiles does not handle files with $ in them
erikj
parents: 47348
diff changeset
   110
  )
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
   111
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 23984
diff changeset
   112
endef