Skip to content

Conversation

@GaryQian
Copy link
Contributor

@GaryQian GaryQian commented Feb 17, 2021

This PR adds the full build system that allows building deferred components apps using flutter build appbundle

Behavior is controlled via two negatable flags: --[no-]deferred-components and --[no-]-verify-deferred-components

Split off of #63773

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 17, 2021
@google-cla google-cla bot added the cla: yes label Feb 17, 2021
@GaryQian
Copy link
Contributor Author

Still plan on adding additional tests, but requesting review now for more preliminary feedback!

Copy link
Contributor

Choose a reason for hiding this comment

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

Should there be some more validation here? Could you have deferred components and no component names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That particular case is a valid use case. Developers can include no component names to generate the loading units without packing them into dynamic features during development.

Copy link
Contributor

Choose a reason for hiding this comment

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

document what this is

Copy link
Contributor

Choose a reason for hiding this comment

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

Pull this into a helper method

Copy link
Contributor

Choose a reason for hiding this comment

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

globals.fs.path should have a path separator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we can't build a split aot in debug mode, could we structure this so that the calling code always passes false for debug and otherwise leaves the build mode out of the asset system?

Copy link
Contributor

Choose a reason for hiding this comment

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

The manifest doesn't get produced if its not a split AOT right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I'll change this to track the manifest in the depfile in case the app does not include any loading units.

Copy link
Contributor

Choose a reason for hiding this comment

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

Pass this through as a build define instead of creating a special argument for it. The build apk/appbundle et cetera commands should have the well documented arg

Copy link
Contributor

Choose a reason for hiding this comment

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

This should all be performed in the build system, why move it out here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Like we talked about, no usage of the build system outside of assemble

@jonahwilliams
Copy link
Contributor

We don't have a super verbose mode, but if you want to see why the targets are re-running, I would recommend adding logging to https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/build_system/build_system.dart#L806-L856

GaryQian added 7 commits March 4, 2021 02:08
t # This is a combination of 3 commits.

Separate prebuild and build tooling, early working(ish) version

Refactor, cleanup

Integrate dart library names

golden generation refactor

REmove extra deps

Remove conflicts

Sync version numbers with local.properties in modules

Remove no-use-bare-instructions

Use strings.xml for loading unit -> module mapping

Copy assets prototype

Begin assets packaging

Pack assets into split mdoule

Package assets

Fix after rebase

Add shrinking disable back to support multi-apk builds

Rename to deferred_component_config

Move commands to proper location

Move commands to new locations, cleanup

Additional cleanup, rename to deferred d components

Begin transition into single command setup

Basic one-command verification and setup

Build multiple ABIs

Assets work

Working intermediates system

Shift .so multiplexing into dart, cleanup

Consolidation and additional cleanup

Goldens work

Migrate so copy to new target

Move setup to prebuild

Working prebuild for setup

Setup verification work

Working setup system

Cleanup and begin backwards/debug compatibility

Cleanup

More cleanup:

Refactor verification and setup into calss, split into two parts: pre and post assembly

Refactor setup code, address comments

Refactoring, begin templates impl, address comments

Working template based generation

Docs, refactor, rename

Refactor, libs copy depfile

More depfiles work, debug run assets working

Add dynamicFeatures build.gradle programmatically

More refactoring, depfile fixes, improvement to copying and loading unit parsing

Include unused loading units in base module

Crash fixes:

Prevent validation on debug builds, fix flutter run behavior

Flutter run working again

AndroidManifest.xml validation and writing

Move check to Target to track dependencies.

Resolve various crashes and flutter run issues

Fix multi-split assets

Generate diff

Message formatting, async fixes

Fix strings.xml edits and log recommended command to apply diff

Improve strings.xml algorithm

Improve regex, Add unit tests

Begin validator tests, custom loggers

Null safety

Passing initial tests

Add many validator tests

Component android dir tests

Add tests for AndroidManifest mapping and string.xml names

Finish validator tests

Test for deferred components .so copying

Add validator Target test

flutter manifest tests

Round 1 analyzer fixes

Refactor, passes analyzer

Fix casts

Merge with upstream

Merge

Fix abi mismatch when switching targets between builds

Pass abi to validator

Switch to BufferLogger

Begin integration tests for tooling

Building deferred components apps works in integration test

Passing build appbundle integration tests

Fix tests and analyzer, cleanup:

Whitespaces

Update diff

Sync with validator PR

Sync with validator PR tests

Integrate with new validator

Sync with splitbuild

Fix null dep

Merge changes

Add tests for target
if (!_allTargetsCached(file)) {
print('${red}Not all build targets cached after second run.$reset');
print('The target performance data was: ${file.readAsStringSync()}');
print('The target performance data was: ${file.readAsStringSync().replaceAll('},', '},\n')}');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes the log much more readable. Quick fix for me totally missing the "skipped: false" entries in this line because it was 90% cut off onscreen.

Copy link
Contributor

Choose a reason for hiding this comment

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

awesome!

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

I would like to see some of the usages of flutter project to pass config in the build rules cleaned up a bit, but we can handle that in a follow up

Copy link
Contributor

Choose a reason for hiding this comment

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

You could lose a level of indentation here by doing an early return if components is null.

if (!_allTargetsCached(file)) {
print('${red}Not all build targets cached after second run.$reset');
print('The target performance data was: ${file.readAsStringSync()}');
print('The target performance data was: ${file.readAsStringSync().replaceAll('},', '},\n')}');
Copy link
Contributor

Choose a reason for hiding this comment

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

awesome!

@GaryQian
Copy link
Contributor Author

GaryQian commented Mar 4, 2021

I'll definitely follow up with additional cleanup and I do also want to add additional tests in areas.

@GaryQian GaryQian added c: new feature Nothing broken; request for a new capability waiting for tree to go green labels Mar 4, 2021
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@jonahwilliams
Copy link
Contributor

Ahh, the change in the asset manager API needs to be updated in g3 too. You'll need to make a g3fix using frob

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

Labels

c: new feature Nothing broken; request for a new capability tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants