Bundles.gmk revision 2428:4650659a4f55
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_DIRS to add to bundle 47# SPECIAL_INCLUDES : List of directories inside BASE_DIRS 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_DIRS : Base directories for the root dir in the bundle. 51# SUBDIR : Optional name of root dir in bundle. 52SetupBundleFile = $(NamedParamsMacroTemplate) 53define SetupBundleFileBody 54 55 $$(foreach d, $$($1_BASE_DIRS), \ 56 $$(eval $1_$$d_RELATIVE_FILES := $$$$(patsubst $$d/%, %, \ 57 $$$$(filter $$d/%, $$$$($1_FILES)))) \ 58 $$(eval $1_$$d_LIST_FILE := \ 59 $(SUPPORT_OUTPUTDIR)/bundles/_$1_$$$$(subst /,_,$$$$(patsubst $(TOPDIR)/%,%,$$d)_files)) \ 60 ) 61 62 ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), ) 63 $1_TYPE := tar.gz 64 else ifneq ($$(filter %.zip, $$($1_BUNDLE_NAME)), ) 65 $1_TYPE := zip 66 else 67 $$(error Unknown bundle type $$($1_BUNDLE_NAME)) 68 endif 69 70 $$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false) 71 72 $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES) 73 $$(foreach d, $$($1_BASE_DIRS), \ 74 $$(eval $$(call ListPathsSafely, \ 75 $1_$$d_RELATIVE_FILES, $$($1_$$d_LIST_FILE))) \ 76 ) 77 $$(call MakeDir, $$(@D)) 78 ifneq ($$($1_SPECIAL_INCLUDES), ) 79 $$(foreach i, $$($1_SPECIAL_INCLUDES), \ 80 $$(foreach d, $$d, \ 81 ($(CD) $$d && $(FIND) $$i \ 82 >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; )) 83 endif 84 ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO), .-zip-false) 85 # If no subdir is specified, zip can be done directly from BASE_DIRS. 86 $$(foreach d, $$($1_BASE_DIRS), \ 87 ( $(CD) $$d \ 88 && $(ZIPEXE) -qru $$@ . -i@$$($1_$$d_LIST_FILE) \ 89 || test "$$$$?" = "12" )$$(NEWLINE)) 90 else ifeq ($$($1_SUBDIR)-$$($1_TYPE)-$$($1_UNZIP_DEBUGINFO)-$$(words $$($1_BASE_DIRS)), \ 91 .-tar.gz-false-1) 92 # If no subdir is specified and only one BASE_DIR, tar.gz can be done 93 # directly from BASE_DIR. 94 $(CD) $$($1_BASE_DIRS) \ 95 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 96 -$(TAR_INCLUDE_PARAM) $$($1_$$($1_BASE_DIRS)_LIST_FILE) \ 97 $(TAR_IGNORE_EXIT_VALUE) ) \ 98 | $(GZIP) > $$@ 99 else ifeq ($$($1_TYPE)-$(TAR_SUPPORTS_TRANSFORM)-$$($1_UNZIP_DEBUGINFO)-$$(words $$($1_BASE_DIRS)), \ 100 tar.gz-true-false-1) 101 # If only one BASE_DIR, but with a SUBDIR set, tar.gz can use the 102 # transform option to create bundle directly from the BASE_DIR. 103 $(CD) $$($1_BASE_DIRS) \ 104 && ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 105 -$(TAR_INCLUDE_PARAM) $$($1_$$($1_BASE_DIRS)_LIST_FILE) \ 106 $$(if $$($1_SUBDIR), --transform 's|^|$$($1_SUBDIR)/|S') \ 107 $(TAR_IGNORE_EXIT_VALUE) ) \ 108 | $(GZIP) > $$@ 109 else 110 # In all other cases, need to copy all files into a temporary location 111 # before creation bundle. 112 $(RM) -r $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 113 $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) 114 $$(foreach d, $$($1_BASE_DIRS), \ 115 ( $(CD) $$d \ 116 && $(TAR) cf - -$(TAR_INCLUDE_PARAM) $$($1_$$d_LIST_FILE) \ 117 $(TAR_IGNORE_EXIT_VALUE) ) \ 118 | ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - )$$(NEWLINE) ) 119 # Unzip any zipped debuginfo files 120 ifeq ($$($1_UNZIP_DEBUGINFO), true) 121 for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \ 122 $(CD) $$$${f%/*} && $(UNZIP) -q $$$${f} && $(RM) $$$${f}; \ 123 done 124 endif 125 ifeq ($$($1_TYPE), tar.gz) 126 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && \ 127 ( $(TAR) cf - $(TAR_CREATE_EXTRA_PARAM) \ 128 $$(if $$($1_SUBDIR), $$($1_SUBDIR), .) $(TAR_IGNORE_EXIT_VALUE) ) \ 129 | $(GZIP) > $$@ 130 else ifeq ($$($1_TYPE), zip) 131 $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIPEXE) -qr $$@ . 132 endif 133 endif 134 135 $1 += $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME) 136 137endef 138 139################################################################################ 140 141# On Macosx, we bundle up the macosx specific images which already have the 142# correct base directories. 143ifeq ($(OPENJDK_TARGET_OS)-$(DEBUG_LEVEL), macosx-release) 144 JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) 145 JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR) 146 JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home 147 JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home 148 JDK_BUNDLE_SUBDIR := 149 JRE_BUNDLE_SUBDIR := 150else 151 JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR) 152 JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR) 153 JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER) 154 JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER) 155 JRE_COMPACT1_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact1 156 JRE_COMPACT2_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact2 157 JRE_COMPACT3_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER)-compact3 158 ifneq ($(DEBUG_LEVEL), release) 159 JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 160 JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) 161 endif 162endif 163 164################################################################################ 165 166ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) 167 $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR))) 168 169 SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map 170 171 ALL_JDK_FILES := $(call CacheFind, $(JDK_IMAGE_DIR)) 172 173 # Create special filter rules when dealing with unzipped .dSYM directories on 174 # macosx 175 ifeq ($(OPENJDK_TARGET_OS), macosx) 176 ifeq ($(ZIP_DEBUGINFO_FILES), false) 177 JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 178 $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES)))) 179 endif 180 endif 181 182 JDK_BUNDLE_FILES := \ 183 $(filter-out \ 184 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 185 $(JDK_EXTRA_EXCLUDES) \ 186 $(SYMBOLS_EXCLUDE_PATTERN) \ 187 $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ 188 , \ 189 $(ALL_JDK_FILES) \ 190 ) 191 DEMOS_BUNDLE_FILES := \ 192 $(filter-out \ 193 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 194 $(SYMBOLS_EXCLUDE_PATTERN) \ 195 , \ 196 $(filter \ 197 $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ 198 $(JDK_IMAGE_HOMEDIR)/release \ 199 , \ 200 $(ALL_JDK_FILES) \ 201 ) \ 202 ) 203 JDK_SYMBOLS_BUNDLE_FILES := \ 204 $(filter \ 205 $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ 206 $(SYMBOLS_EXCLUDE_PATTERN) \ 207 , \ 208 $(filter-out \ 209 $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ 210 , \ 211 $(ALL_JDK_FILES) \ 212 ) \ 213 ) \ 214 $(call CacheFind, $(SYMBOLS_IMAGE_DIR)) 215 216 ALL_JRE_FILES := $(call CacheFind, $(JRE_IMAGE_DIR)) 217 218 # Create special filter rules when dealing with unzipped .dSYM directories on 219 # macosx 220 ifeq ($(OPENJDK_TARGET_OS), macosx) 221 ifeq ($(ZIP_DEBUGINFO_FILES), false) 222 JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ 223 $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES)))) 224 endif 225 endif 226 227 JRE_BUNDLE_FILES := $(filter-out \ 228 $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ 229 $(SYMBOLS_EXCLUDE_PATTERN), \ 230 $(ALL_JRE_FILES)) 231 JRE_SYMBOLS_BUNDLE_FILES := $(filter \ 232 $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ 233 $(SYMBOLS_EXCLUDE_PATTERN), \ 234 $(ALL_JRE_FILES)) 235 236 $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \ 237 BUNDLE_NAME := $(JDK_BUNDLE_NAME), \ 238 FILES := $(JDK_BUNDLE_FILES), \ 239 SPECIAL_INCLUDES := $(JDK_SPECIAL_INCLUDES), \ 240 BASE_DIRS := $(JDK_IMAGE_DIR), \ 241 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 242 )) 243 244 PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE) 245 246 $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \ 247 BUNDLE_NAME := $(JRE_BUNDLE_NAME), \ 248 FILES := $(JRE_BUNDLE_FILES), \ 249 BASE_DIRS := $(JRE_IMAGE_DIR), \ 250 SUBDIR := $(JRE_BUNDLE_SUBDIR), \ 251 )) 252 253 PRODUCT_TARGETS += $(BUILD_JRE_BUNDLE) 254 255 $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \ 256 BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \ 257 FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \ 258 BASE_DIRS := $(JDK_IMAGE_DIR) $(wildcard $(SYMBOLS_IMAGE_DIR)), \ 259 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 260 UNZIP_DEBUGINFO := true, \ 261 )) 262 263 PRODUCT_TARGETS += $(BUILD_JDK_SYMBOLS_BUNDLE) 264 265 $(eval $(call SetupBundleFile, BUILD_JRE_SYMBOLS_BUNDLE, \ 266 BUNDLE_NAME := $(JRE_SYMBOLS_BUNDLE_NAME), \ 267 FILES := $(JRE_SYMBOLS_BUNDLE_FILES), \ 268 BASE_DIRS := $(JRE_IMAGE_DIR), \ 269 SUBDIR := $(JRE_BUNDLE_SUBDIR), \ 270 UNZIP_DEBUGINFO := true, \ 271 )) 272 273 PRODUCT_TARGETS += $(BUILD_JRE_SYMBOLS_BUNDLE) 274 275 $(eval $(call SetupBundleFile, BUILD_DEMOS_BUNDLE, \ 276 BUNDLE_NAME := $(DEMOS_BUNDLE_NAME), \ 277 FILES := $(DEMOS_BUNDLE_FILES), \ 278 BASE_DIRS := $(JDK_IMAGE_DIR), \ 279 SUBDIR := $(JDK_BUNDLE_SUBDIR), \ 280 )) 281 282 PRODUCT_TARGETS += $(BUILD_DEMOS_BUNDLE) 283endif 284 285################################################################################ 286 287ifneq ($(filter profiles-bundles, $(MAKECMDGOALS)), ) 288 ifeq ($(OPENJDK_TARGET_OS), macosx) 289 $(error Creating compact profiles bundles on macosx is unsupported) 290 endif 291 292 define GenerateCompactProfilesBundles 293 ALL_JRE_COMPACT$1_FILES := $$(call CacheFind, $$(JRE_COMPACT$1_IMAGE_DIR)) 294 295 JRE_COMPACT$1_BUNDLE_FILES := $$(filter-out \ 296 $$(SYMBOLS_EXCLUDE_PATTERN), \ 297 $$(ALL_JRE_COMPACT$1_FILES)) 298 299 $$(eval $$(call SetupBundleFile, BUILD_JRE_COMPACT$1_BUNDLE, \ 300 BUNDLE_NAME := $$(JRE_COMPACT$1_BUNDLE_NAME), \ 301 FILES := $$(JRE_COMPACT$1_BUNDLE_FILES), \ 302 BASE_DIRS := $$(JRE_COMPACT$1_IMAGE_DIR), \ 303 SUBDIR := $$(JRE_COMPACT$1_BUNDLE_SUBDIR), \ 304 )) 305 306 PROFILES_TARGETS += $$(BUILD_JRE_COMPACT$1_BUNDLE) 307 endef 308 309 $(eval $(call GenerateCompactProfilesBundles,1)) 310 $(eval $(call GenerateCompactProfilesBundles,2)) 311 $(eval $(call GenerateCompactProfilesBundles,3)) 312endif 313 314################################################################################ 315 316ifneq ($(filter test-bundles, $(MAKECMDGOALS)), ) 317 TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR)) 318 319 $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \ 320 BUNDLE_NAME := $(TEST_BUNDLE_NAME), \ 321 FILES := $(TEST_BUNDLE_FILES), \ 322 BASE_DIRS := $(TEST_IMAGE_DIR), \ 323 )) 324 325 TEST_TARGETS += $(BUILD_TEST_BUNDLE) 326endif 327 328################################################################################ 329 330ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), ) 331 DOCS_BUNDLE_FILES := $(call CacheFind, $(DOCS_IMAGE_DIR)) 332 333 $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \ 334 BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \ 335 FILES := $(DOCS_BUNDLE_FILES), \ 336 BASE_DIRS := $(DOCS_IMAGE_DIR), \ 337 SUBDIR := docs, \ 338 )) 339 340 DOCS_TARGETS += $(BUILD_DOCS_BUNDLE) 341endif 342 343################################################################################ 344 345# Hook to include the corresponding custom file, if present. 346$(eval $(call IncludeCustomExtension, , Bundles.gmk)) 347 348################################################################################ 349 350product-bundles: $(PRODUCT_TARGETS) 351profiles-bundles: $(PROFILES_TARGETS) 352test-bundles: $(TEST_TARGETS) 353docs-bundles: $(DOCS_TARGETS) 354 355.PHONY: all default product-bundles profiles-bundles test-bundles docs-bundles 356