8055856: checkdeps build target doesn't work for cross-compilation builds
8056113: [build] tools.jar missing modules.xml Reviewed-by: ihse, erikj
This commit is contained in:
parent
2f0e7c08db
commit
53f5fa9af2
@ -134,7 +134,7 @@ TOOL_CHECKDEPS = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
|
|||||||
|
|
||||||
TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
|
TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
|
||||||
-cp "$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)" \
|
-cp "$(JDK_OUTPUTDIR)/btclasses$(PATH_SEP)$(JDK_OUTPUTDIR)" \
|
||||||
build.tools.module.GenerateModulesXml
|
build.tools.module.GenJdepsModulesXml
|
||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
@ -23,47 +23,24 @@
|
|||||||
# questions.
|
# questions.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Default target declared first
|
include GendataCommon.gmk
|
||||||
default: all
|
|
||||||
|
|
||||||
include $(SPEC)
|
$(eval $(call IncludeCustomExtension, jdk, gendata/Gendata-jdk.dev.gmk))
|
||||||
include MakeBase.gmk
|
|
||||||
include Tools.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
|
# Generate modules.xml for jdeps to use
|
||||||
# It augments $(TOPDIR)/modules.xml to include module membership
|
# It augments $(TOPDIR)/modules.xml to include module membership
|
||||||
#
|
#
|
||||||
JDEPS_MODULES_XML := $(JDK_OUTPUTDIR)/modules/jdk.dev/com/sun/tools/jdeps/resources/modules.xml
|
$(GENDATA): $(BUILD_TOOLS_JDK) $(METADATA_FILES)
|
||||||
|
|
||||||
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)
|
|
||||||
$(MKDIR) -p $(@D)
|
$(MKDIR) -p $(@D)
|
||||||
$(RM) $@
|
$(RM) $@
|
||||||
$(TOOL_GENMODULESXML) $@ $(JDK_OUTPUTDIR)/modules
|
$(TOOL_GENMODULESXML) -o $@ -mp $(JDK_OUTPUTDIR)/modules $(METADATA_FILES)
|
||||||
|
|
||||||
#
|
jdk.dev: $(GENDATA)
|
||||||
# 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
|
|
||||||
|
|
||||||
gen-modules-xml: $(JDEPS_MODULES_XML)
|
all: $(GENDATA)
|
||||||
|
|
||||||
all: checkdeps
|
.PHONY: all jdk.dev
|
||||||
|
|
||||||
.PHONY: all
|
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package build.tools.module;
|
package build.tools.module;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -49,47 +50,56 @@ import javax.xml.stream.events.Attribute;
|
|||||||
import javax.xml.stream.events.XMLEvent;
|
import javax.xml.stream.events.XMLEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tool is used to generate com/sun/tools/jdeps/resources/modules.xml
|
* GenJdepsModulesXml augments the input modules.xml file(s)
|
||||||
* for jdeps to analyze dependencies and enforce module boundaries.
|
* 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 \
|
* The input modules.xml file defines the modular structure of
|
||||||
* com/sun/tools/jdeps/resources/modules.xml $OUTPUTDIR/modules
|
* 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
|
* $ java build.tools.module.GenJdepsModulesXml \
|
||||||
* the metadata to include module membership (jdeps needs the
|
* -o com/sun/tools/jdeps/resources/modules.xml \
|
||||||
* membership information to determine which module a type belongs to.)
|
* -mp $OUTPUTDIR/modules \
|
||||||
|
* top/modules.xml
|
||||||
*/
|
*/
|
||||||
public final class GenerateModulesXml {
|
public final class GenJdepsModulesXml {
|
||||||
private final static String USAGE =
|
private final static String USAGE =
|
||||||
"Usage: GenerateModulesXml <output file> build/modules";
|
"Usage: GenJdepsModulesXml -o <output file> -mp build/modules path-to-modules-xml";
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
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.err.println(USAGE);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Path outfile = Paths.get(args[0]);
|
GenJdepsModulesXml gentool = new GenJdepsModulesXml(modulepath);
|
||||||
Path modulepath = Paths.get(args[1]);
|
Set<Module> modules = new HashSet<>();
|
||||||
|
for (; i < args.length; i++) {
|
||||||
if (!Files.isDirectory(modulepath)) {
|
Path p = Paths.get(args[i]);
|
||||||
System.err.println(modulepath + " is not a directory");
|
try (InputStream in = new BufferedInputStream(Files.newInputStream(p))) {
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
GenerateModulesXml gentool =
|
|
||||||
new GenerateModulesXml(modulepath);
|
|
||||||
Set<Module> 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 {
|
|
||||||
Set<Module> mods = gentool.load(in);
|
Set<Module> mods = gentool.load(in);
|
||||||
modules.addAll(mods);
|
modules.addAll(mods);
|
||||||
} finally {
|
|
||||||
in.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +108,7 @@ public final class GenerateModulesXml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Path modulepath;
|
final Path modulepath;
|
||||||
public GenerateModulesXml(Path modulepath) {
|
public GenJdepsModulesXml(Path modulepath) {
|
||||||
this.modulepath = modulepath;
|
this.modulepath = modulepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +285,7 @@ public final class GenerateModulesXml {
|
|||||||
m.exports().keySet().stream()
|
m.exports().keySet().stream()
|
||||||
.filter(pn -> m.exports().get(pn).isEmpty())
|
.filter(pn -> m.exports().get(pn).isEmpty())
|
||||||
.sorted()
|
.sorted()
|
||||||
.forEach(pn -> GenerateModulesXml.this.writeExportElement(xtw, pn, depth+1));
|
.forEach(pn -> writeExportElement(xtw, pn, depth+1));
|
||||||
m.exports().entrySet().stream()
|
m.exports().entrySet().stream()
|
||||||
.filter(e -> !e.getValue().isEmpty())
|
.filter(e -> !e.getValue().isEmpty())
|
||||||
.sorted(Map.Entry.comparingByKey())
|
.sorted(Map.Entry.comparingByKey())
|
Loading…
x
Reference in New Issue
Block a user