Skip to content

Commit 802a624

Browse files
committed
Try testing selective build in OSS buck
1 parent c9f46e2 commit 802a624

File tree

2 files changed

+140
-95
lines changed

2 files changed

+140
-95
lines changed

codegen/tools/targets.bzl

Lines changed: 139 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def define_common_targets(is_fbcode = False):
2929
deps = [
3030
":gen_oplist_lib",
3131
],
32-
preload_deps = [] if runtime.is_oss else ["//executorch/codegen/tools:selective_build"], # TODO(larryliu0820) :selective_build doesn't build in OSS yet
32+
preload_deps = ["//executorch/codegen/tools:selective_build"],
3333
package_style = "inplace",
3434
visibility = [
3535
"//executorch/...",
@@ -43,15 +43,25 @@ def define_common_targets(is_fbcode = False):
4343
srcs = ["yaml_util.py"],
4444
)
4545

46-
runtime.python_library(
47-
name = "merge_yaml_lib",
48-
srcs = ["merge_yaml.py"],
49-
base_module = "executorch.codegen.tools",
50-
deps = [
51-
":yaml_util",
52-
],
53-
external_deps = ["torchgen"],
54-
)
46+
if not runtime.is_oss and is_fbcode:
47+
runtime.python_library(
48+
name = "merge_yaml_lib",
49+
srcs = ["merge_yaml.py"],
50+
base_module = "executorch.codegen.tools",
51+
deps = [
52+
":yaml_util",
53+
],
54+
external_deps = ["torchgen"],
55+
)
56+
else:
57+
runtime.python_library(
58+
name = "merge_yaml_lib",
59+
srcs = ["merge_yaml.py"],
60+
base_module = "executorch.codegen.tools",
61+
deps = [
62+
":yaml_util",
63+
],
64+
)
5565

5666
runtime.python_binary(
5767
name = "merge_yaml",
@@ -64,31 +74,43 @@ def define_common_targets(is_fbcode = False):
6474
visibility = ["PUBLIC"],
6575
)
6676

67-
runtime.python_test(
68-
name = "test_gen_oplist",
69-
base_module = "",
70-
srcs = [
71-
"test/test_gen_oplist.py",
72-
],
73-
deps = [
74-
":gen_oplist_lib",
75-
],
76-
package_style = "inplace",
77-
visibility = [
78-
"//executorch/...",
79-
"@EXECUTORCH_CLIENTS",
80-
],
81-
)
77+
if not runtime.is_oss and is_fbcode:
78+
runtime.python_test(
79+
name = "test_gen_oplist",
80+
base_module = "",
81+
srcs = [
82+
"test/test_gen_oplist.py",
83+
],
84+
deps = [
85+
":gen_oplist_lib",
86+
],
87+
external_deps = ["torchgen"],
88+
package_style = "inplace",
89+
visibility = [
90+
"//executorch/...",
91+
"@EXECUTORCH_CLIENTS",
92+
],
93+
)
8294

83-
runtime.python_library(
84-
name = "gen_all_oplist_lib",
85-
srcs = ["gen_all_oplist.py"],
86-
base_module = "executorch.codegen.tools",
87-
visibility = [
88-
"//executorch/...",
89-
],
90-
external_deps = ["torchgen"],
91-
)
95+
if not runtime.is_oss and is_fbcode:
96+
runtime.python_library(
97+
name = "gen_all_oplist_lib",
98+
srcs = ["gen_all_oplist.py"],
99+
base_module = "executorch.codegen.tools",
100+
visibility = [
101+
"//executorch/...",
102+
],
103+
external_deps = ["torchgen"],
104+
)
105+
else:
106+
runtime.python_library(
107+
name = "gen_all_oplist_lib",
108+
srcs = ["gen_all_oplist.py"],
109+
base_module = "executorch.codegen.tools",
110+
visibility = [
111+
"//executorch/...",
112+
],
113+
)
92114

93115
runtime.python_binary(
94116
name = "gen_all_oplist",
@@ -123,20 +145,22 @@ def define_common_targets(is_fbcode = False):
123145
_is_external_target = True,
124146
)
125147

126-
runtime.python_test(
127-
name = "test_gen_all_oplist",
128-
srcs = [
129-
"test/test_gen_all_oplist.py",
130-
],
131-
package_style = "inplace",
132-
visibility = [
133-
"PUBLIC",
134-
],
135-
deps = [
136-
":gen_all_oplist_lib",
137-
],
138-
_is_external_target = True,
139-
)
148+
if not runtime.is_oss and is_fbcode:
149+
runtime.python_test(
150+
name = "test_gen_all_oplist",
151+
srcs = [
152+
"test/test_gen_all_oplist.py",
153+
],
154+
package_style = "inplace",
155+
visibility = [
156+
"PUBLIC",
157+
],
158+
deps = [
159+
":gen_all_oplist_lib",
160+
],
161+
external_deps = ["torchgen"],
162+
_is_external_target = True,
163+
)
140164

141165
runtime.python_library(
142166
name = "gen_selected_op_variants_lib",
@@ -159,29 +183,38 @@ def define_common_targets(is_fbcode = False):
159183
_is_external_target = True,
160184
)
161185

