use of org.robovm.compiler.clazz.Path in project robovm by robovm.
the class Config method mergeConfigsFromClasspath.
private void mergeConfigsFromClasspath() throws IOException {
List<String> dirs = Arrays.asList("META-INF/robovm/" + os + "/" + sliceArch, "META-INF/robovm/" + os);
// The algorithm below preserves the order of config data from the
// classpath. Last the config from this object is added.
// First merge all configs on the classpath to an empty Config
Config config = new Config();
for (Path path : clazzes.getPaths()) {
for (String dir : dirs) {
if (path.contains(dir + "/robovm.xml")) {
File configXml = new File(new File(extractIfNeeded(path), dir), "robovm.xml");
Builder builder = new Builder();
builder.read(configXml);
mergeConfig(builder.config, config);
break;
}
}
}
// Then merge with this Config
mergeConfig(this, config);
// Copy back to this Config
this.exportedSymbols = config.exportedSymbols;
this.unhideSymbols = config.unhideSymbols;
this.forceLinkClasses = config.forceLinkClasses;
this.frameworkPaths = config.frameworkPaths;
this.frameworks = config.frameworks;
this.libs = config.libs;
this.resources = config.resources;
this.weakFrameworks = config.weakFrameworks;
}
use of org.robovm.compiler.clazz.Path in project robovm by robovm.
the class AppCompilerTest method testMultipleMetainfServiceImplsAdded.
@Test
public void testMultipleMetainfServiceImplsAdded() throws Exception {
final Path impl1 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Integer");
final Path impl2 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Long");
Clazzes clazzes = createClazzes(impl1, impl2);
Clazz interfaceClazz = clazzes.load("java/lang/Number");
Set<Clazz> compiled = new HashSet<>();
Set<Clazz> queue = new LinkedHashSet<>();
AppCompiler.addMetaInfImplementations(clazzes, interfaceClazz, compiled, queue);
assertEquals("Two items added to queue: " + queue, 2, queue.size());
assertTrue("Integer in queue" + queue, queue.contains(clazzes.load("java/lang/Integer")));
assertTrue("Long in queue" + queue, queue.contains(clazzes.load("java/lang/Long")));
}
use of org.robovm.compiler.clazz.Path in project robovm by robovm.
the class AppCompilerTest method testMissingImplIsIgnore.
@Test
public void testMissingImplIsIgnore() throws Exception {
final Path impl1 = new MockPath("META-INF/services/java.lang.Number", "java.lang.Integer");
final Path impl2 = new MockPath("META-INF/services/java.lang.Number", "nobody.knows.such.Class");
Clazzes clazzes = createClazzes(impl1, impl2);
Clazz interfaceClazz = clazzes.load("java/lang/Number");
Set<Clazz> compiled = new HashSet<>();
Set<Clazz> queue = new LinkedHashSet<>();
AppCompiler.addMetaInfImplementations(clazzes, interfaceClazz, compiled, queue);
assertEquals("Just one item added to queue: " + queue, 1, queue.size());
assertTrue("Integer in queue" + queue, queue.contains(clazzes.load("java/lang/Integer")));
}
use of org.robovm.compiler.clazz.Path in project robovm by robovm.
the class AppCompiler method getMatchingClasses.
/**
* Returns all {@link Clazz}es in all {@link Path}s matching the specified
* ANT-style pattern.
*/
private Collection<Clazz> getMatchingClasses(String pattern) {
AntPathMatcher matcher = new AntPathMatcher(pattern, ".");
Map<String, Clazz> matches = new HashMap<String, Clazz>();
for (Path path : config.getClazzes().getPaths()) {
for (Clazz clazz : path.listClasses()) {
if (!matches.containsKey(clazz.getClassName()) && matcher.matches(clazz.getClassName())) {
matches.put(clazz.getClassName(), clazz);
}
}
}
return matches.values();
}
use of org.robovm.compiler.clazz.Path in project robovm by robovm.
the class AppCompiler method build.
/**
* Builds the binary (possibly a fat binary with multiple archs).
*/
public void build() throws IOException {
List<Arch> archs = this.config.getArchs();
if (archs.isEmpty()) {
archs = config.getTarget().getDefaultArchs();
}
if (archs.isEmpty()) {
throw new IllegalArgumentException("No archs specified in config");
}
if (archs.size() == 1 && this.config.getArch().equals(archs.get(0))) {
// No need to clone configs for each slice.
compile();
} else {
Map<Arch, File> slices = new TreeMap<>();
for (Arch arch : archs) {
this.config.getLogger().info("Building %s slice", arch);
Config sliceConfig = this.config.builder().arch(arch).tmpDir(new File(this.config.getTmpDir(), arch.toString())).build();
new AppCompiler(sliceConfig).compile();
slices.put(arch, new File(sliceConfig.getTmpDir(), sliceConfig.getExecutableName()));
for (Path path : sliceConfig.getResourcesPaths()) {
if (!this.config.getResourcesPaths().contains(path)) {
this.config.addResourcesPath(path);
}
}
}
this.config.getTarget().buildFat(slices);
}
}
Aggregations