Skip to content

Commit f9d7870

Browse files
Fix parallel Gradle build problems in teapots (#1167)
When building the entire project with Gradle, if Gradle-level inter-project parallelism is enabled (either via the property `org.gradle.parallel=true`, or via Android Studio injected flags), then the build was failing, because these sub-projects under the teapots project all try to write their ndkHelper library outputs to the same path, causing a race condition. When we use a relative path for the output binary (instead of an absolute path like it used to be), then AGP puts the CMake/Ninja outputs to per-subproject folders under `$project/.cxx` which avoids the race condition.
1 parent 66ab8b4 commit f9d7870

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

teapots/choreographer-30fps/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ find_package(base CONFIG REQUIRED)
2424
get_filename_component(commonDir ${CMAKE_CURRENT_SOURCE_DIR}/../../../../common ABSOLUTE)
2525
get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE)
2626
add_subdirectory(${ndkHelperSrc}
27-
${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
27+
ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
2828

2929
# now build app's shared lib
3030
add_app_library(${PROJECT_NAME}

teapots/classic-teapot/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include(AppLibrary)
2323
get_filename_component(commonDir ${CMAKE_CURRENT_SOURCE_DIR}/../../../../common ABSOLUTE)
2424
get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE)
2525
add_subdirectory(${ndkHelperSrc}
26-
${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
26+
ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
2727

2828
# now build app's shared lib
2929
add_app_library(${PROJECT_NAME}

teapots/image-decoder/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ get_filename_component(commonDir ${CMAKE_CURRENT_SOURCE_DIR}/../../../../common
2424
# build the ndk-helper library
2525
get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE)
2626
add_subdirectory(${ndkHelperSrc}
27-
${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
27+
ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
2828

2929
# now build app's shared lib
3030
add_app_library(${PROJECT_NAME}

teapots/more-teapots/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include(AppLibrary)
2323
get_filename_component(commonDir ${CMAKE_CURRENT_SOURCE_DIR}/../../../../common ABSOLUTE)
2424
get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE)
2525
add_subdirectory(${ndkHelperSrc}
26-
${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
26+
ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
2727

2828

2929
# now build app's shared lib

teapots/textured-teapot/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif()
3131
# build the ndk-helper library
3232
get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE)
3333
add_subdirectory(${ndkHelperSrc}
34-
${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
34+
ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI})
3535

3636
# now build app's shared lib
3737
add_app_library(${PROJECT_NAME}

0 commit comments

Comments
 (0)