JS backend: add -meta-info command line option for cli compiler
This commit is contained in:
+4
@@ -38,6 +38,10 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "source-map", description = "Generate source map")
|
||||
public boolean sourceMap;
|
||||
|
||||
@Argument(value = "meta-info", description = "Generate meta information and save to the given file")
|
||||
@ValueDescription("<path>")
|
||||
public String metaInfo;
|
||||
|
||||
@Argument(value = "target", description = "Generate JS files for specific ECMA version (only ECMA 5 is supported)")
|
||||
@ValueDescription("<version>")
|
||||
public String target;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<orderEntry type="module" module-name="backend-common" />
|
||||
<orderEntry type="module" module-name="serialization" />
|
||||
<orderEntry type="module" module-name="serialization.jvm" />
|
||||
<orderEntry type="module" module-name="js.serializer" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -29,6 +29,7 @@ import kotlin.Function1;
|
||||
import kotlin.Unit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.utils.serializer.KotlinJavaScriptSerializer;
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler;
|
||||
@@ -191,6 +192,10 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
}
|
||||
OutputUtilsPackage.writeAll(outputFiles, outputDir, messageCollector);
|
||||
|
||||
if (arguments.metaInfo != null) {
|
||||
new KotlinJavaScriptSerializer().serialize(config.getModuleId(), analysisResult.getModuleDescriptor(), new File(arguments.metaInfo));
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ where possible options include:
|
||||
-no-stdlib Don't use bundled Kotlin stdlib
|
||||
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
|
||||
-source-map Generate source map
|
||||
-meta-info <path> Generate meta information and save to the given file
|
||||
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
|
||||
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||
|
||||
Reference in New Issue
Block a user