Skip to content

Commit

Permalink
Cleanup src tree (#288)
Browse files Browse the repository at this point in the history
* Move CompilationTaskContext to toolchain, as it doesn't really belong in utils.

* Move KotlinCompilerPluginArgsEncoder to toolchain. Temporary placement, new location TBD

* Isolate the utils package

* Move toolchain into a separate compilation unit. Causes some issues with inlining.

* Split apart test packages.

* Split apart test packages.

* Split apart test packages.

* add bazel version for development

* factor out JvmCompilationTask extensions to reuse in abi generation

* move compiler to source package. add .bazelversion for development
  • Loading branch information
restingbull authored Feb 27, 2020
1 parent 3ae7902 commit ffcd2b2
Show file tree
Hide file tree
Showing 22 changed files with 584 additions and 401 deletions.
8 changes: 5 additions & 3 deletions .bazelproject
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ targets:
//examples/dagger/...
# These targets are built for the ide only. Primary purpose is to ensure the builder can build the targets, but it's
# also a good way of testing the intellij plugin.
//src/main/kotlin/io/bazel/kotlin/builder:builder_kt_for_ide
//src/main/kotlin:compiler_lib_for_ide
//src/main/kotlin/io/bazel/kotlin/builder/tasks:tasks_for_ide
//src/main/kotlin/io/bazel/kotlin/builder/utils:utils_for_ide
//src/main/kotlin/io/bazel/kotlin/builder/toolchain:toolchain_for_ide
//src/main/kotlin/io/bazel/kotlin/compiler:compiler_for_ide

test_sources:
src/test/*
Expand All @@ -36,4 +38,4 @@ additional_languages:
kotlin

import_run_configurations:
src/test/Bazel_all_local_tests.xml
src/test/Bazel_all_local_tests.xml
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build --strategy=KotlinCompile=worker
build --test_output=errors
build --test_output=all
build --verbose_failures

1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.0.0
17 changes: 2 additions & 15 deletions src/main/kotlin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@rules_java//java:defs.bzl", "java_binary")
load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")
load("//kotlin:kotlin.bzl", "kt_jvm_library")
load("//third_party:jarjar.bzl", "jar_jar")
load("//kotlin/internal/utils:packager.bzl", "release_archive")

# The compiler library, this is co-located in the kotlin compiler classloader.
kt_bootstrap_library(
name = "compiler_lib",
srcs = glob(["io/bazel/kotlin/compiler/*.kt"]),
neverlink_deps = [
"@com_github_jetbrains_kotlin//:kotlin-compiler",
"@com_github_jetbrains_kotlin//:kotlin-annotation-processing",
"@com_github_jetbrains_kotlin//:kotlin-script-runtime",
],
visibility = ["//src/test/kotlin/io/bazel/kotlin/builder:__subpackages__"],
)

java_binary(
name = "builder_raw",
create_executable = False,
Expand All @@ -46,7 +33,7 @@ jar_jar(
java_binary(
name = "builder",
data = [
":compiler_lib.jar",
"//src/main/kotlin/io/bazel/kotlin/compiler:compiler",
"@com_github_jetbrains_kotlin//:lib/kotlin-compiler.jar",
],
jvm_flags = [
Expand All @@ -63,7 +50,7 @@ java_binary(
release_archive(
name = "pkg",
srcs = [
":compiler_lib.jar",
"//src/main/kotlin/io/bazel/kotlin/compiler:compiler",
],
package_dir = "src/main/kotlin", # explicitly set the package directory, as there are no parent release_archives.
src_map = {
Expand Down
24 changes: 3 additions & 21 deletions src/main/kotlin/io/bazel/kotlin/builder/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
load("@rules_java//java:defs.bzl", "java_library")
load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")

kt_bootstrap_library(
name = "builder_kt",
srcs = glob([
"toolchain/*.kt",
"tasks/**/*.kt",
"utils/**/*.kt",
]),
deps = [
"//src/main/protobuf:deps_java_proto",
"//src/main/protobuf:kotlin_model_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"@com_github_jetbrains_kotlin//:kotlin-preloader",
"@kotlin_rules_maven//:com_google_protobuf_protobuf_java",
"@kotlin_rules_maven//:com_google_protobuf_protobuf_java_util",
"@kotlin_rules_maven//:javax_inject_javax_inject",
],
)

