Mon, 28 Jan 2013 16:22:03 -0400
8006676: Integrate Nashorn into new build system
Reviewed-by: jlaskey
Contributed-by: james.laskey@oracle.com
1 #
2 # Copyright (c) 2010, 2013, 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 #
26 # This must be the first rule
27 default: all
29 -include $(SPEC)
30 include MakeBase.gmk
31 include JavaCompilation.gmk
33 # TODO: build-infra, move this to SPEC
34 JAVAC_JARS ?= "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
35 -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
37 JDK_CLASSES := $(JDK_OUTPUTDIR)/classes
38 # TODO: Remove dependency?
39 DYNALINK_JAR := $(NASHORN_TOPDIR)/build/dynalink/dynalink.jar
41 NASHORN_JAR := $(NASHORN_DIST)/nashorn.jar
42 NASHORN_VERSION := 0.1
44 # Need to use source and target 7 for nasgen to work.
45 $(eval $(call SetupJavaCompiler,COMPILER_SETUP,\
46 JVM:=$(JAVA),\
47 JAVAC:=$(JAVAC_JARS),\
48 FLAGS:=-g -source 7 -target 7 -bootclasspath $(JDK_CLASSES),\
49 SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
50 SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
52 # Build nashorn into intermediate directory
53 $(eval $(call SetupJavaCompilation,BUILD_NASHORN,\
54 SETUP:=COMPILER_SETUP,\
55 SRC:=$(NASHORN_TOPDIR)/src,\
56 COPY:=.properties .js,\
57 BIN:=$(NASHORN_OUTPUTDIR)/nashorn_classes,\
58 ADD_JAVAC_FLAGS:=-cp $(DYNALINK_JAR)))
60 # Build nasgen
61 $(eval $(call SetupJavaCompilation,BUILD_NASGEN,\
62 SETUP:=COMPILER_SETUP,\
63 SRC:=$(NASHORN_TOPDIR)/buildtools/nasgen/src,\
64 BIN:=$(NASHORN_OUTPUTDIR)/nasgen_classes,\
65 ADD_JAVAC_FLAGS:=-cp $(NASHORN_OUTPUTDIR)/nashorn_classes))
67 # Nasgen needs nashorn classes
68 $(BUILD_NASGEN): $(BUILD_NASHORN)
70 # Copy classes to final classes dir and run nasgen to modify classes in jdk.nashorn.internal.objects package
71 # Finally rename classes in jdk.nashorn.internal.objects package
72 $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run: $(BUILD_NASGEN)
73 $(ECHO) Running nasgen
74 $(MKDIR) -p $(@D)
75 $(RM) -rf $(@D)/jdk $(@D)/netscape
76 $(CP) -R -p $(NASHORN_OUTPUTDIR)/nashorn_classes/* $(@D)/
77 $(JDK_OUTPUTDIR)/bin/java \
78 -cp $(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes \
79 jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
80 for f in `$(FIND) $(@D)/jdk/nashorn/internal/objects/ -name "*.class"`; do \
81 mv "$$f" `$(ECHO) "$$f" | $(SED) "s/\.class$$/\.clazz/"`; \
82 done
83 $(TOUCH) $@
85 # Unpack dynalink.jar for inclusion in nashorn.jar
86 $(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked: $(DYNALINK_JAR)
87 $(ECHO) Unpacking dynalink.jar
88 $(MKDIR) -p $(@D)
89 $(RM) -rf $(@D)/org
90 $(UNZIP) -q $(DYNALINK_JAR) -x "META-INF*" -d $(@D)
91 $(TOUCH) $@
93 # Version file needs to be processed with version numbers
94 VERSION_FILE := $(NASHORN_OUTPUTDIR)/classes/jdk/nashorn/internal/runtime/resources/version.properties
95 # Needs to happen after nasgen run since nasgen run deletes it
96 $(VERSION_FILE): $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run
97 $(VERSION_FILE): $(NASHORN_TOPDIR)/src/jdk/nashorn/internal/runtime/resources/version.properties-template
98 $(ECHO) Creating version.properties
99 $(MKDIR) -p $(@D)
100 $(CAT) $< | $(SED) -e 's/$$(FULL_VERSION)/$(NASHORN_VERSION)/g' \
101 -e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \
102 -e '/^#.*$$/d' -e '/^$$/d' > $@
105 MANIFEST_ATTRIBUTES:=Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_VERSION)
107 # Create nashorn.jar from the final classes dir
108 $(eval $(call SetupArchive,BUILD_NASHORN_JAR,\
109 $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run \
110 $(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked \
111 $(VERSION_FILE),\
112 SRCS:=$(NASHORN_OUTPUTDIR)/classes,\
113 SUFFIXES:=.class .clazz .js .properties Factory,\
114 MANIFEST:=$(NASHORN_TOPDIR)/src/META-INF/MANIFEST.MF,\
115 EXTRA_MANIFEST_ATTR:=$(MANIFEST_ATTRIBUTES),\
116 SKIP_METAINF:=true,\
117 JAR:=$(NASHORN_JAR)))
119 all: $(NASHORN_JAR)
121 .PHONY: all