1 #
   2 # Copyright (c) 2010, 2015, 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 
  26 # This must be the first rule
  27 default: all
  28 
  29 -include $(SPEC)
  30 include MakeBase.gmk
  31 include JarArchive.gmk
  32 include JavaCompilation.gmk
  33 include SetupJavaCompilers.gmk
  34 include TextFileProcessing.gmk
  35 
  36 JDK_CLASSES := $(call PathList, $(strip $(addprefix $(JDK_OUTPUTDIR)/modules/, \
  37       java.base java.logging java.scripting jdk.dynalink)))
  38 
  39 NASHORN_JAR := $(IMAGES_OUTPUTDIR)/nashorn.jar
  40 
  41 MODULESOURCEPATH := $(NASHORN_TOPDIR)/src/*/share/classes
  42 
  43 # Need to use source and target 8 for nasgen to work.
  44 $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE_DEBUG, \
  45     JVM := $(JAVA), \
  46     JAVAC := $(NEW_JAVAC), \
  47     FLAGS := -g -source 9 -target 9 -upgrademodulepath "$(JDK_OUTPUTDIR)/modules/" \
  48          -system none -modulesourcepath "$(MODULESOURCEPATH)", \
  49     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
  50     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
  51 
  52 # Build nashorn into intermediate directory
  53 # Name the compilation setup the same as the module, as is done in the global
  54 # CompileJavaModules.gmk, to make dependency checking with other modules work
  55 # seamlessly.
  56 $(eval $(call SetupJavaCompilation,jdk.scripting.nashorn, \
  57     SETUP := GENERATE_NEWBYTECODE_DEBUG, \
  58     MODULE := jdk.scripting.nashorn, \
  59     SRC := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes, \
  60     EXCLUDE_FILES := META-INF/MANIFEST.MF, \
  61     COPY := .properties .js, \
  62     BIN := $(SUPPORT_OUTPUTDIR)/special_classes))
  63 
  64 NASGEN_SRC := $(NASHORN_TOPDIR)/buildtools/nasgen/src
  65 ASM_SRC := $(JDK_TOPDIR)/src/java.base/share/classes/jdk/internal/org/objectweb/asm
  66 
  67 # Build nasgen
  68 $(eval $(call SetupJavaCompilation,BUILD_NASGEN, \
  69     SETUP := GENERATE_OLDBYTECODE, \
  70     SRC := $(NASGEN_SRC) $(ASM_SRC), \
  71     BIN := $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes))
  72 
  73 NASHORN_CLASSES_DIR := $(JDK_OUTPUTDIR)/modules/jdk.scripting.nashorn
  74 NASGEN_RUN_FILE := $(NASHORN_CLASSES_DIR)/_the.nasgen.run
  75 
  76 ifeq ($(BOOT_JDK_MODULAR), true)
  77   NASGEN_OPTIONS := \
  78       -cp $(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
  79       -Xpatch:java.base=$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes \
  80       -XaddExports:java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \
  81       -XaddExports:java.base/jdk.internal.org.objectweb.asm.util=ALL-UNNAMED \
  82       #
  83 else
  84   NASGEN_OPTIONS := \
  85       -Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/nasgen_classes
  86 endif
  87 
  88 # Copy classes to final classes dir and run nasgen to modify classes in jdk.nashorn.internal.objects package
  89 $(NASGEN_RUN_FILE): $(BUILD_NASGEN) $(jdk.scripting.nashorn)
  90         $(ECHO) Running nasgen
  91         $(MKDIR) -p $(@D)
  92         $(RM) -rf $(@D)/jdk $(@D)/netscape
  93         $(CP) -R -p $(SUPPORT_OUTPUTDIR)/special_classes/jdk.scripting.nashorn/* $(@D)/
  94         $(JAVA) $(NASGEN_OPTIONS) \
  95             jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
  96         $(TOUCH) $@
  97 
  98 # Version file needs to be processed with version numbers
  99 $(eval $(call SetupTextFileProcessing, BUILD_VERSION_FILE, \
 100   SOURCE_FILES := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/version.properties.template, \
 101   OUTPUT_FILE := $(JDK_OUTPUTDIR)/modules/jdk.scripting.nashorn/jdk/nashorn/internal/runtime/resources/version.properties, \
 102   REPLACEMENTS := \
 103       @@VERSION_STRING@@ => $(VERSION_STRING) ; \
 104       @@VERSION_SHORT@@ => $(VERSION_SHORT) , \
 105 ))
 106 
 107 # Version processing needs to happen after nasgen run since nasgen run deletes it
 108 $(BUILD_VERSION_FILE): $(NASGEN_RUN_FILE)
 109 
 110 
 111 MANIFEST_ATTRIBUTES := Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(VERSION_SHORT)
 112 
 113 # Create nashorn.jar from the final classes dir
 114 $(eval $(call SetupJarArchive,BUILD_NASHORN_JAR, \
 115     DEPENDENCIES := $(NASGEN_RUN_FILE) $(BUILD_VERSION_FILE), \
 116     SRCS := $(NASHORN_CLASSES_DIR), \
 117     SUFFIXES := .class .js .properties Factory, \
 118     MANIFEST := $(NASHORN_TOPDIR)/src/jdk.scripting.nashorn/share/classes/META-INF/MANIFEST.MF, \
 119     EXTRA_MANIFEST_ATTR := $(MANIFEST_ATTRIBUTES), \
 120     SKIP_METAINF := true, \
 121     JAR := $(NASHORN_JAR), \
 122 ))
 123 
 124 compile: $(NASHORN_RUN_FILE) $(BUILD_VERSION_FILE)
 125 all: $(NASHORN_JAR)
 126 
 127 .PHONY: compile all