Skip to content

Commit

Permalink
fuchsia_sdk: Exclude targets from non-linux builds
Browse files Browse the repository at this point in the history
Move all references to @fuchsia_sdk into //pw_bluetooth_sapphire/fuchsia
and specify --deleted-packages=//pw_bluetooth_sapphire/fuchsia for macos
and windows host build configurations.

Bug: 357895400
Change-Id: Ib4eb9ea5556cc673ba1b40d2234324def23cdb35
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230391
Reviewed-by: Armando Montanez <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Ben Lawson <[email protected]>
Commit-Queue: Darren Chan <[email protected]>
  • Loading branch information
chandarrengoog authored and CQ Bot Account committed Aug 23, 2024
1 parent b0b9007 commit c82a1f3
Show file tree
Hide file tree
Showing 33 changed files with 712 additions and 383 deletions.
15 changes: 15 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,21 @@ common:remote_cache --remote_upload_local_results=false
# of --test_strategy value).
test --test_output=errors

# Exclude //pw_bluetooth_sapphire/fuchsia when the host platform is not
# linux-amd64. This is the only platform that the Fuchsia SDK supports.
common --enable_platform_specific_config
# Incompatible host platforms.
common:macos --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:windows --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
# Target build configurations for which @fuchsia_sdk is irrelevant and thus
# targets should be pruned to avoid fetching @fuchsia_sdk.
common:rp2350 --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:rp2040 --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:stm32f429i_baremetal --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:stm32f429i_freertos --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:lm3s6965evb --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...
common:microbit --deleted_packages=//pw_bluetooth_sapphire/fuchsia/...

# User bazelrc file; see
# https://bazel.build/configure/best-practices#bazelrc-file
#
Expand Down
25 changes: 4 additions & 21 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,12 @@ load("@fuchsia_infra//:workspace.bzl", "fuchsia_infra_workspace")

fuchsia_infra_workspace()

FUCHSIA_LINUX_SDK_VERSION = "version:22.20240717.3.1"

# The Fuchsia SDK is no longer released for MacOS, so we need to pin an older
# version, from the halcyon days when this OS was still supported.
FUCHSIA_MAC_SDK_VERSION = "version:20.20240408.3.1"
FUCHSIA_SDK_VERSION = "version:22.20240717.3.1"

cipd_repository(
name = "fuchsia_sdk",
path = "fuchsia/sdk/core/fuchsia-bazel-rules/${os}-amd64",
tag_by_os = {
"linux": FUCHSIA_LINUX_SDK_VERSION,
"mac": FUCHSIA_MAC_SDK_VERSION,
},
path = "fuchsia/sdk/core/fuchsia-bazel-rules/linux-amd64",
tag = FUCHSIA_SDK_VERSION,
)

load("@fuchsia_sdk//fuchsia:deps.bzl", "rules_fuchsia_deps")
Expand All @@ -83,10 +76,7 @@ register_toolchains("@fuchsia_sdk//:fuchsia_toolchain_sdk")
cipd_repository(
name = "fuchsia_products_metadata",
path = "fuchsia/development/product_bundles/v2",
tag_by_os = {
"linux": FUCHSIA_LINUX_SDK_VERSION,
"mac": FUCHSIA_MAC_SDK_VERSION,
},
tag = FUCHSIA_SDK_VERSION,
)

load("@fuchsia_sdk//fuchsia:products.bzl", "fuchsia_products_repository")
Expand All @@ -111,13 +101,6 @@ load("@fuchsia_clang//:defs.bzl", "register_clang_toolchains")

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",
)

