@@ -4,7 +4,7 @@ use miette::Diagnostic;
4
4
use pixi_manifest:: Manifest ;
5
5
6
6
// pub use protocol::Protocol;
7
- use rattler_conda_types:: ChannelConfig ;
7
+ use rattler_conda_types:: { ChannelConfig , MatchSpec } ;
8
8
use thiserror:: Error ;
9
9
10
10
use super :: pixi:: { self , ProtocolBuildError as PixiProtocolBuildError } ;
@@ -19,9 +19,11 @@ use crate::{
19
19
pub enum FinishError {
20
20
#[ error( transparent) ]
21
21
Tool ( #[ from] ToolCacheError ) ,
22
+
22
23
#[ error( transparent) ]
23
24
#[ diagnostic( transparent) ]
24
25
Init ( #[ from] InitializeError ) ,
26
+
25
27
#[ error( "failed to setup a build backend, the project manifest at {0} does not contain a [build] section" ) ]
26
28
NoBuildSection ( PathBuf ) ,
27
29
}
@@ -45,7 +47,7 @@ pub struct ProtocolBuilder {
45
47
recipe_dir : PathBuf ,
46
48
47
49
/// The path to the manifest file.
48
- manifest_path : PathBuf ,
50
+ manifest_path : Option < PathBuf > ,
49
51
50
52
/// The backend tool to install.
51
53
backend_spec : Option < ToolSpec > ,
@@ -63,25 +65,27 @@ impl ProtocolBuilder {
63
65
// first we need to discover that pixi protocol also can be built.
64
66
// it is used to get the manifest
65
67
66
- // Ignore the error if we cannot find the pixi protocol.
67
- let pixi_protocol = match pixi:: ProtocolBuilder :: discover ( source_dir) {
68
- Ok ( inner_value) => inner_value,
69
- Err ( _) => return Ok ( None ) , // Handle the case where the Option is None
70
- } ;
68
+ // // Ignore the error if we cannot find the pixi protocol.
69
+ // let pixi_protocol = match pixi::ProtocolBuilder::discover(source_dir) {
70
+ // Ok(inner_value) => inner_value,
71
+ // Err(_) => return Ok(None), // Handle the case where the Option is None
72
+ // };
71
73
72
- // we cannot find pixi protocol, so we cannot build rattler-build protocol.
73
- let manifest = if let Some ( pixi_protocol) = pixi_protocol {
74
- pixi_protocol. manifest ( ) . clone ( )
75
- } else {
76
- return Ok ( None ) ;
77
- } ;
74
+ // // we cannot find pixi protocol, so we cannot build rattler-build protocol.
75
+ // let manifest = if let Some(pixi_protocol) = pixi_protocol {
76
+ // pixi_protocol.manifest().clone()
77
+ // } else {
78
+ // return Ok(None);
79
+ // };
80
+
81
+ let manifest = None ;
78
82
79
83
let recipe_dir = source_dir. join ( "recipe" ) ;
80
84
81
85
let protocol = if source_dir. join ( "recipe.yaml" ) . is_file ( ) {
82
- Self :: new ( source_dir, source_dir, & manifest)
86
+ Self :: new ( source_dir, source_dir, manifest)
83
87
} else if recipe_dir. join ( "recipe.yaml" ) . is_file ( ) {
84
- Self :: new ( source_dir, & recipe_dir, & manifest)
88
+ Self :: new ( source_dir, & recipe_dir, manifest)
85
89
} else {
86
90
return Ok ( None ) ;
87
91
} ;
@@ -90,15 +94,19 @@ impl ProtocolBuilder {
90
94
}
91
95
92
96
/// Constructs a new instance from a manifest.
93
- pub fn new ( source_dir : & Path , recipe_dir : & Path , manifest : & Manifest ) -> Self {
94
- let backend_spec = manifest
95
- . build_section ( )
96
- . map ( IsolatedToolSpec :: from_build_section) ;
97
+ pub fn new ( source_dir : & Path , recipe_dir : & Path , manifest : Option < Manifest > ) -> Self {
98
+ let backend_spec = if let Some ( manifest) = & manifest {
99
+ manifest
100
+ . build_section ( )
101
+ . map ( IsolatedToolSpec :: from_build_section)
102
+ } else {
103
+ None
104
+ } ;
97
105
98
106
Self {
99
107
source_dir : source_dir. to_path_buf ( ) ,
100
108
recipe_dir : recipe_dir. to_path_buf ( ) ,
101
- manifest_path : manifest. path . clone ( ) ,
109
+ manifest_path : manifest. map ( |m| m . path . clone ( ) ) ,
102
110
backend_spec : backend_spec. map ( Into :: into) ,
103
111
_channel_config : ChannelConfig :: default_with_root_dir ( PathBuf :: new ( ) ) ,
104
112
cache_dir : None ,
@@ -134,15 +142,27 @@ impl ProtocolBuilder {
134
142
tool : & ToolCache ,
135
143
build_id : usize ,
136
144
) -> Result < JsonRPCBuildProtocol , FinishError > {
137
- let tool_spec = self
138
- . backend_spec
139
- . ok_or ( FinishError :: NoBuildSection ( self . manifest_path . clone ( ) ) ) ?;
145
+ let tool_spec = self . backend_spec . unwrap_or_else ( || {
146
+ ToolSpec :: Isolated ( IsolatedToolSpec :: from_specs ( [ "pixi-build-rattler-build"
147
+ . parse ( )
148
+ . unwrap ( ) ] ) . with_command ( "pixi-build-rattler-build" ) )
149
+ } ) ;
140
150
141
151
let tool = tool
142
152
. instantiate ( tool_spec)
143
153
. await
144
154
. map_err ( FinishError :: Tool ) ?;
145
155
156
+ tracing:: warn!( "Tool instantiated .... {:?}" , tool) ;
157
+
158
+ tracing:: warn!( "Cache dir / build id: {:?} / {:?}" , self . cache_dir, build_id) ;
159
+ if let Some ( cache_dir) = self . cache_dir . as_ref ( ) {
160
+ let _ = std:: fs:: create_dir_all ( cache_dir) . map_err ( |e| {
161
+ tracing:: warn!( "Failed to create cache dir: {:?}" , e) ;
162
+ e
163
+ } ) ;
164
+ }
165
+
146
166
Ok ( JsonRPCBuildProtocol :: setup (
147
167
self . source_dir ,
148
168
self . recipe_dir . join ( "recipe.yaml" ) ,
0 commit comments