Skip to content

Commit e4e11e9

Browse files
feat(build): consume package.xml manifest for ROS (#4820)
Co-authored-by: nichmor <[email protected]>
1 parent 65336fc commit e4e11e9

File tree

13 files changed

+225
-58
lines changed

13 files changed

+225
-58
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,8 @@ jobs:
916916
steps:
917917
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
918918
with:
919-
repository: prefix-dev/pixi-build-testsuite
919+
repository: nichmor/pixi-build-testsuite
920+
ref: feat/change-manifest-path-to-path-in-pixi-build
920921

921922
- name: Set up pixi
922923
uses: prefix-dev/setup-pixi@main
@@ -947,7 +948,8 @@ jobs:
947948
steps:
948949
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
949950
with:
950-
repository: prefix-dev/pixi-build-testsuite
951+
repository: nichmor/pixi-build-testsuite
952+
ref: feat/change-manifest-path-to-path-in-pixi-build
951953

952954
- name: Create Dev Drive
953955
run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1
@@ -985,7 +987,8 @@ jobs:
985987
steps:
986988
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
987989
with:
988-
repository: prefix-dev/pixi-build-testsuite
990+
repository: nichmor/pixi-build-testsuite
991+
ref: feat/change-manifest-path-to-path-in-pixi-build
989992

990993
- name: Set up pixi
991994
uses: prefix-dev/setup-pixi@main

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pixi/tests/integration_rust/common/builders.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,44 @@ pub struct BuildBuilder {
619619
pub args: build::Args,
620620
}
621621

622+
impl BuildBuilder {
623+
/// Set the target platform for the build
624+
pub fn with_target_platform(mut self, platform: Platform) -> Self {
625+
self.args.target_platform = platform;
626+
self
627+
}
628+
629+
/// Set the build platform for the build
630+
pub fn with_build_platform(mut self, platform: Platform) -> Self {
631+
self.args.build_platform = platform;
632+
self
633+
}
634+
635+
/// Set the output directory for built artifacts
636+
pub fn with_output_dir(mut self, output_dir: impl Into<PathBuf>) -> Self {
637+
self.args.output_dir = output_dir.into();
638+
self
639+
}
640+
641+
/// Set the build directory for incremental builds
642+
pub fn with_build_dir(mut self, build_dir: impl Into<PathBuf>) -> Self {
643+
self.args.build_dir = Some(build_dir.into());
644+
self
645+
}
646+
647+
/// Set whether to clean the build directory before building
648+
pub fn with_clean(mut self, clean: bool) -> Self {
649+
self.args.clean = clean;
650+
self
651+
}
652+
653+
/// Set the path to the package manifest or directory
654+
pub fn with_path(mut self, path: impl Into<PathBuf>) -> Self {
655+
self.args.path = Some(path.into());
656+
self
657+
}
658+
}
659+
622660
impl IntoFuture for BuildBuilder {
623661
type Output = miette::Result<()>;
624662
type IntoFuture = Pin<Box<dyn Future<Output = Self::Output> + 'static>>;

crates/pixi/tests/integration_rust/common/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
str::FromStr,
1414
};
1515

16-
use builders::{BuildBuilder, LockBuilder, SearchBuilder};
16+
use builders::{LockBuilder, SearchBuilder};
1717
use indicatif::ProgressDrawTarget;
1818
use miette::{Context, Diagnostic, IntoDiagnostic};
1919
use pixi_cli::LockFileUsageConfig;
@@ -46,8 +46,9 @@ use thiserror::Error;
4646

4747
use self::builders::{HasDependencyConfig, RemoveBuilder};
4848
use crate::common::builders::{
49-
AddBuilder, InitBuilder, InstallBuilder, ProjectChannelAddBuilder, ProjectChannelRemoveBuilder,
50-
ProjectEnvironmentAddBuilder, TaskAddBuilder, TaskAliasBuilder, UpdateBuilder,
49+
AddBuilder, BuildBuilder, InitBuilder, InstallBuilder, ProjectChannelAddBuilder,
50+
ProjectChannelRemoveBuilder, ProjectEnvironmentAddBuilder, TaskAddBuilder, TaskAliasBuilder,
51+
UpdateBuilder,
5152
};
5253

5354
const DEFAULT_PROJECT_CONFIG: &str = r#"
@@ -682,17 +683,15 @@ impl PixiControl {
682683
pub fn build(&self) -> BuildBuilder {
683684
BuildBuilder {
684685
args: build::Args {
685-
project_config: WorkspaceConfig {
686-
manifest_path: Some(self.manifest_path()),
687-
..Default::default()
688-
},
686+
backend_override: Default::default(),
689687
config_cli: Default::default(),
690688
lock_and_install_config: Default::default(),
691689
target_platform: rattler_conda_types::Platform::current(),
692690
build_platform: rattler_conda_types::Platform::current(),
693691
output_dir: PathBuf::from("."),
694692
build_dir: None,
695693
clean: false,
694+
path: Some(self.manifest_path()),
696695
},
697696
}
698697
}

crates/pixi_build_discovery/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ rattler_conda_types = { workspace = true }
2323
pixi_build_type_conversions = { workspace = true }
2424
pixi_build_types = { workspace = true }
2525
pixi_config = { workspace = true }
26+
pixi_consts = { workspace = true }
2627
pixi_manifest = { workspace = true }
2728
pixi_spec = { workspace = true }
2829
pixi_spec_containers = { workspace = true }

crates/pixi_build_discovery/src/discovery.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use ordermap::OrderMap;
99
use pixi_build_type_conversions::{to_project_model_v1, to_target_selector_v1};
1010
use pixi_build_types::{ProjectModelV1, TargetSelectorV1};
1111
use pixi_config::Config;
12+
use pixi_consts::consts::{RATTLER_BUILD_DIRS, RATTLER_BUILD_FILE_NAMES, ROS_BACKEND_FILE_NAMES};
1213
use pixi_manifest::{
1314
DiscoveryStart, ExplicitManifestError, PackageManifest, PrioritizedChannel, WithProvenance,
1415
WorkspaceDiscoverer, WorkspaceDiscoveryError, WorkspaceManifest,
@@ -23,10 +24,6 @@ use crate::{
2324
backend_spec::{CommandSpec, EnvironmentSpec, JsonRpcBackendSpec},
2425
};
2526

26-
const RATTLER_BUILD_FILE_NAMES: [&str; 2] = ["recipe.yaml", "recipe.yml"];
27-
const RATTLER_BUILD_DIRS: [&str; 2] = ["", "recipe"];
28-
const ROS_BACKEND_FILE_NAMES: [&str; 1] = ["package.xml"];
29-
3027
/// Describes a backend discovered for a given source location.
3128
#[derive(Debug, Clone)]
3229
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
@@ -118,9 +115,12 @@ pub enum DiscoveryError {
118115

119116
#[error("the source directory '{0}', does not contain a supported manifest")]
120117
#[diagnostic(help(
121-
"Ensure that the source directory contains a valid pixi.toml or recipe.yaml file."
118+
"Ensure that the source directory contains a valid pixi.toml, pyproject.toml, recipe.yaml, package.xml or mojoproject.toml file."
122119
))]
123120
FailedToDiscover(String),
121+
122+
#[error("the manifest path '{0}', does not have a parent directory")]
123+
NoParentDir(PathBuf),
124124
}
125125

