Add properties expansion.

This commit is contained in:
Nikolay Igotti
2016-10-03 20:56:33 +03:00
parent 059f890a1e
commit f92da32454
4 changed files with 30 additions and 7 deletions
@@ -10,5 +10,3 @@ linker = clang
linkerOpts = -fPIC \
-lclang
excludedFunctions =
@@ -22,11 +22,37 @@ fun main(args: Array<String>) {
}
}
// Performs substitution similar to:
// foo = ${foo} ${foo.${arch}} ${foo.${os}}
private fun substitute(properties: Properties, substitutions: Map<String, String>) {
for (key in properties.stringPropertyNames()) {
if (key.contains('.')) {
continue
}
var value = ""
for (substitution in substitutions.keys) {
val property = properties.getProperty(key + "." + substitutions[substitution])
if (property != null) {
value += " " + property
}
}
if (value != "") {
properties.setProperty(key, properties.getProperty(key, "") + " " + value)
}
}
}
private fun processDefFile(ktSrcRoot: String, defFile: File, ktGenRoot: String, nativeLibsDir: String, llvmInstallPath: String) {
val config = Properties()
defFile.bufferedReader().use { reader ->
config.load(reader)
}
// TODO: remove OSX defaults.
val substitutions = mapOf(
"arch" to (System.getenv("TARGET_ARCH") ?: "x86-64"),
"os" to (System.getenv("TARGET_OS") ?: "osx")
)
substitute(config, substitutions)
val headerFiles = config.getProperty("headers").split(' ')
val compilerOpts = config.getProperty("compilerOpts").split(' ')
+2 -3
View File
@@ -23,7 +23,6 @@ linkerOpts = -stdlib=libc++ -fPIC -fvisibility-inlines-hidden \
-lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMInterpreter \
-lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMProfileData -lLLVMTransformUtils \
-lLLVMBitWriter -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser \
-lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lcurses -lpthread -lz -lm \
-lffi
-lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lz -lm -lffi
excludedFunctions =
linkerOpts.osx = -lcurses
@@ -23,7 +23,7 @@ linkerOpts = -stdlib=libc++ -fPIC -fvisibility-inlines-hidden \
-lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMInterpreter \
-lLLVMCodeGen -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMProfileData -lLLVMTransformUtils \
-lLLVMBitWriter -lLLVMExecutionEngine -lLLVMTarget -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser \
-lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lcurses -lpthread -lz -lm \
-lLLVMBitReader -lLLVMMC -lLLVMCore -lLLVMSupport -lpthread -lz -lm \
-lffi
excludedFunctions =
linkerOpts.osx = -lcurses