| # Copyright 2024 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| # |
| # A starlark input file for bazel cquery that prints two lines of output that |
| # contain the paths of a fuchsia package archive, and its manifest file, |
| # followed by lines listing the directories containing the debug symbols for all |
| # binaries of a given fuchsia package. |
| # |
| # All paths are relative to the Bazel execroot. Example output: |
| # |
| # ``` |
| # bazel-out/x86_64-fastbuild-ST-191ad9aaea0e/bin/examples/drivers/template/pkg_fuchsia_package.far |
| # bazel-out/x86_64-fastbuild-ST-191ad9aaea0e/bin/examples/drivers/template/pkg_fuchsia_package_pkg/package_manifest.json |
| # bazel-out/x86_64-fastbuild-ST-191ad9aaea0e/bin/examples/drivers/template/pkg_fuchsia_package.elf_binaries/.build-id |
| # bazel-out/x86_64-fastbuild-ST-191ad9aaea0e/bin/examples/drivers/template/pkg_fuchsia_package_build_id_dir |
| # external/fuchsia_clang/lib/debug/.build-id |
| # external/fuchsia_sdk/.build-id |
| # ``` |
| # |
| # Example use: |
| # bazel cquery <config-options> |
| # --output=starlark --starlark:file=/path/to/this/file \ |
| # //path/to/fuchsia:package |
| # |
| def format(target): |
| package_info = providers(target)["@@fuchsia_rules_common+//packages:providers.bzl%FuchsiaPackageInfo"] |
| lines = [ |
| package_info.far_file.path, |
| package_info.package_manifest.path, |
| ] |
| debug_info = providers(target)["@@rules_fuchsia+//fuchsia/private:providers.bzl%FuchsiaDebugSymbolInfo"] |
| for dirs in debug_info.build_id_dirs_mapping.values(): |
| lines += [dir.path for dir in dirs.to_list()] |
| return "\n".join(lines) |