Skip to content

Commit 9c5cede

Browse files
mergennachinfacebook-github-bot
authored andcommitted
Shift Left: Try building and testing selective_build in OSS (#14499)
Summary: - Enable buck targets in OSS under codegen/tools/targets.bzl - Build all buck targets in OSS under codegen/tools/... (Can't test yet due to torch not available in OSS buck) - Run test_tools_selective_build.py in pytest - Building on top of #14488 Pull Request resolved: #14499 Reviewed By: lucylq Differential Revision: D83024265 Pulled By: mergennachin
1 parent 7239bfe commit 9c5cede

File tree

6 files changed

+41
-31
lines changed

6 files changed

+41
-31
lines changed

.ci/scripts/unittest-buck2.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ buck2 query "//backends/apple/... + //backends/arm: + //backends/arm/debug/... +
1515
//backends/arm/_passes/... + //backends/arm/runtime/... + //backends/arm/tosa/... \
1616
+ //backends/example/... + \
1717
//backends/mediatek/... + //backends/transforms/... + \
18-
//backends/xnnpack/... + //configurations/... + //extension/flat_tensor: + \
18+
//backends/xnnpack/... + //codegen/tools/... + \
19+
//configurations/... + //extension/flat_tensor: + \
1920
//extension/llm/runner: + //kernels/aten/... + //kernels/optimized/... + \
2021
//kernels/portable/... + //kernels/quantized/... + //kernels/test/... + \
2122
//runtime/... + //schema/... + //test/... + //util/..."
@@ -38,3 +39,6 @@ for op in "build" "test"; do
3839
$BUILDABLE_KERNELS_PRIM_OPS_TARGETS //runtime/backend/... //runtime/core/... \
3940
//runtime/executor: //runtime/kernel/... //runtime/platform/...
4041
done
42+
43+
# Build only without testing
44+
buck2 build //codegen/tools/... # Needs torch for testing which we don't have in our OSS buck setup.

codegen/tools/targets.bzl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ def define_common_targets(is_fbcode = False):
1717
],
1818
deps = [
1919
"//executorch/codegen:gen_lib",
20-
] + ([] if runtime.is_oss else select({
21-
"DEFAULT": [],
22-
"ovr_config//os:linux": ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
23-
})),
20+
"//executorch/codegen/tools:selective_build",
21+
],
2422
)
2523

2624
runtime.python_binary(
@@ -29,7 +27,7 @@ def define_common_targets(is_fbcode = False):
2927
deps = [
3028
":gen_oplist_lib",
3129
],
32-
preload_deps = [] if runtime.is_oss else ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
30+
preload_deps = ["//executorch/codegen/tools:selective_build"],
3331
package_style = "inplace",
3432
visibility = [
3533
"//executorch/...",
@@ -196,27 +194,27 @@ def define_common_targets(is_fbcode = False):
196194
_is_external_target = True,
197195
)
198196

199-
if not runtime.is_oss:
200-
runtime.cxx_python_extension(
201-
name = "selective_build",
202-
srcs = [
203-
"selective_build.cpp",
204-
],
205-
base_module = "executorch.codegen.tools",
206-
types = ["selective_build.pyi"],
207-
preprocessor_flags = [
208-
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
209-
],
210-
deps = [
211-
"//executorch/runtime/core:core",
212-
"//executorch/schema:program",
213-
],
214-
external_deps = [
215-
"pybind11",
216-
],
217-
use_static_deps = True,
218-
visibility = ["//executorch/codegen/..."],
219-
)
197+
198+
runtime.cxx_python_extension(
199+
name = "selective_build",
200+
srcs = [
201+
"selective_build.cpp",
202+
],
203+
base_module = "executorch.codegen.tools",
204+
types = ["selective_build.pyi"],
205+
preprocessor_flags = [
206+
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
207+
],
208+
deps = [
209+
"//executorch/runtime/core:core",
210+
"//executorch/schema:program",
211+
],
212+
external_deps = [
213+
"pybind11",
214+
],
215+
use_static_deps = True,
216+
visibility = ["//executorch/codegen/..."],
217+
)
220218

221219

222220
# TODO(larryliu0820): This is a hack to only run these two on fbcode. These targets depends on exir which is only available in fbcode.
@@ -255,10 +253,12 @@ def define_common_targets(is_fbcode = False):
255253
],
256254
)
257255

256+
if runtime.is_oss or is_fbcode:
257+
# Doesn't work on xplat. But works on fbcode and OSS.
258258
runtime.python_test(
259-
name = "test_selective_build",
259+
name = "test_tools_selective_build",
260260
srcs = [
261-
"test/test_selective_build.py",
261+
"test/test_tools_selective_build.py",
262262
],
263263
package_style = "inplace",
264264
visibility = [
File renamed without changes.

extension/pytree/TARGETS

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ runtime.cxx_python_extension(
1515
],
1616
base_module = "executorch.extension.pytree",
1717
deps = [
18-
"fbsource//third-party/pybind11:pybind11",
1918
":pytree",
2019
],
20+
external_deps = [
21+
"pybind11",
22+
],
2123
)
2224

2325
runtime.cxx_python_extension(
@@ -27,9 +29,11 @@ runtime.cxx_python_extension(
2729
],
2830
base_module = "executorch.extension.pytree",
2931
deps = [
30-
"fbsource//third-party/pybind11:pybind11",
3132
":pytree",
3233
],
34+
external_deps = [
35+
"pybind11",
36+
],
3337
)
3438

3539
runtime.python_library(

pytest.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ addopts =
3131

3232
# codegen
3333
codegen/test
34+
codegen/tools/test/test_tools_selective_build.py
3435

3536
# devtools
3637
devtools/

shim_et/xplat/executorch/build/runtime_wrapper.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ def _python_binary(*args, **kwargs):
346346

347347
def _python_test(*args, **kwargs):
348348
_patch_kwargs_common(kwargs)
349+
_remove_caffe2_deps(kwargs)
349350
env.python_test(*args, **kwargs)
350351

351352
def get_oss_build_kwargs():

0 commit comments

Comments
 (0)