new kompiler parameter
This commit is contained in:
+4
@@ -55,6 +55,9 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@ValueDescription("<path>")
|
||||
public String kotlinHome;
|
||||
|
||||
@Argument(value = "module-name", description = "Module name")
|
||||
public String moduleName;
|
||||
|
||||
// Advanced options
|
||||
|
||||
@Argument(value = "Xno-call-assertions", description = "Don't generate not-null assertion after each invocation of method returning not-null")
|
||||
@@ -74,4 +77,5 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
public String executableScriptFileName() {
|
||||
return "kotlinc-jvm";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ public open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
else
|
||||
emptyList<AnalyzerScriptParameter>())
|
||||
|
||||
configuration.put(JVMConfigurationKeys.MODULE_NAME, arguments.moduleName ?: "main")
|
||||
|
||||
putAdvancedOptions(configuration, arguments)
|
||||
|
||||
messageSeverityCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment", CompilerMessageLocation.NO_LOCATION)
|
||||
|
||||
+2
-1
@@ -318,7 +318,8 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
@Override
|
||||
public AnalysisResult invoke() {
|
||||
BindingTrace sharedTrace = new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace();
|
||||
ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.getProject());
|
||||
ModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(environment.getProject(),
|
||||
getModuleName(environment));
|
||||
|
||||
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationWithCustomContext(
|
||||
moduleContext,
|
||||
|
||||
@@ -50,4 +50,8 @@ public class JVMConfigurationKeys {
|
||||
|
||||
public static final CompilerConfigurationKey<List<String>> MODULE_IDS =
|
||||
CompilerConfigurationKey.create("module id strings");
|
||||
|
||||
public static final CompilerConfigurationKey<String> MODULE_NAME =
|
||||
CompilerConfigurationKey.create("module name");
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.config
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
|
||||
public fun KotlinCoreEnvironment.getModuleName(): String = configuration.get(JVMConfigurationKeys.MODULE_NAME)!!
|
||||
@@ -78,6 +78,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.getJvmClasspathRoots;
|
||||
import static org.jetbrains.kotlin.cli.jvm.config.ConfigPackage.getModuleName;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.asmTypeByFqNameWithoutInnerClasses;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.registerClassNameForScript;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
@@ -106,7 +107,7 @@ public class ReplInterpreter {
|
||||
Project project = environment.getProject();
|
||||
this.psiFileFactory = (PsiFileFactoryImpl) PsiFileFactory.getInstance(project);
|
||||
this.trace = new CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace();
|
||||
MutableModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project);
|
||||
MutableModuleContext moduleContext = TopDownAnalyzerFacadeForJVM.createContextWithSealedModule(project, getModuleName(environment));
|
||||
this.module = moduleContext.getModule();
|
||||
|
||||
scriptDeclarationFactory = new ScriptMutableDeclarationProviderFactory();
|
||||
|
||||
Reference in New Issue
Block a user