java_library(
name = "builder",
srcs = glob(["*.java"]),
visibility = ["//src:__subpackages__"],
exports = [":builder_kt"],
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8",
],
deps = [
":builder_kt",
"//src/main/protobuf:deps_java_proto",
"//src/main/protobuf:kotlin_model_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"//third_party:dagger",
"@com_github_jetbrains_kotlin//:annotations",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@kotlin_rules_maven//:javax_inject_javax_inject",
"//src/main/kotlin/io/bazel/kotlin/builder/utils:utils",
"//src/main/kotlin/io/bazel/kotlin/builder/toolchain:toolchain",
"//src/main/kotlin/io/bazel/kotlin/builder/tasks:tasks",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor;
import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor;
import io.bazel.kotlin.builder.toolchain.KotlinToolchain;
import io.bazel.kotlin.builder.utils.KotlinCompilerPluginArgsEncoder;
import io.bazel.kotlin.builder.toolchain.KotlinCompilerPluginArgsEncoder;

import javax.inject.Singleton;
import java.io.PrintStream;
Expand Down
34 changes: 34 additions & 0 deletions src/main/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2020 The Bazel Authors. All rights reserved.
#
# 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.

load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")

kt_bootstrap_library(
name = "tasks",
srcs = glob([
"**/*.kt",
]),
visibility = ["//src:__subpackages__"],
deps = [
"//src/main/protobuf:deps_java_proto",
"//src/main/protobuf:kotlin_model_java_proto",
"//src/main/protobuf:worker_protocol_java_proto",
"@com_github_jetbrains_kotlin//:kotlin-preloader",
"@kotlin_rules_maven//:com_google_protobuf_protobuf_java",
"@kotlin_rules_maven//:com_google_protobuf_protobuf_java_util",
"@kotlin_rules_maven//:javax_inject_javax_inject",
"//src/main/kotlin/io/bazel/kotlin/builder/utils:utils",
"//src/main/kotlin/io/bazel/kotlin/builder/toolchain:toolchain",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package io.bazel.kotlin.builder.tasks
import io.bazel.kotlin.builder.tasks.js.Kotlin2JsTaskExecutor
import io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor
import io.bazel.kotlin.builder.toolchain.CompilationStatusException
import io.bazel.kotlin.builder.toolchain.CompilationTaskContext
import io.bazel.kotlin.builder.utils.*
import io.bazel.kotlin.model.*
import java.io.PrintStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package io.bazel.kotlin.builder.tasks.js

import io.bazel.kotlin.builder.toolchain.CompilationException
import io.bazel.kotlin.builder.toolchain.KotlinToolchain
import io.bazel.kotlin.builder.utils.CompilationTaskContext
import io.bazel.kotlin.builder.toolchain.CompilationTaskContext
import io.bazel.kotlin.builder.utils.addAll
import io.bazel.kotlin.builder.utils.jars.JarCreator
import io.bazel.kotlin.builder.utils.jars.SourceJarCreator
import io.bazel.kotlin.builder.utils.resolveTwinVerified
import io.bazel.kotlin.builder.utils.verifiedPath
import io.bazel.kotlin.model.JsCompilationTask
import java.io.FileOutputStream
import java.nio.file.Files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package io.bazel.kotlin.builder.tasks.jvm

import io.bazel.kotlin.builder.toolchain.KotlinToolchain
import io.bazel.kotlin.builder.utils.CompilationTaskContext
import io.bazel.kotlin.builder.toolchain.CompilationTaskContext
import io.bazel.kotlin.builder.utils.addAll
import io.bazel.kotlin.builder.utils.joinedClasspath
import io.bazel.kotlin.model.JvmCompilationTask
Expand Down
Loading

0 comments on commit ffcd2b2

Please sign in to comment.