Skip to content

Commit

Permalink
reflow the repository with buildifier
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyed committed Aug 10, 2018
1 parent 71e20d6 commit 24d69a6
Show file tree
Hide file tree
Showing 35 changed files with 475 additions and 347 deletions.
12 changes: 6 additions & 6 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
test_suite(
name = "all_tests",
tests = [
"//kotlin/builder/unittests",
"//kotlin/builder/integrationtests",
"//tests/integrationtests"
]
"//kotlin/builder/unittests",
"//tests/integrationtests",
],
)

# Local tests. Tests that shouldn't be run on the CI server.
test_suite(
name = "all_local_tests",
tests = [
":all_tests",
"//tests/integrationtests:integrationtests_local"
]
)
"//tests/integrationtests:integrationtests_local",
],
)
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ test.no_worker:
bazel shutdown
bazel test --strategy=KotlinCompile=local //:all_tests

reformat:
buildifier -mode=fix -v kotlin/*.bzl
buildifier -mode=fix -v kotlin/internal/*.bzl
sky.reflow:
scripts/reflow_skylark

deps.regen:
scripts/regen_deps
Expand Down
25 changes: 17 additions & 8 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,51 +11,60 @@
# 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.
workspace(name="io_bazel_rules_kotlin")
load("//kotlin/internal/repositories:repositories.bzl","github_archive")
workspace(name = "io_bazel_rules_kotlin")

load("//kotlin/internal/repositories:repositories.bzl", "github_archive")

github_archive(
name = "com_google_protobuf",
repo = "google/protobuf",
commit = "106ffc04be1abf3ff3399f54ccf149815b287dd9",
repo = "google/protobuf",
)

github_archive(
name = "build_bazel_rules_nodejs",
repo = "bazelbuild/rules_nodejs",
commit = "df3d2f577ec57ef5a622c809288a29545470c15d",
repo = "bazelbuild/rules_nodejs",
)

load("@build_bazel_rules_nodejs//:defs.bzl", "node_repositories")

node_repositories(package_json = [])

github_archive(
name = "io_bazel_rules_sass",
commit = "38989d69ef3ba5847640f007fee5cc489be6ede9",
repo = "bazelbuild/rules_sass",
commit = "38989d69ef3ba5847640f007fee5cc489be6ede9"
)

load("@io_bazel_rules_sass//sass:sass_repositories.bzl", "sass_repositories")

sass_repositories()

github_archive(
name = "bazel_skylib",
commit = "3fea8cb680f4a53a129f7ebace1a5a4d1e035914",
repo = "bazelbuild/bazel-skylib",
commit = "3fea8cb680f4a53a129f7ebace1a5a4d1e035914"
)

github_archive(
name = "io_bazel_skydoc",
commit = "f531844d137c7accc44d841c08a2a2a366688571",
repo = "bazelbuild/skydoc",
commit="f531844d137c7accc44d841c08a2a2a366688571"
)

load("@io_bazel_skydoc//skylark:skylark.bzl", "skydoc_repositories")

skydoc_repositories()

http_jar(
name = "bazel_deps",
url = "https://github.com/hsyed/bazel-deps/releases/download/v0.1.0/parseproject_deploy.jar",
sha256 = "05498224710808be9687f5b9a906d11dd29ad592020246d4cd1a26eeaed0735e",
url = "https://github.com/hsyed/bazel-deps/releases/download/v0.1.0/parseproject_deploy.jar",
)

load("//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")

kotlin_repositories()

kt_register_toolchains()
2 changes: 1 addition & 1 deletion examples/dagger/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ kt_jvm_library(
name = "coffee_lib",
srcs = glob(["src/**"]) + [
# Adding a file ending with .srcjar is how code generation patterns are implemented.
":tea_lib_src"
":tea_lib_src",
],
deps = [
":dagger_lib",
Expand Down
4 changes: 2 additions & 2 deletions kotlin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("//kotlin/internal:toolchains.bzl", "kt_toolchain_ide_info")

toolchain_type(
name = "kt_toolchain_type",
visibility = ["//visibility:public"]
visibility = ["//visibility:public"],
)

kt_toolchain_ide_info(name="kt_toolchain_ide_info")
kt_toolchain_ide_info(name = "kt_toolchain_ide_info")
18 changes: 9 additions & 9 deletions kotlin/builder/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@ java_binary(

filegroup(
name = "data_for_tests",
testonly = 1,
srcs = [
":compiler_lib",
"@com_github_jetbrains_kotlin//:kotlin-annotation-processing",
"@com_github_jetbrains_kotlin//:kotlin-compiler",
"@com_github_jetbrains_kotlin//:kotlin-script-runtime",
],
testonly = 1,
visibility = ["//visibility:private"],
)

java_library(
name = "builder_lib_for_tests",
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-reflect",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
],
testonly = 1,
data = [":data_for_tests"],
visibility = [
"//kotlin/builder/integrationtests:__subpackages__",
"//kotlin/builder/unittests:__subpackages__",
],
exports = [
"//kotlin/builder/src/io/bazel/kotlin/builder",
"//third_party/jvm/com/google/truth",
Expand All @@ -63,8 +63,8 @@ java_library(
"@io_bazel_rules_kotlin_com_google_guava_guava//jar",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
],
visibility = [
"//kotlin/builder/integrationtests:__subpackages__",
"//kotlin/builder/unittests:__subpackages__"
]
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-reflect",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
],
)
23 changes: 12 additions & 11 deletions kotlin/builder/bootstrap.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
load("//kotlin:kotlin.bzl", _for_ide = "kt_jvm_library")

_BOOTSTRAP_LIB_ARGS=["-jvm-target","1.8"]
_BOOTSTRAP_LIB_ARGS = ["-jvm-target", "1.8"]

def _resolve_dep_label(d):
if d.startswith("//kotlin/builder/src/io/bazel/kotlin") and not d.endswith("_for_ide"):
Expand All @@ -22,12 +22,12 @@ def _resolve_dep_label(d):
# untested
return d + "_for_ide"
else:
_ , _, target = d.rpartition("/")
_, _, target = d.rpartition("/")
return d + ":" + target + "_for_ide"
else:
return d

def kt_bootstrap_library(name, srcs, deps=[], neverlink_deps=[], runtime_deps=[]):
def kt_bootstrap_library(name, srcs, deps = [], neverlink_deps = [], runtime_deps = []):
"""
Simple compilation of a kotlin library using a non-persistent worker. The target is a JavaInfo provider.
Expand All @@ -44,9 +44,9 @@ def kt_bootstrap_library(name, srcs, deps=[], neverlink_deps=[], runtime_deps=[]
name = dep_label,
srcs = deps + neverlink_deps,
tags = ["no-ide"],
visibility=["//visibility:private"]
visibility = ["//visibility:private"],
)
command="""
command = """
KOTLIN_HOME=external/com_github_jetbrains_kotlin
function join_by { local IFS="$$1"; shift; echo "$$*"; }
Expand All @@ -69,30 +69,31 @@ $(location @bazel_tools//tools/jdk:singlejar) \
rm $${NAME}_temp.jar
""" % (name, dep_label, " ".join(_BOOTSTRAP_LIB_ARGS))
native.genrule(
name = jar_label,
name = jar_label,
tools = [
"@com_github_jetbrains_kotlin//:home",
"@local_jdk//:jdk",
"@bazel_tools//tools/jdk:singlejar",
dep_label
dep_label,
],
srcs = srcs,
outs = [name + ".jar"],
tags = ["no-ide"],
visibility = ["//visibility:private"],
cmd = command
cmd = command,
)
native.java_import(
name = name,
jars = [jar_label],
tags = ["no-ide"],
runtime_deps=deps + runtime_deps,
visibility=["//visibility:public"]
runtime_deps = deps + runtime_deps,
visibility = ["//visibility:public"],
)

# hsyed todo this part of the graph should not be wired up outside of development.
_for_ide(
name = name + "_for_ide",
srcs = srcs,
deps = [_resolve_dep_label(d) for d in deps] + neverlink_deps,
visibility = ["//kotlin/builder:__subpackages__"]
visibility = ["//kotlin/builder:__subpackages__"],
)
4 changes: 2 additions & 2 deletions kotlin/builder/integrationtests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ java_test(
name = "integrationtests",
srcs = glob(["*.java"]),
test_class = "io.bazel.kotlin.builder.KotlinBuilderTestSuite",
deps = ["//kotlin/builder:builder_lib_for_tests"]
)
deps = ["//kotlin/builder:builder_lib_for_tests"],
)
24 changes: 13 additions & 11 deletions kotlin/builder/proto/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,33 @@
# 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(default_visibility=["//visibility:public"])
package(default_visibility = ["//visibility:public"])

proto_library(
name = "kotlin_model_proto",
srcs = [":kotlin_model.proto"],
visibility=["//visibility:public"]
visibility = ["//visibility:public"],
)

java_proto_library(
name = "kotlin_model_java_proto",
deps = [":kotlin_model_proto"]
deps = [":kotlin_model_proto"],
)

_PROTO_LIBS=["deps", "worker_protocol"]
_PROTO_LIBS = [
"deps",
"worker_protocol",
]

[proto_library(
name="%s_proto" % lib,
srcs=["%s.proto" % lib]
) for lib in _PROTO_LIBS]
name = "%s_proto" % lib,
srcs = ["%s.proto" % lib],
) for lib in _PROTO_LIBS]

[java_proto_library(
name="%s_java_proto" % lib,
deps=["%s_proto" % lib],
) for lib in _PROTO_LIBS]

name = "%s_java_proto" % lib,
deps = ["%s_proto" % lib],
) for lib in _PROTO_LIBS]

java_import(
name = "deps",
Expand Down
Binary file modified kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
Binary file not shown.
10 changes: 5 additions & 5 deletions kotlin/builder/src/io/bazel/kotlin/builder/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ java_library(
srcs = glob(["*.java"]),
visibility = ["//kotlin/builder:__subpackages__"],
exports = [":builder_kt"],
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8",
"@io_bazel_rules_kotlin_com_google_code_gson_gson//jar",
],
deps = [
":builder_kt",
"//kotlin/builder/proto:kotlin_model",
"//third_party:dagger",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
],
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8",
"@io_bazel_rules_kotlin_com_google_code_gson_gson//jar",
]
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2018 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.
*/
package io.bazel.kotlin.builder.toolchain

sealed class KotlinToolException(
Expand Down
4 changes: 2 additions & 2 deletions kotlin/builder/unittests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ java_test(
test_class = "io.bazel.kotlin.builder.BuilderUnitTestSuite",
deps = [
"//kotlin/builder:builder_lib_for_tests",
"//third_party/jvm/com/google/truth:truth",
"//third_party/jvm/com/google/truth",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@io_bazel_rules_kotlin//kotlin/builder/proto:deps",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
]
],
)
14 changes: 7 additions & 7 deletions kotlin/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ load("//kotlin/internal:toolchains.bzl", "define_kt_toolchain")

config_setting(
name = "builder_debug_timings",
values = { "define": "kt_timings=1" }
values = {"define": "kt_timings=1"},
)

config_setting(
name = "builder_debug_trace",
values = { "define": "kt_trace=1" }
values = {"define": "kt_trace=1"},
)

define_kt_toolchain(
name = "default_toolchain",
debug=
debug =
select({
":builder_debug_trace": ["trace"],
"//conditions:default": []
"//conditions:default": [],
}) +
select({
":builder_debug_timings": ["timings"],
"//conditions:default": []
})
)
"//conditions:default": [],
}),
)
Loading

0 comments on commit 24d69a6

Please sign in to comment.