-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change adds a platform-independent //third-party:probe-rs executable target in order to allow flashing utilities to make use of prebuilt probe-rs binaries. Change-Id: Ia23a59610b99dc33abb7722c0eae80c1d1f86c63 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/213693 Lint: Lint 🤖 <[email protected]> Commit-Queue: Taylor Cramer <[email protected]> Reviewed-by: Ted Pudlik <[email protected]>
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# 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("per_platform_alias.bzl", "per_platform_alias") | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
per_platform_alias( | ||
name = "probe-rs", | ||
platform_to_label = { | ||
"aarch64-linux": "@probe-rs-tools-aarch64-unknown-linux-gnu//:probe-rs", | ||
"aarch64-osx": "@probe-rs-tools-aarch64-apple-darwin//:probe-rs", | ||
"x86_64-linux": "@probe-rs-tools-x86_64-unknown-linux-gnu//:probe-rs", | ||
"x86_64-osx": "@probe-rs-tools-x86_64-apple-darwin//:probe-rs", | ||
"x86_64-windows": "@probe-rs-tools-x86_64-pc-windows-msvc//:probe-rs", | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
"""Defines the per_platform_alias rule.""" | ||
|
||
load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS") | ||
|
||
def _get_host_platform(): | ||
"""Return the <cpu>-<os> platform string (e.g. x86_64-linux).""" | ||
|
||
# HACK: HOST_CONSTRAINTS is a list containing the CPU constraint | ||
# followed by the OS constraint. We use this to figure out the | ||
# current CPU+OS pair. | ||
if len(HOST_CONSTRAINTS) != 2: | ||
fail("Unexpected HOST_CONSTRAINTS: " + HOST_CONSTRAINTS) | ||
cpu_constraint, os_constraint = HOST_CONSTRAINTS | ||
cpu = cpu_constraint.removeprefix("@platforms//cpu:") | ||
os = os_constraint.removeprefix("@platforms//os:") | ||
return cpu + "-" + os | ||
|
||
def per_platform_alias(name, platform_to_label): | ||
"""Aliases to a different target depending on platform. | ||
Args: | ||
name: The name of the resulting target. | ||
platform_to_label: A mapping from "<cpu>-<os>" platform string | ||
(e.g. x86_64-linux") to label that you wish to alias. | ||
""" | ||
host_platform = _get_host_platform() | ||
if not host_platform in platform_to_label: | ||
fail("No alias provided for platform " + host_platform) | ||
label = platform_to_label[host_platform] | ||
native.alias(name = name, actual = label) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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. | ||
|
||
""" | ||
A build file for probe-rs releases which merely exports the probe-rs binary. | ||
""" | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
exports_files(["probe-rs"]) |