@@ -46,6 +46,7 @@ use context::Ctx;
46
46
use package_id:: PkgId ;
47
47
use package_source:: PkgSrc ;
48
48
49
+ pub mod api;
49
50
mod conditions;
50
51
mod context;
51
52
mod crate;
@@ -104,8 +105,10 @@ impl<'self> PkgScript<'self> {
104
105
let binary = os:: args ( ) [ 0 ] . to_managed ( ) ;
105
106
// Build the rustc session data structures to pass
106
107
// to the compiler
108
+ debug ! ( "pkgscript parse: %?" , os:: self_exe_path( ) ) ;
107
109
let options = @session:: options {
108
110
binary : binary,
111
+ maybe_sysroot : Some ( @os:: self_exe_path ( ) . get ( ) . pop ( ) ) ,
109
112
crate_type : session:: bin_crate,
110
113
.. copy * session:: basic_options ( )
111
114
} ;
@@ -132,8 +135,7 @@ impl<'self> PkgScript<'self> {
132
135
/// Returns a pair of an exit code and list of configs (obtained by
133
136
/// calling the package script's configs() function if it exists
134
137
// FIXME (#4432): Use workcache to only compile the script when changed
135
- fn run_custom ( & self , what : ~str ) -> ( ~[ ~str ] , ExitCode ) {
136
- debug ! ( "run_custom: %s" , what) ;
138
+ fn run_custom ( & self , sysroot : @Path ) -> ( ~[ ~str ] , ExitCode ) {
137
139
let sess = self . sess ;
138
140
139
141
debug ! ( "Working directory = %s" , self . build_dir. to_str( ) ) ;
@@ -152,9 +154,12 @@ impl<'self> PkgScript<'self> {
152
154
sess,
153
155
crate ,
154
156
driver:: build_configuration ( sess,
155
- binary, & self . input ) ) ;
156
- debug ! ( "Running program: %s %s %s" , exe. to_str( ) , root. to_str( ) , what) ;
157
- let status = run:: process_status ( exe. to_str ( ) , [ root. to_str ( ) , what] ) ;
157
+ binary, & self . input ) ,
158
+ driver:: cu_parse) ;
159
+ debug ! ( "Running program: %s %s %s %s" , exe. to_str( ) ,
160
+ sysroot. to_str( ) , root. to_str( ) , "install" ) ;
161
+ // FIXME #7401 should support commands besides `install`
162
+ let status = run:: process_status ( exe. to_str ( ) , [ sysroot. to_str ( ) , ~"install"] ) ;
158
163
if status != 0 {
159
164
return ( ~[ ] , status) ;
160
165
}
@@ -291,10 +296,8 @@ impl Ctx {
291
296
let pscript = PkgScript :: parse ( package_script_path,
292
297
workspace,
293
298
pkgid) ;
294
- // Limited right now -- we're only running the post_build
295
- // hook and probably fail otherwise
296
- // also post_build should be called pre_build
297
- let ( cfgs, hook_result) = pscript. run_custom ( ~"post_build") ;
299
+ let sysroot = self . sysroot_opt . expect ( "custom build needs a sysroot" ) ;
300
+ let ( cfgs, hook_result) = pscript. run_custom ( sysroot) ;
298
301
debug ! ( "Command return code = %?" , hook_result) ;
299
302
if hook_result != 0 {
300
303
fail ! ( "Error running custom build command" )
@@ -341,13 +344,17 @@ impl Ctx {
341
344
}
342
345
343
346
fn install ( & self , workspace : & Path , id : & PkgId ) {
344
- use conditions:: copy_failed:: cond;
345
-
346
- // Should use RUST_PATH in the future.
347
+ // FIXME #7402: Use RUST_PATH to determine target dir
347
348
// Also should use workcache to not build if not necessary.
348
349
self . build ( workspace, id) ;
349
350
debug ! ( "install: workspace = %s, id = %s" , workspace. to_str( ) ,
350
351
id. to_str( ) ) ;
352
+ self . install_no_build ( workspace, id) ;
353
+
354
+ }
355
+
356
+ fn install_no_build ( & self , workspace : & Path , id : & PkgId ) {
357
+ use conditions:: copy_failed:: cond;
351
358
352
359
// Now copy stuff into the install dirs
353
360
let maybe_executable = built_executable_in_workspace ( id, workspace) ;
0 commit comments