jdk

Форк
0
/
CopyFiles.gmk 
112 строк · 3.8 Кб
1
#
2
# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
10
#
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
16
#
17
# You should have received a copy of the GNU General Public License version
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
ifeq (,$(_MAKEBASE_GMK))
27
  $(error You must include MakeBase.gmk prior to including CopyFiles.gmk)
28
endif
29

30
################################################################################
31
#
32
# Code for handling the SetupCopyFiles macro.
33
#
34
################################################################################
35

36
define AddFileToCopy
37
  # Helper macro for SetupCopyFiles
38
  # 1 : Source file
39
  # 2 : Dest file
40
  # 3 : Variable to add targets to
41
  # 4 : Macro to call for copy operation
42
  # 5 : Action text to log
43
  $2: $1
44
	$$(call LogInfo, $(strip $5) $$(patsubst $(OUTPUTDIR)/%,%,$$(call DecodeSpace, $$@)))
45
	$$($$(strip $4))
46

47
  $3 += $2
48
  $3_SOURCES += $1
49
endef
50

51
# Returns the value of the first argument
52
identity = \
53
    $(strip $1)
54

55
# Setup make rules for copying files, with an option to do more complex
56
# processing instead of copying.
57
#
58
# Parameter 1 is the name of the rule. This name is used as variable prefix,
59
# and the targets generated are listed in a variable by that name.
60
#
61
# The list of all source files is returned in $1_SOURCES.
62
#
63
# Remaining parameters are named arguments. These include:
64
#   SRC     : Source root dir (defaults to dir of first file)
65
#   DEST    : Dest root dir
66
#   FILES   : List of files to copy with absolute paths, or path relative to SRC.
67
#             Must be in SRC.
68
#   FLATTEN : Set to flatten the directory structure in the DEST dir.
69
#   MACRO   : Optionally override the default macro used for making the copy.
70
#             Default is 'install-file'
71
#   NAME_MACRO : Optionally supply a macro that rewrites the target file name
72
#                based on the source file name
73
#   LOG_ACTION : Optionally specify a different action text for log messages
74
SetupCopyFiles = $(NamedParamsMacroTemplate)
75
define SetupCopyFilesBody
76

77
  ifeq ($$($1_MACRO), )
78
    $1_MACRO := install-file
79
  endif
80

81
  # Default SRC to the dir of the first file.
82
  ifeq ($$($1_SRC), )
83
    $1_SRC := $$(dir $$(firstword $$($1_FILES)))
84
  endif
85

86
  ifeq ($$($1_NAME_MACRO), )
87
    $1_NAME_MACRO := identity
88
  endif
89

90
  ifeq ($$($1_LOG_ACTION), )
91
    $1_LOG_ACTION := Copying
92
  endif
93

94
  # Remove any trailing slash from SRC and DEST
95
  $1_SRC := $$(patsubst %/,%,$$($1_SRC))
96
  $1_DEST := $$(patsubst %/,%,$$($1_DEST))
97

98
  # Need to wrap arguments in DoubleDollar because of the eval nested inside an
99
  # eval macro body.
100
  $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
101
    $$(eval $$(call AddFileToCopy, \
102
        $$(call DoubleDollar, $$($1_SRC)/$$f), \
103
        $$(call DoubleDollar, \
104
            $$($1_DEST)/$$(call $$(strip $$($1_NAME_MACRO)),$$(if $$($1_FLATTEN),$$(notdir $$f),$$f)) \
105
        ), \
106
        $1, \
107
        $$($1_MACRO), \
108
        $$($1_LOG_ACTION) \
109
    )) \
110
  )
111

112
endef
113

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.