1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") 2load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib") 3load(":lib_defs.bzl", "define_libs") 4 5def define_common_targets(is_fbcode=False): 6 """Defines targets that should be shared between fbcode and xplat. 7 8 The directory containing this targets.bzl file should also contain both 9 TARGETS and BUCK files that call this function. 10 """ 11 12 define_libs(is_fbcode) 13 14 runtime.export_file( 15 name = "optimized.yaml", 16 visibility = [ 17 "//executorch/...", 18 "@EXECUTORCH_CLIENTS", 19 ], 20 ) 21 22 runtime.export_file( 23 name = "optimized-oss.yaml", 24 visibility = [ 25 "//executorch/...", 26 "@EXECUTORCH_CLIENTS", 27 ], 28 ) 29 30 runtime.cxx_library( 31 name = "optimized_operators", 32 srcs = [], 33 visibility = [ 34 "//executorch/...", 35 "@EXECUTORCH_CLIENTS", 36 ], 37 exported_deps = [ 38 "//executorch/kernels/optimized/cpu:cpu_optimized", 39 ], 40 ) 41 42 et_operator_library( 43 name = "optimized_oplist", 44 ops_schema_yaml_target = ":optimized.yaml", 45 visibility = [ 46 "@EXECUTORCH_CLIENTS", 47 ], 48 ) 49 50 # Used mainly for operator testing. In practice, a generated lib specific 51 # to a project should be created that contains only the required operators 52 # for a particular model. 53 executorch_generated_lib( 54 name = "generated_lib", 55 deps = [ 56 ":optimized_oplist", 57 ":optimized_operators", 58 ], 59 functions_yaml_target = ":optimized.yaml", 60 define_static_targets = True, 61 visibility = [ 62 "//executorch/...", 63 "@EXECUTORCH_CLIENTS", 64 ], 65 ) 66