# TODO: b/354268150 - googletest is in the BCR, but its MODULE.bazel doesn't
# express its dependency on the Fuchsia SDK correctly.
git_repository(
Expand Down
1 change: 1 addition & 0 deletions pw_bluetooth_sapphire/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,5 @@ cc_library(
includes = [
"public",
],
tags = ["manual"],
)
5 changes: 5 additions & 0 deletions pw_bluetooth_sapphire/docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ Fuchsia support
demonstrate building, running, and testing Fuchsia components and packages with
the Fuchsia SDK.

.. note::
Please do not add any fuchsia-specific dependencies (targets that load from
``@fuchsia_sdk``) outside of ``//pw_bluetooth_sapphire/fuchsia`` since that
will break the global pigweed build (``//...``) for macos hosts.

It will eventually be filled with the real `bt-host component`_ once that's
migrated. See https://fxbug.dev/321267390.

Expand Down
21 changes: 18 additions & 3 deletions pw_bluetooth_sapphire/fuchsia/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ load(
"fuchsia_test_group",
)
load("@rules_license//rules:license.bzl", "license")
load("//pw_bluetooth_sapphire/fuchsia:host_x64.bzl", "MANUAL_IF_NOT_LINUX_X64")

license(
name = "license_fuchsia",
package_name = "pw_bluetooth_sapphire (Fuchsia)",
license_text = "//:LICENSE",
license_text = "@pigweed//:LICENSE",
)

qemu_tests = [
Expand All @@ -44,6 +43,22 @@ fuchsia_test_group(
fuchsia_builder_group(
name = "infra",
build_only = [
# TODO: https://pwbug.dev/360411906 - Reenable once we can specify the
# correct build configuration for these tests.
# Then, move to `qemu_tests`.
# "//pw_bluetooth_sapphire/fuchsia/host/att:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/common:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/gap:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/gatt:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/hci:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/hci-spec:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/iso:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/l2cap:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/sco:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/sdp:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/sm:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/testing:test_pkg",
# "//pw_bluetooth_sapphire/fuchsia/host/transport:test_pkg",
],
test_groups = [
":tests_qemu",
Expand All @@ -52,5 +67,5 @@ fuchsia_builder_group(
"//pw_bluetooth_sapphire/fuchsia/bt_host:bt_host_x64_cipd",
"//pw_bluetooth_sapphire/fuchsia/bt_host:bt_host_arm64_cipd",
],
tags = MANUAL_IF_NOT_LINUX_X64,
tags = ["integration"],
)
44 changes: 44 additions & 0 deletions pw_bluetooth_sapphire/fuchsia/host/att/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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.

load(
"@fuchsia_sdk//fuchsia:defs.bzl",
"fuchsia_cc_test",
"fuchsia_unittest_package",
)
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

fuchsia_cc_test(
name = "att_test",
death_unittest = True,
# TODO: b/310957361 - gtest not supported on device
target_compatible_with = incompatible_with_mcu(),
deps = [
"//pw_bluetooth_sapphire/host/att",
"//pw_bluetooth_sapphire/host/att:att_test.lib",
"//pw_bluetooth_sapphire/host/l2cap:testing",
"//pw_bluetooth_sapphire/host/testing:gtest_main",
],
)

fuchsia_unittest_package(
name = "test_pkg",
package_name = "att_tests",
fuchsia_api_level = "22",
tags = ["manual"],
unit_tests = [
":att_test",
],
visibility = ["//visibility:public"],
)
46 changes: 46 additions & 0 deletions pw_bluetooth_sapphire/fuchsia/host/common/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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.

load(
"@fuchsia_sdk//fuchsia:defs.bzl",
"fuchsia_cc_test",
"fuchsia_unittest_package",
)
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

fuchsia_cc_test(
name = "common_test",
death_unittest = True,
# TODO: b/310957361 - gtest not supported on device
target_compatible_with = incompatible_with_mcu(),
deps = [
"//pw_async:fake_dispatcher_fixture",
"//pw_bluetooth_sapphire/host/common",
"//pw_bluetooth_sapphire/host/common:common_test.lib",
"//pw_bluetooth_sapphire/host/common:uuid_string_util",
"//pw_bluetooth_sapphire/host/testing",
"//pw_bluetooth_sapphire/host/testing:gtest_main",
],
)

fuchsia_unittest_package(
name = "test_pkg",
package_name = "common_tests",
fuchsia_api_level = "22",
tags = ["manual"],
unit_tests = [
":common_test",
],
visibility = ["//visibility:public"],
)
51 changes: 51 additions & 0 deletions pw_bluetooth_sapphire/fuchsia/host/gap/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# 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.

load(
"@fuchsia_sdk//fuchsia:defs.bzl",
"fuchsia_cc_test",
"fuchsia_unittest_package",
)
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

fuchsia_cc_test(
name = "gap_test",
death_unittest = True,
# TODO: b/310957361 - gtest not supported on device
target_compatible_with = incompatible_with_mcu(),
deps = [
"//pw_bluetooth_sapphire/host/common",
"//pw_bluetooth_sapphire/host/gap",
"//pw_bluetooth_sapphire/host/gap:gap_test.lib",
"//pw_bluetooth_sapphire/host/gap:testing",
"//pw_bluetooth_sapphire/host/gatt:testing",
"//pw_bluetooth_sapphire/host/hci:testing",
"//pw_bluetooth_sapphire/host/l2cap:testing",
"//pw_bluetooth_sapphire/host/sm",
"//pw_bluetooth_sapphire/host/sm:testing",
"//pw_bluetooth_sapphire/host/testing",
"//pw_bluetooth_sapphire/host/testing:gtest_main",
],
)

fuchsia_unittest_package(
name = "test_pkg",
package_name = "gap_tests",
fuchsia_api_level = "22",
tags = ["manual"],
unit_tests = [
":gap_test",
],
visibility = ["//visibility:public"],
)
42 changes: 42 additions & 0 deletions pw_bluetooth_sapphire/fuchsia/host/gatt/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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.

load(
"@fuchsia_sdk//fuchsia:defs.bzl",
"fuchsia_cc_test",
"fuchsia_unittest_package",
)
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

fuchsia_cc_test(
name = "gatt_test",
death_unittest = True,
# TODO: b/310957361 - gtest not supported on device
target_compatible_with = incompatible_with_mcu(),
deps = [
"//pw_bluetooth_sapphire/host/gatt:gatt_test.lib",
"@pigweed//pw_bluetooth_sapphire/host/testing:gtest_main",
],
)

fuchsia_unittest_package(
name = "test_pkg",
package_name = "gatt_tests",
fuchsia_api_level = "22",
tags = ["manual"],
unit_tests = [
":gatt_test",
],
visibility = ["//visibility:public"],
)
43 changes: 43 additions & 0 deletions pw_bluetooth_sapphire/fuchsia/host/hci-spec/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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.

load(
"@fuchsia_sdk//fuchsia:defs.bzl",
"fuchsia_cc_test",
"fuchsia_unittest_package",
)
load("//pw_build:compatibility.bzl", "incompatible_with_mcu")

fuchsia_cc_test(
name = "hci_spec_test",
size = "small",
# TODO: b/310957361 - gtest not supported on device
target_compatible_with = incompatible_with_mcu(),
deps = [
"//pw_bluetooth_sapphire/host/hci-spec",
"//pw_bluetooth_sapphire/host/hci-spec:hci-spec_test.lib",
"//pw_bluetooth_sapphire/host/testing:gtest_main",
],
)

fuchsia_unittest_package(
name = "test_pkg",
package_name = "hci_spec_tests",
fuchsia_api_level = "22",
tags = ["manual"],
unit_tests = [
":hci_spec_test",
],
visibility = ["//visibility:public"],
)
Loading

0 comments on commit c82a1f3

Please sign in to comment.