Added "Additional command line parameters" to the Kotlin Compiler Settings tab.
Original commit: faa82317b6
This commit is contained in:
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JSCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.jet.compiler.AdditionalCompilerSettings;
|
||||
import org.jetbrains.jps.model.JpsElementChildRole;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase;
|
||||
@@ -34,6 +35,8 @@ public class JpsKotlinCompilerSettings extends JpsElementBase<JpsKotlinCompilerS
|
||||
public K2JVMCompilerArguments k2JvmCompilerSettings = new K2JVMCompilerArguments();
|
||||
@NotNull
|
||||
public K2JSCompilerArguments k2JsCompilerSettings = new K2JSCompilerArguments();
|
||||
@NotNull
|
||||
public AdditionalCompilerSettings additionalCompilerSettings = new AdditionalCompilerSettings();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -42,6 +45,7 @@ public class JpsKotlinCompilerSettings extends JpsElementBase<JpsKotlinCompilerS
|
||||
copy.commonCompilerSettings = this.commonCompilerSettings;
|
||||
copy.k2JvmCompilerSettings = this.k2JvmCompilerSettings;
|
||||
copy.k2JsCompilerSettings = this.k2JsCompilerSettings;
|
||||
copy.additionalCompilerSettings = this.additionalCompilerSettings;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -95,4 +99,13 @@ public class JpsKotlinCompilerSettings extends JpsElementBase<JpsKotlinCompilerS
|
||||
public static void setK2JsSettings(@NotNull JpsProject project, @NotNull K2JSCompilerArguments k2JsCompilerSettings) {
|
||||
getOrCreateSettings(project).k2JsCompilerSettings = k2JsCompilerSettings;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AdditionalCompilerSettings getAdditionalSettings(@NotNull JpsProject project) {
|
||||
return getSettings(project).additionalCompilerSettings;
|
||||
}
|
||||
|
||||
public static void setAdditionalSettings(@NotNull JpsProject project, @NotNull AdditionalCompilerSettings additionalCompilerSettings) {
|
||||
getOrCreateSettings(project).additionalCompilerSettings = additionalCompilerSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.compiler.AdditionalCompilerSettings;
|
||||
import org.jetbrains.jet.compiler.runner.CompilerEnvironment;
|
||||
import org.jetbrains.jet.compiler.runner.CompilerRunnerConstants;
|
||||
import org.jetbrains.jet.compiler.runner.OutputItemsCollectorImpl;
|
||||
@@ -117,6 +118,7 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
|
||||
JpsProject project = representativeTarget.getModule().getProject();
|
||||
CommonCompilerArguments commonSettings = JpsKotlinCompilerSettings.getCommonSettings(project);
|
||||
AdditionalCompilerSettings additionalSettings = JpsKotlinCompilerSettings.getAdditionalSettings(project);
|
||||
|
||||
if (JpsUtils.isJsKotlinModule(representativeTarget)) {
|
||||
if (chunk.getModules().size() > 1) {
|
||||
@@ -141,7 +143,8 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
List<String> libraryFiles = JpsJsModuleUtils.getLibraryFilesAndDependencies(representativeTarget);
|
||||
K2JSCompilerArguments k2JsSettings = JpsKotlinCompilerSettings.getK2JsSettings(project);
|
||||
|
||||
runK2JsCompiler(commonSettings, k2JsSettings, messageCollector, environment, outputItemCollector, sourceFiles, libraryFiles, outputFile);
|
||||
runK2JsCompiler(commonSettings, k2JsSettings, additionalSettings, messageCollector, environment,
|
||||
outputItemCollector, sourceFiles, libraryFiles, outputFile);
|
||||
}
|
||||
else {
|
||||
if (chunk.getModules().size() > 1) {
|
||||
@@ -160,7 +163,8 @@ public class KotlinBuilder extends ModuleLevelBuilder {
|
||||
|
||||
K2JVMCompilerArguments k2JvmSettings = JpsKotlinCompilerSettings.getK2JvmSettings(project);
|
||||
|
||||
runK2JvmCompiler(commonSettings, k2JvmSettings, messageCollector, environment, moduleFile, outputItemCollector);
|
||||
runK2JvmCompiler(commonSettings, k2JvmSettings, additionalSettings, messageCollector, environment,
|
||||
moduleFile, outputItemCollector);
|
||||
}
|
||||
|
||||
// If there's only one target, this map is empty: get() always returns null, and the representativeTarget will be used below
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.jps.model;
|
||||
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.compiler.AdditionalCompilerSettings;
|
||||
import org.jetbrains.jet.jps.JpsKotlinCompilerSettings;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.serialization.JpsProjectExtensionSerializer;
|
||||
|
||||
import static org.jetbrains.jet.compiler.SettingConstants.KOTLIN_ADDITIONAL_COMPILER_SETTINGS_SECTION;
|
||||
import static org.jetbrains.jet.compiler.SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE;
|
||||
|
||||
class KotlinAdditionalCompilerSettingsSerializer extends JpsProjectExtensionSerializer {
|
||||
KotlinAdditionalCompilerSettingsSerializer() {
|
||||
super(KOTLIN_COMPILER_SETTINGS_FILE, KOTLIN_ADDITIONAL_COMPILER_SETTINGS_SECTION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
|
||||
AdditionalCompilerSettings settings = XmlSerializer.deserialize(componentTag, AdditionalCompilerSettings.class);
|
||||
if (settings == null) {
|
||||
settings = new AdditionalCompilerSettings();
|
||||
}
|
||||
|
||||
JpsKotlinCompilerSettings.setAdditionalSettings(project, settings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveExtension(@NotNull JpsProject project, @NotNull Element componentTag) {
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ public class KotlinModelSerializerService extends JpsModelSerializerExtension {
|
||||
public List<? extends JpsProjectExtensionSerializer> getProjectExtensionSerializers() {
|
||||
return Arrays.asList(new KotlinCommonCompilerSettingsSerializer(),
|
||||
new Kotlin2JvmCompilerSettingsSerializer(),
|
||||
new Kotlin2JsCompilerSettingsSerializer());
|
||||
new Kotlin2JsCompilerSettingsSerializer(),
|
||||
new KotlinAdditionalCompilerSettingsSerializer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user