Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/kotlin/file/CLICommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum class CLICommand {
TYPECHECK,
OUTDATED,
BUILD,
EXPORTOBJECTS,
SELF_UPDATE
}

Expand Down
38 changes: 37 additions & 1 deletion src/main/kotlin/file/SetupApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ object SetupApp {
}
setup.command == CLICommand.TEST ||
setup.command == CLICommand.TYPECHECK ||
setup.command == CLICommand.BUILD -> {
setup.command == CLICommand.BUILD ||
setup.command == CLICommand.EXPORTOBJECTS -> {
// Only needs to know a compiler is present; skip the version subprocess and update check.
InstallationManager.verifyInstallation(probeVersion = false)
}
Expand Down Expand Up @@ -149,6 +150,7 @@ object SetupApp {
| typecheck Typecheck the project without building a map
| outdated Check whether project dependencies are up to date
| build <mapfile> Build the project using the given input map
| exportobjects <mapfile|folder> Export object editor data to Wurst source
|
|Global options:
| --quiet Suppress wurst output; only print errors and final result
Expand Down Expand Up @@ -271,6 +273,25 @@ object SetupApp {
}
}
}
setup.command == CLICommand.EXPORTOBJECTS -> {
progress("Exporting object editor data...")
val mapArg = if (setup.commandArg.isBlank()) {
val maps = findMaps()
when (maps.size) {
0 -> { missingMap(); null }
1 -> { log.info("Auto-detected map: ${maps[0].fileName}"); maps[0].fileName.toString() }
else -> { multipleMaps(maps); null }
}
} else setup.commandArg
if (mapArg != null) {
val mapPath = setup.projectRoot.resolve(mapArg)
if (!Files.exists(mapPath)) {
missingMap(mapArg)
} else if (InstallationManager.status != InstallationManager.InstallationStatus.NOT_INSTALLED) {
exportObjects(mapPath)
}
}
}
setup.command == CLICommand.SELF_UPDATE -> {
log.info("🔄 Updating...")
try {
Expand Down Expand Up @@ -978,6 +999,21 @@ object SetupApp {
}
}

private fun exportObjects(mapPath: Path) {
val args = ArrayList(InstallationManager.compilerLaunchCommand().toList())
args.add("-exportobjects")
Comment thread
Frotty marked this conversation as resolved.
args.add(mapPath.toAbsolutePath().toString())

val result = startWurstProcess(args)
when (result.exitCode) {
0 -> { pass("Object editor data exported."); ExitHandler.exit(0) }
else -> {
printCompilerFailure("exportobjects", result)
ExitHandler.exit(1)
}
}
}

private fun testProject(configData: WurstProjectConfigData) {
val args = commonArgs(configData)

Expand Down
Loading