@@ -43,12 +43,56 @@ def get_vec_fbcode_preprocessor_flags():
4343 ]
4444 return preprocessor_flags
4545
46+ def get_apple_framework_deps_kwargs (is_fbcode ):
47+ # various ovr_configs are not available in oss
48+ if not runtime .is_oss and not is_fbcode :
49+ # Jump through few hoops since 'frameworks' is not a valid kwarg
50+ # for some buck rules
51+ frameworks = {'frameworks' : select ({
52+ "DEFAULT" : [],
53+ "ovr_config//os:iphoneos" : ["$SDKROOT/System/Library/Frameworks/Accelerate.framework" ],
54+ "ovr_config//os:macos-arm64" : ["$SDKROOT/System/Library/Frameworks/Accelerate.framework" ],
55+ "ovr_config//os:macos-x86_64" : ["$SDKROOT/System/Library/Frameworks/Accelerate.framework" ],
56+ })}
57+ return frameworks
58+ return {'fbobjc_frameworks' : ["Accelerate" ]}
59+
60+ def get_preprocessor_flags ():
61+ # various ovr_configs are not available in oss
62+ preprocessor_flags = select ({
63+ ":linux-x86_64" : [
64+ "-DET_BUILD_WITH_BLAS" ,
65+ ] if not runtime .is_oss else [],
66+ "DEFAULT" : [],
67+ })
68+
69+ if not runtime .is_oss :
70+ # various ovr_configs are not available in oss
71+ additional_preprocessor_flags = select ({
72+ "ovr_config//os:iphoneos" : [
73+ "-DET_BUILD_WITH_BLAS" ,
74+ "-DET_BUILD_FOR_APPLE" ,
75+ ] if not runtime .is_oss else [],
76+ "ovr_config//os:macos-arm64" : [
77+ "-DET_BUILD_WITH_BLAS" ,
78+ "-DET_BUILD_FOR_APPLE" ,
79+ ] if not runtime .is_oss else [],
80+ "ovr_config//os:macos-x86_64" : [
81+ "-DET_BUILD_WITH_BLAS" ,
82+ "-DET_BUILD_FOR_APPLE" ,
83+ ] if not runtime .is_oss else [],
84+ "DEFAULT" : [],
85+ })
86+ preprocessor_flags = preprocessor_flags + additional_preprocessor_flags
87+ return preprocessor_flags
88+
89+
4690# Currently, having a dependency on fbsource//third-party/sleef:sleef may cause
4791# duplicate symbol errors when linking fbcode targets in opt mode that also
4892# depend on ATen. This is because ATen accesses sleef via the third-party folder
4993# in caffe2 (caffe2/third-party//sleef:sleef).
5094# TODO(ssjia): Enable -DCPU_CAPABILITY_AVX2 in fbcode, which requires sleef.
51- def define_libs ():
95+ def define_libs (is_fbcode = False ):
5296 runtime .cxx_library (
5397 name = "libvec" ,
5498 srcs = [],
@@ -131,12 +175,7 @@ def define_libs():
131175 "//executorch/..." ,
132176 "@EXECUTORCH_CLIENTS" ,
133177 ],
134- preprocessor_flags = select ({
135- ":linux-x86_64" : [
136- "-DET_BUILD_WITH_BLAS" ,
137- ] if not runtime .is_oss else [],
138- "DEFAULT" : [],
139- }),
178+ preprocessor_flags = get_preprocessor_flags (),
140179 fbandroid_platform_preprocessor_flags = [
141180 (
142181 "^android-arm64.*$" ,
@@ -157,9 +196,6 @@ def define_libs():
157196 "-DET_BUILD_WITH_BLAS" ,
158197 "-DET_BUILD_FOR_APPLE" ,
159198 ],
160- fbobjc_frameworks = [
161- "Accelerate" ,
162- ],
163199 deps = select ({
164200 ":linux-x86_64" : [mkl_dep ] if not runtime .is_oss else [],
165201 "DEFAULT" : [],
@@ -169,4 +205,5 @@ def define_libs():
169205 "//executorch/kernels/optimized:libutils" ,
170206 "//executorch/runtime/core/exec_aten:lib" ,
171207 ],
208+ ** get_apple_framework_deps_kwargs (is_fbcode ),
172209 )
0 commit comments