|
6 | 6 | import rustc::syntax::{ast, codemap};
|
7 | 7 | import rustc::syntax::parse::parser;
|
8 | 8 | import rustc::util::filesearch::{get_cargo_root, get_cargo_root_nearest,
|
9 |
| - get_cargo_sysroot}; |
| 9 | + get_cargo_sysroot, libdir}; |
10 | 10 | import rustc::driver::diagnostic;
|
11 | 11 |
|
12 | 12 | import std::fs;
|
@@ -467,10 +467,31 @@ fn install_one_crate(c: cargo, _path: str, cf: str, _p: pkg) {
|
467 | 467 | #debug(" bin: %s", ct);
|
468 | 468 | // FIXME: need libstd fs::copy or something
|
469 | 469 | run::run_program("cp", [ct, c.bindir]);
|
| 470 | + if c.opts.mode == system_mode { |
| 471 | + install_one_crate_to_sysroot(ct, "bin"); |
| 472 | + } |
470 | 473 | } else {
|
471 | 474 | #debug(" lib: %s", ct);
|
472 | 475 | run::run_program("cp", [ct, c.libdir]);
|
| 476 | + if c.opts.mode == system_mode { |
| 477 | + install_one_crate_to_sysroot(ct, libdir()); |
| 478 | + } |
| 479 | + } |
| 480 | + } |
| 481 | +} |
| 482 | + |
| 483 | +fn install_one_crate_to_sysroot(ct: str, target: str) { |
| 484 | + alt os::get_exe_path() { |
| 485 | + some(_path) { |
| 486 | + let path = [_path, "..", target]; |
| 487 | + check vec::is_not_empty(path); |
| 488 | + let target_dir = fs::normalize(fs::connect_many(path)); |
| 489 | + let p = run::program_output("cp", [ct, target_dir]); |
| 490 | + if p.status != 0 { |
| 491 | + warn(#fmt["Copying %s to %s is failed", ct, target_dir]); |
| 492 | + } |
473 | 493 | }
|
| 494 | + none { } |
474 | 495 | }
|
475 | 496 | }
|
476 | 497 |
|
@@ -827,23 +848,25 @@ fn cmd_usage() {
|
827 | 848 | "
|
828 | 849 |
|
829 | 850 | init Set up .cargo
|
830 |
| - install [--test] [source/]package-name Install by name |
831 |
| - install [--test] uuid:[source/]package-uuid Install by uuid |
| 851 | + install [options] [source/]package-name Install by name |
| 852 | + install [options] uuid:[source/]package-uuid Install by uuid |
832 | 853 | list [source] List packages
|
833 | 854 | search <name | '*'> [tags...] Search packages
|
834 | 855 | sync Sync all sources
|
835 | 856 | usage This
|
836 | 857 |
|
837 | 858 | Options:
|
838 | 859 |
|
| 860 | + cargo install |
| 861 | +
|
839 | 862 | --mode=[system,user,local] change mode as (system/user/local)
|
840 | 863 | -g equivalent to --mode=user
|
841 | 864 | -G equivalent to --mode=system
|
842 | 865 |
|
843 | 866 | NOTE:
|
844 |
| -This command creates/uses local-level .cargo by default. |
845 |
| -To create/use user-level .cargo, use option -g/--mode=user. |
846 |
| -To create/use system-level .cargo, use option -G/--mode=system. |
| 867 | +\"cargo install\" installs bin/libs to local-level .cargo by default. |
| 868 | +To install them into user-level .cargo, use option -g/--mode=user. |
| 869 | +To install them into bin/lib on sysroot, use option -G/--mode=system. |
847 | 870 | ");
|
848 | 871 | }
|
849 | 872 |
|
|
0 commit comments