makefiles/BuildNashorn.gmk

changeset 54
b6c69beebde6
child 56
755404d7d189
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/makefiles/BuildNashorn.gmk	Mon Jan 28 16:22:03 2013 -0400
     1.3 @@ -0,0 +1,121 @@
     1.4 +#
     1.5 +# Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 +#
     1.8 +# This code is free software; you can redistribute it and/or modify it
     1.9 +# under the terms of the GNU General Public License version 2 only, as
    1.10 +# published by the Free Software Foundation.  Oracle designates this
    1.11 +# particular file as subject to the "Classpath" exception as provided
    1.12 +# by Oracle in the LICENSE file that accompanied this code.
    1.13 +#
    1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 +# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 +# version 2 for more details (a copy is included in the LICENSE file that
    1.18 +# accompanied this code).
    1.19 +#
    1.20 +# You should have received a copy of the GNU General Public License version
    1.21 +# 2 along with this work; if not, write to the Free Software Foundation,
    1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 +#
    1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 +# or visit www.oracle.com if you need additional information or have any
    1.26 +# questions.
    1.27 +#
    1.28 +
    1.29 +# This must be the first rule
    1.30 +default: all
    1.31 +
    1.32 +-include $(SPEC)
    1.33 +include MakeBase.gmk
    1.34 +include JavaCompilation.gmk
    1.35 +
    1.36 +# TODO: build-infra, move this to SPEC
    1.37 +JAVAC_JARS ?= "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \
    1.38 +		-jar $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar
    1.39 +
    1.40 +JDK_CLASSES := $(JDK_OUTPUTDIR)/classes
    1.41 +# TODO: Remove dependency?
    1.42 +DYNALINK_JAR := $(NASHORN_TOPDIR)/build/dynalink/dynalink.jar
    1.43 +
    1.44 +NASHORN_JAR := $(NASHORN_DIST)/nashorn.jar
    1.45 +NASHORN_VERSION := 0.1
    1.46 +
    1.47 +# Need to use source and target 7 for nasgen to work.
    1.48 +$(eval $(call SetupJavaCompiler,COMPILER_SETUP,\
    1.49 +    JVM:=$(JAVA),\
    1.50 +    JAVAC:=$(JAVAC_JARS),\
    1.51 +    FLAGS:=-g -source 7 -target 7 -bootclasspath $(JDK_CLASSES),\
    1.52 +    SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
    1.53 +    SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
    1.54 +
    1.55 +# Build nashorn into intermediate directory
    1.56 +$(eval $(call SetupJavaCompilation,BUILD_NASHORN,\
    1.57 +    SETUP:=COMPILER_SETUP,\
    1.58 +    SRC:=$(NASHORN_TOPDIR)/src,\
    1.59 +    COPY:=.properties .js,\
    1.60 +    BIN:=$(NASHORN_OUTPUTDIR)/nashorn_classes,\
    1.61 +    ADD_JAVAC_FLAGS:=-cp $(DYNALINK_JAR)))
    1.62 +
    1.63 +# Build nasgen
    1.64 +$(eval $(call SetupJavaCompilation,BUILD_NASGEN,\
    1.65 +    SETUP:=COMPILER_SETUP,\
    1.66 +    SRC:=$(NASHORN_TOPDIR)/buildtools/nasgen/src,\
    1.67 +    BIN:=$(NASHORN_OUTPUTDIR)/nasgen_classes,\
    1.68 +    ADD_JAVAC_FLAGS:=-cp $(NASHORN_OUTPUTDIR)/nashorn_classes))
    1.69 +
    1.70 +# Nasgen needs nashorn classes
    1.71 +$(BUILD_NASGEN): $(BUILD_NASHORN)
    1.72 +
    1.73 +# Copy classes to final classes dir and run nasgen to modify classes in jdk.nashorn.internal.objects package
    1.74 +# Finally rename classes in jdk.nashorn.internal.objects package
    1.75 +$(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run: $(BUILD_NASGEN)
    1.76 +	$(ECHO) Running nasgen
    1.77 +	$(MKDIR) -p $(@D)
    1.78 +	$(RM) -rf $(@D)/jdk $(@D)/netscape
    1.79 +	$(CP) -R -p $(NASHORN_OUTPUTDIR)/nashorn_classes/* $(@D)/
    1.80 +	$(JDK_OUTPUTDIR)/bin/java \
    1.81 +		-cp $(NASHORN_OUTPUTDIR)/nasgen_classes$(PATH_SEP)$(NASHORN_OUTPUTDIR)/nashorn_classes \
    1.82 +		jdk.nashorn.internal.tools.nasgen.Main $(@D) jdk.nashorn.internal.objects $(@D)
    1.83 +	for f in `$(FIND) $(@D)/jdk/nashorn/internal/objects/ -name "*.class"`; do \
    1.84 +	  mv "$$f" `$(ECHO) "$$f" | $(SED) "s/\.class$$/\.clazz/"`; \
    1.85 +        done
    1.86 +	$(TOUCH) $@
    1.87 +
    1.88 +# Unpack dynalink.jar for inclusion in nashorn.jar
    1.89 +$(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked: $(DYNALINK_JAR)
    1.90 +	$(ECHO) Unpacking dynalink.jar
    1.91 +	$(MKDIR) -p $(@D)
    1.92 +	$(RM) -rf $(@D)/org
    1.93 +	$(UNZIP) -q $(DYNALINK_JAR) -x "META-INF*" -d $(@D)
    1.94 +	$(TOUCH) $@
    1.95 +
    1.96 +# Version file needs to be processed with version numbers
    1.97 +VERSION_FILE := $(NASHORN_OUTPUTDIR)/classes/jdk/nashorn/internal/runtime/resources/version.properties
    1.98 +# Needs to happen after nasgen run since nasgen run deletes it
    1.99 +$(VERSION_FILE): $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run
   1.100 +$(VERSION_FILE): $(NASHORN_TOPDIR)/src/jdk/nashorn/internal/runtime/resources/version.properties-template
   1.101 +	$(ECHO) Creating version.properties
   1.102 +	$(MKDIR) -p $(@D)
   1.103 +	$(CAT) $< | $(SED) -e 's/$$(FULL_VERSION)/$(NASHORN_VERSION)/g' \
   1.104 +		-e 's/$$(RELEASE)/$(NASHORN_VERSION)/g' \
   1.105 +		-e '/^#.*$$/d' -e '/^$$/d'  > $@
   1.106 +
   1.107 +
   1.108 +MANIFEST_ATTRIBUTES:=Name: jdk/nashorn/\nImplementation-Title: Oracle Nashorn\nImplementation-Version: $(NASHORN_VERSION)
   1.109 +
   1.110 +# Create nashorn.jar from the final classes dir
   1.111 +$(eval $(call SetupArchive,BUILD_NASHORN_JAR,\
   1.112 +    $(NASHORN_OUTPUTDIR)/classes/_the.nasgen.run \
   1.113 +    $(NASHORN_OUTPUTDIR)/classes/_the.dynalink.unpacked \
   1.114 +    $(VERSION_FILE),\
   1.115 +    SRCS:=$(NASHORN_OUTPUTDIR)/classes,\
   1.116 +    SUFFIXES:=.class .clazz .js .properties Factory,\
   1.117 +    MANIFEST:=$(NASHORN_TOPDIR)/src/META-INF/MANIFEST.MF,\
   1.118 +    EXTRA_MANIFEST_ATTR:=$(MANIFEST_ATTRIBUTES),\
   1.119 +    SKIP_METAINF:=true,\
   1.120 +    JAR:=$(NASHORN_JAR)))
   1.121 +
   1.122 +all: $(NASHORN_JAR)
   1.123 +
   1.124 +.PHONY: all

mercurial