Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skeleton for multitarget #983

Closed
wants to merge 85 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9aee74f
wip
smparkes Jan 27, 2020
3091da4
Merge remote-tracking branch 'upstream/master' into v2
smparkes Jan 27, 2020
c1e5f88
typo
smparkes Jan 27, 2020
5cccebc
wip
smparkes Jan 27, 2020
f0d27d8
wip
smparkes Jan 27, 2020
8432103
wip
smparkes Jan 27, 2020
fe39370
"unstable"
smparkes Jan 27, 2020
0ef707a
buildifier
smparkes Jan 27, 2020
6cffd0d
wip
smparkes Jan 27, 2020
84e9bfb
lint
smparkes Jan 27, 2020
ea51eae
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 27, 2020
476901e
Include toolchains attrs in example
smparkes Jan 27, 2020
3bc7668
very early documentation
smparkes Jan 28, 2020
12a2bba
typos and clarity
smparkes Jan 28, 2020
d6a3f63
typo
smparkes Jan 28, 2020
ec684ed
yat: yet another typo
smparkes Jan 28, 2020
8a50faa
skeleton for multitarget
smparkes Jan 28, 2020
cccf90a
setting to None should remove key, not leave it unchanged
smparkes Jan 28, 2020
289d9c6
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 28, 2020
cfb93ab
Merge branch 'configuration' into multitarget
smparkes Jan 28, 2020
d97415b
multitarget WIP
smparkes Jan 28, 2020
3ca7ab3
stupid typo during merge :-(
smparkes Jan 28, 2020
87fac0b
Merge branch 'configuration' into multitarget
smparkes Jan 28, 2020
daf8222
buildifier
smparkes Jan 28, 2020
55d16e7
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 28, 2020
5be863c
Merge branch 'configuration' into multitarget
smparkes Jan 28, 2020
6d91828
wip
smparkes Jan 29, 2020
c89aa79
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 29, 2020
c71c273
Merge branch 'configuration' into multitarget
smparkes Jan 29, 2020
4e120e0
wip
smparkes Jan 29, 2020
7a05cbb
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 29, 2020
fae944f
Merge branch 'configuration' into multitarget
smparkes Jan 29, 2020
414f6f6
update readme wrt to alias
smparkes Jan 29, 2020
76c7570
wip
smparkes Jan 29, 2020
ccb535e
thoughts on external repos
smparkes Jan 29, 2020
c4086c0
editing for typos and clarity
smparkes Jan 29, 2020
7de0616
Merge branch 'configuration' into multitarget
smparkes Jan 29, 2020
a3ba279
refactoring of files, buildifer
smparkes Jan 29, 2020
b1692a5
make test builds work
smparkes Jan 30, 2020
0aba00e
wip
smparkes Jan 30, 2020
c830919
wip
smparkes Jan 30, 2020
fa7265f
wip
smparkes Jan 30, 2020
052e029
cleanup
smparkes Jan 30, 2020
2263bdf
cleanup
smparkes Jan 30, 2020
236cafb
use bind to remove loader-specific labels in dependencies
smparkes Jan 30, 2020
6ef373b
simple test works; //test/... does not
smparkes Jan 30, 2020
794574b
cleanup
smparkes Jan 30, 2020
7b756bd
remove scalac provider and use toolchain resolution
smparkes Jan 30, 2020
fdddc97
put the scalac dep into the toolchain
smparkes Jan 30, 2020
f7f2fa3
Merge branch 'factor-scalac-provider' into factor-test-toolchain
smparkes Jan 30, 2020
c244161
missed these pieces
smparkes Jan 30, 2020
d68b94c
wip
smparkes Jan 30, 2020
ac43892
cleanup handling of toolchains
smparkes Jan 31, 2020
578ad8f
cleanup
smparkes Jan 31, 2020
05ed1e4
unused arguements
smparkes Jan 31, 2020
18451d1
wip
smparkes Jan 31, 2020
a5e38a4
lint
smparkes Jan 31, 2020
df5e833
Merge branch 'factor-toolchains' into factor-scalac-provider
smparkes Jan 31, 2020
0d8f08c
lib
smparkes Jan 31, 2020
bc577ec
Merge branch 'factor-scalac-provider' into factor-test-toolchain
smparkes Jan 31, 2020
c4b27ba
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 31, 2020
1b47309
Merge branch 'configuration' into multitarget
smparkes Jan 31, 2020
b738785
Merge remote-tracking branch 'upstream/master' into configuration
smparkes Jan 31, 2020
0ab261f
Merge remote-tracking branch 'upstream/master' into bind-dependencies
smparkes Jan 31, 2020
5bedbe7
Merge branch 'bind-dependencies' into factor-toolchains
smparkes Jan 31, 2020
a4b7d3c
lint
smparkes Jan 31, 2020
d78dd2c
Merge branch 'factor-toolchains' of github.com:smparkes/rules_scala i…
smparkes Jan 31, 2020
8ec626e
Merge branch 'factor-toolchains' into factor-scalac-provider
smparkes Jan 31, 2020
e4911c2
Merge branch 'factor-scalac-provider' into factor-test-toolchain
smparkes Jan 31, 2020
1efa23a
Merge branch 'factor-test-toolchain' into configuration
smparkes Jan 31, 2020
5eaba54
Merge branch 'configuration' into multitarget
smparkes Jan 31, 2020
84d5091
lint
smparkes Jan 31, 2020
f233be9
Merge branch 'multitarget' into multitarget-wip
smparkes Jan 31, 2020
0830776
wip
smparkes Jan 31, 2020
f577d41
update test toochain name
smparkes Jan 31, 2020
d3ce09d
Merge branch 'factor-test-toolchain' into configuration
smparkes Jan 31, 2020
1a24c40
Merge branch 'configuration' into multitarget
smparkes Jan 31, 2020
168728c
Merge branch 'multitarget' into multitarget-wip
smparkes Jan 31, 2020
949bdb7
wip
smparkes Jan 31, 2020
4027bf3
wip
smparkes Feb 1, 2020
2291f00
wip
smparkes Feb 1, 2020
c20abc9
wip
smparkes Feb 3, 2020
949f3d0
wip
smparkes Feb 3, 2020
274244e
wip
smparkes Feb 3, 2020
0c2395a
wip
smparkes Feb 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added BUILD.bazel
Empty file.
10 changes: 9 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ http_archive(
url = "https://github.com/bazelbuild/buildtools/archive/f27d1753c8b3210d9e87cdc9c45bc2739ae2c2db.zip",
)

load("//unstable/multiscala:repositories/rules_jvm_external.bzl", "load_rules_jvm_external")

load_rules_jvm_external()

load("@com_github_bazelbuild_buildtools//buildifier:deps.bzl", "buildifier_dependencies")

buildifier_dependencies()

load("//scala:scala.bzl", "scala_repositories")
load("//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("//scala:scala_repositories.bzl", "scala_repositories")

scala_repositories()

Expand Down
5 changes: 5 additions & 0 deletions private/example/App.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object App extends scala.App {
def version = scala.util.Properties.versionString

println(s"hello, world from $version!")
}
9 changes: 9 additions & 0 deletions private/example/AppTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import org.scalatest._

class AppTest extends FlatSpec with Matchers {
it should "have a successful test" in {
System.err.println(s"hello, world from ${scala.util.Properties.versionString}!")

App.version should be (scala.util.Properties.versionString)
}
}
26 changes: 26 additions & 0 deletions private/example/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load(
"@io_bazel_rules_scala//scala:scala.bzl",
"scala_binary",
"scala_library",
"scala_test",
)

scala_library(
name = "library",
srcs = glob(
["*.scala"],
exclude = ["*Test.scala"],
),
)

scala_binary(
name = "app",
main_class = "App",
runtime_deps = [":library"],
)

scala_test(
name = "test",
srcs = ["AppTest.scala"],
deps = [":library"],
)
27 changes: 27 additions & 0 deletions private/example/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("//repositories:bazel_skylib.bzl", "load_bazel_skylib")

load_bazel_skylib()

load("//repositories:rules_jvm_external.bzl", "load_rules_jvm_external")

load_rules_jvm_external()

load("//repositories:rules_scala.bzl", "load_rules_scala")

load_rules_scala()

load("//repositories:rules_proto.bzl", "load_rules_proto")

load_rules_proto()

load("//repositories:rules_python.bzl", "load_rules_python")

load_rules_python()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("@io_bazel_rules_scala//scala:scala_repositories.bzl", "scala_repositories")

scala_repositories()
Empty file.
11 changes: 11 additions & 0 deletions private/example/repositories/bazel_skylib.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""load skylib"""

load(":tools.bzl", _github_release = "github_release")

def load_bazel_skylib():
_github_release(
name = "bazel_skylib",
sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
repository = "bazelbuild/bazel-skylib",
release = "1.0.2",
)
11 changes: 11 additions & 0 deletions private/example/repositories/rules_jvm_external.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""load rules_jvm_external"""

load(":tools.bzl", _github_archive = "github_archive")

def load_rules_jvm_external():
_github_archive(
name = "rules_jvm_external",
repository = "bazelbuild/rules_jvm_external",
sha256 = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a",
tag = "3.0",
)
11 changes: 11 additions & 0 deletions private/example/repositories/rules_proto.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""load rules_proto: needed by protobuf repo"""

load(":tools.bzl", _github_archive = "github_archive")

def load_rules_proto():
_github_archive(
name = "rules_proto",
repository = "bazelbuild/rules_proto",
sha256 = "62847ac7740865d73a2c8199be292bba913d62e79084442f3e829c3058a25e64",
tag = "d7666ec475c1f8d4a6803cbc0a0b6b4374360868",
)
11 changes: 11 additions & 0 deletions private/example/repositories/rules_python.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""load rules_python: needed by protobuf repo"""

load(":tools.bzl", _github_archive = "github_archive")

def load_rules_python():
_github_archive(
name = "rules_python",
repository = "bazelbuild/rules_python",
sha256 = "7d64815f4b22400bed0f1b9da663037e1578573446b7bc78f20f24b2b5459bb9",
tag = "38f86fb55b698c51e8510c807489c9f4e047480e",
)
7 changes: 7 additions & 0 deletions private/example/repositories/rules_scala.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""link back to parent rules_scala repo"""

def load_rules_scala():
native.local_repository(
name = "io_bazel_rules_scala",
path = "../..",
)
28 changes: 28 additions & 0 deletions private/example/repositories/tools.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""helpers for to remove http_archive boilerplate

N.B.: doesn't currently include the bazel mirros
"""

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def github_release(name, repository, release, sha256):
(org, repo) = repository.split("/")
http_archive(
name = name,
sha256 = sha256,
urls = [
"https://github.com/{repository}/releases/download/{release}/{repo}-{release}.tar.gz".format(repository = repository, repo = repo, release = release),
],
)

def github_archive(name, repository, sha256, tag):
(org, repo) = repository.split("/")
without_v = tag[1:] if tag.startswith("v") else tag
http_archive(
name = name,
sha256 = sha256,
strip_prefix = "{repo}-{without_v}".format(repo = repo, without_v = without_v),
urls = [
"https://github.com/{repository}/archive/{tag}.zip".format(repository = repository, tag = tag),
],
)
94 changes: 69 additions & 25 deletions scala/BUILD
Original file line number Diff line number Diff line change
@@ -1,29 +1,91 @@
load(
"@io_bazel_rules_scala//scala:providers.bzl",
_declare_scalac_provider = "declare_scalac_provider",
)
load("//scala:bootstrap_toolchain.bzl", "bootstrap_toolchain")
load("//scala:scala_toolchain.bzl", "scala_toolchain")
load("//scala:scala_test_toolchain.bzl", "scala_test_toolchain")

# default toolchains registered by `scala_register_toolchains`

# bootstrap toolchain

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

bootstrap_toolchain(
name = "bootstrap_toolchain_impl",
classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
macro_classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
repl_classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
"@io_bazel_rules_scala_scala_compiler",
],
visibility = ["//visibility:public"],
)

toolchain(
name = "bootstrap_toolchain",
toolchain = ":bootstrap_toolchain_impl",
toolchain_type = "@io_bazel_rules_scala//scala:bootstrap_toolchain_type",
visibility = ["//visibility:public"],
)

# standard toolchain

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

scala_toolchain(
name = "default_toolchain_impl",
name = "toolchain_impl",
scalac = "//src/java/io/bazel/rulesscala/scalac",
scalacopts = [],
visibility = ["//visibility:public"],
)

toolchain(
name = "default_toolchain",
toolchain = ":default_toolchain_impl",
name = "toolchain",
toolchain = ":toolchain_impl",
toolchain_type = "@io_bazel_rules_scala//scala:toolchain_type",
visibility = ["//visibility:public"],
)

# test toolchain

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

scala_test_toolchain(
name = "scala_test_toolchain_impl",
reporter = "//scala/support:test_reporter",
runner = "//src/java/io/bazel/rulesscala/scala_test:runner",
visibility = ["//visibility:public"],
deps = [
"//external:io_bazel_rules_scala/dependency/scalatest/scalatest",
],
)

toolchain(
name = "scala_test_toolchain",
toolchain = ":scala_test_toolchain_impl",
toolchain_type = "@io_bazel_rules_scala//scala:scala_test_toolchain_type",
visibility = ["//visibility:public"],
)

# unused dependency checker toolchain

scala_toolchain(
name = "unused_dependency_checker_error_toolchain_impl",
scalac = "//src/java/io/bazel/rulesscala/scalac",
unused_dependency_checker_mode = "error",
visibility = ["//visibility:public"],
)
Expand All @@ -41,24 +103,6 @@ java_import(
visibility = ["//visibility:public"],
)

_declare_scalac_provider(
name = "scalac_default",
default_classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
default_macro_classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
],
default_repl_classpath = [
"@io_bazel_rules_scala_scala_library",
"@io_bazel_rules_scala_scala_reflect",
"@io_bazel_rules_scala_scala_compiler",
],
visibility = ["//visibility:public"],
)

