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