Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fix building Dart Fuchsia components and packages - #28413

Merged
fluttergithubbot merged 3 commits into
flutter-team-archive:masterfrom
richkadel:build-fuchsia-dart-2
Sep 9, 2021
Merged

fluttergithubbot merged 3 commits into
flutter-team-archive:masterfrom
richkadel:build-fuchsia-dart-2

Conversation

@richkadel

@richkadel richkadel commented Sep 1, 2021 •

Copy link
Copy Markdown

The previous PR did not build the Fuchsia packages correctly:

GN build rules for tests using Fuchsia SDK Dart libraries and bindings #27996

The new changes bring in more of the Fuchsia GN-SDK build rules. Some
changes to these rules were required because the fuchsia.git-derived
flutter/dart build rules depend on a different implementation of
similar-sounding rules (fuchsia.git <> Fuchsia GN SDK, regarding build
rule implementations).

I renamed flutter/tools/fuchsia/sdk to flutter/tools/fuchsia/gn-sdk to be more clear that GN SDK was the original source.

Also, I realized there were still some references to python3.8 and python3_action. Now that flutter is building with python3 by default, that action is no longer needed, so I've removed it.

Fixes: flutter/flutter#87999 (because the original fix had deficiencies)

Tested in Fuchsia and confirmed the dart package/component launches and runs.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@richkadel

Copy link
Copy Markdown
Author

@iskakaushik @arbreng - FYI, here are the updated build rules as promised.

@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch 2 times, most recently from f7ae543 to 3e4808f Compare September 2, 2021 16:51
@richkadel

Copy link
Copy Markdown
Author

Oops, I somehow leaked my test code into yesterday's post of this PR. I fixed it this morning, so this commit ONLY has changes to flutter/tools, as intended.

I also added a separate commit, before the main commit, with the original versions of the GN SDK files I adapted, so anyone can see what changes I needed, to make this work for flutter/engine.

This is ready for review, assuming it passes CI.

@richkadel

Copy link
Copy Markdown
Author

@chaselatta - I should have cc'ed you initially!

@chaselatta

Copy link
Copy Markdown
Contributor

I will take a look a little later today.

# # launch the vm service in the runner.
# # This configuration is not compatible with a --release build since the
# # profile aot runner is built without asserts.
# dart_aot_debug_build_cfg = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we still need all of these?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Technically I don't need them for the current state of things, but I assume we want the option of both jit and aot builds?

If you disagree, I'm happy to delete all of the other commented out config options. Or if you know which ones we should keep or remove, I can delete the configs we know we're not going to need.

I figured we'd talk about and resolve the TODO items after the integration tests are working.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That works for me.

rebase_path(_kernel_path, root_build_dir),
]

# TODO(richkadel): Chase said these are not needed in flutter/engine tests,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

They are not needed if you don't passs the --split-output-by-packages flag. If you don't pass that flag it will keep everything in a giant dill file which is how other platforms work. Fuchsia is special in that we split the packages to take advantage of the content addressed file system.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hmm... OK I'll try that, and make sure it still works. I've been trying to keep things as close as possible to how Fuchsia works so I can eliminate variables, and focus on debugging things that are different for a reason.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I haven't tried to make this change yet, but the most recent commit (just uploaded) addresses what I think are all of the other changes.

I'll experiment with what you recommended, now that the other items are out of the way.

args += [ "--embed-sources" ]

# } else {
# args += [ "--no-embed-sources" ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

As above, I assume we're going to want to support AOT mode testing as well as JIT. I wanted to keep the relevant code derived from Fuchsia build rules, but comment it out, to make sure I wasn't picking up non-debug-mode (non-jit) logic when I was focusing only on getting debug/jit to work.

We'll either uncomment or remove this, once things are working, based on the team's expectations.

}
# # Builds the component in a non-product AOT build. This will
# # launch the vm service in the runner.
# # This configuration is not compatible with a --release build since the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same question as above, do we still need these?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

See above answers

