-
Notifications
You must be signed in to change notification settings - Fork 40
implement a dependency graph algorithm for package and kit builds #198
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
Conversation
|
Now using Guppy and getting a bit closer to where we are going with this. |
c128614 to
596002d
Compare
|
Current status: encountered during a Bottlerocket build at the Turns out that Cargo.toml doesn't have [package]
name = "filesystem"
version = "0.1.0"
edition = "2021"
publish = false
build = "../build.rs"
[lib]
path = "../packages.rs" |
|
Over the weekend I made some changes to the Bottlerocket diff and the testing passed. This is ready for review. |
|
Improvement to the algorithm. For package build, for the top-level manifest, we should only consider |
Twoliter projects, and kit builds in particular, will benefit from having a single workspace that includes all packages, kits and variants.
The snafu errors in Buildsys/main.rs were printing the enum value only without any underlying error information,
| included-packages = [ | ||
| "pkg-b", | ||
| "pkg-d", | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we not doing included-packages for kits any more?
It might be more natural to support an optional excluded-packages instead, if the default should be that all packages go into the kit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An included-packages would be sort of gnarly to implement since it would need to inform the graph algorithm. When we talked about it we were thinking we would just go with Cargo dependencies defining the package list. excluded-packages could be a feature add fairly easily if anyone ends up needing that.
| assert!(BuildFlags::Package.includes(PACKAGE | VARIANT)); | ||
| assert!(BuildFlags::Variant.includes(VARIANT)); | ||
| assert!(BuildFlags::Variant.includes(VARIANT | PACKAGE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need kits to include the same build flags that packages do, except we should rebuild on a change to BUILDSYS_KITS_DIR vs BUILDSYS_PACKAGES_DIR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need kits to include the same build flags that packages do, except we should rebuild on a change to BUILDSYS_KITS_DIR vs BUILDSYS_PACKAGES_DIR.
True! I'll get it in the next one when adding the build-kit command and getting it to work.
| /// Lists include the "top-level manifest", i.e. the thing that `buildsys` is being asked to build. | ||
| /// We do not want this, we want only a list of things that it depends on. Here we convert | ||
| /// `PackageMetadata` objects to the `String` name, and filter out the "top-level manifest". | ||
| fn filter_map_to_name(top_manifest_name: &str, pkg_metadata: &PackageMetadata) -> Option<String> { | ||
| if pkg_metadata.name() == top_manifest_name { | ||
| None | ||
| } else { | ||
| // Return the package override name, if it exists, or else the Cargo manifest name. | ||
| Some(get_buildsys_package_name(pkg_metadata)) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we guaranteed that the first entry in the traversal is the node we started from? Naively, that's what I would expect from a graph iterator. If so, we could just skip the first element from the iterator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we guaranteed that the first entry in the traversal is the node we started from? Naively, that's what I would expect from a graph iterator. If so, we could just skip the first element from the iterator.
The documentation is silent on order of returned results. Seems safer and cheap to not make the assumption.
| // Sort so that this function has consistent, dependable output regardless of graph internals. | ||
| packages.sort(); | ||
| Ok(packages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make a difference? Seems like we'd already be getting topologically-sorted output, which should be reasonable consistent. This final sort ends up throwing away the ordering information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make a difference? Seems like we'd already be getting topologically-sorted output, which should be reasonable consistent. This final sort ends up throwing away the ordering information.
The documentation is silent on order of returned results (though topo-sort seems likely). My most common interaction with this list is "is the package I care about in the list?", whereby alphabetical is more convenient.
jmt-lab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
| #[arg(long, env = "BUILDSYS_ARCH")] | ||
| pub(crate) arch: SupportedArch, | ||
|
|
||
| #[arg(long, env = "BUILDSYS_CARGO_METADATA_PATH")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be added to the rebuild vars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this need to be added to the rebuild vars?
I think we're covered by the fact that the package/variant dirs are being watched for changes, and the cargo metadata output should be the same unless something has changed about those packages. In other words, I think if anything important changes, we will be rebuilding anyway.
For kit builds, Buildsys will need to understand the cargo dependency graph. This requires a call to cargo metadata which, for efficiency sake, we do only once before calling cargo build. This commit updates Makefile.toml to provide that information to Buildsys. Additionally, we want to have one workspace at the top-level of the Twoliter project which includes all packages, kits and variants. This commit also includes changes to the Makefile.toml to support a single workspace.
|
Fix a nit by moving a cargo clean in the Makefile to the clean-packages section. |
Issue number:
Closes #185
Description of changes:
For kit builds we are going to need to understand the dependency graph in
buildsys build-kit. We may need it for other operations as well.This PR changes buildsys so that it requires a cargo-metadata json file which is uses to understand the dependency graph and send the list of package dependencies and kit dependencies to the Dockerfile in build args.
This implementation requires that Twoliter projects be organized as in a single workspace with all packages, kits and variants in the same Cargo.toml (which feels like an improvement overall).
Testing done:
local-kitTerms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.