Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hermesFlagsRelease not working with multiple productFlavors #31040

Closed
wants to merge 4 commits into from

Conversation

geraintwhite
Copy link
Contributor

Ref #25601 (comment).

Summary

The hermesFlagsRelease option only works with the release build type, but not with other build types. This PR considers other build types as release and enables hermesFlagsRelease to apply to any non-debug build type.

Changelog

[Android] [Fixed] - Fix hermesFlagsRelease not working with multiple productFlavors

Test Plan

Set hermesFlagsRelease: ["-w"] in android/app/build.gradle and ensure warnings are hidden when running ./gradlew assembleRelease and ./gradlew assembleLive.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 23, 2021
@analysis-bot
Copy link

analysis-bot commented Feb 23, 2021

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: 438a4cf

@analysis-bot
Copy link

analysis-bot commented Feb 23, 2021

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,986,617 +0
android hermes armeabi-v7a 8,493,859 +0
android hermes x86 9,438,889 +0
android hermes x86_64 9,380,654 +0
android jsc arm64-v8a 10,605,031 +0
android jsc armeabi-v7a 10,105,321 +0
android jsc x86 10,624,040 +0
android jsc x86_64 11,207,709 +0

Base commit: 438a4cf

@@ -186,7 +186,7 @@ afterEvaluate {
def hermesFlags;
def hbcTempFile = file("${jsBundleFile}.hbc")
exec {
if (targetName.toLowerCase().contains("release")) {
if (!targetName.toLowerCase().contains("debug")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure changing this logic for everyone won’t break the build somewhere (assuming that some people may have custom debug-oriented buildTypes). Maybe the best solution would be to introduce a lambda similar to enableHermesForVariant or flag like we have with bundleIn$targetName, and configure this logic from outside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes that probably is a better solution

Copy link
Contributor

Choose a reason for hiding this comment

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

@grit96, were you going to make the change based on the suggestion?

@sota000
Copy link
Contributor

sota000 commented Sep 25, 2021

Hi! Closing this PR since the comment hasn't been addressed for a while. Please reopen and ping me if you are still up for working on this. Thanks for your time!

@geraintwhite
Copy link
Contributor Author

@sota000 sorry for not getting back sooner - I've made the changes in a new PR #32281

facebook-github-bot pushed a commit that referenced this pull request Oct 13, 2021
Summary:
Ref #25601 (comment).

From #31040.

The `hermesFlagsRelease` option only works with the release build type, but not with other build types.

This PR allows hermes flags on a per variant basis to be specified using the `hermesFlagsForVariant` lambda.

It also allows the hermes debugger cleanup to be run on a per variant basis using the `deleteDebugFilesForVariant` lambda.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix hermesFlags not working with multiple variants

Pull Request resolved: #32281

Test Plan:
Set the following options in `android/app/build.gradle` and ensure warnings are hidden when running `./gradlew assembleRelease` and `./gradlew assembleLive`.

```
    hermesFlagsForVariant: {
        def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live') ? ['-w'] : []
    },
    deleteDebugFilesForVariant: {
        def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live')
    },
```

Reviewed By: cortinico

Differential Revision: D31234241

Pulled By: ShikaSD

fbshipit-source-id: 2cb3dd63adbcd023061076b5a3b262a87b470518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants