pw_{bluetooth_sapphire, env_setup}: Use amd64 SDK
Fuchsia doesn't release arm64 SDKs.
Fixed: 330214852
Change-Id: I8577d36ae4fbebb52352365d9980c150e603963e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/197510
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Commit-Queue: Darren Chan <chandarren@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/WORKSPACE b/WORKSPACE
index 6c31dd6..36020b2 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -175,7 +175,7 @@
# See https://github.com/bazelbuild/bazel/issues/1550
cipd_repository(
name = "fuchsia_sdk",
- path = "fuchsia/sdk/core/fuchsia-bazel-rules/${os}-${arch}",
+ path = "fuchsia/sdk/core/fuchsia-bazel-rules/${os}-amd64",
tag = "version:19.20240315.0.1",
)
@@ -196,6 +196,13 @@
register_clang_toolchains()
+# Since Fuchsia doesn't release arm64 SDKs, use this to gate Fuchsia targets.
+load("//pw_env_setup:bazel/host_metadata_repository.bzl", "host_metadata_repository")
+
+host_metadata_repository(
+ name = "host_metadata",
+)
+
# Set up rules for Abseil C++.
# Must be included before com_google_googletest and rules_fuzzing.
# Required by: rules_fuzzing, fuzztest
diff --git a/pw_bluetooth_sapphire/fuchsia/hello_world/BUILD.bazel b/pw_bluetooth_sapphire/fuchsia/hello_world/BUILD.bazel
index f6aef26..fda7e5d 100644
--- a/pw_bluetooth_sapphire/fuchsia/hello_world/BUILD.bazel
+++ b/pw_bluetooth_sapphire/fuchsia/hello_world/BUILD.bazel
@@ -24,6 +24,7 @@
"fuchsia_platforms",
"fuchsia_unittest_package",
)
+load("//pw_bluetooth_sapphire/fuchsia:host_x64.bzl", "MANUAL_IF_NOT_HOST_X64")
fuchsia_cc_binary(
name = "hello_world",
@@ -55,6 +56,7 @@
],
fuchsia_api_level = "HEAD",
platform = fuchsia_platforms.x64,
+ tags = MANUAL_IF_NOT_HOST_X64,
)
fuchsia_cc_test(
@@ -74,6 +76,7 @@
fuchsia_api_level = "HEAD",
platform = fuchsia_platforms.x64,
# TODO: b/42178254 - Reenable after we've rolled gtest.
+ # tags = MANUAL_IF_NOT_HOST_X64,
tags = ["manual"],
unit_tests = [
":hello_gtest",
diff --git a/pw_bluetooth_sapphire/fuchsia/host_x64.bzl b/pw_bluetooth_sapphire/fuchsia/host_x64.bzl
new file mode 100644
index 0000000..52d90e4
--- /dev/null
+++ b/pw_bluetooth_sapphire/fuchsia/host_x64.bzl
@@ -0,0 +1,19 @@
+# Copyright 2024 The Pigweed Authors
+#
+# 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
+#
+# https://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.
+
+"""Allows targets to be marked manual if the host/exec architecture is incompatible (non-x64)."""
+
+load("@host_metadata//:host_metadata.bzl", "HOST_ARCH")
+
+MANUAL_IF_NOT_HOST_X64 = [] if HOST_ARCH == "arm64" else ["manual"]
diff --git a/pw_env_setup/bazel/host_metadata_repository.bzl b/pw_env_setup/bazel/host_metadata_repository.bzl
new file mode 100644
index 0000000..121df78
--- /dev/null
+++ b/pw_env_setup/bazel/host_metadata_repository.bzl
@@ -0,0 +1,27 @@
+# Copyright 2024 The Pigweed Authors
+#
+# 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
+#
+# https://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.
+
+"""Intializes a workspace with information about the host os and arch."""
+
+def _host_metadata_repository_impl(rctx):
+ rctx.file("BUILD.bazel", "exports_files(glob(['**/*']))")
+ rctx.file("host_metadata.bzl", """
+HOST_OS = "%s"
+HOST_ARCH = "%s"
+""" % (rctx.os.name, rctx.os.arch))
+
+host_metadata_repository = repository_rule(
+ implementation = _host_metadata_repository_impl,
+ doc = "Intializes a workspace with information about the host os and arch.",
+)