diff --git a/compiler/compiler/src/main/java/org/robovm/compiler/config/Config.java b/compiler/compiler/src/main/java/org/robovm/compiler/config/Config.java index 76dbf3633..abc2f175f 100755 --- a/compiler/compiler/src/main/java/org/robovm/compiler/config/Config.java +++ b/compiler/compiler/src/main/java/org/robovm/compiler/config/Config.java @@ -157,7 +157,7 @@ public enum TreeShakerMode { @ElementList(required = false, entry = "path") private ArrayList appExtensionPaths; @Element(required = false) - private SwiftSupport swiftSupport = null; + private SwiftSupport swiftSupport = new SwiftSupport(); @ElementList(required = false, entry = "resource") private ArrayList resources; @ElementList(required = false, entry = "classpathentry") @@ -478,15 +478,15 @@ public List getAppExtensionPaths() { } public SwiftSupport getSwiftSupport() { - return swiftSupport; + return swiftSupport.isEnabled() ? swiftSupport : null; } public boolean hasSwiftSupport() { - return swiftSupport != null; + return swiftSupport.isEnabled(); } public List getSwiftLibPaths() { - return swiftSupport == null ? Collections.emptyList() + return !swiftSupport.isEnabled() ? Collections.emptyList() : swiftSupport.getSwiftLibPaths().stream() .filter(this::isQualified) .map(f -> f.entry) diff --git a/compiler/compiler/src/main/java/org/robovm/compiler/config/SwiftSupport.java b/compiler/compiler/src/main/java/org/robovm/compiler/config/SwiftSupport.java index 75dca0cc2..abb827cc7 100644 --- a/compiler/compiler/src/main/java/org/robovm/compiler/config/SwiftSupport.java +++ b/compiler/compiler/src/main/java/org/robovm/compiler/config/SwiftSupport.java @@ -12,6 +12,12 @@ * Configuration entry for Swift language related configurations */ public class SwiftSupport { + /** + * specifies if swift support is enabled, allows to disable it if required + */ + @Element(required = false) + private boolean enable = true; + /** * path where swift library to be looked at * also these libraries will be added to linker library search path @@ -23,8 +29,12 @@ public class SwiftSupport { * specifies if swift runtime libraries to be copied */ @Element(required = false) - private Boolean copySwiftLibs = true; + private boolean copySwiftLibs = true; + + public boolean isEnabled() { + return enable; + } public List getSwiftLibPaths() { return swiftLibPaths == null ? Collections.emptyList() @@ -32,6 +42,6 @@ public List getSwiftLibPaths() { } public boolean shouldCopySwiftLibs() { - return copySwiftLibs != null ? copySwiftLibs : true; + return copySwiftLibs; } } diff --git a/compiler/compiler/src/main/java/org/robovm/compiler/target/AbstractTarget.java b/compiler/compiler/src/main/java/org/robovm/compiler/target/AbstractTarget.java index 212bd4d33..877855c78 100755 --- a/compiler/compiler/src/main/java/org/robovm/compiler/target/AbstractTarget.java +++ b/compiler/compiler/src/main/java/org/robovm/compiler/target/AbstractTarget.java @@ -366,7 +366,7 @@ public void processFile(Resource resource, File file, File destDir) throws IOExc if (isDynamicLibrary(file)) { // remove simulator and deprecated archs, also strip bitcode if not used - if (config.getOs() == OS.ios && config.getArch().isArm()) { + if (config.getOs() == OS.ios && config.getArch().getEnv() != Environment.Simulator) { File libFile = new File(destDir, file.getName()); stripExtraArches(libFile); if (!config.isEnableBitcode()) @@ -440,7 +440,7 @@ public boolean processDir(Resource resource, File dir, File destDir) throws IOEx public void processFile(Resource resource, File file, File destDir) throws IOException { copyFile(resource, file, destDir); - if (config.getOs() == OS.ios && config.getArch().isArm()) { + if (config.getOs() == OS.ios && config.getArch().getEnv() != Environment.Simulator) { // remove simulator and deprecated archs, also strip bitcode if not used if (isAppExtension(file)) { File libFile = new File(destDir, file.getName()); @@ -670,7 +670,7 @@ protected void copySwiftLibs(Collection swiftLibraries, File targetDir, // don't strip if libraries goes to SwiftSupport folder if (strip) { // remove simulator and deprecated archs, also strip bitcode if not used - if (config.getOs() == OS.ios && config.getArch().isArm()) { + if (config.getOs() == OS.ios && config.getArch().getEnv() != Environment.Simulator) { File libFile = new File(targetDir, swiftLibrary.getName()); stripExtraArches(libFile); if (!config.isEnableBitcode()) diff --git a/compiler/compiler/src/main/java/org/robovm/compiler/util/ToolchainUtil.java b/compiler/compiler/src/main/java/org/robovm/compiler/util/ToolchainUtil.java index f4e44eab1..69a9ae61e 100755 --- a/compiler/compiler/src/main/java/org/robovm/compiler/util/ToolchainUtil.java +++ b/compiler/compiler/src/main/java/org/robovm/compiler/util/ToolchainUtil.java @@ -329,7 +329,7 @@ public static void lipoRemoveArchs(Config config, File inFile, File outFile, Str } args.add("-output"); args.add(outFile); - new Executor(Logger.NULL_LOGGER, getLipo()).args(args).exec(); + new Executor(config.getLogger(), getLipo()).args(args).exec(); } diff --git a/compiler/compiler/src/test/java/org/robovm/compiler/config/ConfigTest.java b/compiler/compiler/src/test/java/org/robovm/compiler/config/ConfigTest.java index 9b190c82b..4cc992dae 100755 --- a/compiler/compiler/src/test/java/org/robovm/compiler/config/ConfigTest.java +++ b/compiler/compiler/src/test/java/org/robovm/compiler/config/ConfigTest.java @@ -18,10 +18,7 @@ import static org.junit.Assert.*; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.StringWriter; +import java.io.*; import java.util.Arrays; import java.util.Collections; @@ -418,4 +415,34 @@ public void testGetFileName() throws Exception { assertEquals("com/example/AB9ca44297c0e0d22df654119dce73ee52d3d51c71.class.o", Config.getFileName("com/example/ABCDEFGIHJABCDEFGIHJABCDEFGIHJABCDEFGIHJABCDEFGIHJ", "class.o", 50)); } + + @Test + public void testSwiftSupportEnabledByDefault() throws Exception { + String configText = "\n" + + " ios\n" + + ""; + Config.Builder builder = new Config.Builder(); + + builder.read(new StringReader(configText), wd); + Config config = builder.config; + + assertTrue(config.hasSwiftSupport()); + assertNotNull(config.getSwiftSupport()); + assertTrue(config.getSwiftSupport().isEnabled()); + assertTrue(config.getSwiftSupport().shouldCopySwiftLibs()); + } + + @Test + public void testSwiftSupportCanBeDisabled() throws Exception { + String configText = "\n" + + " \n" + + " false\n" + + " \n" + + ""; + Config.Builder builder = new Config.Builder(); + builder.read(new StringReader(configText), wd); + Config config = builder.config; + assertFalse(config.hasSwiftSupport()); + assertNull(config.getSwiftSupport()); + } } diff --git a/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.console.xml b/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.console.xml index d2d815286..c05986389 100644 --- a/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.console.xml +++ b/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.console.xml @@ -15,6 +15,10 @@ Foundation AppKit + + true + true + resources /usr/share/resources diff --git a/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.ios.xml b/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.ios.xml index a481d9881..48fa38450 100644 --- a/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.ios.xml +++ b/compiler/compiler/src/test/resources/org/robovm/compiler/config/ConfigTest.ios.xml @@ -1,4 +1,8 @@ + + true + true + ios 6.1 Info.plist