Description
We should consider adding support for user-defines as command-line arguments from Dart and Flutter.
CLI sketch:
dart run --hook-define=<package>.<key>=<value>
flutter run --hook-define=<package>.<key>=<value>
The defines are namespace by package similar to how these are nested in the pubspec.yaml
user defines.
The defines are shared for all hooks, similar to how the are shared across all hooks (currently only build.dart and link.dart) in the pubspec.yaml
user-defines.
Hooks API: Unchanged from current API. Command-line arguments "override" arguments from the pubspec.
JSON protocol sketch:
{
"user_defines": {
"command_line_arguments": {
"base_path": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/QqYcWN/workspace/pkgs/my_package/",
"defines": {
"user_define_key": "user_define_value",
"some_file": "assets/data.json"
}
},
"workspace_pubspec": {
"base_path": "/private/var/folders/2y/mngq9h194yzglt4kzttzfq6800klzg/T/QqYcWN/workspace/pubspec.yaml",
"defines": {
"user_define_key": "user_define_value",
"user_define_key2": {
"foo": "bar"
},
"some_file": "pkgs/my_package/assets/data.json"
}
},
},
}
Caching behavior:
Overrides the non-cli-args cache with cli args. So for a second invocation with the same cli args the cache is used.
A later invocation without cli args needs to be rerun.
If no CLI args are passed the whole command_line_arguments
from the JSON is omitted. So invoking builds from multiple root packages in the same directory without cli arguments will always hit caching.
Using cli args invalidates caching.
(If we keep the config
in JSON dictates cache directory, we could use a different cache directory if there are any CLI arguments. E.g. config
->has_cli_args
= true
.)
Metadata
Metadata
Assignees
Type
Projects
Status