[K/JS] Introduce the ability to consume platform-specific cli arguments inside the main function ^KT-16981 Fixed
This commit is contained in:
@@ -105,6 +105,7 @@ class JsIrBackendContext(
|
||||
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
|
||||
val errorPolicy = configuration[JSConfigurationKeys.ERROR_TOLERANCE_POLICY] ?: ErrorTolerancePolicy.DEFAULT
|
||||
override val es6mode = configuration[JSConfigurationKeys.USE_ES6_CLASSES] ?: false
|
||||
val platformArgumentsProviderJsExpression = configuration[JSConfigurationKeys.DEFINE_PLATFORM_MAIN_FUNCTION_ARGUMENTS]
|
||||
|
||||
val externalPackageFragment = mutableMapOf<IrFileSymbol, IrFile>()
|
||||
|
||||
|
||||
+7
-1
@@ -179,7 +179,13 @@ internal class ICHasher {
|
||||
hashCalculator.update(value.ordinal)
|
||||
}
|
||||
|
||||
hashCalculator.updateConfigKeys(config, listOf(JSConfigurationKeys.SOURCE_MAP_PREFIX)) { value: String ->
|
||||
hashCalculator.updateConfigKeys(
|
||||
config,
|
||||
listOf(
|
||||
JSConfigurationKeys.SOURCE_MAP_PREFIX,
|
||||
JSConfigurationKeys.DEFINE_PLATFORM_MAIN_FUNCTION_ARGUMENTS
|
||||
)
|
||||
) { value: String ->
|
||||
hashCalculator.update(value)
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -72,7 +72,11 @@ class MainFunctionCallWrapperLowering(private val context: JsIrBackendContext) :
|
||||
|
||||
return listOfNotNull(
|
||||
runIf(generateArgv) {
|
||||
JsIrBuilder.buildArray(
|
||||
context.platformArgumentsProviderJsExpression?.let {
|
||||
JsIrBuilder.buildCall(context.intrinsics.jsCode).apply {
|
||||
putValueArgument(0, it.toIrConst(context.irBuiltIns.stringType))
|
||||
}
|
||||
} ?: JsIrBuilder.buildArray(
|
||||
mainFunctionArgs.map { it.toIrConst(context.irBuiltIns.stringType) },
|
||||
valueParameters.first().type,
|
||||
context.irBuiltIns.stringType
|
||||
|
||||
Reference in New Issue
Block a user