Skip to content

Commit

Permalink
fix empty XMake configuration selected issue
Browse files Browse the repository at this point in the history
  • Loading branch information
windchargerj committed Aug 23, 2024
1 parent 0068537 commit 409edca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
22 changes: 22 additions & 0 deletions src/main/kotlin/io/xmake/run/XMakeRunConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ class XMakeRunConfiguration(
}

companion object {

// the platforms
val platforms = arrayOf("macosx", "linux", "windows", "android", "iphoneos", "watchos", "mingw")

// the modes
val modes = arrayOf("release", "debug")

/* // the architectures
val architectures: Array<String>
get() = getArchitecturesByPlatform(runPlatform)*/

// get architectures by platform
fun getArchitecturesByPlatform(platform: String) = when (platform) {
"macosx", "linux", "mingw" -> arrayOf("x86_64", "i386", "arm64")
"windows" -> arrayOf("x86", "x64")
"iphoneos" -> arrayOf("arm64", "armv7", "armv7s", "x86_64", "i386")
"watchos" -> arrayOf("armv7s", "i386")
"android" -> arrayOf("armv7-a", "armv5te", "armv6", "armv8-a", "arm64-v8a")
else -> arrayOf()
}


private val Log = Logger.getInstance(XMakeRunConfiguration::class.java.getName())
}
}
11 changes: 7 additions & 4 deletions src/main/kotlin/io/xmake/run/XMakeRunConfigurationEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import io.xmake.project.toolkit.Toolkit
import io.xmake.project.toolkit.ToolkitHostType.*
import io.xmake.project.toolkit.ui.ToolkitComboBox
import io.xmake.project.toolkit.ui.ToolkitListItem
import io.xmake.run.XMakeRunConfiguration.Companion.getArchitecturesByPlatform
import io.xmake.run.XMakeRunConfiguration.Companion.modes
import io.xmake.run.XMakeRunConfiguration.Companion.platforms
import io.xmake.shared.xmakeConfiguration
import io.xmake.utils.execute.SyncDirection
import io.xmake.utils.execute.syncProjectBySftp
Expand Down Expand Up @@ -48,13 +51,13 @@ class XMakeRunConfigurationEditor(
private val targetsModel = DefaultComboBoxModel<String>()
private val targetsComboBox = ComboBox(targetsModel).apply { item = runConfiguration.runTarget }

private val platformsModel = DefaultComboBoxModel(project.xmakeConfiguration.platforms)
private val platformsModel = DefaultComboBoxModel(platforms)
private val platformsComboBox = ComboBox(platformsModel).apply { item = runConfiguration.runPlatform }

private val architecturesModel = DefaultComboBoxModel(project.xmakeConfiguration.architectures)
private val architecturesModel = DefaultComboBoxModel(getArchitecturesByPlatform(runConfiguration.runPlatform))
private val architecturesComboBox = ComboBox(architecturesModel).apply { item = runConfiguration.runArchitecture }

private val modesModel = DefaultComboBoxModel(project.xmakeConfiguration.modes)
private val modesModel = DefaultComboBoxModel(modes)
private val modesComboBox = ComboBox(modesModel).apply { item = runConfiguration.runMode }

private val runArguments = RawCommandLineEditor()
Expand Down Expand Up @@ -170,7 +173,7 @@ class XMakeRunConfigurationEditor(
cell(platformsComboBox).applyToComponent {
addItemListener {
architecturesModel.removeAllElements()
architecturesModel.addAll(project.xmakeConfiguration.architectures.toMutableList())
architecturesModel.addAll(getArchitecturesByPlatform(runConfiguration.runPlatform).toMutableList())
}
}.align(AlignX.FILL)
}
Expand Down
33 changes: 6 additions & 27 deletions src/main/kotlin/io/xmake/shared/XMakeConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import io.xmake.utils.exception.XMakeRunConfigurationNotSetException
@Service(Service.Level.PROJECT)
class XMakeConfiguration(val project: Project) {

// the platforms
val platforms = arrayOf("macosx", "linux", "windows", "android", "iphoneos", "watchos", "mingw")

// the architectures
val architectures: Array<String>
get() = getArchitecturesByPlatform(configuration.runPlatform)

// the modes
val modes = arrayOf("release", "debug")

val configuration: XMakeRunConfiguration
get() {
return RunManager.getInstance(project).selectedConfiguration?.configuration as? XMakeRunConfiguration
Expand Down Expand Up @@ -165,25 +155,14 @@ class XMakeConfiguration(val project: Project) {
.withRedirectErrorStream(true)
}

// ensure state
private fun ensureState() {
if (configuration.runArchitecture == "" && architectures.isNotEmpty()) {
configuration.runArchitecture = architectures[0]
}
}
/* // ensure state
private fun ensureState() {
if (configuration.runArchitecture == "" && architectures.isNotEmpty()) {
configuration.runArchitecture = architectures[0]
}
}*/

companion object {

// get architectures by platform
fun getArchitecturesByPlatform(platform: String) = when (platform) {
"macosx", "linux", "mingw" -> arrayOf("x86_64", "i386", "arm64")
"windows" -> arrayOf("x86", "x64")
"iphoneos" -> arrayOf("arm64", "armv7", "armv7s", "x86_64", "i386")
"watchos" -> arrayOf("armv7s", "i386")
"android" -> arrayOf("armv7-a", "armv5te", "armv6", "armv8-a", "arm64-v8a")
else -> arrayOf()
}

// get log
private val Log = Logger.getInstance(XMakeConfiguration::class.java.getName())
}
Expand Down

0 comments on commit 409edca

Please sign in to comment.