Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustpkg: Make checked-out source files read-only, and overhaul where temporary files are stored #9732

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion doc/rustpkg.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ and builds it in any workspace(s) where it finds one.
Supposing such packages are found in workspaces X, Y, and Z,
the command leaves behind files in `X`'s, `Y`'s, and `Z`'s `build` directories,
but not in their `lib` or `bin` directories.
(The exception is when rustpkg fetches a package `foo`'s sources from a remote repository.
In that case, it stores both the sources *and* the build artifacts for `foo`
in the workspace that `foo` will install to (see ##install below)).

## clean

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

## test

Expand Down
28 changes: 17 additions & 11 deletions src/librustpkg/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use target::*;
use version::Version;
use workcache_support::*;

pub use source_control::{safe_git_clone, git_clone_url};

use std::os;
use extra::arc::{Arc,RWArc};
use extra::workcache;
Expand Down Expand Up @@ -68,23 +70,27 @@ pub fn build_lib(sysroot: Path, root: Path, name: ~str, version: Version,
lib: Path) {
let cx = default_context(sysroot);
let pkg_src = PkgSrc {
workspace: root.clone(),
start_dir: root.push("src").push(name),
id: PkgId{ version: version, ..PkgId::new(name)},
// n.b. This assumes the package only has one crate
libs: ~[mk_crate(lib)],
mains: ~[],
tests: ~[],
benchs: ~[]
};
source_workspace: root.clone(),
build_in_destination: false,
destination_workspace: root.clone(),
start_dir: root.push("src").push(name),
id: PkgId{ version: version, ..PkgId::new(name)},
// n.b. This assumes the package only has one crate
libs: ~[mk_crate(lib)],
mains: ~[],
tests: ~[],
benchs: ~[]
};
pkg_src.build(&cx, ~[]);
}

pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
main: Path) {
let cx = default_context(sysroot);
let pkg_src = PkgSrc {
workspace: root.clone(),
source_workspace: root.clone(),
build_in_destination: false,
destination_workspace: root.clone(),
start_dir: root.push("src").push(name),
id: PkgId{ version: version, ..PkgId::new(name)},
libs: ~[],
Expand All @@ -100,7 +106,7 @@ pub fn build_exe(sysroot: Path, root: Path, name: ~str, version: Version,
pub fn install_pkg(sysroot: Path, workspace: Path, name: ~str, version: Version) {
let cx = default_context(sysroot);
let pkgid = PkgId{ version: version, ..PkgId::new(name)};
cx.install(PkgSrc::new(workspace, false, pkgid), &Everything);
cx.install(PkgSrc::new(workspace.clone(), workspace, false, pkgid), &Everything);
}

fn mk_crate(p: Path) -> Crate {
Expand Down
4 changes: 4 additions & 0 deletions src/librustpkg/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ condition! {
condition! {
pub failed_to_create_temp_dir: (~str) -> Path;
}

condition! {
pub git_checkout_failed: (~str, Path) -> ();
}
12 changes: 8 additions & 4 deletions src/librustpkg/package_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ impl PkgId {
}

pub fn prefixes_iter(&self) -> Prefixes {
Prefixes {
components: self.path.components().to_owned(),
remaining: ~[]
}
prefixes_iter(&self.path)
}

// This is the workcache function name for the *installed*
Expand All @@ -116,6 +113,13 @@ impl PkgId {
}
}

pub fn prefixes_iter(p: &Path) -> Prefixes {
Prefixes {
components: p.components().to_owned(),
remaining: ~[]
}
}

struct Prefixes {
priv components: ~[~str],
priv remaining: ~[~str]
Expand Down
Loading