Skip to content

Commit

Permalink
python_binary: add a [debuginfo] subtarget
Browse files Browse the repository at this point in the history
Summary:
This subtarget produces a json file with all debug information associated with the binary in the following format:

1. the file is a single list
2. each entry in the list is a pair of (location in buck-out, logical location), represented as a 2 element list
3. logical location refers to the place where the file would be in the par (next to the .so file), which (I think) is the same as the relative location in the `#debuginfo` folder

Reviewed By: itamaro

Differential Revision: D52905959

fbshipit-source-id: d0ee79d0a0d6b8ce7ccc2c6c9fea32aa33f99151
  • Loading branch information
zsol authored and facebook-github-bot committed Jan 22, 2024
1 parent 3ec582c commit c3e25f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions prelude/python/make_py_package.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ def make_py_package(
allow_cache_upload = allow_cache_upload,
)
default.sub_targets[style] = make_py_package_providers(pex_providers)

default.sub_targets["debuginfo"] = _debuginfo_subtarget(ctx, debug_artifacts)
return default

def _make_py_package_impl(
Expand Down Expand Up @@ -325,6 +327,10 @@ def _make_py_package_impl(
run_cmd = cmd_args(run_args).hidden([a for a, _ in runtime_files] + hidden_resources),
)

def _debuginfo_subtarget(ctx: AnalysisContext, debug_artifacts: list[(ArgLike, str)]) -> list[Provider]:
out = ctx.actions.write_json("debuginfo.manifest.json", debug_artifacts)
return [DefaultInfo(default_output = out, other_outputs = [a for a, _ in debug_artifacts])]

def _preload_libraries_args(ctx: AnalysisContext, shared_libraries: dict[str, (LinkedObject, bool)]) -> cmd_args:
preload_libraries_path = ctx.actions.write(
"__preload_libraries.txt",
Expand Down

0 comments on commit c3e25f9

Please sign in to comment.