java_library(
name = "PlaceHolderClassToCreateEmptyJarForScalaImport",
srcs = ["PlaceHolderClassToCreateEmptyJarForScalaImport.java"],
Expand Down
27 changes: 27 additions & 0 deletions scala/bootstrap_toolchain.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
BootstrapInfo = provider(
doc = "BootstrapInfo",
fields = [
"classpath",
"macro_classpath",
"repl_classpath",
],
)

def _impl(ctx):
toolchain = platform_common.ToolchainInfo(
bootstrapinfo = BootstrapInfo(
classpath = ctx.attr.classpath,
macro_classpath = ctx.attr.macro_classpath,
repl_classpath = ctx.attr.repl_classpath,
),
)
return [toolchain, platform_common.TemplateVariableInfo({})]

bootstrap_toolchain = rule(
_impl,
attrs = {
"classpath": attr.label_list(mandatory = True, allow_files = True),
"repl_classpath": attr.label_list(mandatory = True, allow_files = True),
"macro_classpath": attr.label_list(mandatory = True, allow_files = True),
},
)
2 changes: 1 addition & 1 deletion scala/plusone.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PlusOneDeps = provider(
)

def _collect_plus_one_deps_aspect_impl(target, ctx):
if (ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].plus_one_deps_mode == "off"):
if (ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].scalainfo.plus_one_deps_mode == "off"):
return []
export_plus_one_deps = []
for exported_dep in getattr(ctx.rule.attr, "exports", []):
Expand Down
5 changes: 0 additions & 5 deletions scala/private/common_attributes.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,6 @@ implicit_deps = {
"_java_runtime": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
),
"_scalac": attr.label(
default = Label(
"@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac",
),
),
"_exe": attr.label(
executable = True,
cfg = "host",
Expand Down
2 changes: 1 addition & 1 deletion scala/private/coverage_replacements_provider.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _is_enabled(ctx):
if "@io_bazel_rules_scala//scala:toolchain_type" not in ctx.toolchains:
return False
else:
return ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].enable_code_coverage_aspect == "on"
return ctx.toolchains["@io_bazel_rules_scala//scala:toolchain_type"].scalainfo.enable_code_coverage_aspect == "on"

coverage_replacements_provider = struct(
aspect = _aspect,
Expand Down
Loading