[K/N] cinterop: Do not expand non-constant macros

Expanding macros such as __FILE__ or __TIME__ exposes
arbitrary generated filenames and timestamps from the compiler
pipeline which are not useful for interop and makes the klib
generation non-deterministic. This patch instead redefines
the macros to just map to their name in the properties
available from Kotlin.

Co-authored-by: Johan Bay <jobay@google.com>
This commit is contained in:
Johan Bay
2022-10-12 16:54:00 +00:00
committed by Space
parent 49e343e08e
commit bc13173ea9
4 changed files with 37 additions and 1 deletions
@@ -0,0 +1,7 @@
---
#define KFILE "FILE:" __FILE__
#define KLINE "LINE:" __LINE__
#define KTIME "TIME:" __TIME__
#define KDATE "DATE:" __DATE__
#define KFILENAME "NAME:" __FILE_NAME__
#define KBASEFILE "BASE:" __BASE_FILE__
@@ -0,0 +1,12 @@
import kotlinx.cinterop.*
import kt54284.*
import kotlin.test.*
fun main() {
assertEquals(KFILE, "FILE:__FILE__")
assertEquals(KLINE, "LINE:__LINE__")
assertEquals(KTIME, "TIME:__TIME__")
assertEquals(KDATE, "DATE:__DATE__")
assertEquals(KFILENAME, "NAME:__FILE_NAME__")
assertEquals(KBASEFILE, "BASE:__BASE_FILE__")
}