|
| 1 | +load("//arvr/tools/build_defs:oxx.bzl", "oxx_static_library") |
| 2 | + |
| 3 | +cpu_supported_platforms = [ |
| 4 | + "ovr_config//os:android", |
| 5 | + "ovr_config//os:iphoneos", |
| 6 | + "ovr_config//os:linux-x86_64", |
| 7 | + "ovr_config//os:macos", |
| 8 | + "ovr_config//os:windows-x86_64", |
| 9 | + "ovr_config//runtime:arm64-linux-ubuntu-neon", |
| 10 | + "ovr_config//os:linux-arm64", |
| 11 | +] |
| 12 | + |
| 13 | +def define_torch_headeronly_ovrsource(name, is_mobile): |
| 14 | + if is_mobile: |
| 15 | + pp_flags = ["-DC10_MOBILE=1"] |
| 16 | + else: |
| 17 | + pp_flags = [] |
| 18 | + |
| 19 | + oxx_static_library( |
| 20 | + name = name, |
| 21 | + srcs = [] |
| 22 | + compatible_with = cpu_supported_platforms, |
| 23 | + compiler_flags = select({ |
| 24 | + "DEFAULT": [], |
| 25 | + }), |
| 26 | + include_directories = [".."], |
| 27 | + preprocessor_flags = [], |
| 28 | + fbobjc_compiler_flags = [], |
| 29 | + public_include_directories = [".."], |
| 30 | + public_preprocessor_flags = pp_flags, |
| 31 | + public_raw_headers = native.glob([ |
| 32 | + "macros/*.h", |
| 33 | + ]), |
| 34 | + reexport_all_header_dependencies = False, |
| 35 | + visibility = [ |
| 36 | + "//xplat/caffe2/torch/headeronly:torch_headeronly", |
| 37 | + ], |
| 38 | + deps = select({ |
| 39 | + "DEFAULT": [], |
| 40 | + }), |
| 41 | + ) |
| 42 | + |
| 43 | +def define_ovrsource_targets(): |
| 44 | + oxx_static_library( |
| 45 | + name = "torch_headeronly_ovrsource", |
| 46 | + compatible_with = cpu_supported_platforms, |
| 47 | + exported_deps = select({ |
| 48 | + "DEFAULT": [":torch_headeronly_full_ovrsource"], |
| 49 | + "ovr_config//os:android": [":torch_headeronly_mobile_ovrsource"], |
| 50 | + "ovr_config//os:iphoneos": [":torch_headeronly_mobile_ovrsource"], |
| 51 | + }), |
| 52 | + visibility = ["PUBLIC"], |
| 53 | + ) |
| 54 | + |
| 55 | + """ |
| 56 | + Most users should use torch_headeronly_ovrsource, not these targets directly. |
| 57 | + """ |
| 58 | + define_torch_headeronly_ovrsource("torch_headeronly_mobile_ovrsource", True) |
| 59 | + define_torch_headeronly_ovrsource("torch_headeronly_full_ovrsource", False) |
0 commit comments