From 4e249e7f04a5b2b9de574e1b1a1c1e43a65743c0 Mon Sep 17 00:00:00 2001 From: Jon Janzen Date: Wed, 1 Jul 2026 09:03:25 -0700 Subject: [PATCH] migrate is_fbcode-flagged TARGETS files to BUCK with runtime detection (#20404) Summary: Pull Request resolved: https://github.com/pytorch/executorch/pull/20404 Chunk 2 of fbcode/executorch TARGETS->BUCK migration. 5 directories where TARGETS called `define_common_targets(is_fbcode = True)` and the sister BUCK called `define_common_targets()`. The shared targets.bzl actually branches on is_fbcode, so the flag must be preserved. Replaces the BUCK call with `define_common_targets(is_fbcode = is_fbcode())` using `fbsource_utils.is_fbcode()` for runtime cell detection, then deletes TARGETS. fbcode falls through to BUCK and gets the True branch as before; xplat keeps getting the False branch. Directories migrated: - backends/vulkan/test/custom_ops - backends/vulkan/test/op_tests - codegen/tools - extension/runner_util/test - kernels/optimized Reviewed By: ndmitchell, mzlee Differential Revision: D109082061 --- backends/vulkan/test/custom_ops/BUCK | 5 +++-- backends/vulkan/test/custom_ops/TARGETS | 5 ----- backends/vulkan/test/op_tests/BUCK | 5 +++-- backends/vulkan/test/op_tests/TARGETS | 5 ----- codegen/tools/BUCK | 5 +++-- codegen/tools/TARGETS | 5 ----- extension/runner_util/test/BUCK | 5 +++-- extension/runner_util/test/TARGETS | 8 -------- kernels/optimized/BUCK | 5 +++-- kernels/optimized/TARGETS | 8 -------- 10 files changed, 15 insertions(+), 41 deletions(-) delete mode 100644 backends/vulkan/test/custom_ops/TARGETS delete mode 100644 backends/vulkan/test/op_tests/TARGETS delete mode 100644 codegen/tools/TARGETS delete mode 100644 extension/runner_util/test/TARGETS delete mode 100644 kernels/optimized/TARGETS diff --git a/backends/vulkan/test/custom_ops/BUCK b/backends/vulkan/test/custom_ops/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/backends/vulkan/test/custom_ops/BUCK +++ b/backends/vulkan/test/custom_ops/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/vulkan/test/custom_ops/TARGETS b/backends/vulkan/test/custom_ops/TARGETS deleted file mode 100644 index e84397dc20e..00000000000 --- a/backends/vulkan/test/custom_ops/TARGETS +++ /dev/null @@ -1,5 +0,0 @@ -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets(is_fbcode = True) diff --git a/backends/vulkan/test/op_tests/BUCK b/backends/vulkan/test/op_tests/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/backends/vulkan/test/op_tests/BUCK +++ b/backends/vulkan/test/op_tests/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/backends/vulkan/test/op_tests/TARGETS b/backends/vulkan/test/op_tests/TARGETS deleted file mode 100644 index e84397dc20e..00000000000 --- a/backends/vulkan/test/op_tests/TARGETS +++ /dev/null @@ -1,5 +0,0 @@ -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets(is_fbcode = True) diff --git a/codegen/tools/BUCK b/codegen/tools/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/codegen/tools/BUCK +++ b/codegen/tools/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/codegen/tools/TARGETS b/codegen/tools/TARGETS deleted file mode 100644 index e84397dc20e..00000000000 --- a/codegen/tools/TARGETS +++ /dev/null @@ -1,5 +0,0 @@ -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets(is_fbcode = True) diff --git a/extension/runner_util/test/BUCK b/extension/runner_util/test/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/extension/runner_util/test/BUCK +++ b/extension/runner_util/test/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/extension/runner_util/test/TARGETS b/extension/runner_util/test/TARGETS deleted file mode 100644 index 7ace4add7f9..00000000000 --- a/extension/runner_util/test/TARGETS +++ /dev/null @@ -1,8 +0,0 @@ -# Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. - -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets(is_fbcode = True) diff --git a/kernels/optimized/BUCK b/kernels/optimized/BUCK index 1e8cc179228..f559a6f1cfe 100644 --- a/kernels/optimized/BUCK +++ b/kernels/optimized/BUCK @@ -1,8 +1,9 @@ # Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain xplat-only targets. +# targets.bzl. +load("@fbsource//tools/build_defs:fbsource_utils.bzl", "is_fbcode") load(":targets.bzl", "define_common_targets") oncall("executorch") -define_common_targets() +define_common_targets(is_fbcode = is_fbcode()) diff --git a/kernels/optimized/TARGETS b/kernels/optimized/TARGETS deleted file mode 100644 index beaebb81eeb..00000000000 --- a/kernels/optimized/TARGETS +++ /dev/null @@ -1,8 +0,0 @@ -# Any targets that should be shared between fbcode and xplat must be defined in -# targets.bzl. This file can contain fbcode-only targets. - -load(":targets.bzl", "define_common_targets") - -oncall("executorch") - -define_common_targets(True)