1*523fa7a6SAndroid Build Coastguard Workerload("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") 2*523fa7a6SAndroid Build Coastguard Workerload( 3*523fa7a6SAndroid Build Coastguard Worker "@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl", 4*523fa7a6SAndroid Build Coastguard Worker "get_vec_preprocessor_flags", 5*523fa7a6SAndroid Build Coastguard Worker "get_vec_cxx_preprocessor_flags", 6*523fa7a6SAndroid Build Coastguard Worker) 7*523fa7a6SAndroid Build Coastguard Workerload("@fbsource//xplat/executorch/kernels/test:util.bzl", "define_supported_features_lib") 8*523fa7a6SAndroid Build Coastguard Worker 9*523fa7a6SAndroid Build Coastguard Workerdef _lib_test_bin(name, extra_deps = [], in_cpu = False): 10*523fa7a6SAndroid Build Coastguard Worker """Defines a cxx_binary() for a single test file. 11*523fa7a6SAndroid Build Coastguard Worker """ 12*523fa7a6SAndroid Build Coastguard Worker if not (name.endswith("_test_bin")): 13*523fa7a6SAndroid Build Coastguard Worker fail("'{}' must match the pattern '*_vec_test_bin'") 14*523fa7a6SAndroid Build Coastguard Worker 15*523fa7a6SAndroid Build Coastguard Worker src_root = name[:-len("_bin")] 16*523fa7a6SAndroid Build Coastguard Worker lib_root = name[:-len("_test_bin")] 17*523fa7a6SAndroid Build Coastguard Worker 18*523fa7a6SAndroid Build Coastguard Worker cpu_path = "/cpu" if in_cpu else "" 19*523fa7a6SAndroid Build Coastguard Worker 20*523fa7a6SAndroid Build Coastguard Worker runtime.cxx_binary( 21*523fa7a6SAndroid Build Coastguard Worker name = name, 22*523fa7a6SAndroid Build Coastguard Worker srcs = [ 23*523fa7a6SAndroid Build Coastguard Worker "{}.cpp".format(src_root), 24*523fa7a6SAndroid Build Coastguard Worker ], 25*523fa7a6SAndroid Build Coastguard Worker deps = [ 26*523fa7a6SAndroid Build Coastguard Worker "//executorch/test/utils:utils", 27*523fa7a6SAndroid Build Coastguard Worker "//executorch/kernels/optimized{}:{}".format(cpu_path, lib_root), 28*523fa7a6SAndroid Build Coastguard Worker ] + extra_deps, 29*523fa7a6SAndroid Build Coastguard Worker cxx_platform_preprocessor_flags = get_vec_cxx_preprocessor_flags(), 30*523fa7a6SAndroid Build Coastguard Worker preprocessor_flags = get_vec_preprocessor_flags(), 31*523fa7a6SAndroid Build Coastguard Worker ) 32*523fa7a6SAndroid Build Coastguard Worker 33*523fa7a6SAndroid Build Coastguard Workerdef define_common_targets(): 34*523fa7a6SAndroid Build Coastguard Worker """Defines targets that should be shared between fbcode and xplat. 35*523fa7a6SAndroid Build Coastguard Worker 36*523fa7a6SAndroid Build Coastguard Worker The directory containing this targets.bzl file should also contain both 37*523fa7a6SAndroid Build Coastguard Worker TARGETS and BUCK files that call this function. 38*523fa7a6SAndroid Build Coastguard Worker """ 39*523fa7a6SAndroid Build Coastguard Worker define_supported_features_lib() 40*523fa7a6SAndroid Build Coastguard Worker 41*523fa7a6SAndroid Build Coastguard Worker _lib_test_bin("libvec_test_bin") 42*523fa7a6SAndroid Build Coastguard Worker _lib_test_bin("moments_utils_test_bin", in_cpu = True) 43*523fa7a6SAndroid Build Coastguard Worker _lib_test_bin("libblas_test_bin") 44