Fix parallel Gradle build problems in teapots#1167
Fix parallel Gradle build problems in teapots#1167emrekultursay wants to merge 1 commit intoandroid:mainfrom
Conversation
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.
Summary of ChangesHello @emrekultursay, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical build stability issue within the 'teapots' project when utilizing Gradle's parallel build capabilities. Previously, concurrent builds of sub-projects would attempt to write shared library outputs to the same absolute directory, leading to race conditions and build failures. The changes ensure that each sub-project now directs its 'ndkHelper' library output to a unique, relative path, thereby enabling successful and stable parallel builds. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a race condition during parallel Gradle builds by ensuring each teapot sub-project builds the ndkHelper library into its own unique directory. The change from an absolute to a relative path in the add_subdirectory call is the right approach.
I've added one comment regarding code duplication across the various CMakeLists.txt files. While the current fix is perfectly fine, centralizing the logic for adding the ndk_helper dependency would improve long-term maintainability. This is just a suggestion for future improvement and doesn't block this PR.
| get_filename_component(ndkHelperSrc ${commonDir}/ndk_helper ABSOLUTE) | ||
| add_subdirectory(${ndkHelperSrc} | ||
| ${commonDir}/ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}) | ||
| ndkHelperBin/${CMAKE_BUILD_TYPE}/${ANDROID_ABI}) |
There was a problem hiding this comment.
This change correctly fixes the parallel build issue. However, the logic for adding the ndk_helper library is duplicated across five CMakeLists.txt files, which can make maintenance difficult.
To improve this, you could centralize the logic. For example, a function could be added to cmake/AppLibrary.cmake to handle adding ndk_helper. This would encapsulate the path logic and the add_subdirectory call. Such a function would need to handle cases where commonDir is already defined by the caller, as is the case in some of the other teapot projects.
While a full refactoring is likely beyond the scope of this PR, it's a worthwhile improvement to consider for the future to enhance the maintainability of these build scripts.
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.