gate fbcode-only TARGETS dirs with is_fbcode() and rename to BUCK#21049
Conversation
Summary:
Chunk 6 of fbcode/executorch TARGETS->BUCK migration. 32 directories whose
TARGETS files contained fbcode-only macros (`fbcode_macros` loads,
`fbcode_target(`, `python_library`/`python_binary` from fbcode_macros,
etc.). For each:
1. Created a new `targets.bzl` containing the original loads and a
`define_common_targets(is_fbcode = False)` function whose body opens
with `if not is_fbcode: return` and otherwise contains the original
TARGETS rule definitions.
2. Deleted TARGETS and wrote a thin BUCK that calls
`define_common_targets(is_fbcode = is_fbcode())` using
`fbsource_utils.is_fbcode()` for runtime cell detection.
In fbcode the function body runs and the rules are defined as before. In
xplat the function returns early before any fbcode-only macro is invoked,
so the loads (which do resolve in xplat) are harmless and no rules
materialize.
Directories migrated:
- backends/arm/_passes/fb/test
- backends/arm/fb
- backends/arm/fb/tests
- backends/cortex_m
- backends/cortex_m/quantizer
- backends/example
- backends/vulkan/_passes
- backends/webgpu/test
- devtools/backend_debug/tests
- devtools/fb/visualizer
- devtools/inspector/tests
- devtools/intermediate_output_tap/tests
- devtools/pte_tool/tests
- devtools/size_analysis_tool
- examples/llm_pte_finetuning
- examples/models/fb/gemma3n
- examples/models/fb/gemma4/tests
- examples/models/fb/gemma4/validation
- examples/models/fb/llama4/runner/test
- examples/models/gemma4/tests
- examples/models/phi_4_mini
- examples/models/qwen2_5
- examples/models/qwen3
- examples/models/resnet
- examples/qualcomm
- exir/dialects/edge/spec
- exir/dialects/test
- exir/verification
- extension/audio
- extension/audio/fb/test
- extension/llm/custom_ops/spinquant/test/fb
- scripts/fb/size_monitoring
3 dirs were skipped because they already have a `targets.bzl` and need a
manual merge (devtools/etdump/fb/tests, devtools/etdump/tests, exir/fb).
Reviewed By: mzlee
Differential Revision: D109082044
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21049
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit 0529841 with merge base 2a532de ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@bigfootjon has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109082044. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR continues the fbcode/executorch TARGETS→BUCK migration by moving fbcode-only build rules into targets.bzl behind an is_fbcode gate, and replacing TARGETS with a thin BUCK wrapper that calls define_common_targets(is_fbcode = is_fbcode()). This aims to keep fbcode behavior unchanged while preventing fbcode-only macros/rules from materializing in xplat.
Changes:
- Introduce
targets.bzlfiles containingdefine_common_targets(is_fbcode=False)wrappers (early-returning in xplat) for multiple directories that previously used fbcode-only macros. - Replace deleted
TARGETSfiles with newBUCKfiles that calldefine_common_targets(is_fbcode = is_fbcode()). - Convert/adjust some existing BUCK files to support the migration (notably
backends/webgpu/test/BUCKandbackends/cortex_m/BUCK).
Reviewed changes
Copilot reviewed 56 out of 56 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| extension/audio/targets.bzl | New gated target definitions migrated from TARGETS (includes a duplicate runtime load). |
| extension/audio/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| extension/audio/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| exir/verification/targets.bzl | New gated target definitions migrated from TARGETS. |
| exir/verification/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| exir/verification/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| exir/dialects/test/targets.bzl | New gated unittest target migrated from TARGETS. |
| exir/dialects/test/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| exir/dialects/test/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| exir/dialects/edge/spec/targets.bzl | New gated generator/library targets migrated from TARGETS. |
| exir/dialects/edge/spec/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| exir/dialects/edge/spec/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()) (oncall changed vs old TARGETS). |
| examples/qualcomm/targets.bzl | New gated targets migrated from TARGETS (includes a duplicate runtime load). |
| examples/qualcomm/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| examples/qualcomm/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/models/resnet/targets.bzl | New gated python_library target. |
| examples/models/resnet/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/models/qwen3/targets.bzl | New gated runtime.python_library target with resources. |
| examples/models/qwen3/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/models/qwen2_5/targets.bzl | New gated runtime.python_library target with resources. |
| examples/models/qwen2_5/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/models/phi_4_mini/targets.bzl | New gated runtime.python_library + runtime.python_binary targets. |
| examples/models/phi_4_mini/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/models/gemma4/tests/targets.bzl | New gated fbcode_target-based python test target. |
| examples/models/gemma4/tests/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| examples/llm_pte_finetuning/targets.bzl | New gated training/export runner targets migrated from TARGETS. |
| examples/llm_pte_finetuning/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| examples/llm_pte_finetuning/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()) (oncall changed vs old TARGETS). |
| devtools/size_analysis_tool/targets.bzl | New gated library/binary/unittest targets migrated from TARGETS. |
| devtools/size_analysis_tool/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| devtools/size_analysis_tool/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| devtools/pte_tool/tests/targets.bzl | New gated unittest target migrated from TARGETS. |
| devtools/pte_tool/tests/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| devtools/pte_tool/tests/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| devtools/intermediate_output_tap/tests/targets.bzl | New gated unittest targets migrated from TARGETS. |
| devtools/intermediate_output_tap/tests/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| devtools/intermediate_output_tap/tests/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| devtools/inspector/tests/targets.bzl | New gated unittest + helper library targets migrated from TARGETS. |
| devtools/inspector/tests/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| devtools/inspector/tests/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| devtools/backend_debug/tests/targets.bzl | New gated unittest target migrated from TARGETS. |
| devtools/backend_debug/tests/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| devtools/backend_debug/tests/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| backends/webgpu/test/targets.bzl | New gated test/library targets (currently references a non-existent source path). |
| backends/webgpu/test/BUCK | Modified to use fbcode_target, but does not follow the thin-wrapper pattern described in the PR. |
| backends/vulkan/_passes/targets.bzl | New gated python_library targets migrated from TARGETS. |
| backends/vulkan/_passes/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| backends/vulkan/_passes/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| backends/example/targets.bzl | New gated example backend targets migrated from TARGETS. |
| backends/example/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| backends/example/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| backends/cortex_m/targets.bzl | New gated targets file added, but root BUCK does not call it. |
| backends/cortex_m/quantizer/targets.bzl | New gated quantizer targets migrated from TARGETS. |
| backends/cortex_m/quantizer/TARGETS | Removed in favor of BUCK + targets.bzl pattern. |
| backends/cortex_m/quantizer/BUCK | New thin wrapper calling define_common_targets(is_fbcode = is_fbcode()). |
| backends/cortex_m/BUCK | Modified to use fbcode_target, but does not follow the thin-wrapper pattern described in the PR. |
Comments suppressed due to low confidence (2)
backends/webgpu/test/BUCK:10
- This directory now has a
targets.bzlwithdefine_common_targets(is_fbcode=False)gating, but the BUCK file still defines targets directly and never callsdefine_common_targets(is_fbcode = is_fbcode()). That contradicts the PR description’s migration pattern (thin BUCK wrapper calling targets.bzl) and risks reintroducing fbcode-only targets into xplat parsing.
backends/cortex_m/BUCK:14 backends/cortex_m/targets.bzlwas added with a gateddefine_common_targets(), but this BUCK file still defines targets directly (viafbcode_target) and never callsdefine_common_targets(is_fbcode = is_fbcode()). This is inconsistent with the migration approach described in the PR and suggeststargets.bzlmay be unused or the BUCK conversion is incomplete.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") | ||
| load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") | ||
| load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") |
| load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") | ||
| load("@fbcode_macros//build_defs:python_binary.bzl", "python_binary") | ||
| load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") | ||
| load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version") |
| python_unittest( | ||
| name = "test_add", | ||
| srcs = [ | ||
| "ops/add/test_add.py", | ||
| ], |
| load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") | ||
| load(":targets.bzl", "define_common_targets") | ||
|
|
||
| oncall("executorch") |
| load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") | ||
| load(":targets.bzl", "define_common_targets") | ||
|
|
||
| oncall("executorch") |
Summary:
Chunk 6 of fbcode/executorch TARGETS->BUCK migration. 32 directories whose
TARGETS files contained fbcode-only macros (
fbcode_macrosloads,fbcode_target(,python_library/python_binaryfrom fbcode_macros,etc.). For each:
targets.bzlcontaining the original loads and adefine_common_targets(is_fbcode = False)function whose body openswith
if not is_fbcode: returnand otherwise contains the originalTARGETS rule definitions.
define_common_targets(is_fbcode = is_fbcode())usingfbsource_utils.is_fbcode()for runtime cell detection.In fbcode the function body runs and the rules are defined as before. In
xplat the function returns early before any fbcode-only macro is invoked,
so the loads (which do resolve in xplat) are harmless and no rules
materialize.
Directories migrated:
3 dirs were skipped because they already have a
targets.bzland need amanual merge (devtools/etdump/fb/tests, devtools/etdump/tests, exir/fb).
Reviewed By: mzlee
Differential Revision: D109082044