@@ -46,6 +46,7 @@ use context::Ctx;
4646use package_id:: PkgId ;
4747use package_source:: PkgSrc ;
4848
49+ pub mod api;
4950mod conditions;
5051mod context;
5152mod crate;
@@ -104,8 +105,10 @@ impl<'self> PkgScript<'self> {
104105 let binary = os:: args ( ) [ 0 ] . to_managed ( ) ;
105106 // Build the rustc session data structures to pass
106107 // to the compiler
108+ debug ! ( "pkgscript parse: %?" , os:: self_exe_path( ) ) ;
107109 let options = @session:: options {
108110 binary : binary,
111+ maybe_sysroot : Some ( @os:: self_exe_path ( ) . get ( ) . pop ( ) ) ,
109112 crate_type : session:: bin_crate,
110113 .. copy * session:: basic_options ( )
111114 } ;
@@ -132,8 +135,7 @@ impl<'self> PkgScript<'self> {
132135 /// Returns a pair of an exit code and list of configs (obtained by
133136 /// calling the package script's configs() function if it exists
134137 // 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 ) {
137139 let sess = self . sess ;
138140
139141 debug ! ( "Working directory = %s" , self . build_dir. to_str( ) ) ;
@@ -152,9 +154,12 @@ impl<'self> PkgScript<'self> {
152154 sess,
153155 crate ,
154156 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"] ) ;
158163 if status != 0 {
159164 return ( ~[ ] , status) ;
160165 }
@@ -291,10 +296,8 @@ impl Ctx {
291296 let pscript = PkgScript :: parse ( package_script_path,
292297 workspace,
293298 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) ;
298301 debug ! ( "Command return code = %?" , hook_result) ;
299302 if hook_result != 0 {
300303 fail ! ( "Error running custom build command" )
@@ -341,13 +344,17 @@ impl Ctx {
341344 }
342345
343346 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
347348 // Also should use workcache to not build if not necessary.
348349 self . build ( workspace, id) ;
349350 debug ! ( "install: workspace = %s, id = %s" , workspace. to_str( ) ,
350351 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;
351358
352359 // Now copy stuff into the install dirs
353360 let maybe_executable = built_executable_in_workspace ( id, workspace) ;
0 commit comments