126126
impl DiscoveredBackend {
@@ -327,14 +327,9 @@ impl DiscoveredBackend {
327327
));
328328
};
329329

330-
Self::from_package_and_workspace(
331-
// source_path,
332-
&package_manifest,
333-
&manifests.workspace,
334-
channel_config,
335-
)
336-
.map_err(DiscoveryError::SpecConversionError)
337-
.map(Some)
330+
Self::from_package_and_workspace(&package_manifest, &manifests.workspace, channel_config)
331+
.map_err(DiscoveryError::SpecConversionError)
332+
.map(Some)
338333
}
339334

340335
/// Try to discover a rattler build recipe in the repository.
@@ -376,7 +371,12 @@ impl DiscoveredBackend {
376371
workspace_root: source_dir.clone(),
377372
build_source: None,
378373
source_anchor: source_dir,
379-
manifest_path: package_xml_absolute_path,
374+
manifest_path: package_xml_absolute_path
375+
.parent()
376+
.ok_or(DiscoveryError::NoParentDir(
377+
package_xml_absolute_path.clone(),
378+
))?
379+
.to_path_buf(),
380380
project_model: Some(ProjectModelV1::default()),
381381
configuration: None,
382382
target_configuration: None,

crates/pixi_build_discovery/tests/snapshots/discovery__direct_package_xml.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ init-params:
1616
workspace-root: "file://<ROOT>/ros-package"
1717
build-source: ~
1818
source-anchor: "file://<ROOT>/ros-package"
19-
manifest-path: "file://<ROOT>/ros-package/package.xml"
19+
manifest-path: "file://<ROOT>/ros-package"
2020
project-model:
2121
name: ~
2222
version: ~

0 commit comments

Comments
 (0)