com.jtransc.gen.cs.CSharpCompiler.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransc-gen-cs Show documentation
Show all versions of jtransc-gen-cs Show documentation
JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.
package com.jtransc.gen.cs
import com.jtransc.env.OS
import com.jtransc.error.invalidOp
import com.jtransc.sys.Arch
import com.jtransc.vfs.LocalVfs
import java.io.File
object CSharpCompiler {
val dotNetV4Folder by lazy {
//println(System.getProperty("os.arch"))
val folder = when (Arch.CURRENT) {
Arch.X86 -> System.getenv("SystemRoot") + "\\Microsoft.NET\\Framework"
Arch.X64 -> System.getenv("SystemRoot") + "\\Microsoft.NET\\Framework64"
else -> System.getenv("SystemRoot") + "\\Microsoft.NET\\Framework"
}
val local = LocalVfs(File(folder))
val dotnetv4 = local.listdir().filter { it.name.startsWith("v4") }.firstOrNull() ?: invalidOp("JTransc can't find .net framework v4")
dotnetv4.file
}
fun genCommand(programFile: File, debug: Boolean = false, libs: List = listOf()): List {
if (OS.isWindows) {
return listOf(Windows.CSC, "/debug:full", "/unsafe+", "/checked-", "/optimize+", "/define:UNSAFE", programFile.absolutePath)
} else {
return listOf(Mono.MCS, "-debug", "-unsafe+", "-checked-", "-optimize+", "-define:UNSAFE", programFile.absolutePath)
}
}
object Mono {
val MCS = "mcs"
}
object Windows {
val CSC = dotNetV4Folder["csc"].realpathOS
}
}