-
Notifications
You must be signed in to change notification settings - Fork 275
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
Minimal cross-build support #1546
base: master
Are you sure you want to change the base?
Changes from all commits
19d7cff
79789c0
000c0fc
d8259b1
7afc81a
a02f738
f530160
6af4850
fdf2929
33ffea6
884c503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_binary", "scala_library") | ||
|
||
scala_library( | ||
name = "hello211", | ||
srcs = ["Hello211.scala"], | ||
scala_version = "2.11.12", | ||
) | ||
|
||
scala_library( | ||
name = "hello213", | ||
srcs = ["Hello213.scala"], | ||
scala_version = "2.13.12", | ||
) | ||
|
||
# scala 3.3.1 is default for this workspace | ||
scala_binary( | ||
name = "main", | ||
srcs = ["Main.scala"], | ||
main_class = "hello", | ||
deps = [ | ||
":hello211", | ||
":hello213", | ||
], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package examples.crossbuild | ||
|
||
class Hello211 { | ||
def hello = "Hello" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package examples.crossbuild | ||
|
||
class Hello213 { | ||
def hello = "Hello" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import examples.crossbuild.Hello211 | ||
import examples.crossbuild.Hello213 | ||
|
||
@main def hello = println(s"${(new Hello211).hello} from scala 2.11, ${(new Hello213).hello} from scala 2.13") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
workspace(name = "cross_build") | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
http_archive( | ||
name = "bazel_skylib", | ||
sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7", | ||
urls = [ | ||
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", | ||
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz", | ||
], | ||
) | ||
|
||
local_repository( | ||
name = "io_bazel_rules_scala", | ||
path = "../..", | ||
) | ||
|
||
load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config") | ||
|
||
scala_config( | ||
scala_version = "3.3.1", | ||
scala_versions = [ | ||
"2.11.12", | ||
"2.13.12", | ||
], | ||
) | ||
|
||
load( | ||
"@io_bazel_rules_scala//scala:scala.bzl", | ||
"rules_scala_setup", | ||
"rules_scala_toolchain_deps_repositories", | ||
) | ||
|
||
rules_scala_setup() | ||
|
||
rules_scala_toolchain_deps_repositories(fetch_sources = True) | ||
|
||
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains") | ||
|
||
rules_proto_dependencies() | ||
|
||
rules_proto_toolchains() | ||
|
||
load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains") | ||
|
||
scala_register_toolchains() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,30 @@ implicit_deps = { | |
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac"), | ||
allow_files = True, | ||
), | ||
"_scalac_before_2_12_13": attr.label( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @mateuszkuta256, thanks for PR. Does that mean that every scala version needs to be setup in workspace for this toolchain to work? ie all flavours of scalac worker needs to be compiled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey, let me explain this change in detail, as I am searching for an alternative solution anyway... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I see. At this point it's just a label and magic happens on action when you select As for alternatives I was playing with toolchain setup where each scala version is encapsulated/scoped in it's own repository and compiles it's own There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see you got rid of the circular dependency between toolchain and |
||
executable = True, | ||
cfg = "exec", | ||
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac:scalac_before_2_12_13"), | ||
allow_files = True, | ||
), | ||
"_scalac_after_2_12_13_and_before_2_13_12": attr.label( | ||
executable = True, | ||
cfg = "exec", | ||
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac:scalac_after_2_12_13_and_before_2_13_12"), | ||
allow_files = True, | ||
), | ||
"_scalac_after_2_13_12": attr.label( | ||
executable = True, | ||
cfg = "exec", | ||
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac:scalac_after_2_13_12"), | ||
allow_files = True, | ||
), | ||
"_scalac_3": attr.label( | ||
executable = True, | ||
cfg = "exec", | ||
default = Label("@io_bazel_rules_scala//src/java/io/bazel/rulesscala/scalac:scalac_3"), | ||
allow_files = True, | ||
), | ||
"_exe": attr.label( | ||
executable = True, | ||
cfg = "exec", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add this workspace to
/test/shell/test_examples.sh