162-
runtime.python_test(
163-
name = "test_gen_selected_op_variants",
164-
srcs = [
165-
"test/test_gen_selected_op_variants.py",
166-
],
167-
package_style = "inplace",
168-
visibility = [
169-
"PUBLIC",
170-
],
171-
deps = [
172-
":gen_selected_op_variants_lib",
173-
"fbsource//third-party/pypi/expecttest:expecttest",
174-
],
175-
_is_external_target = True,
176-
)
186+
if not runtime.is_oss and is_fbcode:
187+
runtime.python_test(
188+
name = "test_gen_selected_op_variants",
189+
srcs = [
190+
"test/test_gen_selected_op_variants.py",
191+
],
192+
package_style = "inplace",
193+
visibility = [
194+
"PUBLIC",
195+
],
196+
deps = [
197+
":gen_selected_op_variants_lib",
198+
"fbsource//third-party/pypi/expecttest:expecttest",
199+
],
200+
_is_external_target = True,
201+
)
177202

178-
runtime.python_library(
179-
name = "gen_selected_prim_ops_lib",
180-
srcs = ["gen_selected_prim_ops.py"],
181-
base_module = "executorch.codegen.tools",
182-
visibility = ["//executorch/..."],
183-
external_deps = ["torchgen"],
184-
)
203+
if not runtime.is_oss and is_fbcode:
204+
runtime.python_library(
205+
name = "gen_selected_prim_ops_lib",
206+
srcs = ["gen_selected_prim_ops.py"],
207+
base_module = "executorch.codegen.tools",
208+
visibility = ["//executorch/..."],
209+
external_deps = ["torchgen"],
210+
)
211+
else:
212+
runtime.python_library(
213+
name = "gen_selected_prim_ops_lib",
214+
srcs = ["gen_selected_prim_ops.py"],
215+
base_module = "executorch.codegen.tools",
216+
visibility = ["//executorch/..."],
217+
)
185218

186219
runtime.python_binary(
187220
name = "gen_selected_prim_ops",
@@ -196,46 +229,57 @@ def define_common_targets(is_fbcode = False):
196229
_is_external_target = True,
197230
)
198231

199-
if not runtime.is_oss:
200-
runtime.cxx_python_extension(
201-
name = "selective_build",
202-
srcs = [
203-
"selective_build.cpp",
204-
],
232+
233+
runtime.cxx_python_extension(
234+
name = "selective_build",
235+
srcs = [
236+
"selective_build.cpp",
237+
],
238+
base_module = "executorch.codegen.tools",
239+
types = ["selective_build.pyi"],
240+
preprocessor_flags = [
241+
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
242+
],
243+
deps = [
244+
"//executorch/runtime/core:core",
245+
"//executorch/schema:program",
246+
],
247+
external_deps = [
248+
"pybind11",
249+
],
250+
use_static_deps = True,
251+
visibility = ["//executorch/codegen/..."],
252+
)
253+
254+
255+
# TODO(larryliu0820): This is a hack to only run these on fbcode. These targets depend on exir which is only available in fbcode.
256+
if not runtime.is_oss and is_fbcode:
257+
runtime.python_library(
258+
name = "gen_ops_def_lib",
259+
srcs = ["gen_ops_def.py"],
205260
base_module = "executorch.codegen.tools",
206-
types = ["selective_build.pyi"],
207-
preprocessor_flags = [
208-
"-DEXECUTORCH_PYTHON_MODULE_NAME=selective_build",
261+
visibility = [
262+
"//executorch/...",
209263
],
210264
deps = [
211-
"//executorch/runtime/core:core",
212-
"//executorch/schema:program",
213-
],
214-
external_deps = [
215-
"pybind11",
265+
"fbsource//third-party/pypi/pyyaml:pyyaml",
266+
":yaml_util",
267+
"//caffe2:torch",
268+
"//executorch/exir:schema",
269+
"//executorch/exir/_serialize:lib",
216270
],
217-
use_static_deps = True,
218-
visibility = ["//executorch/codegen/..."],
219271
)
220272

221-
222-
# TODO(larryliu0820): This is a hack to only run these two on fbcode. These targets depends on exir which is only available in fbcode.
223-
if not runtime.is_oss and is_fbcode:
224273
runtime.python_binary(
225274
name = "gen_functions_yaml",
226-
srcs = ["gen_ops_def.py"],
227275
main_module = "executorch.codegen.tools.gen_ops_def",
228276
package_style = "inplace",
229277
visibility = [
230278
"//executorch/...",
231279
"@EXECUTORCH_CLIENTS",
232280
],
233281
deps = [
234-
"fbsource//third-party/pypi/pyyaml:pyyaml",
235-
":yaml_util",
236-
"//caffe2:torch",
237-
"//executorch/exir:schema",
238-
"//executorch/exir/_serialize:lib",
282+
":gen_ops_def_lib",
239283
],
240284
)
241285

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
3435

3536
# devtools
3637
devtools/

0 commit comments

Comments
 (0)