Skip to content

Fix parallel Gradle build problems in teapots#1167

Open
emrekultursay wants to merge 1 commit intoandroid:mainfrom
emrekultursay:fix_parallel_build
Open

Fix parallel Gradle build problems in teapots#1167
emrekultursay wants to merge 1 commit intoandroid:mainfrom
emrekultursay:fix_parallel_build

Conversation

@emrekultursay
Copy link
Contributor

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 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.
@gemini-code-assist
Copy link

Summary of Changes

Hello @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

  • Build Fix for Parallel Gradle: Resolved an issue where Gradle builds would fail when inter-project parallelism was enabled, specifically within the 'teapots' sub-projects.
  • CMakeLists.txt Path Correction: Modified CMakeLists.txt files across multiple 'teapots' sub-projects to use relative paths for 'ndkHelperBin' output, preventing race conditions during parallel builds.

🧠 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
  • teapots/choreographer-30fps/src/main/cpp/CMakeLists.txt
    • Updated the 'add_subdirectory' command for 'ndkHelperSrc' to use a relative path for 'ndkHelperBin' output, resolving parallel build conflicts.
  • teapots/classic-teapot/src/main/cpp/CMakeLists.txt
    • Updated the 'add_subdirectory' command for 'ndkHelperSrc' to use a relative path for 'ndkHelperBin' output, resolving parallel build conflicts.
  • teapots/image-decoder/src/main/cpp/CMakeLists.txt
    • Updated the 'add_subdirectory' command for 'ndkHelperSrc' to use a relative path for 'ndkHelperBin' output, resolving parallel build conflicts.
  • teapots/more-teapots/src/main/cpp/CMakeLists.txt
    • Updated the 'add_subdirectory' command for 'ndkHelperSrc' to use a relative path for 'ndkHelperBin' output, resolving parallel build conflicts.
  • teapots/textured-teapot/src/main/cpp/CMakeLists.txt
    • Updated the 'add_subdirectory' command for 'ndkHelperSrc' to use a relative path for 'ndkHelperBin' output, resolving parallel build conflicts.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant