Skip to content

Conversation

@michaellee8
Copy link
Contributor

Description

add ability to use --dart-define for fuchsia build

Related Issues

Didn't open an issue for trivial changes.

Tests

I added the following tests:

Didn't add tests for trivial changes

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.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Apr 27, 2020
@michaellee8
Copy link
Contributor Author

@jonahwilliams @zanderso please have a look at this. This is just a trivial change so that I can set -Ddart.vm.product=true

@jonahwilliams
Copy link
Contributor

Ddart.vm.product=true should only be set by the flutter tooling when we're targeting release mode. Is this not working correctly?

@jonahwilliams
Copy link
Contributor

Also - yes we should add dart-defines! Thanks for getting started with the PR here.

It does need to be tested, let me take a look at the existing build_fuchsia code and get back to you

@jonahwilliams jonahwilliams self-requested a review April 27, 2020 05:07
@jonahwilliams
Copy link
Contributor

Ahh, just looked - seems we're not passing the same arguments to the fuchsia kernel compiler that we are to the others:

if (buildInfo.mode.isRelease) '-Ddart.vm.release=true',

The fix for release mode would probably be to change this line to dart.vm.product instead of release

@jonahwilliams
Copy link
Contributor

This is also where you would need to add the dart-defines from the buildInfo class. Something like:

for (final Object dartDefine in dartDefines)
  '-D$dartDefine',

In the list of command line arguments

@michaellee8
Copy link
Contributor Author

Oops, but it seems that there are no arguments passed to the kernel compiler command here

[  +51 ms] Building Fuchsia application...
[   +1 ms] executing: /home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/dart-sdk/bin/dart
/home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/artifacts/flutter_runner/flutter/arm64/release/aot/dart_binaries/kernel_compiler.snapshot --target flutter_runner --platform
/home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/artifacts/flutter_runner/flutter/arm64/release/aot/flutter_runner_patched_sdk/platform_strong.dill --filesystem-scheme main-root --filesystem-root
/home/michaellee8/flutter_gallery --packages main-root:///.packages --output build/fuchsia/flutter_gallery.dil --component-name flutter_gallery --aot --tfa --no-embed-sources -Ddart.vm.release=true
-Ddart.developer.causal_async_stacks=false main-root:///lib/main.dart

@michaellee8
Copy link
Contributor Author

Oops, but it seems that there are no arguments passed to the kernel compiler command here

[  +51 ms] Building Fuchsia application...
[   +1 ms] executing: /home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/dart-sdk/bin/dart
/home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/artifacts/flutter_runner/flutter/arm64/release/aot/dart_binaries/kernel_compiler.snapshot --target flutter_runner --platform
/home/michaellee8/flutter_fuchsia_toolchain/flutter/bin/cache/artifacts/flutter_runner/flutter/arm64/release/aot/flutter_runner_patched_sdk/platform_strong.dill --filesystem-scheme main-root --filesystem-root
/home/michaellee8/flutter_gallery --packages main-root:///.packages --output build/fuchsia/flutter_gallery.dil --component-name flutter_gallery --aot --tfa --no-embed-sources -Ddart.vm.release=true
-Ddart.developer.causal_async_stacks=false main-root:///lib/main.dart

Oh my bad here, I thought that -Ddart.vm.release=true is due to my setting.

@jonahwilliams
Copy link
Contributor

The arguments are the flag list here:

@michaellee8
Copy link
Contributor Author

@jonahwilliams I wrote the code to add those flags into the kernel compiler, also refactored it to allow easier testing. Please kindly have a look at it.

@michaellee8
Copy link
Contributor Author

I think the remaining test does not have much to do with my patch? Are there any further problem?


testUsingContext('parse device-finder output', () async {
const String example = '2001:0db8:85a3:0000:0000:8a2e:0370:7334 paper-pulp-bush-angel';
const String example =
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you revert the formatting changes in this file?

'--drop-ast',
],

for (final Object dartDefine in buildInfo.dartDefines) '-D$dartDefine',
Copy link
Contributor

Choose a reason for hiding this comment

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

I would move '-D$dartDefine', to the next line

}

/// Provide flags that are affected by [BuildInfo]
List<String> getBuildInfoFlags({
Copy link
Contributor

Choose a reason for hiding this comment

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

I would make this method static and annotate it with @visibleForTesting from package:meta/meta.dart

@michaellee8
Copy link
Contributor Author

@jonahwilliams Please have a look at this, I have apply the fixes as requested except the contains one.

import '../../src/common.dart';

void main() {
group('Fuchsia Kernel Compiler', () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer 2 space indents in this file

Copy link
Contributor Author

@michaellee8 michaellee8 Apr 27, 2020

Choose a reason for hiding this comment

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

I don't understand this one, what should I do? It should be 2 space indents already.

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
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 with a minor formatting nit

FYI @zanderso

@jonahwilliams
Copy link
Contributor

Thank you for fixing this @michaellee8 !

michaellee8 and others added 2 commits April 28, 2020 01:19
…el_compiler_test.dart

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
…el_compiler_test.dart

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
@michaellee8
Copy link
Contributor Author

Umm are there any formatter config I can use? I just use Crtl+Shift+I in VS Code which should be using dartfmt.

@jonahwilliams
Copy link
Contributor

Unfortunately we don't use autoformatting for the flutter/flutter repo. The style guide is outlined here: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo

But general, format in way that is readable, don't go too long, and intent things 2 spaces instead of 4

@michaellee8
Copy link
Contributor Author

@jonahwilliams Oh i can get it. Are there any problems left?

michaellee8 and others added 5 commits April 28, 2020 01:41
…el_compiler_test.dart

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
…el_compiler_test.dart

Co-Authored-By: Jonah Williams <jonahwilliams@google.com>
@michaellee8
Copy link
Contributor Author

Hey please don't merge this right now. Let me revert all the bad things caused by auto formatter first.

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.

Still LGTM

@michaellee8
Copy link
Contributor Author

All damages are cleaned and looks good to merge now. LGTM

@fluttergithubbot fluttergithubbot merged commit 34b8f83 into flutter:master Apr 27, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 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