Skip to content

Commit 2e1df8e

Browse files
committed
auto merge of #9732 : catamorphism/rust/rustpkg-read-only, r=brson
r? @metajack rustpkg now makes source files that it checks out automatically read-only, and stores them under build/. Also, refactored the `PkgSrc` type to keep track of separate source and destination workspaces, as well as to have a `build_workspace` method that returns the workspace to put temporary files in (usually the source, sometimes the destination -- see comments for more details). Closes #6480
2 parents 6ad1d0f + 8854b78 commit 2e1df8e

11 files changed

+539
-293
lines changed

doc/rustpkg.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ and builds it in any workspace(s) where it finds one.
137137
Supposing such packages are found in workspaces X, Y, and Z,
138138
the command leaves behind files in `X`'s, `Y`'s, and `Z`'s `build` directories,
139139
but not in their `lib` or `bin` directories.
140+
(The exception is when rustpkg fetches a package `foo`'s sources from a remote repository.
141+
In that case, it stores both the sources *and* the build artifacts for `foo`
142+
in the workspace that `foo` will install to (see ##install below)).
140143

141144
## clean
142145

@@ -148,7 +151,11 @@ but not in their `lib` or `bin` directories.
148151
If `RUST_PATH` is declared as an environment variable, then rustpkg installs the
149152
libraries and executables into the `lib` and `bin` subdirectories
150153
of the first entry in `RUST_PATH`.
151-
Otherwise, it installs them into `foo`'s `lib` and `bin` directories.
154+
Otherwise, if the current working directory CWD is a workspace,
155+
it installs them into CWD's `lib` and `bin` subdirectories.
156+
Otherwise, if the current working directory is CWD,
157+
it installs them into the .rust/lib and .rust/bin subdirectories of CWD
158+
(creating them if necessary).
152159

153160
## test
154161

src/librustpkg/api.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use target::*;
1616
use version::Version;
1717
use workcache_support::*;
1818

19+
pub use source_control::{safe_git_clone, git_clone_url};
20+
1921
use std::os;
2022
use extra::arc::{Arc,RWArc};
2123
use extra::workcache;
@@ -68,23 +70,27 @@ pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
6870
lib: Path) {
6971
let cx = default_context(sysroot);
7072
let pkg_src = PkgSrc {
71-
workspace: root.clone(),
72-
start_dir: root.push("src").push(name),
73-
id: PkgId{ version: version, ..PkgId::new(name)},
74-
// n.b. This assumes the package only has one crate
75-
libs: ~[mk_crate(lib)],
76-
mains: ~[],
77-
tests: ~[],
78-
benchs: ~[]
79-
};
73+
source_workspace: root.clone(),
74+
build_in_destination: false,
75+
destination_workspace: root.clone(),
76+
start_dir: root.push("src").push(name),
77+
id: PkgId{ version: version, ..PkgId::new(name)},
78+
// n.b. This assumes the package only has one crate
79+
libs: ~[mk_crate(lib)],
80+
mains: ~[],
81+
tests: ~[],
82+
benchs: ~[]
83+
};
8084
pkg_src.build(&cx, ~[]);
8185
}
8286

8387
pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
8488
main: Path) {
8589
let cx = default_context(sysroot);
8690
let pkg_src = PkgSrc {
87-
workspace: root.clone(),
91+
source_workspace: root.clone(),
92+
build_in_destination: false,
93+
destination_workspace: root.clone(),
8894
start_dir: root.push("src").push(name),
8995
id: PkgId{ version: version, ..PkgId::new(name)},
9096
libs: ~[],
@@ -100,7 +106,7 @@ pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
100106
pub fn install_pkg(sysroot: Path, workspace: Path, name: ~str, version: Version) {
101107
let cx = default_context(sysroot);
102108
let pkgid = PkgId{ version: version, ..PkgId::new(name)};
103-
cx.install(PkgSrc::new(workspace, false, pkgid), &Everything);
109+
cx.install(PkgSrc::new(workspace.clone(), workspace, false, pkgid), &Everything);
104110
}
105111

106112
fn mk_crate(p: Path) -> Crate {

src/librustpkg/conditions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,7 @@ condition! {
5050
condition! {
5151
pub failed_to_create_temp_dir: (~str) -> Path;
5252
}
53+
54+
condition! {
55+
pub git_checkout_failed: (~str, Path) -> ();
56+
}

src/librustpkg/package_id.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,7 @@ impl PkgId {
102102
}
103103

104104
pub fn prefixes_iter(&self) -> Prefixes {
105-
Prefixes {
106-
components: self.path.components().to_owned(),
107-
remaining: ~[]
108-
}
105+
prefixes_iter(&self.path)
109106
}
110107

111108
// This is the workcache function name for the *installed*
@@ -116,6 +113,13 @@ impl PkgId {
116113
}
117114
}
118115

116+
pub fn prefixes_iter(p: &Path) -> Prefixes {
117+
Prefixes {
118+
components: p.components().to_owned(),
119+
remaining: ~[]
120+
}
121+
}
122+
119123
struct Prefixes {
120124
priv components: ~[~str],
121125
priv remaining: ~[~str]

0 commit comments

Comments
 (0)