Initial checkin of klib support.
The libraries exist in two incarnations:
packed foo.klib and unpacked foo/ .
The compiler when given '-library foo' expects to find either
a foo.klib file and unpack it, or an already unpacked foo/ directory.
The stdlib is always unpacked in dist/klib .
The semantics of -o has changed slightly.
It now accepts '-o foo' and the compiler
either produces foo.kexe or foo.klib .
This commit is contained in:
committed by
alexander-gorshenev
parent
77e093354f
commit
3b5ce031f8
@@ -90,36 +90,38 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
||||
|
||||
put(NOSTDLIB, arguments.nostdlib)
|
||||
put(NOLINK, arguments.nolink)
|
||||
put(NOPACK, arguments.nopack)
|
||||
put(NOMAIN, arguments.nomain)
|
||||
put(LIBRARY_FILES,
|
||||
arguments.libraries.toNonNullList())
|
||||
|
||||
put(LINKER_ARGS, arguments.linkerArguments.toNonNullList())
|
||||
if (arguments.target != null)
|
||||
put(TARGET, arguments.target)
|
||||
|
||||
put(NATIVE_LIBRARY_FILES,
|
||||
arguments.nativeLibraries.toNonNullList())
|
||||
|
||||
// TODO: Collect all the explicit file names into an object
|
||||
// and teach the compiler to work with temporaries and -save-temps.
|
||||
val bitcodeFile = if (arguments.nolink) {
|
||||
arguments.outputFile ?: "program.kt.bc"
|
||||
} else {
|
||||
"${arguments.outputFile ?: "program"}.kt.bc"
|
||||
val library = arguments.outputFile ?: "library"
|
||||
if (arguments.nolink)
|
||||
put(LIBRARY_NAME, library)
|
||||
put(LIBRARY_FILE, "${library}.klib")
|
||||
val program = arguments.outputFile ?: "program"
|
||||
if (!arguments.nolink) {
|
||||
put(PROGRAM_NAME,program)
|
||||
put(EXECUTABLE_FILE,"${program}.kexe")
|
||||
}
|
||||
put(BITCODE_FILE, bitcodeFile)
|
||||
|
||||
// This is a decision we could change
|
||||
put(CommonConfigurationKeys.MODULE_NAME, bitcodeFile)
|
||||
val module = if (arguments.nolink) library else program
|
||||
put(CommonConfigurationKeys.MODULE_NAME, module)
|
||||
put(ABI_VERSION, 1)
|
||||
|
||||
put(EXECUTABLE_FILE,
|
||||
arguments.outputFile ?: "program.kexe")
|
||||
if (arguments.runtimeFile != null)
|
||||
put(RUNTIME_FILE, arguments.runtimeFile)
|
||||
if (arguments.propertyFile != null)
|
||||
put(PROPERTY_FILE, arguments.propertyFile)
|
||||
if (arguments.target != null)
|
||||
put(TARGET, arguments.target)
|
||||
put(LIST_TARGETS, arguments.listTargets)
|
||||
put(OPTIMIZATION, arguments.optimization)
|
||||
put(DEBUG, arguments.debug)
|
||||
|
||||
@@ -38,6 +38,9 @@ public class K2NativeCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "-nolink", description = "Don't link, just produce a bitcode file")
|
||||
public boolean nolink;
|
||||
|
||||
@Argument(value = "-nopack", description = "Don't pack the library into a klib file")
|
||||
public boolean nopack;
|
||||
|
||||
@Argument(value = "-nomain", description = "Assume 'main' entry point to be provided by external libraries")
|
||||
public boolean nomain;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user