1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") 2load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib") 3 4def define_common_targets(): 5 """Defines targets that should be shared between fbcode and xplat. 6 7 The directory containing this targets.bzl file should also contain both 8 TARGETS and BUCK files that call this function. 9 """ 10 11 runtime.cxx_library( 12 name = "operators", 13 srcs = [], 14 visibility = [ 15 "//executorch/...", 16 "@EXECUTORCH_CLIENTS", 17 ], 18 exported_deps = [ 19 "//executorch/kernels/portable/cpu:cpu", 20 ], 21 ) 22 23 runtime.cxx_library( 24 name = "operators_aten", 25 srcs = [], 26 visibility = [ 27 "//executorch/...", 28 "@EXECUTORCH_CLIENTS", 29 ], 30 exported_deps = [ 31 "//executorch/kernels/portable/cpu:cpu_aten", 32 ], 33 ) 34 35 runtime.export_file( 36 name = "functions.yaml", 37 visibility = [ 38 "//executorch/...", 39 "@EXECUTORCH_CLIENTS", 40 ], 41 ) 42 43 runtime.export_file( 44 name = "custom_ops.yaml", 45 visibility = [ 46 "//executorch/codegen/...", 47 "@EXECUTORCH_CLIENTS", 48 ], 49 ) 50 51 et_operator_library( 52 name = "executorch_all_ops", 53 include_all_operators = True, 54 define_static_targets = True, 55 visibility = [ 56 "//executorch/codegen/...", 57 "@EXECUTORCH_CLIENTS", 58 ], 59 ) 60 61 et_operator_library( 62 name = "executorch_aten_ops", 63 ops_schema_yaml_target = "//executorch/kernels/portable:functions.yaml", 64 define_static_targets = True, 65 visibility = [ 66 "//executorch/codegen/...", 67 "@EXECUTORCH_CLIENTS", 68 ], 69 ) 70 71 et_operator_library( 72 name = "executorch_custom_ops", 73 ops_schema_yaml_target = "//executorch/kernels/portable:custom_ops.yaml", 74 define_static_targets = True, 75 visibility = [ 76 "//executorch/codegen/...", 77 "@EXECUTORCH_CLIENTS", 78 ], 79 ) 80 81 generated_lib_common_args = { 82 "custom_ops_aten_kernel_deps": [ 83 "//executorch/kernels/portable:operators_aten", 84 ], 85 "custom_ops_yaml_target": "//executorch/kernels/portable:custom_ops.yaml", 86 # size_test expects _static targets to be available for these libraries. 87 "define_static_targets": True, 88 "functions_yaml_target": "//executorch/kernels/portable:functions.yaml", 89 "visibility": [ 90 "//executorch/...", 91 "@EXECUTORCH_CLIENTS", 92 ], 93 } 94 95 executorch_generated_lib( 96 name = "generated_lib", 97 deps = [ 98 ":executorch_aten_ops", 99 ":executorch_custom_ops", 100 ], 101 kernel_deps = ["//executorch/kernels/portable:operators"], 102 **generated_lib_common_args 103 ) 104 105 executorch_generated_lib( 106 name = "generated_lib_aten", 107 deps = [ 108 ":executorch_aten_ops", 109 ":executorch_custom_ops", 110 "//executorch/kernels/portable:operators_aten", 111 ], 112 custom_ops_aten_kernel_deps = [ 113 "//executorch/kernels/portable:operators_aten", 114 ], 115 custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml", 116 aten_mode = True, 117 visibility = [ 118 "//executorch/...", 119 "@EXECUTORCH_CLIENTS", 120 ], 121 define_static_targets = True, 122 ) 123