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/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