Forráskód Böngészése

add default option to run configurations

windchargerj 5 hónapja
szülő
commit
58a19567a5

+ 6 - 6
src/main/kotlin/io/xmake/run/XMakeRunConfiguration.kt

@@ -35,13 +35,13 @@ class XMakeRunConfiguration(
     var runTarget: String = "default"
 
     @OptionTag(tag = "platform")
-    var runPlatform: String = if (platforms.contains(SystemUtils.platform())) SystemUtils.platform() else ""
+    var runPlatform: String = if (platforms.contains(SystemUtils.platform())) SystemUtils.platform() else "default"
 
     @OptionTag(tag = "architecture")
-    var runArchitecture: String = getArchitecturesByPlatform(runPlatform).firstOrNull() ?: ""
+    var runArchitecture: String = getArchitecturesByPlatform(runPlatform).firstOrNull() ?: "default"
 
     @OptionTag(tag = "toolchain")
-    var runToolchain: String = toolchains.firstOrNull() ?: ""
+    var runToolchain: String = toolchains.firstOrNull() ?: "default"
 
     @OptionTag(tag = "mode")
     var runMode: String = "release"
@@ -152,16 +152,16 @@ class XMakeRunConfiguration(
     }
 
     val platforms: Array<String>
-        get() = project.xmakeInfo.architectures.keys.toTypedArray()
+        get() = project.xmakeInfo.architectures.keys.plus("default").toTypedArray()
 
     val toolchains: Array<String>
-        get() = project.xmakeInfo.toolchains.keys.toTypedArray()
+        get() = project.xmakeInfo.toolchains.keys.plus("default").toTypedArray()
 
     val modes: Array<String>
         get() = project.xmakeInfo.buildModes.map { it.substringAfter('.') }.toTypedArray()
 
     fun getArchitecturesByPlatform(platform: String): Array<String> {
-        return (project.xmakeInfo.architectures[platform]?.toTypedArray() ?: emptyArray())
+        return (project.xmakeInfo.architectures[platform]?.toTypedArray() ?: arrayOf("default"))
     }
 
     companion object {

+ 3 - 9
src/main/kotlin/io/xmake/run/XMakeRunConfigurationEditor.kt

@@ -200,14 +200,6 @@ class XMakeRunConfigurationEditor(
                     cell(toolchainsComboBox).align(AlignX.FILL)
                 }
             }.resizableColumn()
-            panel {
-                row {
-                    label("Mode:")
-                }
-                row {
-                    cell(modesComboBox).align(AlignX.FILL)
-                }
-            }.resizableColumn()
         }.layout(RowLayout.PARENT_GRID)
 
         separator()
@@ -228,7 +220,9 @@ class XMakeRunConfigurationEditor(
                         }
                     }
                 })
-            }.align(AlignX.FILL)
+            }.align(AlignX.FILL).resizableColumn()
+            label("Mode:").align(AlignX.FILL)
+            cell(modesComboBox).align(AlignX.FILL)
         }
 
         row("Program arguments:") {

+ 9 - 5
src/main/kotlin/io/xmake/shared/XMakeConfiguration.kt

@@ -88,15 +88,19 @@ class XMakeConfiguration(val project: Project) {
                 mutableListOf(
                     "f",
                     "-y",
-                    "-p",
-                    configuration.runPlatform,
-                    "-a",
-                    configuration.runArchitecture,
-                    "--toolchain=${configuration.runToolchain}",
                     "-m",
                     configuration.runMode,
                     "--policies=run.autobuild"
                 )
+            if (configuration.runPlatform != "default") {
+                parameters.addAll(listOf("-p", configuration.runPlatform))
+            }
+            if (configuration.runArchitecture != "default") {
+                parameters.addAll(listOf("-a", configuration.runArchitecture))
+            }
+            if (configuration.runToolchain != "default" ) {
+                parameters.add("--toolchain=${configuration.runToolchain}")
+            }
             if (configuration.runPlatform == "android" && configuration.androidNDKDirectory != "") {
                 parameters.add("--ndk=\"${configuration.androidNDKDirectory}\"")
             }