-
Notifications
You must be signed in to change notification settings - Fork 229
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
[new feature] build_dependencies #3794
Comments
This design would be similar to Rust/Cargo's |
This package contains the logic for building native assets. This package is the backend that invokes toplevel `build.dart` scripts. For more info on these scripts see https://github.com/dart-lang/native. This is a separate package so that dartdev and flutter_tools can reuse the same logic without flutter_tools having to import dartdev. Some design decisions: * We don't yet have `build_dependencies`, so we use the ordinary dependency graph for ordering of native assets builds. (If there is a cycle we refuse to run.) Bug: dart-lang/pub#3794 * Builds are cached based on all the configuration provided by the caller. Environment variables are ignored in caching. This CL also contains a unit test that invokes the build by not passing through environment variables. However, for Windows we need to pass through at least `SYSTEMROOT` for MSVC to run correctly. So we might need to further explore if we can/want to lock env variables down. Bug: dart-lang/native#32 Bug: dart-lang/native#33 Run tests: ``` dart tools/generate_package_config.dart && \ tools/test.py -n unittest-asserts-release-linux pkg/native_assets_builder ``` Bug: #50565 Change-Id: I133052d7195373e87d20924d61e1e96e3d34ce8f Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300203 Reviewed-by: Liam Appelbe <[email protected]> Commit-Queue: Daco Harkes <[email protected]> Reviewed-by: Martin Kustermann <[email protected]> Reviewed-by: Hossein Yousefi <[email protected]>
Is this issue mostly about decoupling the build dependencies (the package deps in If so, an option to support this that does not require a new Call this directory Perhaps |
Haha, I completely missed this one earlier. 😆 How'd you come up with this! 🤣 Considering the developments in dart-lang/sdk#54334, this should be
I like it, but we'd need to do a |
Yeah, modifying But also you really want your build-dependencies covered by I think there are other reasons for not wanting entirely separate resolutions. If some of your dependencies are in IMO, a safer bet here would be |
In particular, I can imagine that given how packages can pass meta-data and build assets between each other, it could cause problems if Because It's very reasonable for |
Right we talked about a similar thing yesterday. I tried to remember it this morning but couldn't come up with it. So there are multiple places where version skew between different packages
|
@jonasfj Private dependencies is not entirely safe either. Because you could not leak your dependency types to the public API but leak the json-serialized format to metadata or a json encoded asset. So if we introduce private_dependencies, we need to document clearly that you cannot add packages to private_dependencies when you rely on serialized formats (assuming that the serialized formats are versioned by semver). |
You can rely on private_dependencies, you must not re-export anything from a private-dependency. But yes, there be dragons here 🐉 -- including assetIds that might be hard to figure out. I think it's important to recognize that multiple versions of the same package is difficult to do. Even if things run in a different context, data or JSON meta-data might flow between them. It kind of only works, if you promise that packages (and transitive dependencies) of every in That can work, if we make people explicitly promise this. It's complicated. Not perfect. And it doesn't not alleviate us from having to lock everything in the I think all of this is something we can explore if/when version conflicts become a huge issue. |
Reviving this discussion. My worry is that by not having Is there any plan to move forward with some kind of different dependencies for hooks? |
@mosuem Why would you pin dependencies? |
In my understanding the point is that a dependency used for building will constrain the same dependency for run-time while they really are running in separate contexts, and therefore could use separate versions. |
Okay, I understood it as pinning a dependency to the same version. In the case of protobuf (or similar), I would suspect that there easily is a runtime component to it (some library used by the generated code). And said runtime component would need to be compatible. |
Exactly :) Thanks for the clarification.
In the case of storing tree-shaking information, this is only used in the link hook, so no runtime components. I would even argue that hooks can't have runtime components, as they consume a configuration and produce assets, so there can be no code leakage. So the dependencies are actually separate. |
Introduce
build_dependencies
: inpubspec.yaml
, and let dart files inbuild/native.dart
only depend on these dependencies.Consider the following scenario:
package:a
depends onpackage:b
, but thebuild/native.dart
inpackage:a
does not depend onpackage:b
.package:c
andpackage:d
circularly depending on each other, but both of theirbuild/native.dart
builds do not depend on the other package.package:clang
and use it in theirbuild/native.dart
.Specifying build_dependencies has the following advantages:
package:a
to a newer version does not trigger a rebuild ofpackage:b
s’ native assets.package:a
could use a different major version ofpackage:clang
thanpackage:b
. This would not be possible with their dependencies being resolved in one go. Dependency resolution would fail.This means that the
.dart_tool/package_config.json
would contain a resolution set per package for itsbuild_dependencies
.This means we probably need another
dart <...>
command, becausedart run
resolves to thebin/
folder, not thebuild/
folder.This would require the IDE to understand having different versions of dependencies in a project in the
build/
.It is unclear whether any of the benefits outweigh the downsides, so we leave this for when this becomes relevant in the ecosystem.
Workaround: split your package into two packages, and have the native assets in a small package that the rest of the code in the other package depends on.
Context:
Taken from go/dart-native-asset-caching to have a tracking bug.
The text was updated successfully, but these errors were encountered: