From 53f5fa9af292229f906f97831f165c01214ad632 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Fri, 29 Aug 2014 10:47:32 -0700 Subject: [PATCH] 8055856: checkdeps build target doesn't work for cross-compilation builds 8056113: [build] tools.jar missing modules.xml Reviewed-by: ihse, erikj --- jdk/make/Tools.gmk | 2 +- .../Gendata-jdk.dev.gmk} | 43 +++-------- ...odulesXml.java => GenJdepsModulesXml.java} | 72 +++++++++++-------- 3 files changed, 52 insertions(+), 65 deletions(-) rename jdk/make/{ModulesXml.gmk => gendata/Gendata-jdk.dev.gmk} (57%) rename jdk/make/src/classes/build/tools/module/{GenerateModulesXml.java => GenJdepsModulesXml.java} (90%) diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 4cfa33fc9f8..b68d19c3d34 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -134,7 +134,7 @@ TOOL_CHECKDEPS = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \ TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \ -cp "$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)" \ - build.tools.module.GenerateModulesXml + build.tools.module.GenJdepsModulesXml ########################################################################################## diff --git a/jdk/make/ModulesXml.gmk b/jdk/make/gendata/Gendata-jdk.dev.gmk similarity index 57% rename from jdk/make/ModulesXml.gmk rename to jdk/make/gendata/Gendata-jdk.dev.gmk index 1399e46bace..3c24cf4b703 100644 --- a/jdk/make/ModulesXml.gmk +++ b/jdk/make/gendata/Gendata-jdk.dev.gmk @@ -23,47 +23,24 @@ # questions. # -# Default target declared first -default: all +include GendataCommon.gmk -include $(SPEC) -include MakeBase.gmk -include Tools.gmk +$(eval $(call IncludeCustomExtension, jdk, gendata/Gendata-jdk.dev.gmk)) + +GENDATA := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/jdeps-modules.xml +METADATA_FILES += $(TOPDIR)/modules.xml # # Generate modules.xml for jdeps to use # It augments $(TOPDIR)/modules.xml to include module membership # -JDEPS_MODULES_XML := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/modules.xml - -METADATA := $(JDK_OUTPUTDIR)/btclasses/build/tools/module/modules.xml -$(METADATA): $(TOPDIR)/modules.xml - $(call install-file) - -METADATA_FILES := $(METADATA) - -ifndef OPENJDK - CLOSED_METADATA := $(JDK_OUTPUTDIR)/btclasses/build/tools/module/closed/modules.xml - $(CLOSED_METADATA): $(TOPDIR)/closed/modules.xml - $(call install-file) - - METADATA_FILES += $(CLOSED_METADATA) -endif - -$(JDEPS_MODULES_XML): $(BUILD_TOOLS_JDK) $(METADATA_FILES) +$(GENDATA): $(BUILD_TOOLS_JDK) $(METADATA_FILES) $(MKDIR) -p $(@D) $(RM) $@ - $(TOOL_GENMODULESXML) $@ $(JDK_OUTPUTDIR)/modules + $(TOOL_GENMODULESXML) -o $@ -mp $(JDK_OUTPUTDIR)/modules $(METADATA_FILES) -# -# Verify access across module boundaries -# -checkdeps: $(JDEPS_MODULES_XML) - $(ECHO) "Checking dependencies across JDK modules" - $(FIXPATH) $(JDK_OUTPUTDIR)/bin/jdeps -verify:access -mp $(JDK_OUTPUTDIR)/modules +jdk.dev: $(GENDATA) -gen-modules-xml: $(JDEPS_MODULES_XML) +all: $(GENDATA) -all: checkdeps - -.PHONY: all +.PHONY: all jdk.dev diff --git a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java similarity index 90% rename from jdk/make/src/classes/build/tools/module/GenerateModulesXml.java rename to jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java index c2fdf4ae9d1..43ba458f326 100644 --- a/jdk/make/src/classes/build/tools/module/GenerateModulesXml.java +++ b/jdk/make/src/classes/build/tools/module/GenJdepsModulesXml.java @@ -25,6 +25,7 @@ package build.tools.module; +import java.io.BufferedInputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -49,47 +50,56 @@ import javax.xml.stream.events.Attribute; import javax.xml.stream.events.XMLEvent; /** - * This tool is used to generate com/sun/tools/jdeps/resources/modules.xml - * for jdeps to analyze dependencies and enforce module boundaries. + * GenJdepsModulesXml augments the input modules.xml file(s) + * to include the module membership from the given path to + * the JDK exploded image. The output file is used by jdeps + * to analyze dependencies and enforce module boundaries. * - * $ java build.tools.module.GenerateModulesXml \ - * com/sun/tools/jdeps/resources/modules.xml $OUTPUTDIR/modules + * The input modules.xml file defines the modular structure of + * the JDK as described in JEP 200: The Modular JDK + * (http://openjdk.java.net/jeps/200). * - * This will generate modules.xml as jdeps resources that extend - * the metadata to include module membership (jdeps needs the - * membership information to determine which module a type belongs to.) + * $ java build.tools.module.GenJdepsModulesXml \ + * -o com/sun/tools/jdeps/resources/modules.xml \ + * -mp $OUTPUTDIR/modules \ + * top/modules.xml */ -public final class GenerateModulesXml { +public final class GenJdepsModulesXml { private final static String USAGE = - "Usage: GenerateModulesXml build/modules"; + "Usage: GenJdepsModulesXml -o -mp build/modules path-to-modules-xml"; public static void main(String[] args) throws Exception { - if (args.length < 2) { + Path outfile = null; + Path modulepath = null; + int i = 0; + while (i < args.length) { + String arg = args[i]; + if (arg.equals("-o")) { + outfile = Paths.get(args[i+1]); + i = i+2; + } else if (arg.equals("-mp")) { + modulepath = Paths.get(args[i+1]); + i = i+2; + if (!Files.isDirectory(modulepath)) { + System.err.println(modulepath + " is not a directory"); + System.exit(1); + } + } else { + break; + } + } + if (outfile == null || modulepath == null || i >= args.length) { System.err.println(USAGE); System.exit(-1); } - Path outfile = Paths.get(args[0]); - Path modulepath = Paths.get(args[1]); - - if (!Files.isDirectory(modulepath)) { - System.err.println(modulepath + " is not a directory"); - System.exit(1); - } - GenerateModulesXml gentool = - new GenerateModulesXml(modulepath); - Set modules; - try (InputStream in = GenerateModulesXml.class.getResourceAsStream("modules.xml")) { - modules = gentool.load(in); - } - - InputStream in = GenerateModulesXml.class.getResourceAsStream("closed/modules.xml"); - if (in != null) { - try { + GenJdepsModulesXml gentool = new GenJdepsModulesXml(modulepath); + Set modules = new HashSet<>(); + for (; i < args.length; i++) { + Path p = Paths.get(args[i]); + try (InputStream in = new BufferedInputStream(Files.newInputStream(p))) { Set mods = gentool.load(in); modules.addAll(mods); - } finally { - in.close(); } } @@ -98,7 +108,7 @@ public final class GenerateModulesXml { } final Path modulepath; - public GenerateModulesXml(Path modulepath) { + public GenJdepsModulesXml(Path modulepath) { this.modulepath = modulepath; } @@ -275,7 +285,7 @@ public final class GenerateModulesXml { m.exports().keySet().stream() .filter(pn -> m.exports().get(pn).isEmpty()) .sorted() - .forEach(pn -> GenerateModulesXml.this.writeExportElement(xtw, pn, depth+1)); + .forEach(pn -> writeExportElement(xtw, pn, depth+1)); m.exports().entrySet().stream() .filter(e -> !e.getValue().isEmpty()) .sorted(Map.Entry.comparingByKey())