K2JS: add ed outputPrefix and outputPostfix compiler arguments to K2JSCompiler.
This commit is contained in:
+6
@@ -45,4 +45,10 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "main", description = "Whether a main function should be called; either '" + CALL +
|
||||
"' or '" + NO_CALL + "', default '" + CALL + "' (main function will be auto detected)")
|
||||
public String main;
|
||||
|
||||
@Argument(value = "outputPrefix", description = "Path to file which will be added to the begin of output file")
|
||||
public String outputPrefix;
|
||||
|
||||
@Argument(value = "outputPostfix", description = "Path to file which will be added to the end of output file")
|
||||
public String outputPostfix;
|
||||
}
|
||||
|
||||
@@ -104,8 +104,30 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
return COMPILATION_ERROR;
|
||||
}
|
||||
|
||||
File outputPrefixFile = null;
|
||||
if (arguments.outputPrefix != null) {
|
||||
outputPrefixFile = new File(arguments.outputPrefix);
|
||||
if (!outputPrefixFile.exists()) {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR,
|
||||
"Output prefix file '" + arguments.outputPrefix + "' not found",
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
return ExitCode.COMPILATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
File outputPostfixFile = null;
|
||||
if (arguments.outputPostfix != null) {
|
||||
outputPostfixFile = new File(arguments.outputPostfix);
|
||||
if (!outputPostfixFile.exists()) {
|
||||
messageCollector.report(CompilerMessageSeverity.ERROR,
|
||||
"Output postfix file '" + arguments.outputPostfix + "' not found",
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
return ExitCode.COMPILATION_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
MainCallParameters mainCallParameters = createMainCallParameters(arguments.main);
|
||||
return translateAndGenerateOutputFile(mainCallParameters, environmentForJS, config, outputFile);
|
||||
return translateAndGenerateOutputFile(mainCallParameters, environmentForJS, config, outputFile, outputPrefixFile, outputPostfixFile);
|
||||
}
|
||||
|
||||
private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector,
|
||||
@@ -131,10 +153,13 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
@NotNull MainCallParameters mainCall,
|
||||
@NotNull JetCoreEnvironment environmentForJS,
|
||||
@NotNull Config config,
|
||||
@NotNull String outputFile
|
||||
@NotNull String outputFile,
|
||||
@Nullable File outputPrefix,
|
||||
@Nullable File outputPostfix
|
||||
) {
|
||||
try {
|
||||
K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCall, environmentForJS.getSourceFiles(), outputFile, config);
|
||||
K2JSTranslator.translateWithMainCallParametersAndSaveToFile(mainCall, environmentForJS.getSourceFiles(),
|
||||
outputFile, outputPrefix, outputPostfix, config);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user