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

Archives for dart-sdk and flutter_patched_sdk.#30888

Merged
fluttergithubbot merged 6 commits intoflutter:mainfrom
godofredoc:gn_target_2
Feb 4, 2022
Merged

Archives for dart-sdk and flutter_patched_sdk.#30888
fluttergithubbot merged 6 commits intoflutter:mainfrom
godofredoc:gn_target_2

Conversation

@godofredoc
Copy link
Contributor

@godofredoc godofredoc commented Jan 15, 2022

These new targets will be used to archive the artifacts directly
from GN simplifying the recipes and validating artifacts are
generated and archived correctly on presubmit.

Bug: flutter/flutter#81855

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

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

destination = "platform_strong.dill"
},
]
# This is the flutter_sdk from debug configuration.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe:

zip_bundle("flutter_patched_sdk") {
  file_suffix = ""
  path_prefix = ""
  if (flutter_runtime_mode == "release") {
    file_suffix = "_product"
    path_prefix = "flutter_patched_sdk_product/"
  }
  output = "flutter_patched_sdk${file_suffix}.zip"
  deps = [ "//flutter/lib/snapshot:strong_platform" ]
  files = [
    {
      source = "$root_out_dir/flutter_patched_sdk/vm_outline_strong.dill"
      destination = "${path_prefix}vm_outline_strong.dill"
    },
    {
      source = "$root_out_dir/flutter_patched_sdk/platform_strong.dill"
      destination = "${path_prefix}platform_strong.dill"
    },
  ]
}

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!

# Flutter consumes the dart sdk as a prebuilt. Rather than regenerating
# the zip file we are just copying the original file to the artifacts location.
copy("dart_sdk_archive") {
sources = [ "//flutter/prebuilts/dartsdk-$host_os-$target_cpu-release.zip" ]
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit trickier. See the logic and comments in the top-level BUILD.gn.

We probably only want to expose this target when _build_engine_artifacts is true:

https://github.com/flutter/engine/blob/main/BUILD.gn#L59

And the SDK to copy is given by the logic here:

https://github.com/flutter/engine/blob/main/BUILD.gn#L38

I'd suggest hoisting _build_engine_artifacts and the result of the logic on line 38 to constants in https://github.com/flutter/engine/blob/main/common/config.gni at the bottom near the other Dart SDK constants that you can then import here.

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!

destination = "platform_strong.dill"
},
]
# This is the flutter_sdk from debug configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding a comment about this being used for profile mode as well.

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!

if (build_engine_artifacts) {
copy("dart_sdk_archive") {
sources = [ prebuilt_dart_sdk ]
outputs = [ "$root_out_dir/zip_archives/dart-sdk-$host_os-$target_cpu.zip" ]
Copy link
Member

Choose a reason for hiding this comment

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

prebuilt_dart_sdk is a directory, so I'm not quite sure why GN isn't complaining about this. Maybe it's because the build isn't trying to build the target yet. Also $host_os-$target_cpu should probably be host-host or target-target. Here's a suggestion on how to make sure things stay consistent:

if (build_engine_artifacts && flutter_prebuilt_dart_sdk) {
  copy("dart_sdk_archive") {
    sources = [ prebuilt_dart_sdk_archive ]
    outputs = [ "$root_out_dir/zip_archives/dart-sdk-$prebuilt_dart_sdk_config.zip" ]
  }
}

prebuilt_dart_sdk_archive and prebuilt_dart_sdk_config we can define in common/config.gni.

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!

"//flutter/prebuilts/$_target_os_name-$target_cpu/dart-sdk"
host_prebuilt_dart_sdk =
"//flutter/prebuilts/$_host_os_name-$host_cpu/dart-sdk"

Copy link
Member

Choose a reason for hiding this comment

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

_target_prebuilt_dart_sdk_config = "$_target_os_name-$target_cpu"
_host_prebuilt_dart_sdk_config = "$_host_os_name-$host_cpu"
_target_prebuilt_dart_sdk_archive =
    "//flutter/prebuilts/dartsdk-$_target_prebuilt_dart_sdk_config-release.zip"
_host_prebuilt_dart_sdk_archive =
    "//flutter/prebuilts/dartsdk-$_host_prebuilt_dart_sdk_config-release.zip"

target_prebuilt_dart_sdk = "//flutter/prebuilts/$_target_prebuilt_dart_sdk_config/dart-sdk"
host_prebuilt_dart_sdk = "//flutter/prebuilts/$_host_prebuilt_dart_sdk_config/dart-sdk"

# There is no prebuilt Dart SDK targeting Fuchsia, but we also don't need
# one, so even when the build is targeting Fuchsia, use the prebuilt
# Dart SDK for the host.
if (current_toolchain == host_toolchain || is_fuchsia) {
  prebuilt_dart_sdk = host_prebuilt_dart_sdk
  prebuilt_dart_sdk_config = _host_prebuilt_dart_sdk_config
  prebuilt_dart_sdk_archive = _host_prebuilt_dart_sdk_archive
} else {
  prebuilt_dart_sdk = target_prebuilt_dart_sdk
  prebuilt_dart_sdk_config = _target_prebuilt_dart_sdk_config
  prebuilt_dart_sdk_archive = _target_prebuilt_dart_sdk_archive
}

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!

@chinmaygarde
Copy link
Contributor

Is there work ongoing on this front?

@godofredoc
Copy link
Contributor Author

Is there work ongoing on this front?

Actually the work is done, but I haven't rebased yet. Let me do it.

@godofredoc
Copy link
Contributor Author

This is ready for another round of reviews.

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

@godofredoc godofredoc added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Feb 4, 2022
@fluttergithubbot fluttergithubbot merged commit 1232caf into flutter:main Feb 4, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 4, 2022
@godofredoc godofredoc deleted the gn_target_2 branch January 12, 2024 19:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants