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

Flutter assemble for macos take 2! #36987

Merged
merged 13 commits into from
Jul 31, 2019

Conversation

jonahwilliams
Copy link
Member

@jonahwilliams jonahwilliams commented Jul 26, 2019

Description

  • Updates the BuildResult to track input and output files. Due to some issues with other parts of the tool re-writing these files constantly, some have been factored out of the list.

  • Adds an "optional" source and a pod rule to use it. Until I add a configuration/planning phase I need to add the pod step to every build, but only run it when a podfile exists.

Implementation of flutter assemble for the macOS build. This updates the entrypoint script to move all artifact copying/generation into build rules. This also generates an input/output xcfilelist that can be used by xcode to skip the entire script phase.

This requires the project changes in google/flutter-desktop-embedding#459

#32921

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Jul 26, 2019
@codecov
Copy link

codecov bot commented Jul 26, 2019

Codecov Report

Merging #36987 into master will increase coverage by 1.41%.
The diff coverage is 81.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #36987      +/-   ##
==========================================
+ Coverage   54.19%    55.6%   +1.41%     
==========================================
  Files         193      193              
  Lines       17892    17982      +90     
==========================================
+ Hits         9696     9999     +303     
+ Misses       8196     7983     -213
Flag Coverage Δ
#flutter_tool 55.6% <81.59%> (+1.41%) ⬆️
Impacted Files Coverage Δ
...ackages/flutter_tools/lib/src/commands/attach.dart 74.19% <ø> (-0.14%) ⬇️
...ackages/flutter_tools/lib/src/commands/daemon.dart 34.34% <ø> (ø) ⬆️
...es/flutter_tools/lib/src/commands/build_macos.dart 84.21% <ø> (ø) ⬆️
packages/flutter_tools/lib/src/commands/run.dart 60.57% <ø> (-0.19%) ⬇️
packages/flutter_tools/lib/src/project.dart 82.84% <100%> (+2.06%) ⬆️
...utter_tools/lib/src/build_system/targets/dart.dart 73.77% <100%> (+1.35%) ⬆️
...ackages/flutter_tools/lib/src/resident_runner.dart 53.4% <100%> (+0.18%) ⬆️
packages/flutter_tools/lib/src/run_hot.dart 66.81% <100%> (+0.07%) ⬆️
...utter_tools/lib/src/build_system/build_system.dart 93.01% <100%> (+0.88%) ⬆️
packages/flutter_tools/lib/src/ios/xcodeproj.dart 86.66% <100%> (ø) ⬆️
... and 24 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 bd47a31...c98c32d. Read the comment docs.

@jonahwilliams jonahwilliams added the platform-mac Building on or for macOS specifically label Jul 26, 2019
@jonahwilliams jonahwilliams marked this pull request as ready for review July 26, 2019 20:03
${local_engine_flag}
${local_engine_flag} \
assemble \
-dTargetFile="${target_path}" \
Copy link
Member Author

Choose a reason for hiding this comment

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

TBD: flavor?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this a TODO that points to the flavors issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

