Skip to content

Commit 5ed3616

Browse files
authored
Add extended_targets CMake hook for non-OSS JNI extensions (#17947)
## Summary Add a generic hook in `extension/android/CMakeLists.txt` that conditionally includes `fb/extended_targets/CMakeLists.txt` if it exists. This allows internal or partner-specific JNI extensions (e.g., Gemma3N) to plug into the Android JNI build **without modifying OSS files**. When `fb/extended_targets/CMakeLists.txt` does not exist (as in OSS builds), the hook is a complete no-op. ## Motivation PR #17942 added Gemma3N Android demo app support, but required modifying two OSS files (`extension/android/CMakeLists.txt` and `scripts/build_android_library.sh`) with `@oss-disable` lines. This creates ongoing merge friction and scales poorly as more internal models are added. This PR introduces a one-time, stable hook so that: | Build System | How it Works | Result | | :--- | :--- | :--- | | **Internal Buck CI** | Uses TARGETS files directly | No change needed | | **Internal CMake/Gradle** | Hook includes `fb/extended_targets/CMakeLists.txt` which sets internal flags | Works | | **OSS CMake/Gradle** | Hook is a no-op (`fb/extended_targets/` does not exist) | Works | ## Test plan - OSS builds: No behavior change. The `fb/extended_targets/` directory does not exist, so the `if(EXISTS ...)` evaluates to false and is a no-op. - Internal builds: Place a `CMakeLists.txt` in `extension/android/fb/extended_targets/` to verify it gets included.
1 parent eb77ed4 commit 5ed3616

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

extension/android/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ if(EXECUTORCH_BUILD_LLAMA_JNI)
226226
endif()
227227
endif()
228228

229+
# Hook for extended build targets (e.g., internal or partner-specific JNI
230+
# extensions). This is a no-op when extended_targets/ does not exist.
231+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/fb/extended_targets/CMakeLists.txt")
232+
include("${CMAKE_CURRENT_SOURCE_DIR}/fb/extended_targets/CMakeLists.txt")
233+
endif()
234+
229235
target_include_directories(
230236
executorch_jni
231237
PRIVATE

0 commit comments

Comments
 (0)