langtools/make/GenstubsLangtools.gmk
changeset 22703 322d8adeabe1
parent 21888 568c5da9f16b
equal deleted inserted replaced
22702:1297fbaf34fa 22703:322d8adeabe1
       
     1 #
       
     2 # Copyright (c) 2014, 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 
       
    32 include CommonLangtools.gmk
       
    33 
       
    34 # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not
       
    35 # yet built. It is currently not needed but might be again in the future. The following
       
    36 # exercises the functionality to verify that it works.
       
    37 TOOL_GENSTUBS_CMD = $(JAVA) \
       
    38      "-Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR)" \
       
    39      genstubs.GenStubs
       
    40 
       
    41 # We fetch source from the JDK...
       
    42 JDKS := $(JDK_TOPDIR)/src/share/classes
       
    43 
       
    44 # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't
       
    45 # currently needed, but is used as a demo for now.
       
    46 
       
    47 STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \
       
    48     -e "$(JDKS)/java/util/function/Predicate.java")
       
    49 
       
    50 # Rewrite the file names into class names because the GenStubs tool require this.
       
    51 STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES)))
       
    52 
       
    53 # Now setup the build recipe for genstubs.
       
    54 $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs: $(STUBSOURCES)
       
    55 	$(MKDIR) -p $(@D)
       
    56 	$(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs
       
    57 	$(ECHO) $(LOG_INFO) Generating stubs from JDK sources.
       
    58 	$(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES)
       
    59 	if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs \
       
    60 	    > /dev/null 2>&1; then \
       
    61 	  $(ECHO) $(LOG_INFO) No changes in the stubs!; \
       
    62 	  $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \
       
    63 	else \
       
    64 	  $(ECHO) $(LOG_INFO) Changes in stubs detected!; \
       
    65 	  $(RM) -r $(@D); \
       
    66 	  $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \
       
    67 	fi
       
    68 	$(TOUCH) $@
       
    69 
       
    70 all: $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs