Keep the platform and rule type in destructured form in the compilation task.
diff --git a/kotlin/builder/integrationtests/KotlinBuilderTestCase.java b/kotlin/builder/integrationtests/KotlinBuilderTestCase.java
index f21119d..5fe32c7 100644
--- a/kotlin/builder/integrationtests/KotlinBuilderTestCase.java
+++ b/kotlin/builder/integrationtests/KotlinBuilderTestCase.java
@@ -88,7 +88,8 @@
builder.getInfoBuilder()
.setLabel("//some/bogus:" + label)
.setModuleName("some_bogus_module")
- .setRuleKind("kt_jvm_library")
+ .setPlatform(KotlinModel.CompilationTask.Info.Platform.JVM)
+ .setRuleKind(KotlinModel.CompilationTask.Info.RuleKind.LIBRARY)
.setToolchainInfo(
KotlinModel.KotlinToolchainInfo.newBuilder()
.setCommon(
diff --git a/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar b/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
index 80467f0..57e15f8 100755
--- a/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
+++ b/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
Binary files differ
diff --git a/kotlin/builder/proto/kotlin_model.proto b/kotlin/builder/proto/kotlin_model.proto
index 7b5bb38..f54fd54 100644
--- a/kotlin/builder/proto/kotlin_model.proto
+++ b/kotlin/builder/proto/kotlin_model.proto
@@ -67,19 +67,33 @@
// Mested messages not marked with stable could be refactored.
message CompilationTask {
message Info {
+ enum RuleKind {
+ LIBRARY = 0;
+ BINARY = 1;
+ TEST = 2;
+ IMPORT = 3;
+ }
+
+ enum Platform {
+ JVM = 0;
+ JS = 1;
+ }
+
string label = 1;
- // The rule kind requesting the build.
- string rule_kind = 2;
+ // The Platform type.
+ Platform platform = 2;
+ // The kind of the rule.
+ RuleKind rule_kind = 3;
// The name of the module being compiled.
- string module_name = 3;
+ string module_name = 4;
// Flags to be passed straight through to the compiler.
- string passthrough_flags = 4;
+ string passthrough_flags = 5;
// Toolchain info for this build.
- KotlinToolchainInfo toolchain_info = 5;
+ KotlinToolchainInfo toolchain_info = 6;
// Compiler plugin descriptors.
- CompilerPlugins plugins = 6;
+ CompilerPlugins plugins = 7;
// Paths to Jars that the kotlin compiler will allow package private access to.
- repeated string friend_paths = 7;
+ repeated string friend_paths = 8;
}
// Directories used by the builder.
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/TaskBuilder.kt b/kotlin/builder/src/io/bazel/kotlin/builder/TaskBuilder.kt
index 84d24fc..204d623 100644
--- a/kotlin/builder/src/io/bazel/kotlin/builder/TaskBuilder.kt
+++ b/kotlin/builder/src/io/bazel/kotlin/builder/TaskBuilder.kt
@@ -103,7 +103,15 @@
with(root.infoBuilder) {
label = argMap.mandatorySingle(JavaBuilderFlags.TARGET_LABEL.flag)
- ruleKind = argMap.mandatorySingle(JavaBuilderFlags.RULE_KIND.flag)
+ argMap.mandatorySingle(JavaBuilderFlags.RULE_KIND.flag).split("_").also {
+ check(it.size == 3 && it[0] == "kt")
+ platform = checkNotNull(CompilationTask.Info.Platform.valueOf(it[1].toUpperCase())) {
+ "unrecognized platform ${it[1]}"
+ }
+ ruleKind = checkNotNull(CompilationTask.Info.RuleKind.valueOf(it[2].toUpperCase())) {
+ "unrecognized rule kind ${it[2]}"
+ }
+ }
moduleName = argMap.mandatorySingle("--kotlin_module_name").also {
check(it.isNotBlank()) { "--kotlin_module_name should not be blank" }
}
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/OutputJarCreator.kt b/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/OutputJarCreator.kt
index 540f673..15c3be1 100644
--- a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/OutputJarCreator.kt
+++ b/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/OutputJarCreator.kt
@@ -16,6 +16,7 @@
package io.bazel.kotlin.builder.tasks.jvm
import com.google.inject.ImplementedBy
+import io.bazel.kotlin.builder.utils.bazelRuleKind
import io.bazel.kotlin.builder.utils.jars.JarCreator
import io.bazel.kotlin.model.KotlinModel
import java.nio.file.Paths
@@ -34,7 +35,7 @@
).also {
it.addDirectory(Paths.get(command.directories.classes))
it.addDirectory(Paths.get(command.directories.generatedClasses))
- it.setJarOwner(command.info.label, command.info.ruleKind)
+ it.setJarOwner(command.info.label, command.info.bazelRuleKind)
it.execute()
}
}
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt b/kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt
index 55cfc0e..7003979 100644
--- a/kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt
+++ b/kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt
@@ -29,6 +29,8 @@
val CompilationTask.Inputs.joinedClasspath: String get() = this.classpathList.joinToString(File.pathSeparator)
+val CompilationTask.Info.bazelRuleKind: String get() = "kt_${platform.name.toLowerCase()}_${ruleKind.name.toLowerCase()}"
+
private fun CompilationTask.updateBuilder(
init: (CompilationTask.Builder) -> Unit
): CompilationTask =