Skip to content

Commit

Permalink
feat (dist): Native Image {WIP, *BROKEN*}
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Dec 31, 2023
1 parent 4641c45 commit 3971f64
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
19 changes: 19 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,22 @@ bazel_dep(name = "gazelle", version = "0.35.0")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.host()

# https://github.com/sgammon/rules_graalvm
bazel_dep(name = "rules_graalvm", version = "0.10.3")

gvm = use_extension("@rules_graalvm//:extensions.bzl", "graalvm")

gvm.graalvm(
name = "graalvm",
# TODO Upgrade from 20.0.2 to 21.0.1 (here and also bump java_version below)
version = "20.0.2", # See https://github.com/graalvm/graalvm-ce-builds/releases/ or https://www.graalvm.org/release-notes/ or https://www.graalvm.org/downloads/ ?
distribution = "ce", # `oracle`, `ce`, or `community`
java_version = "20", # `17`, `20`, or `21`, as supported by the version provided
components = [
# if you need components like `js` or `wasm`, add them here
],
)
use_repo(gvm, "graalvm")
register_toolchains("@graalvm//:jvm")
register_toolchains("@graalvm//:sdk")
23 changes: 19 additions & 4 deletions cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
# limitations under the License.

load("@rules_java//java:defs.bzl", "java_binary", "java_test")
load("@rules_graalvm//graalvm:defs.bzl", "native_image")

java_binary(
name = "enola",
java_library(
name = "enola_library",
srcs = glob(["src/main/java/**/*.java"]),
main_class = "dev.enola.cli.Enola",
deps = [
"//common/common",
"//common/markdown",
Expand All @@ -40,13 +40,28 @@ java_binary(
],
)

java_binary(
name = "enola",
main_class = "dev.enola.cli.Enola",
runtime_deps = [
":enola_library",
]
)

native_image(
name = "enola-native",
deps = [":enola_library"],
main_class = "dev.enola.cli.Enola",
native_image_tool = "@graalvm//:native-image",
)

[java_test(
name = name[:-len(".java")],
size = "small",
srcs = glob(["src/test/java/**/*.java"]),
resources = glob(["src/test/resources/**/*"]),
deps = [
":enola",
":enola_library",
"//common/common",
"//common/markdown",
"//core/impl",
Expand Down

0 comments on commit 3971f64

Please sign in to comment.