fix: fix uab export, cross arch build and update templates#1551
Conversation
Signed-off-by: reddevillg <reddevillg@gmail.com>
Summary of ChangesHello @reddevillg, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the build system's capability to handle cross-architecture UAB exports and improving the reliability of dependency resolution for different target platforms. It streamlines the process of fetching necessary build utilities and updates the default template configurations to newer versions, ensuring a more robust and up-to-date build environment. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces several fixes and improvements. It addresses issues with UAB export and cross-architecture builds by refactoring the logic for handling package references and dependencies. Specifically, it ensures that dependencies for build-utils are pulled correctly during cross-compilation and improves error handling and logging. The logic for determining the current package reference in exportUAB has been moved up and enhanced with better validation. Additionally, the default versions for base and runtime in the example template have been updated.
My review includes a suggestion to simplify a condition in linglong_builder.cpp by removing a redundant check, which will improve code clarity.
| if (underProject && this->project->package.kind != "app") { | ||
| return LINGLONG_ERR( | ||
| fmt::format("can't export {} kind UAB in executable mode, if you want to export UAB " | ||
| "in distributed mode, please use --ref option instead", | ||
| this->project->package.kind)); | ||
| } |
There was a problem hiding this comment.
The underProject check is redundant here. The preceding check if (!underProject) on line 1402 ensures that underProject is true at this point, and therefore this->project has a value. You can simplify the condition to improve readability.
if (this->project->package.kind != "app") {
return LINGLONG_ERR(
fmt::format("can't export {} kind UAB in executable mode, if you want to export UAB "
"in distributed mode, please use --ref option instead",
this->project->package.kind));
}
deepin pr auto review这份代码diff主要包含两个文件的修改: 1. 代码逻辑与架构审查
|
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes UAB export functionality for cross-architecture builds and updates template base/runtime versions from 23.1.0 to 25.2.1.
Changes:
- Removes architecture restriction in
ensureUtilsto enable cross-architecture dependency pulling for build utilities - Refactors
exportUABto compute package reference earlier and add validation for non-app package kinds in executable mode - Updates example template to use newer base and runtime versions (25.2.1)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| misc/share/linglong/builder/templates/example.yaml | Updates base and runtime version references from 23.1.0 to 25.2.1 |
| libs/linglong/src/linglong/builder/linglong_builder.cpp | Removes architecture check in ensureUtils and refactors exportUAB to support cross-architecture builds with earlier reference resolution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return LINGLONG_ERR("not under project"); | ||
| } | ||
|
|
||
| if (underProject && this->project->package.kind != "app") { |
There was a problem hiding this comment.
The condition underProject && this->project->package.kind != "app" is redundant. At line 1402-1404, there's already a check that returns an error if !underProject. Therefore, at line 1406, underProject is guaranteed to be true and can be removed from the condition.
| if (underProject && this->project->package.kind != "app") { | |
| if (this->project->package.kind != "app") { |
| // assumes these dependencies are available for the current architecture, | ||
| // this requires the same version of `build-utils` to be built for both | ||
| // the target and the current architectures. | ||
| auto baseRef = clearDependency(info.base, false, true); | ||
| if (!baseRef) { | ||
| return LINGLONG_ERR("base not exist: " + QString::fromStdString(info.base)); | ||
| } | ||
| if (!pullDependency(*baseRef, this->repo, "binary")) { | ||
| return LINGLONG_ERR("failed to pull base binary " + QString::fromStdString(info.base)); | ||
| } |
There was a problem hiding this comment.
The removal of the architecture check that previously prevented pulling dependencies for non-matching architectures is a significant behavior change. This allows cross-architecture builds, but the new behavior assumes that the same version of build-utils is available for both target and current architectures (as noted in the comment). This change lacks test coverage to verify that the dependency pulling works correctly for cross-architecture scenarios.
| const bool underProject = this->project.has_value(); | ||
| auto curRef = [this, | ||
| &exportOpts, | ||
| underProject, | ||
| distributedOnly]() -> utils::error::Result<package::Reference> { | ||
| LINGLONG_TRACE("get current reference"); | ||
|
|
||
| if (distributedOnly) { | ||
| auto fuzzyRef = package::FuzzyReference::parse(exportOpts.ref); | ||
| if (!fuzzyRef) { | ||
| return LINGLONG_ERR("fuzzy ref", fuzzyRef); | ||
| } | ||
|
|
||
| auto targetRef = this->repo.clearReference(*fuzzyRef, { .fallbackToRemote = false }); | ||
| if (!targetRef) { | ||
| return LINGLONG_ERR("clear ref", targetRef); | ||
| } | ||
|
|
||
| return targetRef; | ||
| } | ||
|
|
||
| if (!underProject) { | ||
| return LINGLONG_ERR("not under project"); | ||
| } | ||
|
|
||
| if (underProject && this->project->package.kind != "app") { | ||
| return LINGLONG_ERR( | ||
| fmt::format("can't export {} kind UAB in executable mode, if you want to export UAB " | ||
| "in distributed mode, please use --ref option instead", | ||
| this->project->package.kind)); | ||
| } | ||
|
|
||
| return currentReference(*this->project); | ||
| }(); |
There was a problem hiding this comment.
The refactoring that moves the curRef calculation earlier and adds the package kind validation is a significant change to the UAB export flow. This new logic (lines 1381-1414) and its interaction with the architecture checks (line 1420) and utility retrieval (line 1429) lacks test coverage to verify all the edge cases, particularly for non-app package kinds and distributed vs. executable export modes.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengbo11, reddevillg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
No description provided.