[go: nahoru, domu]

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

select ResidentCompiler during FlutterDevice initialization #28603

Merged

Conversation

jonahwilliams
Copy link
Member
@jonahwilliams jonahwilliams commented Feb 27, 2019

Description

Rather than have each command be responsible for creating the correct ResidentCompiler, use a static method to create the FlutterDevice which is responsible for creating it. This simplifies the commands responsible for creating the flutter device, and frees us up to use different generators/build scripts for flutter web or other targets.

This also moves the generation of the .packages file outside of the builders. In cases where the build fails we still to produce a valid .packages file. This also makes it easier for flutter tester

Related Issues

#27141

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes tests for all changed/updated/fixed behaviors (See Test Coverage).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

@zoechi zoechi added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 28, 2019
@jonahwilliams jonahwilliams changed the title wire up codegen directly through flutter device [WIP] wire up codegen directly through flutter device Feb 28, 2019
@jonahwilliams jonahwilliams changed the title [WIP] wire up codegen directly through flutter device Wire up codegen directly through flutter device Mar 2, 2019
@jonahwilliams jonahwilliams changed the title Wire up codegen directly through flutter device select ResidentCompiler during FlutterDevice initialization Mar 2, 2019
@jonahwilliams
Copy link
Member Author

PTAL @yjbanov


// Create a scratch space file that can be read/written by the frontend server.
// It is okay to hard-code these file names because we will copy them back
// from the temp directory at the end of the build step.
final Directory tempDirecory = await Directory.systemTemp.createTemp('_flutter_build');
final File packagesFile = File(path.join(tempDirecory.path, _kPackagesExtension));
final Directory projectDir = File(packagesPath).parent;
final String packagesFilePath = path.join(projectDir.path, '.packages.generated');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: how about generatedPackagesFilePath to disambiguate from .packages?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm going to delete this file in the next PR, so for the sake of brevity I'll leave it as is for now.

import '../dart/pub.dart';
import '../globals.dart';
import '../project.dart';
import '../resident_runner.dart';
import 'build_script_generator.dart';

const String _kMultirootScheme = 'org-dartlang-app';
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment explaining the choice of this value would be helpful, even if it was chosen arbitrarily.

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

}

// Create generated packages file which adds a multi-root scheme to the user's
// project directory. currently we only replace the root package with a multiroot
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "Currently"

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

_server.kill();
return _server.exitCode;
_server?.kill();
return _server?.exitCode;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it meaningful to return null if _server is null? Maybe return 0? If it an unexpected situation, perhaps throw or print a warning?

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

Copy link
Contributor
@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

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

lgtm

@jonahwilliams jonahwilliams merged commit a2d349c into flutter:master Mar 7, 2019
@jonahwilliams jonahwilliams deleted the add_more_codegen_support branch March 7, 2019 19:02
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 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.

None yet

4 participants