BuildNashorn.gmk revision 1415:330ddba6ffc4
1130803Smarcel# 2130803Smarcel# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3130803Smarcel# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4130803Smarcel# 5130803Smarcel# This code is free software; you can redistribute it and/or modify it 6130803Smarcel# under the terms of the GNU General Public License version 2 only, as 7130803Smarcel# published by the Free Software Foundation. Oracle designates this 8130803Smarcel# particular file as subject to the "Classpath" exception as provided 9130803Smarcel# by Oracle in the LICENSE file that accompanied this code. 10130803Smarcel# 11130803Smarcel# This code is distributed in the hope that it will be useful, but WITHOUT 12130803Smarcel# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13130803Smarcel# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14130803Smarcel# version 2 for more details (a copy is included in the LICENSE file that 15130803Smarcel# accompanied this code). 16130803Smarcel# 17130803Smarcel# You should have received a copy of the GNU General Public License version 18130803Smarcel# 2 along with this work; if not, write to the Free Software Foundation, 19130803Smarcel# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20130803Smarcel# 21130803Smarcel# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22130803Smarcel# or visit www.oracle.com if you need additional information or have any 23130803Smarcel# questions. 24130803Smarcel# 25130803Smarcel 26130803Smarcel# This must be the first rule 27130803Smarceldefault: all 28130803Smarcel 29130803Smarcel-include $(SPEC) 30130803Smarcelinclude MakeBase.gmk 31130803Smarcelinclude JavaCompilation.gmk 32130803Smarcelinclude SetupJavaCompilers.gmk 33130803Smarcel 34130803SmarcelJDK_CLASSES := $(call PathList, $(strip $(addprefix $(JDK_OUTPUTDIR)/modules/, \ 35130803Smarcel java.base java.logging java.scripting))) 36130803Smarcel 37130803SmarcelNASHORN_JAR := $(IMAGES_OUTPUTDIR)/nashorn.jar 38130803SmarcelNASHORN_VERSION := $(JDK_VERSION) 39130803SmarcelNASHORN_FULL_VERSION := $(FULL_VERSION) 40130803Smarcel 41130803Smarcelifdef MILESTONE 42130803Smarcel ifeq ($(MILESTONE), internal) 43130803Smarcel NASHORN_VERSION = $(FULL_VERSION) 44130803Smarcel endif 45130803Smarcelendif 46130803Smarcel 47130803Smarcel# Need to use source and target 8 for nasgen to work. 48130803Smarcel$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \ 49130803Smarcel JVM := $(JAVA), \ 50130803Smarcel JAVAC := $(NEW_JAVAC), \ 51130803Smarcel FLAGS := -g -source 8 -target 8 -bootclasspath $(JDK_CLASSES), \ 52130803Smarcel SERVER_DIR := $(SJAVAC_SERVER_DIR), \ 53130803Smarcel SERVER_JVM := $(SJAVAC_SERVER_JAVA))) 54130803Smarcel 55130803Smarcel# Build nashorn into intermediate directory 56130803Smarcel# Name the compilation setup the same as the module, as is done in the global 57130803Smarcel# CompileJavaModules.gmk, to make dependency checking with other modules work 58130803Smarcel# seamlessly. 59130803Smarcel$(eval $(call SetupJavaCompilation,jdk.scripting.nashorn, \ 60130803Smarcel SETUP := GENERATE_NEWBYTECODE_DEBUG, \ 61130803Smarcel SRC := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes, \ 62130803Smarcel EXCLUDE_FILES := META-INF/MANIFEST.MF, \ 63130803Smarcel COPY := .properties .js, \ 64130803Smarcel BIN := $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes)) 65130803Smarcel 66130803SmarcelNASGEN_SRC := $(NASHORN_TOPDIR)/buildtools/nasgen/src 67130803SmarcelASM_SRC := $(JDK_TOPDIR)/src/java.base/share/classes/jdk/internal/org/objectweb/asm 68130803Smarcel 69130803Smarcel# Build nasgen 70130803Smarcel$(eval $(call SetupJavaCompilation,BUILD_NASGEN, \ 71130803Smarcel SETUP := GENERATE_OLDBYTECODE, \ 72130803Smarcel SRC := $(NASGEN_SRC) $(ASM_SRC), \ 73130803Smarcel BIN := $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes, \ 74130803Smarcel ADD_JAVAC_FLAGS := -Xbootclasspath/p:"$(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes")) 75130803Smarcel 76130803Smarcel# Nasgen needs nashorn classes 77130803Smarcel$(BUILD_NASGEN): $(jdk.scripting.nashorn) 78130803Smarcel 79130803SmarcelNASHORN_CLASSES_DIR := $(JDK_OUTPUTDIR)/modules/jdk.scripting.nashorn 80130803SmarcelNASGEN_RUN_FILE := $(NASHORN_CLASSES_DIR)/_the.nasgen.run 81130803Smarcel 82130803Smarcel# Copy classes to final classes dir and run nasgen to modify classes in jdk.nashorn.internal.objects package 83130803Smarcel$(NASGEN_RUN_FILE): $(BUILD_NASGEN) 84130803Smarcel $(ECHO) Running nasgen 85130803Smarcel $(MKDIR) -p $(@D) 86130803Smarcel $(RM) -rf $(@D)/jdk $(@D)/netscape 87 $(CP) -R -p $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes/* $(@D)/ 88 $(FIXPATH) $(JAVA) \ 89 -Xbootclasspath/p:$(call PathList, $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \ 90 $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/classes) \ 91 jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D) 92 $(TOUCH) $@ 93 94# Version file needs to be processed with version numbers 95VERSION_FILE := $(JDK_OUTPUTDIR)/modules/jdk.scripting.nashorn/jdk/nashorn/internal/runtime/resources/version.properties 96VERSION_SRC := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/version.properties-template 97 98# Needs to happen after nasgen run since nasgen run deletes it 99$(VERSION_FILE): $(NASGEN_RUN_FILE) 100$(VERSION_FILE): $(VERSION_SRC) 101 $(ECHO) Creating version.properties 102 $(MKDIR) -p $(@D) 103 $(CAT) $< | $(SED) -e 's/$$(FULL_VERSION)/$(NASHORN_FULL_VERSION)/g' \ 104 -e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \ 105 -e '/^#.*$$/d' -e '/^$$/d' > $@ 106 107 108MANIFEST_ATTRIBUTES := Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_FULL_VERSION) 109 110# Create nashorn.jar from the final classes dir 111$(eval $(call SetupArchive,BUILD_NASHORN_JAR, \ 112 DEPENDENCIES := $(NASGEN_RUN_FILE) \ 113 $(VERSION_FILE), \ 114 SRCS := $(NASHORN_CLASSES_DIR), \ 115 SUFFIXES := .class .js .properties Factory, \ 116 MANIFEST := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes/META-INF/MANIFEST.MF, \ 117 EXTRA_MANIFEST_ATTR := $(MANIFEST_ATTRIBUTES), \ 118 SKIP_METAINF := true, \ 119 JAR := $(NASHORN_JAR))) 120 121compile: $(NASHORN_RUN_FILE) $(VERSION_FILE) 122all: $(NASHORN_JAR) 123 124.PHONY: compile all 125