// Remove "inputs" that were outputs of previous builds.
buildInstance.inputFiles.removeWhere((String path, File file) {
// Leaking implementation detail: remove pubpsec, flutter-plugins, generated.
return buildInstance.outputFiles.containsKey(path) ||
Copy link
Member

Choose a reason for hiding this comment

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

How do these make it into the input list? Is there a sanity check that can be done here instead ahead-of-time?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this check into the input list construction

@@ -472,10 +480,28 @@ class BuildSystem {
// Always persist the file cache to disk.
fileCache.persist();
}
// Remove "inputs" that were outputs of previous builds.
buildInstance.inputFiles.removeWhere((String path, File file) {
// Leaking implementation detail: remove pubpsec, flutter-plugins, generated.
Copy link
Member

Choose a reason for hiding this comment

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

This comment should explain why these are being blacklisted and/or the criteria for adding items to this list.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated with a longer TODO that explains why this is here for now, and what needs to be done to remove it.

@@ -105,6 +105,9 @@ class SourceVisitor {
}
}
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Flip the sense to if (!hasWildcard) and return early under that if to unindent the big chunk.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


@override
List<Source> get outputs => const <Source>[
// No outputs because Cocoapods is fully responsible for tracking. plus there
Copy link
Member

Choose a reason for hiding this comment

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

Can this produce something like a .stamp file that dependent rules can use to track?

Copy link
Member Author

Choose a reason for hiding this comment

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

We'd need to right it such that the file contents changed as well. Just a stamp wont work since we're using file hashes, at that point it is probably close to the same as .flutter-plugins.

I've updated this with an explicit todo to add a planning phase so I can conditionally insert the pod rule. Then I can use the regular outputs.

@jonahwilliams jonahwilliams changed the title Fluter assemble for macos take 2! Flutter assemble for macos take 2! Jul 29, 2019
@jonahwilliams
Copy link
Member Author

@zanderso PTAL

Copy link
Member

@zanderso zanderso left a comment

Choose a reason for hiding this comment

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

lgtm w/ nits

${local_engine_flag}
${local_engine_flag} \
assemble \
-dTargetFile="${target_path}" \
Copy link
Member

Choose a reason for hiding this comment

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

Maybe make this a TODO that points to the flavors issue.

@@ -39,7 +39,7 @@ class SourceVisitor {
/// Visit a [Source] which contains a file uri.
///
/// The uri may that may include constants defined in an [Environment].
void visitPattern(String pattern) {
void visitPattern(String pattern, bool optional) {
Copy link
Member

Choose a reason for hiding this comment

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

Describe 'optional' parameter in the doc comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}

// TODO(jonahwilliams): real AOT implementation.
class ReleaseMacOSApplication extends DebugMacOSApplication {
Copy link
Member

Choose a reason for hiding this comment

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

Should these have a build method that throws an UnimplementedError?

Copy link
Member Author

Choose a reason for hiding this comment

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

The release mode is a bit of a lie today, but it does exist

@@ -106,10 +112,34 @@ class AssembleCommand extends FlutterCommand {
printError('Target ${data.key} failed: ${data.value.exception}');
printError('${data.value.exception}');
}
throwToolExit('build failed');
throwToolExit('build failed.');
} else {
Copy link
Member

Choose a reason for hiding this comment

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

else not needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

if (!flutterBuildDir.existsSync()) {
flutterBuildDir.createSync(recursive: true);
}
// Create the environment used to process the build. This need sto mtach what
Copy link
Member

Choose a reason for hiding this comment

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

this need sto -> this needs to

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

// Set debug or release mode.
String config = 'Debug';
if (buildInfo.isRelease) {
if (buildInfo.isRelease == true) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this because isRelease could be null? In that case, how about buildInfo.isRelease ?? false

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -81,26 +81,28 @@ class MacOSDevice extends Device {
bool ipv6 = false,
}) async {
// Stop any running applications with the same executable.
PrebuiltMacOSApp prebuiltMacOSApp;
if (!prebuiltApplication) {
Copy link
Member

Choose a reason for hiding this comment

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

Think positive (unless there's a good reason not to):

if (prebuiltApplication) {
  ...
} else {
  ...
}

Also, should the Cache lock be released early in both cases, or just when prebuiltAppllication is false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@jonahwilliams jonahwilliams merged commit 2ab4699 into flutter:master Jul 31, 2019
@jonahwilliams jonahwilliams deleted the macos_assemble_impl_2 branch July 31, 2019 23:19
track_widget_creation_flag=""
if [[ -n "$TRACK_WIDGET_CREATION" ]]; then
track_widget_creation_flag="--track-widget-creation"
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing this regressed the bug where hot reload crashes in IDEs; I'm not sure why it was taken out.

I'll send a follow-up PR shortly.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform-mac Building on or for macOS specifically 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