diff --git a/backends/qualcomm/runtime/targets.bzl b/backends/qualcomm/runtime/targets.bzl index 958bad17507..335f4a5c4cb 100644 --- a/backends/qualcomm/runtime/targets.bzl +++ b/backends/qualcomm/runtime/targets.bzl @@ -35,6 +35,29 @@ def define_common_targets(): ], ) + # Platform Abstraction Layer. The headers are included as (matching + # the CMake build's `include_directories(runtime/pal/include)`). They are + # exposed through a header map (dict `exported_headers` with an empty + # namespace) instead of an `-I` flag, so the short include resolves + # identically under both the fbcode (`cpp_library`) and xplat + # (`fb_xplat_cxx_library`) rules, which do not share an include-dir attribute. + # Kept in their own library so the mapping does not disturb the runtime + # target's namespaced exported headers. + runtime.cxx_library( + name = "pal", + srcs = glob([ + "pal/src/linux/*.cpp", + ]), + exported_headers = { + "pal/DynamicLoading.h": "pal/include/pal/DynamicLoading.h", + "pal/Path.h": "pal/include/pal/Path.h", + }, + header_namespace = "", + define_static_target = True, + platforms = [ANDROID], + visibility = ["PUBLIC"], + ) + # "runtime" target is used for offline compile, can be renamed to runtime_aot_build as a BE. for include_aot_qnn_lib in (True, False): qnn_build_suffix = ("" if include_aot_qnn_lib else "_android_build") @@ -43,8 +66,6 @@ def define_common_targets(): srcs = glob( [ "*.cpp", - "pal/src/linux/DynamicLoading.cpp", - "pal/src/linux/Path.cpp", "backends/*.cpp", "backends/gpu/*.cpp", "backends/htp/*.cpp", @@ -60,8 +81,6 @@ def define_common_targets(): exported_headers = glob( [ "*.h", - "pal/include/pal/DynamicLoading.h", - "pal/include/pal/Path.h", "backends/*.h", "backends/gpu/*.h", "backends/htp/*.h", @@ -70,9 +89,6 @@ def define_common_targets(): ], exclude = ["Logging.h"], ), - exported_preprocessor_flags = [ - "-Ibackends/qualcomm/runtime/pal/include", - ], define_static_target = True, link_whole = True, # needed for executorch/examples/models/llama:main to register QnnBackend platforms = [ANDROID], @@ -91,6 +107,7 @@ def define_common_targets(): "//executorch/extension/tensor:tensor", ], exported_deps = [ + ":pal", "//executorch/runtime/backend:interface", "//executorch/runtime/core/exec_aten/util:scalar_type_util", "//executorch/runtime/core:event_tracer",