Bundles.gmk revision 2114:136eeb1d238b
1# 2# Copyright (c) 2016, 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 26default: all 27 28include $(SPEC) 29include MakeBase.gmk 30 31PRODUCT_TARGETS := 32TEST_TARGETS := 33DOCS_TARGETS := 34 35# On Windows tar frequently complains that "file changed as we read it" for 36# some random source files. This seems to be cause by anti virus scanners and 37# is most likely safe to ignore. When it happens, tar returns '1'. 38ifeq ($(OPENJDK_BUILD_OS), windows) 39 TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1" 40endif 41 42# Hook to include the corresponding custom file, if present. 43$(eval $(call IncludeCustomExtension, , Bundles-pre.gmk)) 44################################################################################ 45# BUNDLE : Name of bundle to create 46# FILES : Files in BASE_DIR to add to bundle 47# SPECIAL_INCLUDES : List of directories inside BASE_DIR to look for additional 48# files in. These files will not get proper dependency handling. Use when 49# files or directories may contain spaces. 50# BASE_DIR : Base directory for the root dir in the bundle. 51# SUBDIR : Optional name of root dir in bundle. 52SetupBundleFile = $(NamedParamsMacroTemplate) 53define SetupBundleFileBody 54 55 $1_RELATIVE_FILES := $$(patsubst $$($1_BASE_DIR)/%, ./%, $$($1_FILES)) 56 57 ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), ) 58 $1_TYPE := tar.gz 59 else ifneq ($$(filter %.zip, $$($1_BUNDLE_NAME)), ) 60 $1_TYPE := zip 61 else 62 $$(error Unknown bundle type $$($1_BUNDLE_NAME)) 63 endif 64 65 $$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false) 66 67 $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES) 68 $$(eval $$(call ListPathsSafely, \ 69 $1_RELATIVE_FILES, \ 70 $(SUPPORT_OUTPUTDIR)/bundles/_$1_files)) 71 $$(call MakeDir, $$(@D)) 72 ifneq ($$($1_SPECIAL_INCLUDES), ) 73 $$(foreach i, $$($1_SPECIAL_INCLUDES), \ 74 ($(CD) $$($1_BASE_DIR) && $(FIND) ./$$i \ 75 >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; ) 76 endif 77 ifneq ($$($1_SUBDIR), ) 78 ifeq ($$($1_TYPE)-$(TAR_SUPPORTS_TRANSFORM)-$$($1_UNZIP_DEBUGINFO), tar.gz-true-false) 79 $(CD) $$($1_BASE_DIR) \ 80 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 81 -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ 82 --transform 's|^|$$($1_SUBDIR)/|' $(TAR_IGNORE_EXIT_VALUE) ) \ 83 | $(GZIP) > $$@ 84 else 85 # If a subdir has been specified, copy all files into a temporary 86 # location with this subdir before creating the tar file 87 $(RM) -r $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 88 $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 89 ( $(CD) $$($1_BASE_DIR) \ 90 && $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ 91 $(TAR_IGNORE_EXIT_VALUE) ) \ 92 | ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - ) 93 # Unzip any zipped debuginfo files 94 ifeq ($$($1_UNZIP_DEBUGINFO), true) 95 for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \ 96 $(CD) $$$${f%/*} && $(UNZIP) -q $$$${f} && $(RM) $$$${f}; \ 97 done 98 endif 99 ifeq ($$($1_TYPE), tar.gz) 100 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && \ 101 ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) $$($1_SUBDIR) $(TAR_IGNORE_EXIT_VALUE) ) \ 102 | $(GZIP) > $$@ 103 else ifeq ($$($1_TYPE), zip) 104 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIP) -qr $$@ . 105 endif 106 endif 107 else 108 ifeq ($$($1_TYPE), tar.gz) 109 $(CD) $$($1_BASE_DIR) \ 110 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 111 -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ 112 $(TAR_IGNORE_EXIT_VALUE) ) \ 113 | $(GZIP) > $$@ 114 else ifeq ($$($1_TYPE), zip) 115 $(CD) $$($1_BASE_DIR) \ 116 && $(ZIP) -qr $$@ . -i@$(SUPPORT_OUTPUTDIR)/bundles/_$1_files 117 endif 118 endif 119 120 $1 += $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME) 121 122endef 123 124################################################################################ 125 126# On Macosx, we bundle up the macosx specific images which already have the 127# correct base directories. 128ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) 129 JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) 130 JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR) 131 JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home 132 JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home 133 JDK_BUNDLE_SUBDIR := 134 JRE_BUNDLE_SUBDIR := 135else 136 JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR) 137 JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR) 138 JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER) 139 JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER) 140 ifneq ($(DEBUG_LEVEL), release) 141 JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 142 JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 143 endif 144endif 145 146################################################################################ 147 148ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) 149 $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR))) 150 151 SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map 152 153 ALL_JDK_FILES := $(call CacheFind, $(JDK_IMAGE_DIR)) 154 155 # Create special filter rules when dealing with unzipped .dSYM directories on 156 # macosx 157 ifeq ($(OPENJDK_TARGET_OS), macosx) 158 ifeq ($(ZIP_DEBUGINFO_FILES), false) 159 JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 160 $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES)))) 161 endif 162 endif 163 164 JDK_BUNDLE_FILES := \ 165 $(filter-out \ 166 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 167 $(JDK_EXTRA_EXCLUDES) \ 168 $(SYMBOLS_EXCLUDE_PATTERN) \ 169 $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ 170 , \ 171 $(ALL_JDK_FILES) \ 172 ) 173 DEMOS_BUNDLE_FILES := \ 174 $(filter-out \ 175 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 176 $(SYMBOLS_EXCLUDE_PATTERN) \ 177 , \ 178 $(filter \ 179 $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ 180 $(JDK_IMAGE_HOMEDIR)/release \ 181 , \ 182 $(ALL_JDK_FILES) \ 183 ) \ 184 ) 185 JDK_SYMBOLS_BUNDLE_FILES := \ 186 $(filter \ 187 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 188 $(SYMBOLS_EXCLUDE_PATTERN) \ 189 , \ 190 $(ALL_JDK_FILES) \ 191 ) \ 192 $(call CacheFind, $(SYMBOLS_IMAGE_DIR)) 193 194 ALL_JRE_FILES := $(call CacheFind, $(JRE_IMAGE_DIR)) 195 196 # Create special filter rules when dealing with unzipped .dSYM directories on 197 # macosx 198 ifeq ($(OPENJDK_TARGET_OS), macosx) 199 ifeq ($(ZIP_DEBUGINFO_FILES), false) 200 JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 201 $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES)))) 202 endif 203 endif 204 205 JRE_BUNDLE_FILES := $(filter-out \ 206 $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ 207 $(SYMBOLS_EXCLUDE_PATTERN), \ 208 $(ALL_JRE_FILES)) 209 JRE_SYMBOLS_BUNDLE_FILES := $(filter \ 210 $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ 211 $(SYMBOLS_EXCLUDE_PATTERN), \ 212 $(ALL_JRE_FILES)) 213 214 $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \ 215 BUNDLE_NAME := $(JDK_BUNDLE_NAME), \ 216 FILES := $(JDK_BUNDLE_FILES), \ 217 SPECIAL_INCLUDES := $(JDK_SPECIAL_INCLUDES), \ 218 BASE_DIR := $(JDK_IMAGE_DIR), \ 219 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 220 )) 221 222 PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE) 223 224 $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \ 225 BUNDLE_NAME := $(JRE_BUNDLE_NAME), \ 226 FILES := $(JRE_BUNDLE_FILES), \ 227 BASE_DIR := $(JRE_IMAGE_DIR), \ 228 SUBDIR := $(JRE_BUNDLE_SUBDIR), \ 229 )) 230 231 PRODUCT_TARGETS += $(BUILD_JRE_BUNDLE) 232 233 $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \ 234 BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \ 235 FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \ 236 BASE_DIR := $(JDK_IMAGE_DIR), \ 237 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 238 UNZIP_DEBUGINFO := true, \ 239 )) 240 241 PRODUCT_TARGETS += $(BUILD_JDK_SYMBOLS_BUNDLE) 242 243 $(eval $(call SetupBundleFile, BUILD_JRE_SYMBOLS_BUNDLE, \ 244 BUNDLE_NAME := $(JRE_SYMBOLS_BUNDLE_NAME), \ 245 FILES := $(JRE_SYMBOLS_BUNDLE_FILES), \ 246 BASE_DIR := $(JRE_IMAGE_DIR), \ 247 SUBDIR := $(JRE_BUNDLE_SUBDIR), \ 248 UNZIP_DEBUGINFO := true, \ 249 )) 250 251 PRODUCT_TARGETS += $(BUILD_JRE_SYMBOLS_BUNDLE) 252 253 $(eval $(call SetupBundleFile, BUILD_DEMOS_BUNDLE, \ 254 BUNDLE_NAME := $(DEMOS_BUNDLE_NAME), \ 255 FILES := $(call DoubleDollar, $(DEMOS_BUNDLE_FILES)), \ 256 BASE_DIR := $(JDK_IMAGE_DIR), \ 257 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 258 )) 259 260 PRODUCT_TARGETS += $(BUILD_DEMOS_BUNDLE) 261endif 262 263################################################################################ 264 265ifneq ($(filter test-bundles, $(MAKECMDGOALS)), ) 266 TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR)) 267 268 $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \ 269 BUNDLE_NAME := $(TEST_BUNDLE_NAME), \ 270 FILES := $(call DoubleDollar, $(TEST_BUNDLE_FILES)), \ 271 BASE_DIR := $(TEST_IMAGE_DIR), \ 272 )) 273 274 TEST_TARGETS += $(BUILD_TEST_BUNDLE) 275endif 276 277################################################################################ 278 279ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), ) 280 DOCS_BUNDLE_FILES := $(call CacheFind, $(DOCS_IMAGE_DIR)) 281 282 $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \ 283 BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \ 284 FILES := $(DOCS_BUNDLE_FILES), \ 285 BASE_DIR := $(DOCS_IMAGE_DIR), \ 286 SUBDIR := docs, \ 287 )) 288 289 DOCS_TARGETS += $(BUILD_DOCS_BUNDLE) 290endif 291 292################################################################################ 293 294# Hook to include the corresponding custom file, if present. 295$(eval $(call IncludeCustomExtension, , Bundles.gmk)) 296 297################################################################################ 298 299product-bundles: $(PRODUCT_TARGETS) 300test-bundles: $(TEST_TARGETS) 301docs-bundles: $(DOCS_TARGETS) 302 303.PHONY: all default product-bundles test-bundles docs-bundles 304