Skip to content

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Aug 2, 2019

Description

Update build bundle to delegate the call to build bundle to flutter assemble. Then copy the required assets out of the cache directory and into the build/* directory, or where told.

Problem: depfile generated by dart rule will have the wrong paths. I don't really think we should hack around this, and instead work on shrinking flutter gradle to a single assemble invocation. The tool can then output inputs/outputs in a depfile format

@jonahwilliams jonahwilliams added the tool Affects the "flutter" command-line tool. See also t: labels. label Aug 2, 2019
@codecov
Copy link

codecov bot commented Aug 2, 2019

Codecov Report

Merging #37508 into master will increase coverage by 0.16%.
The diff coverage is 28.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #37508      +/-   ##
==========================================
+ Coverage   58.92%   59.08%   +0.16%     
==========================================
  Files         192      192              
  Lines       18442    18527      +85     
==========================================
+ Hits        10867    10947      +80     
- Misses       7575     7580       +5
Flag Coverage Δ
#flutter_tool 59.08% <28.88%> (+0.16%) ⬆️
Impacted Files Coverage Δ
...kages/flutter_tools/lib/src/commands/assemble.dart 78.68% <ø> (-0.35%) ⬇️
...s/flutter_tools/lib/src/commands/build_bundle.dart 98.11% <ø> (ø) ⬆️
...utter_tools/lib/src/build_system/targets/dart.dart 47.57% <0%> (-28.99%) ⬇️
...ter_tools/lib/src/build_system/targets/assets.dart 64.86% <0%> (-22.41%) ⬇️
...utter_tools/lib/src/build_system/build_system.dart 87.55% <100%> (+0.05%) ⬆️
packages/flutter_tools/lib/src/artifacts.dart 69.2% <100%> (+0.1%) ⬆️
packages/flutter_tools/lib/src/bundle.dart 76.08% <76.92%> (+0.32%) ⬆️
packages/flutter_tools/lib/src/version.dart 90.9% <0%> (-1.92%) ⬇️
packages/flutter_tools/lib/src/cache.dart 43.5% <0%> (-0.73%) ⬇️
packages/flutter_tools/lib/src/vmservice.dart 37.27% <0%> (-0.61%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f877c97...631667a. Read the comment docs.

@jonahwilliams
Copy link
Contributor Author

This should be less risky now, and gives us a path to incrementally adopting assemble.


@override
List<Source> get outputs => const <Source>[
Source.pattern('{BUILD_DIR}/vm_snapshot_data'),
Copy link
Member

Choose a reason for hiding this comment

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

Are these going to get converted to OUTPUT_DIR in https://github.com/flutter/flutter/pull/39274/files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if I land the output dir change this is all much simpler

targetModel: TargetModel.flutter,
targetProductVm: buildMode == BuildMode.release,
outputFilePath: environment.buildDir.childFile('app.dill').path,
depFilePath: null,
Copy link
Member

Choose a reason for hiding this comment

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

Should/can you use the kernel compiler depfile as a sanity check?


@override
List<Target> get dependencies => const <Target>[
CopyAssets(),
Copy link
Member

Choose a reason for hiding this comment

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

Library prefixes could help with namespacing targets, at least internally.

applicationKernelFilePath ??= getDefaultApplicationKernelPath(trackWidgetCreation: trackWidgetCreation);
final FlutterProject flutterProject = FlutterProject.current();

if (shouldBuildWithAssemble) {
Copy link

Choose a reason for hiding this comment

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

do you plan to enable assemble for the remaining cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we could, but I'd like to be conservative here

const _BundleTarget();

@override
Future<void> build(List<File> inputFiles, Environment environment) async { }
Copy link

@blasten blasten Aug 27, 2019

Choose a reason for hiding this comment

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

Would it be common to have an empty build method if the target is used to combine other targets? If that is the case, maybe it needs a lower abstraction (e.g. without build)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This what the planning phase is attempting to address, but until that lands it is necessary for now

flutterProject: FlutterProject.current(),
mainPath: fs.path.join('lib', 'main.dart'),
outputDir: 'example',
targetPlatform: TargetPlatform.ios
Copy link

Choose a reason for hiding this comment

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

nit: trailing comma

@jonahwilliams
Copy link
Contributor Author

Updated to use the new OUTPUT_DIR pattern, and to produce a correct depfile for gradle (it was excluding all of the flutter assets).

@blasten, were the flutter assets being included as a dependency in some other way?

@required String mainPath,
@required String outputDir,
}) async {
final Environment environment = Environment(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmagman This is an example of mapping a build * command to an assemble command. For example, in the iOS framework case this could include multiple calls if need be.

@jonahwilliams
Copy link
Contributor Author

This change requires #39654 to land

try {
final File file = fs.file(fs.path.join(environment.outputDir.path, entry.key));
file.parent.createSync(recursive: true);
await file.writeAsBytes(await entry.value.contentsAsBytes());
Copy link
Member

Choose a reason for hiding this comment

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

How about testing if entry.value is a DevFSFileContent and if so use File.copy() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams
Copy link
Contributor Author

Landed the perquisite PR, will attempt to land if CI passes.

@jonahwilliams
Copy link
Contributor Author

Per my discussion with @yjbanov, I'm going to ignore web failures on this (since it is unrelated). Will land once build is green

} catch (e) {
} catch (e, st) {
print(e);
print(st);
Copy link

Choose a reason for hiding this comment

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

nit: this print and the one above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops!

@jonahwilliams
Copy link
Contributor Author

We believe that the web tests are broken and have disabled them. I'm ignoring them for this PR.

@jonahwilliams jonahwilliams merged commit a7aff56 into flutter:master Sep 11, 2019
@jonahwilliams jonahwilliams deleted the bundle_assemble branch September 11, 2019 02:28
@jonahwilliams jonahwilliams restored the bundle_assemble branch September 11, 2019 03:03
jonahwilliams pushed a commit that referenced this pull request Sep 11, 2019
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
Inconnu08 pushed a commit to Inconnu08/flutter that referenced this pull request Sep 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants