Add split-debug and obfuscation to build aar#56342
Add split-debug and obfuscation to build aar#56342fluttergithubbot merged 6 commits intoflutter:masterfrom
Conversation
There was a problem hiding this comment.
The build_aar command would need to be refactored to get the buildInfo from the flutter command instead of manually constructing it.
Is this what you meant, @jonahwilliams?
There was a problem hiding this comment.
Yup! though there are some edges here. For example, If a user builds a debug aar with obfuscation enabled, the sources might be scrambled. This might cause confusion if there is some expectation that these flags only work on "release" builds
There was a problem hiding this comment.
@xster What do you think the best user experience would be here?
- Ignore the flags for the debug and profile output
- Ignore the flags for the debug and profile output, and print a warning
- Only allow the flags accompanied by
--no-debugand--no-profile
There was a problem hiding this comment.
FWIW we do support --obfuscate on --debug flutter build apk --debug today, but not through flutter run. The former isn't very common so I didn't think it merited any interception, but it might be more common to build artifacts together here
There was a problem hiding this comment.
$ flutter build aar --target-platform=android-arm --obfuscate --split-debug-info=foo/
Building flutter tool...
Changing current working directory to: /Users/magder/Projects/aaa
Dart obfuscation is not supported in Debug mode, skipping.
Running Gradle task 'assembleAarDebug'...
Running Gradle task 'assembleAarDebug'... Done 20.6s
✓ Built build/host/outputs/repo.
Dart obfuscation is not supported in Profile mode, skipping.
Running Gradle task 'assembleAarProfile'...
Running Gradle task 'assembleAarProfile'... Done 21.4s
✓ Built build/host/outputs/repo.
Running Gradle task 'assembleAarRelease'...
Running Gradle task 'assembleAarRelease'... Done 3.2s
✓ Built build/host/outputs/repo.
There was a problem hiding this comment.
LG. "skipping" is a bit ambiguous since you didn't skip building debug/profile. Maybe just say building debug/release in unobfuscated mode?
There was a problem hiding this comment.
Changed to: "Dart obfuscation is not supported in Debug mode, building as unobfuscated."
There was a problem hiding this comment.
|
Forgot to add the integration test. |
There was a problem hiding this comment.
There was a problem hiding this comment.
Possibly overly pedantic, but It would be nice to separate the control flow from the expectations here. You could nest contains and predicate/isA<> matchers to accomplish this, though I don't know if its an improvement
There was a problem hiding this comment.
I tried it, I think it's harder to read...
| return TaskResult.failure('Found project name in obfuscated APK dart library'); | ||
| } | ||
| if (foundAarProjectName) { | ||
| return TaskResult.failure('Found project name in obfuscated AAR dart library'); |
There was a problem hiding this comment.
Bleh this fails:
[android_obfuscate_test] [STDOUT] Executing: grep aaa jni/armeabi-v7a/libapp.so in /var/folders/mv/qlhc4vsj6tqct166rw3zwmth00mfq2/T/flutter_devicelab_gradle_plugin_test.bY7bhQ/aaa
[android_obfuscate_test] [STDOUT] stdout: Binary file jni/armeabi-v7a/libapp.so matches
...
Task result:
{
"success": false,
"reason": "Found project name in obfuscated AAR dart library"
}
There was a problem hiding this comment.
Does the build aar call into assemble in the same way?
|
LGTM. Thanks for fixing! |
| if (androidBuildInfo.buildInfo.treeShakeIcons) { | ||
| command.add('-Pfont-subset=true'); | ||
| } |
There was a problem hiding this comment.
This is in the wrong spot, I moved it out of the local engine check.
There was a problem hiding this comment.
@dnfield Can you confirm you didn't intentionally want the tree shake check to only happen with a local engine?
There was a problem hiding this comment.
Correct - it should be able to work with both. I probably only tested with a local engine.
| '-Poutput-dir=${buildDirectory.path}', | ||
| '-Pis-plugin=true', | ||
| '-PbuildNumber=1.0', | ||
| '-q', |
Description
Add
--split-debug-infoand--obfuscateflags tobuild aar.Related Issues
Fixes #56068
Obviates #56069
Tests
build_aar_test flag parsing. Confirmed the tests also passed on master when I commented out the
--split-debug-infoand--obfuscateparts, so nothing regressed.Add
build aarto android_obfuscate_test` devicelab test.Checklist
///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change