annotate nashorn/makefiles/BuildNashorn.gmk @ 16198:1cfb1fbab2dc

8006676: Integrate Nashorn into new build system Reviewed-by: jlaskey Contributed-by: james.laskey@oracle.com
author jlaskey
date Mon, 28 Jan 2013 16:22:03 -0400
parents
children 1c54dc374fe4
rev   line source
jlaskey@16198 1 #
jlaskey@16198 2 # Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
jlaskey@16198 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jlaskey@16198 4 #
jlaskey@16198 5 # This code is free software; you can redistribute it and/or modify it
jlaskey@16198 6 # under the terms of the GNU General Public License version 2 only, as
jlaskey@16198 7 # published by the Free Software Foundation. Oracle designates this
jlaskey@16198 8 # particular file as subject to the "Classpath" exception as provided
jlaskey@16198 9 # by Oracle in the LICENSE file that accompanied this code.
jlaskey@16198 10 #
jlaskey@16198 11 # This code is distributed in the hope that it will be useful, but WITHOUT
jlaskey@16198 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jlaskey@16198 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jlaskey@16198 14 # version 2 for more details (a copy is included in the LICENSE file that
jlaskey@16198 15 # accompanied this code).
jlaskey@16198 16 #
jlaskey@16198 17 # You should have received a copy of the GNU General Public License version
jlaskey@16198 18 # 2 along with this work; if not, write to the Free Software Foundation,
jlaskey@16198 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jlaskey@16198 20 #
jlaskey@16198 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jlaskey@16198 22 # or visit www.oracle.com if you need additional information or have any
jlaskey@16198 23 # questions.
jlaskey@16198 24 #
jlaskey@16198 25
jlaskey@16198 26 # This must be the first rule
jlaskey@16198 27 default: all
jlaskey@16198 28
jlaskey@16198 29 -include $(SPEC)
jlaskey@16198 30 include MakeBase.gmk
jlaskey@16198 31 include JavaCompilation.gmk
jlaskey@16198 32
jlaskey@16198 33 # TODO: build-infra, move this to SPEC
jlaskey@16198 34 JAVAC_JARS ?= "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
jlaskey@16198 35 -jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
jlaskey@16198 36
jlaskey@16198 37 JDK_CLASSES := $(JDK_OUTPUTDIR)/classes
jlaskey@16198 38 # TODO: Remove dependency?
jlaskey@16198 39 DYNALINK_JAR := $(NASHORN_TOPDIR)/build/dynalink/dynalink.jar
jlaskey@16198 40
jlaskey@16198 41 NASHORN_JAR := $(NASHORN_DIST)/nashorn.jar
jlaskey@16198 42 NASHORN_VERSION := 0.1
jlaskey@16198 43
jlaskey@16198 44 # Need to use source and target 7 for nasgen to work.
jlaskey@16198 45 $(eval $(call SetupJavaCompiler,COMPILER_SETUP,\
jlaskey@16198 46 JVM:=$(JAVA),\
jlaskey@16198 47 JAVAC:=$(JAVAC_JARS),\
jlaskey@16198 48 FLAGS:=-g -source 7 -target 7 -bootclasspath $(JDK_CLASSES),\
jlaskey@16198 49 SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
jlaskey@16198 50 SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
jlaskey@16198 51
jlaskey@16198 52 # Build nashorn into intermediate directory
jlaskey@16198 53 $(eval $(call SetupJavaCompilation,BUILD_NASHORN,\
jlaskey@16198 54 SETUP:=COMPILER_SETUP,\
jlaskey@16198 55 SRC:=$(NASHORN_TOPDIR)/src,\
jlaskey@16198 56 COPY:=.properties .js,\
jlaskey@16198 57 BIN:=$(NASHORN_OUTPUTDIR)/nashorn_classes,\
jlaskey@16198 58 ADD_JAVAC_FLAGS:=-cp $(DYNALINK_JAR)))
jlaskey@16198 59
jlaskey@16198 60 # Build nasgen
jlaskey@16198 61 $(eval $(call SetupJavaCompilation,BUILD_NASGEN,\
jlaskey@16198 62 SETUP:=COMPILER_SETUP,\
jlaskey@16198 63 SRC:=$(NASHORN_TOPDIR)/buildtools/nasgen/src,\
jlaskey@16198 64 BIN:=$(NASHORN_OUTPUTDIR)/nasgen_classes,\
jlaskey@16198 65 ADD_JAVAC_FLAGS:=-cp $(NASHORN_OUTPUTDIR)/nashorn_classes))
jlaskey@16198 66
jlaskey@16198 67 # Nasgen needs nashorn classes
jlaskey@16198 68 $(BUILD_NASGEN): $(BUILD_NASHORN)
jlaskey@16198 69
jlaskey@16198 70 # Copy classes to final classes dir and run nasgen to modify classes in jdk.nashorn.internal.objects package
jlaskey@16198 71 # Finally rename classes in jdk.nashorn.internal.objects package
jlaskey@16198 72 $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run: $(BUILD_NASGEN)
jlaskey@16198 73 $(ECHO) Running nasgen
jlaskey@16198 74 $(MKDIR) -p $(@D)
jlaskey@16198 75 $(RM) -rf $(@D)/jdk $(@D)/netscape
jlaskey@16198 76 $(CP) -R -p $(NASHORN_OUTPUTDIR)/nashorn_classes/* $(@D)/
jlaskey@16198 77 $(JDK_OUTPUTDIR)/bin/java \
jlaskey@16198 78 -cp $(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes \
jlaskey@16198 79 jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
jlaskey@16198 80 for f in `$(FIND) $(@D)/jdk/nashorn/internal/objects/ -name "*.class"`; do \
jlaskey@16198 81 mv "$$f" `$(ECHO) "$$f" | $(SED) "s/\.class$$/\.clazz/"`; \
jlaskey@16198 82 done
jlaskey@16198 83 $(TOUCH) $@
jlaskey@16198 84
jlaskey@16198 85 # Unpack dynalink.jar for inclusion in nashorn.jar
jlaskey@16198 86 $(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked: $(DYNALINK_JAR)
jlaskey@16198 87 $(ECHO) Unpacking dynalink.jar
jlaskey@16198 88 $(MKDIR) -p $(@D)
jlaskey@16198 89 $(RM) -rf $(@D)/org
jlaskey@16198 90 $(UNZIP) -q $(DYNALINK_JAR) -x "META-INF*" -d $(@D)
jlaskey@16198 91 $(TOUCH) $@
jlaskey@16198 92
jlaskey@16198 93 # Version file needs to be processed with version numbers
jlaskey@16198 94 VERSION_FILE := $(NASHORN_OUTPUTDIR)/classes/jdk/nashorn/internal/runtime/resources/version.properties
jlaskey@16198 95 # Needs to happen after nasgen run since nasgen run deletes it
jlaskey@16198 96 $(VERSION_FILE): $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run
jlaskey@16198 97 $(VERSION_FILE): $(NASHORN_TOPDIR)/src/jdk/nashorn/internal/runtime/resources/version.properties-template
jlaskey@16198 98 $(ECHO) Creating version.properties
jlaskey@16198 99 $(MKDIR) -p $(@D)
jlaskey@16198 100 $(CAT) $< | $(SED) -e 's/$$(FULL_VERSION)/$(NASHORN_VERSION)/g' \
jlaskey@16198 101 -e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \
jlaskey@16198 102 -e '/^#.*$$/d' -e '/^$$/d' > $@
jlaskey@16198 103
jlaskey@16198 104
jlaskey@16198 105 MANIFEST_ATTRIBUTES:=Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_VERSION)
jlaskey@16198 106
jlaskey@16198 107 # Create nashorn.jar from the final classes dir
jlaskey@16198 108 $(eval $(call SetupArchive,BUILD_NASHORN_JAR,\
jlaskey@16198 109 $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run \
jlaskey@16198 110 $(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked \
jlaskey@16198 111 $(VERSION_FILE),\
jlaskey@16198 112 SRCS:=$(NASHORN_OUTPUTDIR)/classes,\
jlaskey@16198 113 SUFFIXES:=.class .clazz .js .properties Factory,\
jlaskey@16198 114 MANIFEST:=$(NASHORN_TOPDIR)/src/META-INF/MANIFEST.MF,\
jlaskey@16198 115 EXTRA_MANIFEST_ATTR:=$(MANIFEST_ATTRIBUTES),\
jlaskey@16198 116 SKIP_METAINF:=true,\
jlaskey@16198 117 JAR:=$(NASHORN_JAR)))
jlaskey@16198 118
jlaskey@16198 119 all: $(NASHORN_JAR)
jlaskey@16198 120
jlaskey@16198 121 .PHONY: all