Skip to content

Commit 2fad4c8

Browse files
chaselattaCQ Bot
authored andcommitted
Revert "[bazel] pass platform in refresh-bazel-compdb"
This reverts commit b5eee20. Reason for revert: platforms should be informed by the bazel transition Original change's description: > [bazel] pass platform in refresh-bazel-compdb > > With the newer version of bazel, this tool started failing because the > c++ toolchain could not be resolved when there was no platform passed > in. This change includes the platform based on the current target_cpu. > > Change-Id: I7fe7bd696bd8bd311a3c9c009f794c0e6402670a > Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1182315 > Commit-Queue: Auto-Submit <[email protected]> > Fuchsia-Auto-Submit: Chase Latta <[email protected]> > Reviewed-by: Jiaming Li <[email protected]> Change-Id: I2263111b0b03a67798888a828a0ee050f2c7a4b9 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1182454 Reviewed-by: RubberStamper 🤖 <[email protected]> Commit-Queue: Chase Latta <[email protected]>
1 parent 2f8e3b1 commit 2fad4c8

File tree

2 files changed

+4
-41
lines changed

2 files changed

+4
-41
lines changed

tools/devshell/contrib/refresh-bazel-compdb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,13 @@ source "${_script_dir}/../lib/bazel_utils.sh" || exit $?
2222

2323
# We need to figure out our compilation mode to pass to bazel
2424
fx-build-dir-if-present || return 1
25-
optimization=$(
26-
fx-command-run gn args "${FUCHSIA_BUILD_DIR}" --list=optimize --json | \
27-
# Sometimes fx will print warnings so we pass it through sed to only grab the json between
28-
# the [].
29-
sed 's/.*\[\([^]]*\)\].*/\1/' | \
30-
fx-command-run jq '.[0] | if .current then .current else .default end | .value'
31-
)
32-
33-
# TODO: figure out the --platform to build
25+
optimization=$(fx-command-run gn args ${FUCHSIA_BUILD_DIR} --list=optimize --json | fx-command-run jq ".[0] | if .current then .current else .default end | .value")
26+
3427
BAZEL_EXE="$(fx-get-bazel)"
3528
"${_script_dir}/refresh-bazel-compdb-bin.py" \
36-
--bazel "$BAZEL_EXE" \
29+
--bazel $BAZEL_EXE \
3730
--optimization "${optimization}" \
3831
--build-dir "${FUCHSIA_BUILD_DIR}" \
39-
--target_cpu "$FUCHSIA_ARCH" \
4032
"$@"
4133

4234

tools/devshell/contrib/refresh-bazel-compdb-bin.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,6 @@
1616

1717
_SHOULD_LOG = False
1818

19-
_CPU_ALIASES = {
20-
"k8": "x86_64",
21-
"x86_64": "x86_64",
22-
"aarch64": "aarch64",
23-
"arm64": "aarch64",
24-
"riscv64": "riscv64",
25-
}
26-
_FUCHSIA_PLATFORMS_MAP = {
27-
"x86_64": "fuchsia_x64",
28-
"aarch64": "fuchsia_arm64",
29-
"riscv64": "fuchsia_riscv64",
30-
}
31-
3219

3320
class Action:
3421
"""Represents an action that comes from aquery"""
@@ -158,19 +145,8 @@ def collect_actions(action_graph: Sequence[Dict]) -> Sequence[Action]:
158145
return actions
159146

160147

161-
def platform_arg_for_target_cpu(target_cpu) -> str:
162-
cpu = _CPU_ALIASES[target_cpu]
163-
platform = _FUCHSIA_PLATFORMS_MAP[cpu]
164-
return (
165-
f"--platforms=@rules_fuchsia//fuchsia/constraints/platforms:{platform}"
166-
)
167-
168-
169148
def get_action_graph_from_labels(
170-
bazel_exe: str,
171-
compilation_mode: str,
172-
target_cpu: str,
173-
labels: Sequence[str],
149+
bazel_exe: str, compilation_mode, labels: Sequence[str]
174150
) -> Sequence[Dict]:
175151
labels_set = "set({})".format(" ".join(labels))
176152
info("Getting action graph for {}".format(labels_set))
@@ -180,7 +156,6 @@ def get_action_graph_from_labels(
180156
"aquery",
181157
"mnemonic('CppCompile',deps({}))".format(labels_set),
182158
compilation_mode,
183-
platform_arg_for_target_cpu(target_cpu),
184159
"--output=jsonproto",
185160
"--ui_event_filters=-info,-warning",
186161
"--noshow_loading_progress",
@@ -290,9 +265,6 @@ def main(argv: Sequence[str]):
290265
parser.add_argument(
291266
"--optimization", required=True, help="The build level optimization"
292267
)
293-
parser.add_argument(
294-
"--target_cpu", required=True, help="The target cpu we are building for"
295-
)
296268
parser.add_argument(
297269
"-v",
298270
"--verbose",
@@ -320,7 +292,6 @@ def main(argv: Sequence[str]):
320292
actions = get_action_graph_from_labels(
321293
args.bazel,
322294
compilation_mode(args),
323-
args.target_cpu,
324295
labels,
325296
)
326297

0 commit comments

Comments
 (0)