@@ -19,6 +19,8 @@ pub struct Args {
1919 pub forwarded_args : Vec < OsString > ,
2020 /// "debug", "release" etc.
2121 pub profile : String ,
22+ /// The target architecture. None for native builds.
23+ pub arch : Option < String > ,
2224 /// The absolute path to the Cargo.toml file. Currently the --manifest-path option is not implemented.
2325 pub manifest_path : PathBuf ,
2426}
@@ -60,6 +62,10 @@ impl ArgsOrHelp {
6062 String :: from ( "debug" )
6163 } ;
6264
65+ let arch = args
66+ . opt_value_from_str ( "--target" ) ?
67+ . or_else ( || std:: env:: var ( "CARGO_BUILD_TARGET" ) . ok ( ) ) ;
68+
6369 let build_base = args
6470 . opt_value_from_str ( "--target-dir" ) ?
6571 . unwrap_or_else ( || "target" . into ( ) ) ;
@@ -78,6 +84,7 @@ impl ArgsOrHelp {
7884 build_base,
7985 forwarded_args,
8086 profile,
87+ arch,
8188 manifest_path,
8289 } ;
8390
@@ -222,9 +229,15 @@ pub fn install_binaries(
222229 build_base : impl AsRef < Path > ,
223230 package_name : & str ,
224231 profile : & str ,
232+ arch : Option < & str > ,
225233 binaries : & [ Product ] ,
226234) -> Result < ( ) > {
227- let src_dir = build_base. as_ref ( ) . join ( profile) ;
235+ let src_dir = if let Some ( arch) = arch {
236+ build_base. as_ref ( ) . join ( arch) . join ( profile)
237+ } else {
238+ build_base. as_ref ( ) . join ( profile)
239+ } ;
240+
228241 let dest_dir = install_base. as_ref ( ) . join ( "lib" ) . join ( package_name) ;
229242 if dest_dir. is_dir ( ) {
230243 std:: fs:: remove_dir_all ( & dest_dir) ?;
0 commit comments