CreateJmods.gmk revision 2212:8b1d348ad6a2
1343171Sdim 2343171Sdim# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. 3353358Sdim# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4353358Sdim# 5353358Sdim# This code is free software; you can redistribute it and/or modify it 6343171Sdim# under the terms of the GNU General Public License version 2 only, as 7343171Sdim# published by the Free Software Foundation. Oracle designates this 8343171Sdim# particular file as subject to the "Classpath" exception as provided 9343171Sdim# by Oracle in the LICENSE file that accompanied this code. 10343171Sdim# 11343171Sdim# This code is distributed in the hope that it will be useful, but WITHOUT 12343171Sdim# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13343171Sdim# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14343171Sdim# version 2 for more details (a copy is included in the LICENSE file that 15343171Sdim# accompanied this code). 16343171Sdim# 17343171Sdim# You should have received a copy of the GNU General Public License version 18343171Sdim# 2 along with this work; if not, write to the Free Software Foundation, 19343171Sdim# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20343171Sdim# 21343171Sdim# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22343171Sdim# or visit www.oracle.com if you need additional information or have any 23343171Sdim# questions. 24343171Sdim# 25343171Sdim 26343171Sdimdefault: all 27343171Sdim 28343171Sdiminclude $(SPEC) 29343171Sdiminclude MakeBase.gmk 30343171Sdiminclude Modules.gmk 31343171Sdim 32343171Sdimifeq ($(MODULE), ) 33343171Sdim $(error MODULE must be set when calling CreateJmods.gmk) 34343171Sdimendif 35343171Sdim 36343171Sdim################################################################################ 37343171Sdim 38343171SdimJMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods 39343171Sdim 40343171SdimLIBS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 41343171Sdim $(SUPPORT_OUTPUTDIR)/modules_libs-stripped $(IMPORT_MODULES_LIBS)))) 42343171SdimCMDS_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 43 $(SUPPORT_OUTPUTDIR)/modules_cmds-stripped $(IMPORT_MODULES_CMDS)))) 44CONF_DIR := $(firstword $(wildcard $(addsuffix /$(MODULE), \ 45 $(SUPPORT_OUTPUTDIR)/modules_conf $(IMPORT_MODULES_CONF)))) 46CLASSES_DIR := $(wildcard $(JDK_OUTPUTDIR)/modules/$(MODULE)) 47 48$(eval $(call FillCacheFind, \ 49 $(LIBS_DIR) $(CMDS_DIR) $(CONF_DIR) $(CLASSES_DIR) \ 50)) 51 52ifneq ($(LIBS_DIR), ) 53 JMOD_FLAGS += --libs $(LIBS_DIR) 54 DEPS += $(call CacheFind, $(LIBS_DIR)) 55endif 56ifneq ($(CMDS_DIR), ) 57 JMOD_FLAGS += --cmds $(CMDS_DIR) 58 DEPS += $(call CacheFind, $(CMDS_DIR)) 59endif 60ifneq ($(CONF_DIR), ) 61 JMOD_FLAGS += --config $(CONF_DIR) 62 DEPS += $(call CacheFind, $(CONF_DIR)) 63endif 64ifneq ($(CLASSES_DIR), ) 65 JMOD_FLAGS += --class-path $(CLASSES_DIR) 66 DEPS += $(call CacheFind, $(CLASSES_DIR)) 67endif 68 69# Add dependencies on other jmod files. Only java.base needs access to other 70# jmods. 71ifeq ($(MODULE), java.base) 72 ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules) 73 # When creating a BUILDJDK, we don't need to add hashes to java.base 74 ifneq ($(CREATING_BUILDJDK), true) 75 DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \ 76 $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules))) 77 78 EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES)))) 79 80 JMOD_FLAGS += --module-path $(JMODS_DIR) \ 81 --hash-modules '^(?!$(EXCLUDE_PATTERN))' 82 endif 83endif 84 85# Changes to the jmod tool itself should also trigger a rebuild of all jmods. 86# The variable JMOD_CMD could contain an environment variable assignment before 87# the actual command. Filter that out using wildcard before adding to DEPS. 88DEPS += $(wildcard $(JMOD_CMD)) 89ifeq ($(EXTERNAL_BUILDJDK), false) 90 DEPS += $(call CacheFind, $(JDK_OUTPUTDIR)/modules/jdk.jlink/jdk/tools/jmod) 91endif 92 93# TODO: What about headers? 94# Create jmods in a temp dir and then move them into place to keep the 95# module path in $(IMAGES_OUTPUTDIR)/jmods valid at all times. 96$(JMODS_DIR)/$(MODULE).jmod: $(DEPS) 97 $(call LogWarn, Creating $(patsubst $(OUTPUT_ROOT)/%, %, $@)) 98 $(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/jmods) 99 $(RM) $@ $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) 100 $(JMOD) create \ 101 --module-version $(VERSION_SHORT) \ 102 --os-name $(REQUIRED_OS_NAME) \ 103 --os-arch $(OPENJDK_TARGET_CPU_LEGACY) \ 104 --os-version $(REQUIRED_OS_VERSION) \ 105 --module-path $(JMODS_DIR) \ 106 --exclude '**{_the.*,*.diz,*.debuginfo,*.dSYM/**,*.pdb,*.map}' \ 107 $(JMOD_FLAGS) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) 108 $(MV) $(SUPPORT_OUTPUTDIR)/jmods/$(notdir $@) $@ 109 110TARGETS += $(IMAGES_OUTPUTDIR)/jmods/$(MODULE).jmod 111 112################################################################################ 113 114all: $(TARGETS) 115 116################################################################################ 117