# copy the snapshot as a resource
_snapshot_resource_target_name = "${target_name}_snapshot_resource"

# TODO(richkadel): It looks like this is the _ONLY_ place resource() is used

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

resource just writes to metadata and gets collected by the package

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, I left it in for now (but with the TODO) so the structure of files derived from Fuchsia is as similar to the original as possible. (As mentioned in my earlier comment, this helps see what did and did not change. I figure it can be optimized in a subsequent PR once we're happy that everything else is working as expected.

_convert_kernel_target_name =
"${_kernel_target_name}_convert_kernel_manifest"
_convert_kernel_manifest_file =
# TODO(richkadel): This is prefixed by "dartlang/", which is not found.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dartlang/ is specific to the fuchsia build

@richkadel richkadel Sep 2, 2021 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry, this was a bit of a hack here. I ran into some really frustrating issues debugging some GN rules, and for this one, I couldn't figure out why I was getting the toolchain prefix, or how to remove it. Eventually I just punted, and decided to strip it out for now.

This works, but is clearly not optimal. I have no immediate solution for it though, but if you or anyone has a recommendation on how to fix the rules, I'm happy to try.

(I can give it another go, but wasted hours on just this problem already. Some GN magic still eludes me.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Update: If/when we resolve the limitation in flutter_runner to allow loading packages that don't include a .dilplist file, I can remove all of the code related to generate_manifest, including this one. In the mean time, I'm planning to leave this as-is, if that's OK, and come back to it later, one way or the other, to resolve the TODO item.

Comment thread tools/fuchsia/gn-sdk/component.gni Outdated
@@ -1,4 +1,4 @@
# Copyright 2013 The Flutter Authors. All rights reserved.
# Copyright 2019 The Fuchsia Authors. All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The copyright needs to be 2013 for the copyright checker to work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right. I'll fix those. Thanks!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@richkadel

Copy link
Copy Markdown
Author

@chaselatta - In addition to addressing "most" of your comments (so far), the commit I just uploaded also adds BUILD.gn rules to package up one Fuchsia-based Dart test, already present in flutter/engine. It can be built via:

$ flutter_build flutter/shell/platform/fuchsia/dart-pkg/zircon/test

And produces:

out/fuchsia_release_x64/gen/flutter/shell/platform/fuchsia/dart-pkg/zircon/test/channel_test/channel_test.far

I expanded the .far to examine it and the contents look valid. The point is not (yet) to run this test, but I wanted to test the build rules, without adding a commit dependency on the integration tests, which really depend on these improved build rules instead.

The only thing I still need to address is to try removing --split-output-by-packages and --manifest.

I addressed the copyright headers, and responded to your questions on the other items.

You'll have to tell me if the answers are satisfactory, or if you are looking for changes, but the general theme seems to be that, you're right, some things are not strictly needed, and/or are derived from Fuchsia, but I kept some build rule features so I could compare them more equally with the build rules and ninja execution of the same tests in Fuchsia (which has been helpful).

I think once we're comfortable the rules are working as expected, we can strip out more of the rules that are never likely to be needed by flutter/engine.

@richkadel

Copy link
Copy Markdown
Author

Oh, one more thing. I changed where I'm putting the dart_library() rules for third_party dart library dependencies (for including dart libraries in a Fuchsia component/package). Up to this point, I was mirroring the location of the library between //third_party and //build/secondary/third_party.

This was short sighted. It adds unneeded complexity. Instead, I started (so far with a couple of additional libraries I needed for the build test I added in the latest commit) centralizing these Fuchsia-specific dart_library() rules to the existing //flutter/shell/platform/fuchsia/dart/BUILD.gn, and I set package_root to wherever the actual library is.

This saves me having to add BUILD.gn files to flutter/buildroot separately (which is a minor annoyance, no longer).

If you don't object, I will move all of the other dart_library() rules from their individual BUILD.gn files under //build/secondary to the same BUILD.gn file.

As it turns out, this should also allow me to remove find_dart_libraries.py, a python script I wrote that I felt was a bit hacky anyway... searching for the "best match" among many possible paths to find a dart library dependency.

@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch from 3e8ae90 to 5fe010d Compare September 8, 2021 17:36
Rich Kadel added 2 commits September 8, 2021 10:44
This commit includes only the files copied from the Fuchsia GN SDK, that
had to be adapted to support flutter/engine integration tests. Most of
these GN rule implementations were reusable as written (modulo some
directory paths); however, some rules had to be adjusted to overcome
current limitations.

The required changes are implemented in the succeeding git commit, which
also includes the additional flutter/engine build rules needed to build
Dart-based Fuchsia packages, based on the Fuchsia SDK, to be published
and tested in a compatible Fuchsia instance.
The previous PR did not build the Fuchsia packages correctly:

> GN build rules for tests using Fuchsia SDK Dart libraries
  and bindings flutter-team-archive#27996

The new changes bring in more of the Fuchsia GN-SDK build rules. Some
changes to these rules were required because the fuchsia.git-derived
flutter/dart build rules depend on a different implementation of
similar-sounding rules (fuchsia.git <> Fuchsia GN SDK, regarding build
rule implementations).

I renamed flutter/tools/fuchsia/sdk to flutter/tools/fuchsia/gn-sdk to
be more clear that GN SDK was the original source.

Also, I realized there were still some references to python3.8 and
python3_action. Now that flutter is building with python3 by default,
that action is no longer needed, so I've removed it.

Fixes: flutter/flutter#87999 (because the original fix had
deficiencies)

Tested in Fuchsia and confirmed the dart package/component launches
and runs.
@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch from 5fe010d to 4e24e74 Compare September 8, 2021 17:47
@richkadel

Copy link
Copy Markdown
Author

@iskakaushik - Just FYI, I added build rules to package up one of the existing tests as a flutter component. (I did not actually try running the component in Fuchsia, and I had to mock up a .cmx file that probably isn't valid, but I confirmed that the resulting .far appears to be structured correctly to run.) The test is not in the standard build dependencies, but you can directly invoke the build via the following command, if you're interested:

$ flutter_build flutter/shell/platform/fuchsia/dart-pkg/zircon/test

So I included this as a validation of the build rules, like we once discussed. (I think you had started something similar, using the same files (?), to at least test dart_library, if I'm not mistaken, so that's why I picked that test.)

Any concerns? I can leave it in or remove it if required.

@chaselatta - Let me know if you think this should stay or be removed.

@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch 2 times, most recently from 08d8083 to 5e9885d Compare September 8, 2021 18:33
@richkadel

Copy link
Copy Markdown
Author

Oh, I see Kaushik's change to use vpython3 (which also supplied yaml) was reverted due to flakes on Windows. I removed all of the references to vpython3, and added pyyaml to DEPS, and updated the imports to load pyyaml into the path before import yaml (as done in Fuchsia today).

@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch 3 times, most recently from 5fff63c to b3279b5 Compare September 8, 2021 21:33
Confirmed the new test build rules generate a Dart Fuchsia package that
appears to be structured correctly for testing on a Fuchsia platform.
@richkadel
richkadel force-pushed the build-fuchsia-dart-2 branch from b3279b5 to 183b377 Compare September 8, 2021 21:53
@richkadel

Copy link
Copy Markdown
Author

The license check finally passed in CI... just waiting out the rest of the CI checks (which all passed earlier today)

# # launch the vm service in the runner.
# # This configuration is not compatible with a --release build since the
# # profile aot runner is built without asserts.
# dart_aot_debug_build_cfg = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That works for me.

@chinmaygarde

Copy link
Copy Markdown
Contributor

Seems good to go. May I land this?

@richkadel

Copy link
Copy Markdown
Author

yes, please!

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

Labels

cla: yes platform-fuchsia waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Development

Successfully merging this pull request may close these issues.

Enable flutter/engine tests via Fuchsia components

4 participants