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

Demo of using a root .dart_tool/package_config.json instead of pubspec.yaml #51782

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions .dart_tool/package_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

Is there are a tool or package other than pub that knows how to generate a package_config.json file with the right schema?

Copy link
Contributor

@jakemac53 jakemac53 Mar 29, 2024

Choose a reason for hiding this comment

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

The package_config package has a toJson method on PackageConfig. I am not sure what the API for creating PackageConfig objects is like, but you could use that. Ultimately it would just be more complicated I think than maintaining this file.

The Dart SDK has a bespoke tool for it also which does more sort of auto-creation based on looking in specific directories for packages, which might be an option here.

"configVersion": 2,
"packages": [
{
"name": "args",
"rootUri": "../../third_party/dart/third_party/pkg/args",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "async",
"rootUri": "../../third_party/dart/third_party/pkg/async",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "async_helper",
"rootUri": "../../third_party/dart/pkg/async_helper",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "collection",
"rootUri": "../../third_party/dart/third_party/pkg/collection",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "engine_build_configs",
"rootUri": "../tools/pkg/engine_build_configs",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "engine_repo_tools",
"rootUri": "../tools/pkg/engine_repo_tools",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "engine_tool",
"rootUri": "../tools/engine_tool",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "expect",
"rootUri": "../../third_party/dart/pkg/expect",
"packageUri": "lib/",
"languageVersion": "2.19"
},
{
"name": "file",
"rootUri": "../../third_party/dart/third_party/pkg/file/packages/file",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "litetest",
"rootUri": "../testing/litetest",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "logging",
"rootUri": "../../third_party/dart/third_party/pkg/logging",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "meta",
"rootUri": "../../third_party/dart/pkg/meta",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "path",
"rootUri": "../../third_party/dart/third_party/pkg/path",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "platform",
"rootUri": "../third_party/pkg/platform",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "process",
"rootUri": "../third_party/pkg/process",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "process_fakes",
"rootUri": "../tools/pkg/process_fakes",
"packageUri": "lib/",
"languageVersion": "3.2"
},
{
"name": "process_runner",
"rootUri": "../third_party/pkg/process_runner",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "smith",
"rootUri": "../../third_party/dart/pkg/smith",
"packageUri": "lib/",
"languageVersion": "2.12"
},
{
"name": "source_span",
"rootUri": "../../third_party/dart/third_party/pkg/source_span",
"packageUri": "lib/",
"languageVersion": "3.1"
},
{
"name": "string_scanner",
"rootUri": "../../third_party/dart/third_party/pkg/string_scanner",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "term_glyph",
"rootUri": "../../third_party/dart/third_party/pkg/term_glyph",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "yaml",
"rootUri": "../../third_party/dart/third_party/pkg/yaml",
"packageUri": "lib/",
"languageVersion": "3.0"
},
{
"name": "_engine",
"rootUri": "../",
"packageUri": "lib/",
"languageVersion": "3.3"
}
]
}
12 changes: 9 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# commonly generated files
# Commonly generated files
*.pyc
*~
.*.sw?
Expand All @@ -8,7 +8,6 @@
.classpath
.clangd/
.cproject
.dart_tool
.gdb_history
.checkstyle
.gdbinit
Expand All @@ -28,6 +27,14 @@ pubspec.lock
docs/doxygen/
xcuserdata

# Typical projects would hide all of .dart_tool, but we're treating it as a
# mono repository to resolve packages across the entire repository, so hide
# .dart_tool but allow the .dart_tool/package_config.json file.
.dart_tool/**
!.dart_tool/package_config.json
# But ignore the .dart_tool directory in any subdirectories.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/But/and

*/**/.dart_tool/

# Miscellaneous
*.class
*.lock
Expand Down Expand Up @@ -56,7 +63,6 @@ xcuserdata

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
Expand Down
11 changes: 11 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ analyzer:
deprecated_member_use: ignore
deprecated_member_use_from_same_package: ignore
exclude: # DIFFERENT FROM FLUTTER/FLUTTER
# Directories that might have Dart code, but aren't part of the engine, i.e.
# vended directories or code that is copied by tooling.
- prebuilts/
- third_party/
# Directories that have Dart code, but the Dart code isn't resolvable by the
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we already think we're analyzing some or all of this Dart code: https://github.com/flutter/engine/blob/main/ci/analyze.sh#L58 and below. Why are we not already hitting problems with this?

# analyzer, i.e. it uses custom embedding or other tooling that the analyzer
# can't be aware of.
- examples/
- impeller/
- runtime/
- shell/
# Fixture depends on dart:ui and raises false positives.
- flutter_frontend_server/test/fixtures/lib/main.dart

Expand Down
9 changes: 3 additions & 6 deletions bin/et
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ PLATFORM="${OS}-${CPU}"
DART_SDK_DIR="${ENGINE_DIR}/prebuilts/${PLATFORM}/dart-sdk"
DART="${DART_SDK_DIR}/bin/dart"

if [ ! -d "${ENGINE_DIR}/tools/engine_tool/.dart_tool" ]; then
echo "You must run 'gclient sync -D' before using this tool."
exit 1
fi

"${DART}" --disable-dart-dev "${ENGINE_DIR}/tools/engine_tool/bin/et.dart" "$@"
"${DART}" \
--disable-dart-dev \
"${ENGINE_DIR}/tools/engine_tool/bin/et.dart" "$@"
76 changes: 0 additions & 76 deletions tools/engine_tool/pubspec.yaml
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 we'd probably want some documentation to explain how to add/remove dependencies.

This file was deleted.

1 change: 0 additions & 1 deletion tools/pub_get_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
os.path.join(ENGINE_DIR, 'tools', 'compare_goldens'),
os.path.join(ENGINE_DIR, 'tools', 'const_finder'),
os.path.join(ENGINE_DIR, 'tools', 'dir_contents_diff'),
os.path.join(ENGINE_DIR, 'tools', 'engine_tool'),
os.path.join(ENGINE_DIR, 'tools', 'gen_web_locale_keymap'),
os.path.join(ENGINE_DIR, 'tools', 'githooks'),
os.path.join(ENGINE_DIR, 'tools', 'golden_tests_harvester'),
Expand Down