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

Conversation

@whesse
Copy link
Contributor

@whesse whesse commented Jun 7, 2022

If a gclient checkout checks out engine source to a different directory than src/,
the source packages should be found relative to the script location.

The instructions for Flutter developers say to check out engine to engine/src,
and this change allows a gclient solution to check out to a different path and
still run the hooks.

Bug: dart-lang/sdk#49163

If a gclient checkout checks out engine source to a different directory,
the source packages should be found relative to the script location.

Bug: dart-lang/sdk#49163
@whesse whesse requested a review from zanderso June 7, 2022 12:28
pub_count = 0
for package in ALL_PACKAGES:
if FetchPackage(pubcmd, package) != 0:
package_path = os.path.join(engine_src, ".." , package)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could modify the package paths to remove the need for .., or I could create the array of package paths based on engine_src, moving it to a global variable ENGINE_SRC, if that is better.

leading = os.path.join(
"src", "third_party", "dart", "tools", "sdks", "dart-sdk", "bin"
)
script = os.path.realpath(__file__)
Copy link
Member

Choose a reason for hiding this comment

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

I think the right thing to do is to follow the pattern that we use in other scripts for setting these paths up as globals like in:

https://github.com/flutter/engine/blob/main/tools/githooks/setup.py#L14,

then you can rewrite the paths in ALL_PACKAGES.

# Check that this is right.
SRC_ROOT = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
FLUTTER_DIR = os.path.join(SRC_ROOT, 'flutter')
DART_BIN = os.path.join(SRC_ROOT, 'third_party', 'dart', 'tools', 'sdks', 'dart-sdk', 'dart')

ALL_PACKAGES = [
  os.path.join(FLUTTER_DIR, "ci"),
  ...
]

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, changed to match that pattern.
Ran ci/bin/format.dart.
Tested the script by running from different working directories.
Tested the script detecting missing packages by injecting a missing dependency and testing.

whesse added 3 commits June 7, 2022 18:19
If a gclient checkout checks out engine source to a different directory,
the source packages should be found relative to the script location.

Bug: dart-lang/sdk#49163
@zanderso
Copy link
Member

zanderso commented Jun 9, 2022

Huh. Sorry about the delay. My GitHub workflow is email driven, and I don't know why I missed this one.

@zanderso zanderso merged commit ab9932e into flutter:main Jun 9, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 9, 2022
houhuayong pushed a commit to houhuayong/engine that referenced this pull request Jun 21, 2022
…utter#33869)

* Change pub_get_offline hook to find engine src relative to script

If a gclient checkout checks out engine source to a different directory,
the source packages should be found relative to the script location.

Bug: dart-lang/sdk#49163

* Change pub_get_offline hook to find engine src relative to script

If a gclient checkout checks out engine source to a different directory,
the source packages should be found relative to the script location.

Bug: dart-lang/sdk#49163

* Fix merge errors, run ci/bin/format.dart
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants