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

fix(native_image): fix C++ toolchain env setup #72

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 7 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ bazel_dep(
name = "bazel_skylib",
version = "1.4.2",
)
bazel_dep(
name = "apple_support",
version = "1.8.1",
repo_name = "build_bazel_apple_support",
)

##
## Dependencies: Development
Expand Down Expand Up @@ -212,7 +217,8 @@ pip.parse(
python_version = PYTHON_VERSION,
requirements_lock = "@//:requirements_lock.txt",
extra_pip_args = [
"--no-binary", "grequests",
"--no-binary",
"grequests",
],
)
use_repo(pip, "pip", "pip_311")
Expand Down
10 changes: 2 additions & 8 deletions graalvm/nativeimage/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ _native_image = rule(
}),
executable = True,
fragments = [
"apple",
"cpp",
"java",
"platform",
"xcode",
],
toolchains = [
_BAZEL_CPP_TOOLCHAIN_TYPE,
Expand All @@ -55,17 +57,9 @@ def native_image(name, **kwargs):
"@bazel_tools//src/conditions:windows": "%target%-bin.exe",
"//conditions:default": "%target%-bin",
}),
enable_default_shell_env = select({
"@bazel_tools//src/conditions:windows": True,
"//conditions:default": True,
}),
check_toolchains = select({
"@bazel_tools//src/conditions:windows": True,
"//conditions:default": False,
}),
pass_compiler_path = select({
"@bazel_tools//src/conditions:windows": False,
"//conditions:default": True,
}),
**kwargs
)
19 changes: 10 additions & 9 deletions graalvm/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,31 @@ load(

# Exports.
def rules_graalvm_repositories(
omit_rules_java = False,
omit_bazel_skylib = False):

omit_rules_java = False,
omit_bazel_skylib = False,
omit_apple_support = False):
"""Register dependency repositories for the GraalVM Rules for Bazel.

This function only needs to be called if consuming the GraalVM Rules from a non-Bzlmod environment.
The only dependencies the rules have are: (1) `rules_java`, and (2) `bazel_skylib`. Either or both
can be omitted with the provided arguments.
The only dependencies the rules have are: (1) `rules_java`, (2) `bazel_skylib`, and
(3) `apple_support`. Any of those can be omitted with the provided arguments.

Args:
omit_rules_java: Omit the `rules_java` dependency.
omit_bazel_skylib: Omit the `bazel_skylib` dependency.
omit_apple_support: Omit the `apple_support` dependency.
"""

_rules_graalvm_repositories(
omit_rules_java = omit_rules_java,
omit_bazel_skylib = omit_bazel_skylib,
omit_apple_support = omit_apple_support,
)

def register_graalvm_toolchains(
name = "@graalvm",
register_java_toolchain = True,
register_gvm_toolchain = True):

name = "@graalvm",
register_java_toolchain = True,
register_gvm_toolchain = True):
"""Register Bazel toolchains via the installed GraalVM repository.

The default repository `name` is `@graalvm`, but this should be set to whatever the target repository
Expand Down
69 changes: 40 additions & 29 deletions internal/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,47 @@ load(
"maybe",
)

def rules_graalvm_repositories(
omit_rules_java = False,
omit_bazel_skylib = False,
omit_apple_support = False):
"""Defines dependencies for the GraalVM Rules for Bazel.

def rules_graalvm_repositories(omit_rules_java = False, omit_bazel_skylib = False):
"""Defines dependencies for the GraalVM Rules for Bazel.

This function only needs to be called if consuming the GraalVM Rules from a non-Bzlmod environment.
The only dependencies the rules have are: (1) `rules_java`, and (2) `bazel_skylib`. Either or both
can be omitted with the provided arguments.
This function only needs to be called if consuming the GraalVM Rules from a non-Bzlmod environment.
The only dependencies the rules have are: (1) `rules_java`, (2) `bazel_skylib`, and
(3) `apple_support`. Any of those can be omitted with the provided arguments.

Args:
omit_rules_java: Omit the `rules_java` dependency.
omit_bazel_skylib: Omit the `bazel_skylib` dependency.
"""
Args:
omit_rules_java: Omit the `rules_java` dependency.
omit_bazel_skylib: Omit the `bazel_skylib` dependency.
omit_apple_support: Omit the `apple_support` dependency.
"""

if not omit_rules_java:
maybe(
name = "rules_java",
repo_rule = http_archive,
sha256 = "27abf8d2b26f4572ba4112ae8eb4439513615018e03a299f85a8460f6992f6a3",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.4.0/rules_java-6.4.0.tar.gz",
],
)
if not omit_rules_java:
maybe(
name = "rules_java",
repo_rule = http_archive,
sha256 = "27abf8d2b26f4572ba4112ae8eb4439513615018e03a299f85a8460f6992f6a3",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.4.0/rules_java-6.4.0.tar.gz",
],
)

if not omit_bazel_skylib:
maybe(
name = "bazel_skylib",
repo_rule = http_archive,
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
],
)
if not omit_bazel_skylib:
maybe(
name = "bazel_skylib",
repo_rule = http_archive,
sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
],
)

if not omit_apple_support:
maybe(
name = "build_bazel_apple_support",
repo_rule = http_archive,
sha256 = "45d6bbad5316c9c300878bf7fffc4ffde13d620484c9184708c917e20b8b63ff",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.8.1/apple_support.1.8.1.tar.gz",
)
Loading