commit
f37b746699
31 changed files with 432 additions and 430 deletions
12
doc/rust.md
12
doc/rust.md
|
@ -610,7 +610,7 @@ the behavior of the compiler.
|
||||||
|
|
||||||
~~~~
|
~~~~
|
||||||
// Package ID
|
// Package ID
|
||||||
#[ pkgid = "projx#2.5" ];
|
#[ crate_id = "projx#2.5" ];
|
||||||
|
|
||||||
// Additional metadata attributes
|
// Additional metadata attributes
|
||||||
#[ desc = "Project X" ];
|
#[ desc = "Project X" ];
|
||||||
|
@ -776,9 +776,9 @@ as the `ident` provided in the `extern_mod_decl`.
|
||||||
The external crate is resolved to a specific `soname` at compile time, and a
|
The external crate is resolved to a specific `soname` at compile time, and a
|
||||||
runtime linkage requirement to that `soname` is passed to the linker for
|
runtime linkage requirement to that `soname` is passed to the linker for
|
||||||
loading at runtime. The `soname` is resolved at compile time by scanning the
|
loading at runtime. The `soname` is resolved at compile time by scanning the
|
||||||
compiler's library path and matching the optional `pkgid` provided as a string literal
|
compiler's library path and matching the optional `crateid` provided as a string literal
|
||||||
against the `pkgid` attributes that were declared on the external crate when
|
against the `crateid` attributes that were declared on the external crate when
|
||||||
it was compiled. If no `pkgid` is provided, a default `name` attribute is
|
it was compiled. If no `crateid` is provided, a default `name` attribute is
|
||||||
assumed, equal to the `ident` given in the `extern_mod_decl`.
|
assumed, equal to the `ident` given in the `extern_mod_decl`.
|
||||||
|
|
||||||
Four examples of `extern mod` declarations:
|
Four examples of `extern mod` declarations:
|
||||||
|
@ -1729,7 +1729,7 @@ names are effectively reserved. Some significant attributes include:
|
||||||
* The `cfg` attribute, for conditional-compilation by build-configuration.
|
* The `cfg` attribute, for conditional-compilation by build-configuration.
|
||||||
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
|
* The `lang` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [Language items](#language-items)).
|
||||||
* The `link` attribute, for describing linkage metadata for a extern blocks.
|
* The `link` attribute, for describing linkage metadata for a extern blocks.
|
||||||
* The `pkgid` attribute, for describing the package ID of a crate.
|
* The `crate_id` attribute, for describing the package ID of a crate.
|
||||||
* The `test` attribute, for marking functions as unit tests.
|
* The `test` attribute, for marking functions as unit tests.
|
||||||
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
|
* The `allow`, `warn`, `forbid`, and `deny` attributes, for
|
||||||
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
|
controlling lint checks (see [Lint check attributes](#lint-check-attributes)).
|
||||||
|
@ -3792,7 +3792,7 @@ specified then log level 4 is assumed. Debug messages can be omitted
|
||||||
by passing `--cfg ndebug` to `rustc`.
|
by passing `--cfg ndebug` to `rustc`.
|
||||||
|
|
||||||
As an example, to see all the logs generated by the compiler, you would set
|
As an example, to see all the logs generated by the compiler, you would set
|
||||||
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `pkgid`
|
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `crate_id`
|
||||||
[attribute](#attributes)). To narrow down the logs to just crate resolution,
|
[attribute](#attributes)). To narrow down the logs to just crate resolution,
|
||||||
you would set it to `rustc::metadata::creader`. To see just error logging
|
you would set it to `rustc::metadata::creader`. To see just error logging
|
||||||
use `rustc=0`.
|
use `rustc=0`.
|
||||||
|
|
|
@ -13,7 +13,7 @@ comments":
|
||||||
~~~
|
~~~
|
||||||
// the "link" crate attribute is currently required for rustdoc, but normally
|
// the "link" crate attribute is currently required for rustdoc, but normally
|
||||||
// isn't needed.
|
// isn't needed.
|
||||||
#[pkgid = "universe"];
|
#[crate_id = "universe"];
|
||||||
#[crate_type="lib"];
|
#[crate_type="lib"];
|
||||||
|
|
||||||
//! Tools for dealing with universes (this is a doc comment, and is shown on
|
//! Tools for dealing with universes (this is a doc comment, and is shown on
|
||||||
|
|
|
@ -90,7 +90,7 @@ then both `bar` and `bar/extras/baz` are valid package identifiers
|
||||||
in the workspace `foo`.
|
in the workspace `foo`.
|
||||||
|
|
||||||
Because rustpkg uses generic source file names as the main inputs, you will
|
Because rustpkg uses generic source file names as the main inputs, you will
|
||||||
need to specify the package identifier in them using the `pkgid` attribute
|
need to specify the package identifier in them using the `crate_id` attribute
|
||||||
on the crate.
|
on the crate.
|
||||||
|
|
||||||
## Source files
|
## Source files
|
||||||
|
|
|
@ -45,7 +45,7 @@ c.write(
|
||||||
"""
|
"""
|
||||||
// AUTO-GENERATED FILE: DO NOT EDIT
|
// AUTO-GENERATED FILE: DO NOT EDIT
|
||||||
#[crate_id=\"run_pass_stage2#0.1\"];
|
#[crate_id=\"run_pass_stage2#0.1\"];
|
||||||
#[pkgid=\"run_pass_stage2#0.1\"];
|
#[crate_id=\"run_pass_stage2#0.1\"];
|
||||||
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
|
#[feature(globs, macro_rules, struct_variant, managed_boxes)];
|
||||||
#[allow(warnings)];
|
#[allow(warnings)];
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -41,7 +41,7 @@ use syntax::ast;
|
||||||
use syntax::ast_map::{path, path_mod, path_name, path_pretty_name};
|
use syntax::ast_map::{path, path_mod, path_name, path_pretty_name};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
use syntax::pkgid::PkgId;
|
use syntax::crateid::CrateId;
|
||||||
|
|
||||||
#[deriving(Clone, Eq)]
|
#[deriving(Clone, Eq)]
|
||||||
pub enum output_type {
|
pub enum output_type {
|
||||||
|
@ -444,13 +444,13 @@ pub mod write {
|
||||||
*
|
*
|
||||||
* So here is what we do:
|
* So here is what we do:
|
||||||
*
|
*
|
||||||
* - Consider the package id; every crate has one (specified with pkgid
|
* - Consider the package id; every crate has one (specified with crate_id
|
||||||
* attribute). If a package id isn't provided explicitly, we infer a
|
* attribute). If a package id isn't provided explicitly, we infer a
|
||||||
* versionless one from the output name. The version will end up being 0.0
|
* versionless one from the output name. The version will end up being 0.0
|
||||||
* in this case. CNAME and CVERS are taken from this package id. For
|
* in this case. CNAME and CVERS are taken from this package id. For
|
||||||
* example, github.com/mozilla/CNAME#CVERS.
|
* example, github.com/mozilla/CNAME#CVERS.
|
||||||
*
|
*
|
||||||
* - Define CMH as SHA256(pkgid).
|
* - Define CMH as SHA256(crateid).
|
||||||
*
|
*
|
||||||
* - Define CMH8 as the first 8 characters of CMH.
|
* - Define CMH8 as the first 8 characters of CMH.
|
||||||
*
|
*
|
||||||
|
@ -469,13 +469,13 @@ pub fn build_link_meta(sess: Session,
|
||||||
symbol_hasher: &mut Sha256)
|
symbol_hasher: &mut Sha256)
|
||||||
-> LinkMeta {
|
-> LinkMeta {
|
||||||
// This calculates CMH as defined above
|
// This calculates CMH as defined above
|
||||||
fn crate_hash(symbol_hasher: &mut Sha256, pkgid: &PkgId) -> @str {
|
fn crate_hash(symbol_hasher: &mut Sha256, crateid: &CrateId) -> @str {
|
||||||
symbol_hasher.reset();
|
symbol_hasher.reset();
|
||||||
symbol_hasher.input_str(pkgid.to_str());
|
symbol_hasher.input_str(crateid.to_str());
|
||||||
truncated_hash_result(symbol_hasher).to_managed()
|
truncated_hash_result(symbol_hasher).to_managed()
|
||||||
}
|
}
|
||||||
|
|
||||||
let pkgid = match attr::find_pkgid(attrs) {
|
let crateid = match attr::find_crateid(attrs) {
|
||||||
None => {
|
None => {
|
||||||
let stem = session::expect(
|
let stem = session::expect(
|
||||||
sess,
|
sess,
|
||||||
|
@ -487,10 +487,10 @@ pub fn build_link_meta(sess: Session,
|
||||||
Some(s) => s,
|
Some(s) => s,
|
||||||
};
|
};
|
||||||
|
|
||||||
let hash = crate_hash(symbol_hasher, &pkgid);
|
let hash = crate_hash(symbol_hasher, &crateid);
|
||||||
|
|
||||||
LinkMeta {
|
LinkMeta {
|
||||||
pkgid: pkgid,
|
crateid: crateid,
|
||||||
crate_hash: hash,
|
crate_hash: hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -509,7 +509,7 @@ pub fn symbol_hash(tcx: ty::ctxt,
|
||||||
// to be independent of one another in the crate.
|
// to be independent of one another in the crate.
|
||||||
|
|
||||||
symbol_hasher.reset();
|
symbol_hasher.reset();
|
||||||
symbol_hasher.input_str(link_meta.pkgid.name);
|
symbol_hasher.input_str(link_meta.crateid.name);
|
||||||
symbol_hasher.input_str("-");
|
symbol_hasher.input_str("-");
|
||||||
symbol_hasher.input_str(link_meta.crate_hash);
|
symbol_hasher.input_str(link_meta.crate_hash);
|
||||||
symbol_hasher.input_str("-");
|
symbol_hasher.input_str("-");
|
||||||
|
@ -669,7 +669,7 @@ pub fn mangle_exported_name(ccx: &CrateContext,
|
||||||
let hash = get_symbol_hash(ccx, t);
|
let hash = get_symbol_hash(ccx, t);
|
||||||
return exported_name(ccx.sess, path,
|
return exported_name(ccx.sess, path,
|
||||||
hash,
|
hash,
|
||||||
ccx.link_meta.pkgid.version_or_default());
|
ccx.link_meta.crateid.version_or_default());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
|
pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
|
||||||
|
@ -710,9 +710,9 @@ pub fn mangle_internal_name_by_path(ccx: &CrateContext, path: path) -> ~str {
|
||||||
|
|
||||||
pub fn output_lib_filename(lm: &LinkMeta) -> ~str {
|
pub fn output_lib_filename(lm: &LinkMeta) -> ~str {
|
||||||
format!("{}-{}-{}",
|
format!("{}-{}-{}",
|
||||||
lm.pkgid.name,
|
lm.crateid.name,
|
||||||
lm.crate_hash.slice_chars(0, 8),
|
lm.crate_hash.slice_chars(0, 8),
|
||||||
lm.pkgid.version_or_default())
|
lm.crateid.version_or_default())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_cc_prog(sess: Session) -> ~str {
|
pub fn get_cc_prog(sess: Session) -> ~str {
|
||||||
|
|
|
@ -1030,12 +1030,12 @@ pub fn build_output_filenames(input: &input,
|
||||||
str_input(_) => @"rust_out"
|
str_input(_) => @"rust_out"
|
||||||
};
|
};
|
||||||
|
|
||||||
// If a pkgid is present, we use it as the link name
|
// If a crateid is present, we use it as the link name
|
||||||
let pkgid = attr::find_pkgid(attrs);
|
let crateid = attr::find_crateid(attrs);
|
||||||
match pkgid {
|
match crateid {
|
||||||
None => {}
|
None => {}
|
||||||
Some(pkgid) => {
|
Some(crateid) => {
|
||||||
stem = pkgid.name.to_managed()
|
stem = crateid.name.to_managed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -384,7 +384,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_extra(crate: &ast::Crate) -> bool {
|
fn is_extra(crate: &ast::Crate) -> bool {
|
||||||
match attr::find_pkgid(crate.attrs) {
|
match attr::find_crateid(crate.attrs) {
|
||||||
Some(ref s) if "extra" == s.name => true,
|
Some(ref s) if "extra" == s.name => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,18 +292,18 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
|
||||||
let t_outputs = d::build_output_filenames(&input, &odir, &ofile,
|
let t_outputs = d::build_output_filenames(&input, &odir, &ofile,
|
||||||
attrs, sess);
|
attrs, sess);
|
||||||
if crate_id || crate_name {
|
if crate_id || crate_name {
|
||||||
let pkgid = match attr::find_pkgid(attrs) {
|
let crateid = match attr::find_crateid(attrs) {
|
||||||
Some(pkgid) => pkgid,
|
Some(crateid) => crateid,
|
||||||
None => {
|
None => {
|
||||||
sess.fatal("No crate_id and --crate-id or \
|
sess.fatal("No crate_id and --crate-id or \
|
||||||
--crate-name requested")
|
--crate-name requested")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if crate_id {
|
if crate_id {
|
||||||
println(pkgid.to_str());
|
println(crateid.to_str());
|
||||||
}
|
}
|
||||||
if crate_name {
|
if crate_name {
|
||||||
println(pkgid.name);
|
println(crateid.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::cast;
|
use std::cast;
|
||||||
use syntax::pkgid::PkgId;
|
use syntax::crateid::CrateId;
|
||||||
|
|
||||||
// EBML enum definitions and utils shared by the encoder and decoder
|
// EBML enum definitions and utils shared by the encoder and decoder
|
||||||
|
|
||||||
|
@ -206,6 +206,6 @@ pub static tag_native_libraries_kind: uint = 0x106;
|
||||||
|
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
pub struct LinkMeta {
|
pub struct LinkMeta {
|
||||||
pkgid: PkgId,
|
crateid: CrateId,
|
||||||
crate_hash: @str,
|
crate_hash: @str,
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use syntax::codemap::{Span, dummy_sp};
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::span_handler;
|
||||||
use syntax::parse::token;
|
use syntax::parse::token;
|
||||||
use syntax::parse::token::ident_interner;
|
use syntax::parse::token::ident_interner;
|
||||||
use syntax::pkgid::PkgId;
|
use syntax::crateid::CrateId;
|
||||||
use syntax::visit;
|
use syntax::visit;
|
||||||
|
|
||||||
// Traverses an AST, reading all the information about use'd crates and extern
|
// Traverses an AST, reading all the information about use'd crates and extern
|
||||||
|
@ -73,7 +73,7 @@ struct cache_entry {
|
||||||
cnum: ast::CrateNum,
|
cnum: ast::CrateNum,
|
||||||
span: Span,
|
span: Span,
|
||||||
hash: @str,
|
hash: @str,
|
||||||
pkgid: PkgId,
|
crateid: CrateId,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dump_crates(crate_cache: &[cache_entry]) {
|
fn dump_crates(crate_cache: &[cache_entry]) {
|
||||||
|
@ -89,10 +89,10 @@ fn warn_if_multiple_versions(e: &mut Env,
|
||||||
diag: @mut span_handler,
|
diag: @mut span_handler,
|
||||||
crate_cache: &[cache_entry]) {
|
crate_cache: &[cache_entry]) {
|
||||||
if crate_cache.len() != 0u {
|
if crate_cache.len() != 0u {
|
||||||
let name = crate_cache[crate_cache.len() - 1].pkgid.name.clone();
|
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
|
||||||
|
|
||||||
let (matches, non_matches) = crate_cache.partitioned(|entry|
|
let (matches, non_matches) = crate_cache.partitioned(|entry|
|
||||||
name == entry.pkgid.name);
|
name == entry.crateid.name);
|
||||||
|
|
||||||
assert!(!matches.is_empty());
|
assert!(!matches.is_empty());
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ fn warn_if_multiple_versions(e: &mut Env,
|
||||||
format!("using multiple versions of crate `{}`", name));
|
format!("using multiple versions of crate `{}`", name));
|
||||||
for match_ in matches.iter() {
|
for match_ in matches.iter() {
|
||||||
diag.span_note(match_.span, "used here");
|
diag.span_note(match_.span, "used here");
|
||||||
loader::note_pkgid_attr(diag, &match_.pkgid);
|
loader::note_crateid_attr(diag, &match_.crateid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,15 +138,15 @@ fn visit_view_item(e: &mut Env, i: &ast::view_item) {
|
||||||
ident, path_opt);
|
ident, path_opt);
|
||||||
let (name, version) = match path_opt {
|
let (name, version) = match path_opt {
|
||||||
Some((path_str, _)) => {
|
Some((path_str, _)) => {
|
||||||
let pkgid: Option<PkgId> = from_str(path_str);
|
let crateid: Option<CrateId> = from_str(path_str);
|
||||||
match pkgid {
|
match crateid {
|
||||||
None => (@"", @""),
|
None => (@"", @""),
|
||||||
Some(pkgid) => {
|
Some(crateid) => {
|
||||||
let version = match pkgid.version {
|
let version = match crateid.version {
|
||||||
None => @"",
|
None => @"",
|
||||||
Some(ref ver) => ver.to_managed(),
|
Some(ref ver) => ver.to_managed(),
|
||||||
};
|
};
|
||||||
(pkgid.name.to_managed(), version)
|
(crateid.name.to_managed(), version)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,12 +245,12 @@ fn visit_item(e: &Env, i: @ast::item) {
|
||||||
fn existing_match(e: &Env, name: @str, version: @str, hash: &str) -> Option<ast::CrateNum> {
|
fn existing_match(e: &Env, name: @str, version: @str, hash: &str) -> Option<ast::CrateNum> {
|
||||||
let crate_cache = e.crate_cache.borrow();
|
let crate_cache = e.crate_cache.borrow();
|
||||||
for c in crate_cache.get().iter() {
|
for c in crate_cache.get().iter() {
|
||||||
let pkgid_version = match c.pkgid.version {
|
let crateid_version = match c.crateid.version {
|
||||||
None => @"0.0",
|
None => @"0.0",
|
||||||
Some(ref ver) => ver.to_managed(),
|
Some(ref ver) => ver.to_managed(),
|
||||||
};
|
};
|
||||||
if (name.is_empty() || c.pkgid.name.to_managed() == name) &&
|
if (name.is_empty() || c.crateid.name.to_managed() == name) &&
|
||||||
(version.is_empty() || pkgid_version == version) &&
|
(version.is_empty() || crateid_version == version) &&
|
||||||
(hash.is_empty() || c.hash.as_slice() == hash) {
|
(hash.is_empty() || c.hash.as_slice() == hash) {
|
||||||
return Some(c.cnum);
|
return Some(c.cnum);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ fn resolve_crate(e: &mut Env,
|
||||||
} = load_ctxt.load_library_crate();
|
} = load_ctxt.load_library_crate();
|
||||||
|
|
||||||
let attrs = decoder::get_crate_attributes(metadata.as_slice());
|
let attrs = decoder::get_crate_attributes(metadata.as_slice());
|
||||||
let pkgid = attr::find_pkgid(attrs).unwrap();
|
let crateid = attr::find_crateid(attrs).unwrap();
|
||||||
let hash = decoder::get_crate_hash(metadata.as_slice());
|
let hash = decoder::get_crate_hash(metadata.as_slice());
|
||||||
|
|
||||||
// Claim this crate number and cache it
|
// Claim this crate number and cache it
|
||||||
|
@ -293,7 +293,7 @@ fn resolve_crate(e: &mut Env,
|
||||||
cnum: cnum,
|
cnum: cnum,
|
||||||
span: span,
|
span: span,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
pkgid: pkgid,
|
crateid: crateid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
e.next_crate_num += 1;
|
e.next_crate_num += 1;
|
||||||
|
|
|
@ -1173,9 +1173,9 @@ pub fn get_crate_hash(data: &[u8]) -> @str {
|
||||||
|
|
||||||
pub fn get_crate_vers(data: &[u8]) -> @str {
|
pub fn get_crate_vers(data: &[u8]) -> @str {
|
||||||
let attrs = decoder::get_crate_attributes(data);
|
let attrs = decoder::get_crate_attributes(data);
|
||||||
match attr::find_pkgid(attrs) {
|
match attr::find_crateid(attrs) {
|
||||||
None => @"0.0",
|
None => @"0.0",
|
||||||
Some(pkgid) => pkgid.version_or_default().to_managed(),
|
Some(crateid) => crateid.version_or_default().to_managed(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1559,19 +1559,19 @@ fn encode_attributes(ebml_w: &mut writer::Encoder, attrs: &[Attribute]) {
|
||||||
ebml_w.end_tag();
|
ebml_w.end_tag();
|
||||||
}
|
}
|
||||||
|
|
||||||
// So there's a special crate attribute called 'pkgid' which defines the
|
// So there's a special crate attribute called 'crate_id' which defines the
|
||||||
// metadata that Rust cares about for linking crates. If the user didn't
|
// metadata that Rust cares about for linking crates. If the user didn't
|
||||||
// provide it we will throw it in anyway with a default value.
|
// provide it we will throw it in anyway with a default value.
|
||||||
fn synthesize_crate_attrs(ecx: &EncodeContext,
|
fn synthesize_crate_attrs(ecx: &EncodeContext,
|
||||||
crate: &Crate) -> ~[Attribute] {
|
crate: &Crate) -> ~[Attribute] {
|
||||||
|
|
||||||
fn synthesize_pkgid_attr(ecx: &EncodeContext) -> Attribute {
|
fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute {
|
||||||
assert!(!ecx.link_meta.pkgid.name.is_empty());
|
assert!(!ecx.link_meta.crateid.name.is_empty());
|
||||||
|
|
||||||
attr::mk_attr(
|
attr::mk_attr(
|
||||||
attr::mk_name_value_item_str(
|
attr::mk_name_value_item_str(
|
||||||
@"crate_id",
|
@"crate_id",
|
||||||
ecx.link_meta.pkgid.to_str().to_managed()))
|
ecx.link_meta.crateid.to_str().to_managed()))
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut attrs = ~[];
|
let mut attrs = ~[];
|
||||||
|
@ -1580,7 +1580,7 @@ fn synthesize_crate_attrs(ecx: &EncodeContext,
|
||||||
attrs.push(*attr);
|
attrs.push(*attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attrs.push(synthesize_pkgid_attr(ecx));
|
attrs.push(synthesize_crateid_attr(ecx));
|
||||||
|
|
||||||
attrs
|
attrs
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ use metadata::filesearch;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::diagnostic::span_handler;
|
use syntax::diagnostic::span_handler;
|
||||||
use syntax::parse::token::ident_interner;
|
use syntax::parse::token::ident_interner;
|
||||||
use syntax::pkgid::PkgId;
|
use syntax::crateid::CrateId;
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
use syntax::attr::AttrMetaMethods;
|
use syntax::attr::AttrMetaMethods;
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ impl Context {
|
||||||
Some(cvec) =>
|
Some(cvec) =>
|
||||||
if crate_matches(cvec.as_slice(), self.name,
|
if crate_matches(cvec.as_slice(), self.name,
|
||||||
self.version, self.hash) {
|
self.version, self.hash) {
|
||||||
debug!("found {} with matching pkgid",
|
debug!("found {} with matching crate_id",
|
||||||
path.display());
|
path.display());
|
||||||
let (rlib, dylib) = if file.ends_with(".rlib") {
|
let (rlib, dylib) = if file.ends_with(".rlib") {
|
||||||
(Some(path.clone()), None)
|
(Some(path.clone()), None)
|
||||||
|
@ -126,7 +126,7 @@ impl Context {
|
||||||
});
|
});
|
||||||
FileMatches
|
FileMatches
|
||||||
} else {
|
} else {
|
||||||
debug!("skipping {}, pkgid doesn't match",
|
debug!("skipping {}, crate_id doesn't match",
|
||||||
path.display());
|
path.display());
|
||||||
FileDoesntMatch
|
FileDoesntMatch
|
||||||
},
|
},
|
||||||
|
@ -165,10 +165,10 @@ impl Context {
|
||||||
}
|
}
|
||||||
let data = lib.metadata.as_slice();
|
let data = lib.metadata.as_slice();
|
||||||
let attrs = decoder::get_crate_attributes(data);
|
let attrs = decoder::get_crate_attributes(data);
|
||||||
match attr::find_pkgid(attrs) {
|
match attr::find_crateid(attrs) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(pkgid) => {
|
Some(crateid) => {
|
||||||
note_pkgid_attr(self.sess.diagnostic(), &pkgid);
|
note_crateid_attr(self.sess.diagnostic(), &crateid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,9 +231,9 @@ impl Context {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn note_pkgid_attr(diag: @mut span_handler,
|
pub fn note_crateid_attr(diag: @mut span_handler,
|
||||||
pkgid: &PkgId) {
|
crateid: &CrateId) {
|
||||||
diag.handler().note(format!("pkgid: {}", pkgid.to_str()));
|
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn crate_matches(crate_data: &[u8],
|
fn crate_matches(crate_data: &[u8],
|
||||||
|
@ -241,15 +241,15 @@ fn crate_matches(crate_data: &[u8],
|
||||||
version: @str,
|
version: @str,
|
||||||
hash: @str) -> bool {
|
hash: @str) -> bool {
|
||||||
let attrs = decoder::get_crate_attributes(crate_data);
|
let attrs = decoder::get_crate_attributes(crate_data);
|
||||||
match attr::find_pkgid(attrs) {
|
match attr::find_crateid(attrs) {
|
||||||
None => false,
|
None => false,
|
||||||
Some(pkgid) => {
|
Some(crateid) => {
|
||||||
if !hash.is_empty() {
|
if !hash.is_empty() {
|
||||||
let chash = decoder::get_crate_hash(crate_data);
|
let chash = decoder::get_crate_hash(crate_data);
|
||||||
if chash != hash { return false; }
|
if chash != hash { return false; }
|
||||||
}
|
}
|
||||||
name == pkgid.name.to_managed() &&
|
name == crateid.name.to_managed() &&
|
||||||
(version.is_empty() || version == pkgid.version_or_default().to_managed())
|
(version.is_empty() || version == crateid.version_or_default().to_managed())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3048,8 +3048,8 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
|
||||||
let sym_name = if is_top {
|
let sym_name = if is_top {
|
||||||
~"_rust_crate_map_toplevel"
|
~"_rust_crate_map_toplevel"
|
||||||
} else {
|
} else {
|
||||||
symname(sess, "_rust_crate_map_" + mapmeta.pkgid.name, mapmeta.crate_hash,
|
symname(sess, "_rust_crate_map_" + mapmeta.crateid.name, mapmeta.crate_hash,
|
||||||
mapmeta.pkgid.version_or_default())
|
mapmeta.crateid.version_or_default())
|
||||||
};
|
};
|
||||||
|
|
||||||
let slicetype = Type::struct_([int_type, int_type], false);
|
let slicetype = Type::struct_([int_type, int_type], false);
|
||||||
|
@ -3168,8 +3168,8 @@ pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
|
||||||
flate::deflate_bytes(metadata);
|
flate::deflate_bytes(metadata);
|
||||||
let llmeta = C_bytes(compressed);
|
let llmeta = C_bytes(compressed);
|
||||||
let llconst = C_struct([llmeta], false);
|
let llconst = C_struct([llmeta], false);
|
||||||
let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.pkgid.name,
|
let name = format!("rust_metadata_{}_{}_{}", cx.link_meta.crateid.name,
|
||||||
cx.link_meta.pkgid.version_or_default(), cx.link_meta.crate_hash);
|
cx.link_meta.crateid.version_or_default(), cx.link_meta.crate_hash);
|
||||||
let llglobal = name.with_c_str(|buf| {
|
let llglobal = name.with_c_str(|buf| {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMAddGlobal(cx.metadata_llmod, val_ty(llconst).to_ref(), buf)
|
llvm::LLVMAddGlobal(cx.metadata_llmod, val_ty(llconst).to_ref(), buf)
|
||||||
|
@ -3205,7 +3205,7 @@ pub fn trans_crate(sess: session::Session,
|
||||||
// crashes if the module identifer is same as other symbols
|
// crashes if the module identifer is same as other symbols
|
||||||
// such as a function name in the module.
|
// such as a function name in the module.
|
||||||
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
|
||||||
let llmod_id = link_meta.pkgid.name.clone() + ".rc";
|
let llmod_id = link_meta.crateid.name.clone() + ".rc";
|
||||||
|
|
||||||
let ccx = @CrateContext::new(sess,
|
let ccx = @CrateContext::new(sess,
|
||||||
llmod_id,
|
llmod_id,
|
||||||
|
|
|
@ -2827,7 +2827,7 @@ fn namespace_for_item(cx: &CrateContext,
|
||||||
|
|
||||||
if def_id.crate == ast::LOCAL_CRATE {
|
if def_id.crate == ast::LOCAL_CRATE {
|
||||||
// prepend crate name if not already present
|
// prepend crate name if not already present
|
||||||
let crate_namespace_ident = token::str_to_ident(cx.link_meta.pkgid.name);
|
let crate_namespace_ident = token::str_to_ident(cx.link_meta.crateid.name);
|
||||||
item_path.insert(0, ast_map::path_mod(crate_namespace_ident));
|
item_path.insert(0, ast_map::path_mod(crate_namespace_ident));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1855,7 +1855,7 @@ pub fn trans_log_level(bcx: @Block) -> DatumBlock {
|
||||||
Some(&src) => {
|
Some(&src) => {
|
||||||
ccx.sess.cstore.get_crate_data(src.crate).name
|
ccx.sess.cstore.get_crate_data(src.crate).name
|
||||||
}
|
}
|
||||||
None => ccx.link_meta.pkgid.name.to_managed(),
|
None => ccx.link_meta.crateid.name.to_managed(),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))];
|
let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))];
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub struct Crate {
|
||||||
|
|
||||||
impl Clean<Crate> for visit_ast::RustdocVisitor {
|
impl Clean<Crate> for visit_ast::RustdocVisitor {
|
||||||
fn clean(&self) -> Crate {
|
fn clean(&self) -> Crate {
|
||||||
use syntax::attr::find_pkgid;
|
use syntax::attr::find_crateid;
|
||||||
let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
|
let cx = local_data::get(super::ctxtkey, |x| *x.unwrap());
|
||||||
|
|
||||||
let mut externs = HashMap::new();
|
let mut externs = HashMap::new();
|
||||||
|
@ -82,7 +82,7 @@ impl Clean<Crate> for visit_ast::RustdocVisitor {
|
||||||
});
|
});
|
||||||
|
|
||||||
Crate {
|
Crate {
|
||||||
name: match find_pkgid(self.attrs) {
|
name: match find_crateid(self.attrs) {
|
||||||
Some(n) => n.name,
|
Some(n) => n.name,
|
||||||
None => fail!("rustdoc requires a `crate_id` crate attribute"),
|
None => fail!("rustdoc requires a `crate_id` crate attribute"),
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use context::*;
|
use context::*;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use package_id::*;
|
use crate_id::*;
|
||||||
use package_source::*;
|
use package_source::*;
|
||||||
use path_util::{platform_library_name, target_build_dir};
|
use path_util::{platform_library_name, target_build_dir};
|
||||||
use target::*;
|
use target::*;
|
||||||
|
@ -92,7 +92,7 @@ pub fn build_lib_with_cfgs(sysroot: Path, root: Path, name: ~str,
|
||||||
build_in_destination: false,
|
build_in_destination: false,
|
||||||
destination_workspace: root.clone(),
|
destination_workspace: root.clone(),
|
||||||
start_dir: root.join_many(["src", name.as_slice()]),
|
start_dir: root.join_many(["src", name.as_slice()]),
|
||||||
id: PkgId{ version: version, ..PkgId::new(name)},
|
id: CrateId{ version: version, ..CrateId::new(name)},
|
||||||
// n.b. This assumes the package only has one crate
|
// n.b. This assumes the package only has one crate
|
||||||
libs: ~[mk_crate(lib)],
|
libs: ~[mk_crate(lib)],
|
||||||
mains: ~[],
|
mains: ~[],
|
||||||
|
@ -115,7 +115,7 @@ pub fn build_exe_with_cfgs(sysroot: Path, root: Path, name: ~str,
|
||||||
build_in_destination: false,
|
build_in_destination: false,
|
||||||
destination_workspace: root.clone(),
|
destination_workspace: root.clone(),
|
||||||
start_dir: root.join_many(["src", name.as_slice()]),
|
start_dir: root.join_many(["src", name.as_slice()]),
|
||||||
id: PkgId{ version: version, ..PkgId::new(name)},
|
id: CrateId{ version: version, ..CrateId::new(name)},
|
||||||
libs: ~[],
|
libs: ~[],
|
||||||
// n.b. This assumes the package only has one crate
|
// n.b. This assumes the package only has one crate
|
||||||
mains: ~[mk_crate(main)],
|
mains: ~[mk_crate(main)],
|
||||||
|
@ -132,8 +132,8 @@ pub fn install_pkg(cx: &BuildContext,
|
||||||
version: Version,
|
version: Version,
|
||||||
// For now, these inputs are assumed to be inputs to each of the crates
|
// For now, these inputs are assumed to be inputs to each of the crates
|
||||||
more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path
|
more_inputs: ~[(~str, Path)]) { // pairs of Kind and Path
|
||||||
let pkgid = PkgId{ version: version, ..PkgId::new(name)};
|
let crateid = CrateId{ version: version, ..CrateId::new(name)};
|
||||||
cx.install(PkgSrc::new(workspace.clone(), workspace, false, pkgid),
|
cx.install(PkgSrc::new(workspace.clone(), workspace, false, crateid),
|
||||||
&WhatToBuild{ build_type: Inferred,
|
&WhatToBuild{ build_type: Inferred,
|
||||||
inputs_to_discover: more_inputs,
|
inputs_to_discover: more_inputs,
|
||||||
sources: Everything });
|
sources: Everything });
|
||||||
|
@ -157,10 +157,10 @@ pub fn build_library_in_workspace(exec: &mut workcache::Exec,
|
||||||
let out_name = workspace_build_dir.join_many([package_name.to_str(),
|
let out_name = workspace_build_dir.join_many([package_name.to_str(),
|
||||||
platform_library_name(output)]);
|
platform_library_name(output)]);
|
||||||
// make paths absolute
|
// make paths absolute
|
||||||
let pkgid = PkgId::new(package_name);
|
let crateid = CrateId::new(package_name);
|
||||||
let absolute_paths = paths.map(|s| {
|
let absolute_paths = paths.map(|s| {
|
||||||
let whatever = workspace.join_many([~"src",
|
let whatever = workspace.join_many([~"src",
|
||||||
pkgid.to_str(),
|
crateid.to_str(),
|
||||||
s.to_owned()]);
|
s.to_owned()]);
|
||||||
whatever.as_str().unwrap().to_owned()
|
whatever.as_str().unwrap().to_owned()
|
||||||
});
|
});
|
||||||
|
@ -190,8 +190,8 @@ pub fn my_workspace(context: &Context, package_name: &str) -> Path {
|
||||||
use bad_pkg_id = conditions::bad_pkg_id::cond;
|
use bad_pkg_id = conditions::bad_pkg_id::cond;
|
||||||
|
|
||||||
// (this assumes no particular version is requested)
|
// (this assumes no particular version is requested)
|
||||||
let pkgid = PkgId::new(package_name);
|
let crateid = CrateId::new(package_name);
|
||||||
let workspaces = pkg_parent_workspaces(context, &pkgid);
|
let workspaces = pkg_parent_workspaces(context, &crateid);
|
||||||
if workspaces.is_empty() {
|
if workspaces.is_empty() {
|
||||||
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
|
bad_pkg_id.raise((Path::new(package_name), package_name.to_owned()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
// Useful conditions
|
// Useful conditions
|
||||||
|
|
||||||
pub use package_id::PkgId;
|
pub use crate_id::CrateId;
|
||||||
pub use std::io::FileStat;
|
pub use std::io::FileStat;
|
||||||
pub use std::io::process::ProcessExit;
|
pub use std::io::process::ProcessExit;
|
||||||
pub use std::path::Path;
|
pub use std::path::Path;
|
||||||
|
@ -20,15 +20,15 @@ condition! {
|
||||||
}
|
}
|
||||||
|
|
||||||
condition! {
|
condition! {
|
||||||
pub nonexistent_package: (PkgId, ~str) -> Path;
|
pub nonexistent_package: (CrateId, ~str) -> Path;
|
||||||
}
|
}
|
||||||
|
|
||||||
condition! {
|
condition! {
|
||||||
pub missing_pkg_files: (PkgId) -> ();
|
pub missing_pkg_files: (CrateId) -> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
condition! {
|
condition! {
|
||||||
pub bad_pkg_id: (Path, ~str) -> PkgId;
|
pub bad_pkg_id: (Path, ~str) -> CrateId;
|
||||||
}
|
}
|
||||||
|
|
||||||
condition! {
|
condition! {
|
||||||
|
|
|
@ -17,7 +17,7 @@ use std::hash;
|
||||||
/// 'github.com/graydon/test'; path must be a relative
|
/// 'github.com/graydon/test'; path must be a relative
|
||||||
/// path with >=1 component.
|
/// path with >=1 component.
|
||||||
#[deriving(Clone)]
|
#[deriving(Clone)]
|
||||||
pub struct PkgId {
|
pub struct CrateId {
|
||||||
/// This is a path, on the local filesystem, referring to where the
|
/// This is a path, on the local filesystem, referring to where the
|
||||||
/// files for this package live. For example:
|
/// files for this package live. For example:
|
||||||
/// github.com/mozilla/quux-whatever (it's assumed that if we're
|
/// github.com/mozilla/quux-whatever (it's assumed that if we're
|
||||||
|
@ -35,14 +35,14 @@ pub struct PkgId {
|
||||||
version: Version
|
version: Version
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for PkgId {
|
impl Eq for CrateId {
|
||||||
fn eq(&self, other: &PkgId) -> bool {
|
fn eq(&self, other: &CrateId) -> bool {
|
||||||
self.path == other.path && self.version == other.version
|
self.path == other.path && self.version == other.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PkgId {
|
impl CrateId {
|
||||||
pub fn new(s: &str) -> PkgId {
|
pub fn new(s: &str) -> CrateId {
|
||||||
use conditions::bad_pkg_id::cond;
|
use conditions::bad_pkg_id::cond;
|
||||||
|
|
||||||
let mut given_version = None;
|
let mut given_version = None;
|
||||||
|
@ -60,10 +60,10 @@ impl PkgId {
|
||||||
|
|
||||||
let path = Path::new(s);
|
let path = Path::new(s);
|
||||||
if !path.is_relative() {
|
if !path.is_relative() {
|
||||||
return cond.raise((path, ~"absolute pkgid"));
|
return cond.raise((path, ~"absolute crate_id"));
|
||||||
}
|
}
|
||||||
if path.filename().is_none() {
|
if path.filename().is_none() {
|
||||||
return cond.raise((path, ~"0-length pkgid"));
|
return cond.raise((path, ~"0-length crate_id"));
|
||||||
}
|
}
|
||||||
let short_name = path.filestem_str().expect(format!("Strange path! {}", s));
|
let short_name = path.filestem_str().expect(format!("Strange path! {}", s));
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ impl PkgId {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PkgId {
|
CrateId {
|
||||||
path: path.clone(),
|
path: path.clone(),
|
||||||
short_name: short_name.to_owned(),
|
short_name: short_name.to_owned(),
|
||||||
version: version
|
version: version
|
||||||
|
@ -142,7 +142,7 @@ impl Iterator<(Path, Path)> for Prefixes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStr for PkgId {
|
impl ToStr for CrateId {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
// should probably use the filestem and not the whole path
|
// should probably use the filestem and not the whole path
|
||||||
format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str())
|
format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str())
|
|
@ -16,7 +16,7 @@ use std::os;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
|
|
||||||
pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool {
|
pub fn list_installed_packages(f: |&CrateId| -> bool) -> bool {
|
||||||
let workspaces = rust_path();
|
let workspaces = rust_path();
|
||||||
for p in workspaces.iter() {
|
for p in workspaces.iter() {
|
||||||
let binfiles = {
|
let binfiles = {
|
||||||
|
@ -28,7 +28,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool {
|
||||||
match exec.filestem_str() {
|
match exec.filestem_str() {
|
||||||
None => (),
|
None => (),
|
||||||
Some(exec_path) => {
|
Some(exec_path) => {
|
||||||
if !f(&PkgId::new(exec_path)) {
|
if !f(&CrateId::new(exec_path)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ pub fn list_installed_packages(f: |&PkgId| -> bool) -> bool {
|
||||||
let rel_path = rel_p.join(basename);
|
let rel_path = rel_p.join(basename);
|
||||||
rel_path.display().with_str(|s| {
|
rel_path.display().with_str(|s| {
|
||||||
debug!("Rel name: {}", s);
|
debug!("Rel name: {}", s);
|
||||||
f(&PkgId::new(s));
|
f(&CrateId::new(s));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => ()
|
None => ()
|
||||||
|
@ -78,7 +78,7 @@ pub fn has_library(p: &Path) -> Option<~str> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn package_is_installed(p: &PkgId) -> bool {
|
pub fn package_is_installed(p: &CrateId) -> bool {
|
||||||
let mut is_installed = false;
|
let mut is_installed = false;
|
||||||
list_installed_packages(|installed| {
|
list_installed_packages(|installed| {
|
||||||
if installed == p {
|
if installed == p {
|
||||||
|
|
|
@ -45,7 +45,7 @@ use workspace::determine_destination;
|
||||||
use context::{Context, BuildContext,
|
use context::{Context, BuildContext,
|
||||||
RustcFlags, Trans, Link, Nothing, Pretty, Analysis, Assemble,
|
RustcFlags, Trans, Link, Nothing, Pretty, Analysis, Assemble,
|
||||||
LLVMAssemble, LLVMCompileBitcode};
|
LLVMAssemble, LLVMCompileBitcode};
|
||||||
use package_id::PkgId;
|
use crate_id::CrateId;
|
||||||
use package_source::PkgSrc;
|
use package_source::PkgSrc;
|
||||||
use target::{WhatToBuild, Everything, is_lib, is_main, is_test, is_bench};
|
use target::{WhatToBuild, Everything, is_lib, is_main, is_test, is_bench};
|
||||||
use target::{Main, Tests, MaybeCustom, Inferred, JustOne};
|
use target::{Main, Tests, MaybeCustom, Inferred, JustOne};
|
||||||
|
@ -59,7 +59,7 @@ mod crate;
|
||||||
pub mod exit_codes;
|
pub mod exit_codes;
|
||||||
mod installed_packages;
|
mod installed_packages;
|
||||||
mod messages;
|
mod messages;
|
||||||
pub mod package_id;
|
pub mod crate_id;
|
||||||
pub mod package_source;
|
pub mod package_source;
|
||||||
mod path_util;
|
mod path_util;
|
||||||
mod source_control;
|
mod source_control;
|
||||||
|
@ -78,7 +78,7 @@ pub mod usage;
|
||||||
/// an explicit package script.
|
/// an explicit package script.
|
||||||
struct PkgScript<'a> {
|
struct PkgScript<'a> {
|
||||||
/// Uniquely identifies this package
|
/// Uniquely identifies this package
|
||||||
id: &'a PkgId,
|
id: &'a CrateId,
|
||||||
/// File path for the package script
|
/// File path for the package script
|
||||||
input: Path,
|
input: Path,
|
||||||
/// The session to use *only* for compiling the custom
|
/// The session to use *only* for compiling the custom
|
||||||
|
@ -99,7 +99,7 @@ impl<'a> PkgScript<'a> {
|
||||||
fn parse<'a>(sysroot: Path,
|
fn parse<'a>(sysroot: Path,
|
||||||
script: Path,
|
script: Path,
|
||||||
workspace: &Path,
|
workspace: &Path,
|
||||||
id: &'a PkgId) -> PkgScript<'a> {
|
id: &'a CrateId) -> PkgScript<'a> {
|
||||||
// Get the executable name that was invoked
|
// Get the executable name that was invoked
|
||||||
let binary = os::args()[0].to_managed();
|
let binary = os::args()[0].to_managed();
|
||||||
// Build the rustc session data structures to pass
|
// Build the rustc session data structures to pass
|
||||||
|
@ -208,10 +208,10 @@ pub trait CtxMethods {
|
||||||
fn run(&self, cmd: &str, args: ~[~str]);
|
fn run(&self, cmd: &str, args: ~[~str]);
|
||||||
fn do_cmd(&self, _cmd: &str, _pkgname: &str);
|
fn do_cmd(&self, _cmd: &str, _pkgname: &str);
|
||||||
/// Returns a pair of the selected package ID, and the destination workspace
|
/// Returns a pair of the selected package ID, and the destination workspace
|
||||||
fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)>;
|
fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)>;
|
||||||
/// Returns the destination workspace
|
/// Returns the destination workspace
|
||||||
fn build(&self, pkg_src: &mut PkgSrc, what: &WhatToBuild);
|
fn build(&self, pkg_src: &mut PkgSrc, what: &WhatToBuild);
|
||||||
fn clean(&self, workspace: &Path, id: &PkgId);
|
fn clean(&self, workspace: &Path, id: &CrateId);
|
||||||
fn info(&self);
|
fn info(&self);
|
||||||
/// Returns a pair. First component is a list of installed paths,
|
/// Returns a pair. First component is a list of installed paths,
|
||||||
/// second is a list of declared and discovered inputs
|
/// second is a list of declared and discovered inputs
|
||||||
|
@ -221,24 +221,24 @@ pub trait CtxMethods {
|
||||||
build_workspace: &Path,
|
build_workspace: &Path,
|
||||||
build_inputs: &[Path],
|
build_inputs: &[Path],
|
||||||
target_workspace: &Path,
|
target_workspace: &Path,
|
||||||
id: &PkgId) -> ~[~str];
|
id: &CrateId) -> ~[~str];
|
||||||
fn prefer(&self, _id: &str, _vers: Option<~str>);
|
fn prefer(&self, _id: &str, _vers: Option<~str>);
|
||||||
fn test(&self, id: &PkgId, workspace: &Path);
|
fn test(&self, id: &CrateId, workspace: &Path);
|
||||||
fn uninstall(&self, _id: &str, _vers: Option<~str>);
|
fn uninstall(&self, _id: &str, _vers: Option<~str>);
|
||||||
fn unprefer(&self, _id: &str, _vers: Option<~str>);
|
fn unprefer(&self, _id: &str, _vers: Option<~str>);
|
||||||
fn init(&self);
|
fn init(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CtxMethods for BuildContext {
|
impl CtxMethods for BuildContext {
|
||||||
fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(PkgId, Path)> {
|
fn build_args(&self, args: ~[~str], what: &WhatToBuild) -> Option<(CrateId, Path)> {
|
||||||
let cwd = os::getcwd();
|
let cwd = os::getcwd();
|
||||||
|
|
||||||
if args.len() < 1 {
|
if args.len() < 1 {
|
||||||
match cwd_to_workspace() {
|
match cwd_to_workspace() {
|
||||||
None if dir_has_crate_file(&cwd) => {
|
None if dir_has_crate_file(&cwd) => {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let pkgid = PkgId::new(cwd.filename_str().unwrap());
|
let crateid = CrateId::new(cwd.filename_str().unwrap());
|
||||||
let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, pkgid);
|
let mut pkg_src = PkgSrc::new(cwd, default_workspace(), true, crateid);
|
||||||
self.build(&mut pkg_src, what);
|
self.build(&mut pkg_src, what);
|
||||||
match pkg_src {
|
match pkg_src {
|
||||||
PkgSrc { destination_workspace: ws,
|
PkgSrc { destination_workspace: ws,
|
||||||
|
@ -248,8 +248,8 @@ impl CtxMethods for BuildContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => { usage::build(); None }
|
None => { usage::build(); None }
|
||||||
Some((ws, pkgid)) => {
|
Some((ws, crateid)) => {
|
||||||
let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, pkgid);
|
let mut pkg_src = PkgSrc::new(ws.clone(), ws, false, crateid);
|
||||||
self.build(&mut pkg_src, what);
|
self.build(&mut pkg_src, what);
|
||||||
match pkg_src {
|
match pkg_src {
|
||||||
PkgSrc { destination_workspace: ws,
|
PkgSrc { destination_workspace: ws,
|
||||||
|
@ -262,23 +262,23 @@ impl CtxMethods for BuildContext {
|
||||||
} else {
|
} else {
|
||||||
// The package id is presumed to be the first command-line
|
// The package id is presumed to be the first command-line
|
||||||
// argument
|
// argument
|
||||||
let pkgid = PkgId::new(args[0].clone());
|
let crateid = CrateId::new(args[0].clone());
|
||||||
let mut dest_ws = default_workspace();
|
let mut dest_ws = default_workspace();
|
||||||
each_pkg_parent_workspace(&self.context, &pkgid, |workspace| {
|
each_pkg_parent_workspace(&self.context, &crateid, |workspace| {
|
||||||
debug!("found pkg {} in workspace {}, trying to build",
|
debug!("found pkg {} in workspace {}, trying to build",
|
||||||
pkgid.to_str(), workspace.display());
|
crateid.to_str(), workspace.display());
|
||||||
dest_ws = determine_destination(os::getcwd(),
|
dest_ws = determine_destination(os::getcwd(),
|
||||||
self.context.use_rust_path_hack,
|
self.context.use_rust_path_hack,
|
||||||
workspace);
|
workspace);
|
||||||
let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(),
|
let mut pkg_src = PkgSrc::new(workspace.clone(), dest_ws.clone(),
|
||||||
false, pkgid.clone());
|
false, crateid.clone());
|
||||||
self.build(&mut pkg_src, what);
|
self.build(&mut pkg_src, what);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
// n.b. If this builds multiple packages, it only returns the workspace for
|
// n.b. If this builds multiple packages, it only returns the workspace for
|
||||||
// the last one. The whole building-multiple-packages-with-the-same-ID is weird
|
// the last one. The whole building-multiple-packages-with-the-same-ID is weird
|
||||||
// anyway and there are no tests for it, so maybe take it out
|
// anyway and there are no tests for it, so maybe take it out
|
||||||
Some((pkgid, dest_ws))
|
Some((crateid, dest_ws))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn run(&self, cmd: &str, args: ~[~str]) {
|
fn run(&self, cmd: &str, args: ~[~str]) {
|
||||||
|
@ -293,15 +293,15 @@ impl CtxMethods for BuildContext {
|
||||||
None => { usage::clean(); return }
|
None => { usage::clean(); return }
|
||||||
// tjc: Maybe clean should clean all the packages in the
|
// tjc: Maybe clean should clean all the packages in the
|
||||||
// current workspace, though?
|
// current workspace, though?
|
||||||
Some((ws, pkgid)) => self.clean(&ws, &pkgid)
|
Some((ws, crateid)) => self.clean(&ws, &crateid)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// The package id is presumed to be the first command-line
|
// The package id is presumed to be the first command-line
|
||||||
// argument
|
// argument
|
||||||
let pkgid = PkgId::new(args[0].clone());
|
let crateid = CrateId::new(args[0].clone());
|
||||||
self.clean(&cwd, &pkgid); // tjc: should use workspace, not cwd
|
self.clean(&cwd, &crateid); // tjc: should use workspace, not cwd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"do" => {
|
"do" => {
|
||||||
|
@ -320,15 +320,15 @@ impl CtxMethods for BuildContext {
|
||||||
None if dir_has_crate_file(&cwd) => {
|
None if dir_has_crate_file(&cwd) => {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
|
|
||||||
let inferred_pkgid =
|
let inferred_crateid =
|
||||||
PkgId::new(cwd.filename_str().unwrap());
|
CrateId::new(cwd.filename_str().unwrap());
|
||||||
self.install(PkgSrc::new(cwd, default_workspace(),
|
self.install(PkgSrc::new(cwd, default_workspace(),
|
||||||
true, inferred_pkgid),
|
true, inferred_crateid),
|
||||||
&WhatToBuild::new(MaybeCustom, Everything));
|
&WhatToBuild::new(MaybeCustom, Everything));
|
||||||
}
|
}
|
||||||
None => { usage::install(); return; }
|
None => { usage::install(); return; }
|
||||||
Some((ws, pkgid)) => {
|
Some((ws, crateid)) => {
|
||||||
let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, pkgid);
|
let pkg_src = PkgSrc::new(ws.clone(), ws.clone(), false, crateid);
|
||||||
self.install(pkg_src, &WhatToBuild::new(MaybeCustom,
|
self.install(pkg_src, &WhatToBuild::new(MaybeCustom,
|
||||||
Everything));
|
Everything));
|
||||||
}
|
}
|
||||||
|
@ -337,13 +337,13 @@ impl CtxMethods for BuildContext {
|
||||||
else {
|
else {
|
||||||
// The package id is presumed to be the first command-line
|
// The package id is presumed to be the first command-line
|
||||||
// argument
|
// argument
|
||||||
let pkgid = PkgId::new(args[0]);
|
let crateid = CrateId::new(args[0]);
|
||||||
let workspaces = pkg_parent_workspaces(&self.context, &pkgid);
|
let workspaces = pkg_parent_workspaces(&self.context, &crateid);
|
||||||
debug!("package ID = {}, found it in {:?} workspaces",
|
debug!("package ID = {}, found it in {:?} workspaces",
|
||||||
pkgid.to_str(), workspaces.len());
|
crateid.to_str(), workspaces.len());
|
||||||
if workspaces.is_empty() {
|
if workspaces.is_empty() {
|
||||||
let d = default_workspace();
|
let d = default_workspace();
|
||||||
let src = PkgSrc::new(d.clone(), d, false, pkgid.clone());
|
let src = PkgSrc::new(d.clone(), d, false, crateid.clone());
|
||||||
self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
|
self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -354,7 +354,7 @@ impl CtxMethods for BuildContext {
|
||||||
let src = PkgSrc::new(workspace.clone(),
|
let src = PkgSrc::new(workspace.clone(),
|
||||||
dest,
|
dest,
|
||||||
self.context.use_rust_path_hack,
|
self.context.use_rust_path_hack,
|
||||||
pkgid.clone());
|
crateid.clone());
|
||||||
self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
|
self.install(src, &WhatToBuild::new(MaybeCustom, Everything));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -400,8 +400,8 @@ impl CtxMethods for BuildContext {
|
||||||
return usage::uninstall();
|
return usage::uninstall();
|
||||||
}
|
}
|
||||||
|
|
||||||
let pkgid = PkgId::new(args[0]);
|
let crateid = CrateId::new(args[0]);
|
||||||
if !installed_packages::package_is_installed(&pkgid) {
|
if !installed_packages::package_is_installed(&crateid) {
|
||||||
warn(format!("Package {} doesn't seem to be installed! \
|
warn(format!("Package {} doesn't seem to be installed! \
|
||||||
Doing nothing.", args[0]));
|
Doing nothing.", args[0]));
|
||||||
return;
|
return;
|
||||||
|
@ -409,10 +409,10 @@ impl CtxMethods for BuildContext {
|
||||||
else {
|
else {
|
||||||
let rp = rust_path();
|
let rp = rust_path();
|
||||||
assert!(!rp.is_empty());
|
assert!(!rp.is_empty());
|
||||||
each_pkg_parent_workspace(&self.context, &pkgid, |workspace| {
|
each_pkg_parent_workspace(&self.context, &crateid, |workspace| {
|
||||||
path_util::uninstall_package_from(workspace, &pkgid);
|
path_util::uninstall_package_from(workspace, &crateid);
|
||||||
note(format!("Uninstalled package {} (was installed in {})",
|
note(format!("Uninstalled package {} (was installed in {})",
|
||||||
pkgid.to_str(), workspace.display()));
|
crateid.to_str(), workspace.display()));
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -437,34 +437,34 @@ impl CtxMethods for BuildContext {
|
||||||
use conditions::git_checkout_failed::cond;
|
use conditions::git_checkout_failed::cond;
|
||||||
|
|
||||||
let workspace = pkg_src.source_workspace.clone();
|
let workspace = pkg_src.source_workspace.clone();
|
||||||
let pkgid = pkg_src.id.clone();
|
let crateid = pkg_src.id.clone();
|
||||||
|
|
||||||
debug!("build: workspace = {} (in Rust path? {:?} is git dir? {:?} \
|
debug!("build: workspace = {} (in Rust path? {:?} is git dir? {:?} \
|
||||||
pkgid = {} pkgsrc start_dir = {}", workspace.display(),
|
crateid = {} pkgsrc start_dir = {}", workspace.display(),
|
||||||
in_rust_path(&workspace), is_git_dir(&workspace.join(&pkgid.path)),
|
in_rust_path(&workspace), is_git_dir(&workspace.join(&crateid.path)),
|
||||||
pkgid.to_str(), pkg_src.start_dir.display());
|
crateid.to_str(), pkg_src.start_dir.display());
|
||||||
debug!("build: what to build = {:?}", what_to_build);
|
debug!("build: what to build = {:?}", what_to_build);
|
||||||
|
|
||||||
// If workspace isn't in the RUST_PATH, and it's a git repo,
|
// If workspace isn't in the RUST_PATH, and it's a git repo,
|
||||||
// then clone it into the first entry in RUST_PATH, and repeat
|
// then clone it into the first entry in RUST_PATH, and repeat
|
||||||
if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&pkgid.path)) {
|
if !in_rust_path(&workspace) && is_git_dir(&workspace.join(&crateid.path)) {
|
||||||
let mut out_dir = default_workspace().join("src");
|
let mut out_dir = default_workspace().join("src");
|
||||||
out_dir.push(&pkgid.path);
|
out_dir.push(&crateid.path);
|
||||||
let git_result = source_control::safe_git_clone(&workspace.join(&pkgid.path),
|
let git_result = source_control::safe_git_clone(&workspace.join(&crateid.path),
|
||||||
&pkgid.version,
|
&crateid.version,
|
||||||
&out_dir);
|
&out_dir);
|
||||||
match git_result {
|
match git_result {
|
||||||
CheckedOutSources => make_read_only(&out_dir),
|
CheckedOutSources => make_read_only(&out_dir),
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
_ => cond.raise((pkgid.path.as_str().unwrap().to_owned(), out_dir.clone()))
|
_ => cond.raise((crateid.path.as_str().unwrap().to_owned(), out_dir.clone()))
|
||||||
};
|
};
|
||||||
let default_ws = default_workspace();
|
let default_ws = default_workspace();
|
||||||
debug!("Calling build recursively with {:?} and {:?}", default_ws.display(),
|
debug!("Calling build recursively with {:?} and {:?}", default_ws.display(),
|
||||||
pkgid.to_str());
|
crateid.to_str());
|
||||||
return self.build(&mut PkgSrc::new(default_ws.clone(),
|
return self.build(&mut PkgSrc::new(default_ws.clone(),
|
||||||
default_ws,
|
default_ws,
|
||||||
false,
|
false,
|
||||||
pkgid.clone()), what_to_build);
|
crateid.clone()), what_to_build);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there custom build logic? If so, use it
|
// Is there custom build logic? If so, use it
|
||||||
|
@ -482,7 +482,7 @@ impl CtxMethods for BuildContext {
|
||||||
let subsysroot = sysroot.clone();
|
let subsysroot = sysroot.clone();
|
||||||
let psp = package_script_path.clone();
|
let psp = package_script_path.clone();
|
||||||
let ws = workspace.clone();
|
let ws = workspace.clone();
|
||||||
let pid = pkgid.clone();
|
let pid = crateid.clone();
|
||||||
prep.exec(proc(exec) {
|
prep.exec(proc(exec) {
|
||||||
let mut pscript = PkgScript::parse(subsysroot.clone(),
|
let mut pscript = PkgScript::parse(subsysroot.clone(),
|
||||||
psp.clone(),
|
psp.clone(),
|
||||||
|
@ -550,7 +550,7 @@ impl CtxMethods for BuildContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean(&self, workspace: &Path, id: &PkgId) {
|
fn clean(&self, workspace: &Path, id: &CrateId) {
|
||||||
// Could also support a custom build hook in the pkg
|
// Could also support a custom build hook in the pkg
|
||||||
// script for cleaning files rustpkg doesn't know about.
|
// script for cleaning files rustpkg doesn't know about.
|
||||||
// Do something reasonable for now
|
// Do something reasonable for now
|
||||||
|
@ -616,7 +616,7 @@ impl CtxMethods for BuildContext {
|
||||||
build_workspace: &Path,
|
build_workspace: &Path,
|
||||||
build_inputs: &[Path],
|
build_inputs: &[Path],
|
||||||
target_workspace: &Path,
|
target_workspace: &Path,
|
||||||
id: &PkgId) -> ~[~str] {
|
id: &CrateId) -> ~[~str] {
|
||||||
|
|
||||||
debug!("install_no_build: assuming {} comes from {} with target {}",
|
debug!("install_no_build: assuming {} comes from {} with target {}",
|
||||||
id.to_str(), build_workspace.display(), target_workspace.display());
|
id.to_str(), build_workspace.display(), target_workspace.display());
|
||||||
|
@ -705,8 +705,8 @@ impl CtxMethods for BuildContext {
|
||||||
fail!("prefer not yet implemented");
|
fail!("prefer not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test(&self, pkgid: &PkgId, workspace: &Path) {
|
fn test(&self, crateid: &CrateId, workspace: &Path) {
|
||||||
match built_test_in_workspace(pkgid, workspace) {
|
match built_test_in_workspace(crateid, workspace) {
|
||||||
Some(test_exec) => {
|
Some(test_exec) => {
|
||||||
debug!("test: test_exec = {}", test_exec.display());
|
debug!("test: test_exec = {}", test_exec.display());
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
|
@ -723,7 +723,7 @@ impl CtxMethods for BuildContext {
|
||||||
None => {
|
None => {
|
||||||
error(format!("Internal error: test executable for package ID {} in workspace {} \
|
error(format!("Internal error: test executable for package ID {} in workspace {} \
|
||||||
wasn't built! Please report this as a bug.",
|
wasn't built! Please report this as a bug.",
|
||||||
pkgid.to_str(), workspace.display()));
|
crateid.to_str(), workspace.display()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
extern mod extra;
|
extern mod extra;
|
||||||
|
|
||||||
use target::*;
|
use target::*;
|
||||||
use package_id::PkgId;
|
use crate_id::CrateId;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
use std::os;
|
use std::os;
|
||||||
|
@ -49,7 +49,7 @@ pub struct PkgSrc {
|
||||||
// Directory to start looking in for packages -- normally
|
// Directory to start looking in for packages -- normally
|
||||||
// this is workspace/src/id but it may be just workspace
|
// this is workspace/src/id but it may be just workspace
|
||||||
start_dir: Path,
|
start_dir: Path,
|
||||||
id: PkgId,
|
id: CrateId,
|
||||||
libs: ~[Crate],
|
libs: ~[Crate],
|
||||||
mains: ~[Crate],
|
mains: ~[Crate],
|
||||||
tests: ~[Crate],
|
tests: ~[Crate],
|
||||||
|
@ -77,7 +77,7 @@ impl PkgSrc {
|
||||||
pub fn new(mut source_workspace: Path,
|
pub fn new(mut source_workspace: Path,
|
||||||
destination_workspace: Path,
|
destination_workspace: Path,
|
||||||
use_rust_path_hack: bool,
|
use_rust_path_hack: bool,
|
||||||
id: PkgId) -> PkgSrc {
|
id: CrateId) -> PkgSrc {
|
||||||
use conditions::nonexistent_package::cond;
|
use conditions::nonexistent_package::cond;
|
||||||
|
|
||||||
debug!("Checking package source for package ID {}, \
|
debug!("Checking package source for package ID {}, \
|
||||||
|
@ -133,14 +133,14 @@ impl PkgSrc {
|
||||||
// See if any of the prefixes of this package ID form a valid package ID
|
// See if any of the prefixes of this package ID form a valid package ID
|
||||||
// That is, is this a package ID that points into the middle of a workspace?
|
// That is, is this a package ID that points into the middle of a workspace?
|
||||||
for (prefix, suffix) in id.prefixes() {
|
for (prefix, suffix) in id.prefixes() {
|
||||||
let package_id = PkgId::new(prefix.as_str().unwrap());
|
let crate_id = CrateId::new(prefix.as_str().unwrap());
|
||||||
let path = build_dir.join(&package_id.path);
|
let path = build_dir.join(&crate_id.path);
|
||||||
debug!("in loop: checking if {} is a directory", path.display());
|
debug!("in loop: checking if {} is a directory", path.display());
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
let ps = PkgSrc::new(source_workspace,
|
let ps = PkgSrc::new(source_workspace,
|
||||||
destination_workspace,
|
destination_workspace,
|
||||||
use_rust_path_hack,
|
use_rust_path_hack,
|
||||||
package_id);
|
crate_id);
|
||||||
match ps {
|
match ps {
|
||||||
PkgSrc {
|
PkgSrc {
|
||||||
source_workspace: source,
|
source_workspace: source,
|
||||||
|
@ -264,36 +264,36 @@ impl PkgSrc {
|
||||||
/// if this was successful, None otherwise. Similarly, if the package id
|
/// if this was successful, None otherwise. Similarly, if the package id
|
||||||
/// refers to a git repo on the local version, also check it out.
|
/// refers to a git repo on the local version, also check it out.
|
||||||
/// (right now we only support git)
|
/// (right now we only support git)
|
||||||
pub fn fetch_git(local: &Path, pkgid: &PkgId) -> Option<Path> {
|
pub fn fetch_git(local: &Path, crateid: &CrateId) -> Option<Path> {
|
||||||
use conditions::git_checkout_failed::cond;
|
use conditions::git_checkout_failed::cond;
|
||||||
|
|
||||||
let cwd = os::getcwd();
|
let cwd = os::getcwd();
|
||||||
debug!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
|
debug!("Checking whether {} (path = {}) exists locally. Cwd = {}, does it? {:?}",
|
||||||
pkgid.to_str(), pkgid.path.display(),
|
crateid.to_str(), crateid.path.display(),
|
||||||
cwd.display(),
|
cwd.display(),
|
||||||
pkgid.path.exists());
|
crateid.path.exists());
|
||||||
|
|
||||||
match safe_git_clone(&pkgid.path, &pkgid.version, local) {
|
match safe_git_clone(&crateid.path, &crateid.version, local) {
|
||||||
CheckedOutSources => {
|
CheckedOutSources => {
|
||||||
make_read_only(local);
|
make_read_only(local);
|
||||||
Some(local.clone())
|
Some(local.clone())
|
||||||
}
|
}
|
||||||
DirToUse(clone_target) => {
|
DirToUse(clone_target) => {
|
||||||
if pkgid.path.components().nth(1).is_none() {
|
if crateid.path.components().nth(1).is_none() {
|
||||||
// If a non-URL, don't bother trying to fetch
|
// If a non-URL, don't bother trying to fetch
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let url = format!("https://{}", pkgid.path.as_str().unwrap());
|
let url = format!("https://{}", crateid.path.as_str().unwrap());
|
||||||
debug!("Fetching package: git clone {} {} [version={}]",
|
debug!("Fetching package: git clone {} {} [version={}]",
|
||||||
url, clone_target.display(), pkgid.version.to_str());
|
url, clone_target.display(), crateid.version.to_str());
|
||||||
|
|
||||||
let mut failed = false;
|
let mut failed = false;
|
||||||
|
|
||||||
cond.trap(|_| {
|
cond.trap(|_| {
|
||||||
failed = true;
|
failed = true;
|
||||||
}).inside(|| git_clone_url(url, &clone_target, &pkgid.version));
|
}).inside(|| git_clone_url(url, &clone_target, &crateid.version));
|
||||||
|
|
||||||
if failed {
|
if failed {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#[allow(dead_code)];
|
#[allow(dead_code)];
|
||||||
|
|
||||||
pub use package_id::PkgId;
|
pub use crate_id::CrateId;
|
||||||
pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
|
pub use target::{OutputType, Main, Lib, Test, Bench, Target, Build, Install};
|
||||||
pub use version::{Version, NoVersion, split_version_general, try_parsing_version};
|
pub use version::{Version, NoVersion, split_version_general, try_parsing_version};
|
||||||
pub use rustc::metadata::filesearch::rust_path;
|
pub use rustc::metadata::filesearch::rust_path;
|
||||||
|
@ -59,12 +59,12 @@ pub fn make_dir_rwx_recursive(p: &Path) -> bool {
|
||||||
// now. Should fix that.
|
// now. Should fix that.
|
||||||
|
|
||||||
/// True if there's a directory in <workspace> with
|
/// True if there's a directory in <workspace> with
|
||||||
/// pkgid's short name
|
/// crateid's short name
|
||||||
pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool {
|
pub fn workspace_contains_crate_id(crateid: &CrateId, workspace: &Path) -> bool {
|
||||||
workspace_contains_package_id_(pkgid, workspace, |p| p.join("src")).is_some()
|
workspace_contains_crate_id_(crateid, workspace, |p| p.join("src")).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
|
pub fn workspace_contains_crate_id_(crateid: &CrateId, workspace: &Path,
|
||||||
// Returns the directory it was actually found in
|
// Returns the directory it was actually found in
|
||||||
workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
|
workspace_to_src_dir: |&Path| -> Path) -> Option<Path> {
|
||||||
if !workspace.is_dir() {
|
if !workspace.is_dir() {
|
||||||
|
@ -77,14 +77,14 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
|
||||||
let mut found = None;
|
let mut found = None;
|
||||||
for p in fs::walk_dir(&src_dir) {
|
for p in fs::walk_dir(&src_dir) {
|
||||||
if p.is_dir() {
|
if p.is_dir() {
|
||||||
if p == src_dir.join(&pkgid.path) || {
|
if p == src_dir.join(&crateid.path) || {
|
||||||
let pf = p.filename_str();
|
let pf = p.filename_str();
|
||||||
pf.iter().any(|&g| {
|
pf.iter().any(|&g| {
|
||||||
match split_version_general(g, '-') {
|
match split_version_general(g, '-') {
|
||||||
None => false,
|
None => false,
|
||||||
Some((ref might_match, ref vers)) => {
|
Some((ref might_match, ref vers)) => {
|
||||||
*might_match == pkgid.short_name
|
*might_match == crateid.short_name
|
||||||
&& (pkgid.version == *vers || pkgid.version == NoVersion)
|
&& (crateid.version == *vers || crateid.version == NoVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -96,9 +96,9 @@ pub fn workspace_contains_package_id_(pkgid: &PkgId, workspace: &Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
if found.is_some() {
|
if found.is_some() {
|
||||||
debug!("Found {} in {}", pkgid.to_str(), workspace.display());
|
debug!("Found {} in {}", crateid.to_str(), workspace.display());
|
||||||
} else {
|
} else {
|
||||||
debug!("Didn't find {} in {}", pkgid.to_str(), workspace.display());
|
debug!("Didn't find {} in {}", crateid.to_str(), workspace.display());
|
||||||
}
|
}
|
||||||
found
|
found
|
||||||
}
|
}
|
||||||
|
@ -126,11 +126,11 @@ fn target_bin_dir(workspace: &Path) -> Path {
|
||||||
workspace.join("bin")
|
workspace.join("bin")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Figure out what the executable name for <pkgid> in <workspace>'s build
|
/// Figure out what the executable name for <crateid> in <workspace>'s build
|
||||||
/// directory is, and if the file exists, return it.
|
/// directory is, and if the file exists, return it.
|
||||||
pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
|
pub fn built_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
|
||||||
let mut result = target_build_dir(workspace);
|
let mut result = target_build_dir(workspace);
|
||||||
result = mk_output_path(Main, Build, pkgid, result);
|
result = mk_output_path(Main, Build, crateid, result);
|
||||||
debug!("built_executable_in_workspace: checking whether {} exists",
|
debug!("built_executable_in_workspace: checking whether {} exists",
|
||||||
result.display());
|
result.display());
|
||||||
if result.exists() {
|
if result.exists() {
|
||||||
|
@ -142,22 +142,22 @@ pub fn built_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Figure out what the test name for <pkgid> in <workspace>'s build
|
/// Figure out what the test name for <crateid> in <workspace>'s build
|
||||||
/// directory is, and if the file exists, return it.
|
/// directory is, and if the file exists, return it.
|
||||||
pub fn built_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
|
pub fn built_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
|
||||||
output_in_workspace(pkgid, workspace, Test)
|
output_in_workspace(crateid, workspace, Test)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Figure out what the test name for <pkgid> in <workspace>'s build
|
/// Figure out what the test name for <crateid> in <workspace>'s build
|
||||||
/// directory is, and if the file exists, return it.
|
/// directory is, and if the file exists, return it.
|
||||||
pub fn built_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
|
pub fn built_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
|
||||||
output_in_workspace(pkgid, workspace, Bench)
|
output_in_workspace(crateid, workspace, Bench)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Option<Path> {
|
fn output_in_workspace(crateid: &CrateId, workspace: &Path, what: OutputType) -> Option<Path> {
|
||||||
let mut result = target_build_dir(workspace);
|
let mut result = target_build_dir(workspace);
|
||||||
// should use a target-specific subdirectory
|
// should use a target-specific subdirectory
|
||||||
result = mk_output_path(what, Build, pkgid, result);
|
result = mk_output_path(what, Build, crateid, result);
|
||||||
debug!("output_in_workspace: checking whether {} exists",
|
debug!("output_in_workspace: checking whether {} exists",
|
||||||
result.display());
|
result.display());
|
||||||
if result.exists() {
|
if result.exists() {
|
||||||
|
@ -169,10 +169,11 @@ fn output_in_workspace(pkgid: &PkgId, workspace: &Path, what: OutputType) -> Opt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Figure out what the library name for <pkgid> in <workspace>'s build
|
/// Figure out what the library name for <crateid> in <workspace>'s build
|
||||||
/// directory is, and if the file exists, return it.
|
/// directory is, and if the file exists, return it.
|
||||||
pub fn built_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option<Path> {
|
pub fn built_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Option<Path> {
|
||||||
library_in_workspace(&pkgid.path, pkgid.short_name, Build, workspace, "build", &pkgid.version)
|
library_in_workspace(&crateid.path, crateid.short_name, Build, workspace, "build",
|
||||||
|
&crateid.version)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Does the actual searching stuff
|
/// Does the actual searching stuff
|
||||||
|
@ -292,45 +293,45 @@ fn library_in(short_name: &str, version: &Version, dir_to_search: &Path) -> Opti
|
||||||
abs_path
|
abs_path
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the executable that would be installed for <pkgid>
|
/// Returns the executable that would be installed for <crateid>
|
||||||
/// in <workspace>
|
/// in <workspace>
|
||||||
/// As a side effect, creates the bin-dir if it doesn't exist
|
/// As a side effect, creates the bin-dir if it doesn't exist
|
||||||
pub fn target_executable_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
pub fn target_executable_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
|
||||||
target_file_in_workspace(pkgid, workspace, Main, Install)
|
target_file_in_workspace(crateid, workspace, Main, Install)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns the executable that would be installed for <pkgid>
|
/// Returns the executable that would be installed for <crateid>
|
||||||
/// in <workspace>
|
/// in <workspace>
|
||||||
/// As a side effect, creates the lib-dir if it doesn't exist
|
/// As a side effect, creates the lib-dir if it doesn't exist
|
||||||
pub fn target_library_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
pub fn target_library_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
|
||||||
use conditions::bad_path::cond;
|
use conditions::bad_path::cond;
|
||||||
if !workspace.is_dir() {
|
if !workspace.is_dir() {
|
||||||
cond.raise(((*workspace).clone(),
|
cond.raise(((*workspace).clone(),
|
||||||
format!("Workspace supplied to target_library_in_workspace \
|
format!("Workspace supplied to target_library_in_workspace \
|
||||||
is not a directory! {}", workspace.display())));
|
is not a directory! {}", workspace.display())));
|
||||||
}
|
}
|
||||||
target_file_in_workspace(pkgid, workspace, Lib, Install)
|
target_file_in_workspace(crateid, workspace, Lib, Install)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the test executable that would be installed for <pkgid>
|
/// Returns the test executable that would be installed for <crateid>
|
||||||
/// in <workspace>
|
/// in <workspace>
|
||||||
/// note that we *don't* install test executables, so this is just for unit testing
|
/// note that we *don't* install test executables, so this is just for unit testing
|
||||||
pub fn target_test_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
pub fn target_test_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
|
||||||
target_file_in_workspace(pkgid, workspace, Test, Install)
|
target_file_in_workspace(crateid, workspace, Test, Install)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the bench executable that would be installed for <pkgid>
|
/// Returns the bench executable that would be installed for <crateid>
|
||||||
/// in <workspace>
|
/// in <workspace>
|
||||||
/// note that we *don't* install bench executables, so this is just for unit testing
|
/// note that we *don't* install bench executables, so this is just for unit testing
|
||||||
pub fn target_bench_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
pub fn target_bench_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
|
||||||
target_file_in_workspace(pkgid, workspace, Bench, Install)
|
target_file_in_workspace(crateid, workspace, Bench, Install)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Returns the path that pkgid `pkgid` would have if placed `where`
|
/// Returns the path that crateid `crateid` would have if placed `where`
|
||||||
/// in `workspace`
|
/// in `workspace`
|
||||||
fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
|
fn target_file_in_workspace(crateid: &CrateId, workspace: &Path,
|
||||||
what: OutputType, where: Target) -> Path {
|
what: OutputType, where: Target) -> Path {
|
||||||
use conditions::bad_path::cond;
|
use conditions::bad_path::cond;
|
||||||
|
|
||||||
|
@ -340,25 +341,25 @@ fn target_file_in_workspace(pkgid: &PkgId, workspace: &Path,
|
||||||
// Artifacts in the build directory live in a package-ID-specific subdirectory,
|
// Artifacts in the build directory live in a package-ID-specific subdirectory,
|
||||||
// but installed ones don't.
|
// but installed ones don't.
|
||||||
let result = match (where, what) {
|
let result = match (where, what) {
|
||||||
(Build, _) => target_build_dir(workspace).join(&pkgid.path),
|
(Build, _) => target_build_dir(workspace).join(&crateid.path),
|
||||||
(Install, Lib) => target_lib_dir(workspace),
|
(Install, Lib) => target_lib_dir(workspace),
|
||||||
(Install, _) => target_bin_dir(workspace)
|
(Install, _) => target_bin_dir(workspace)
|
||||||
};
|
};
|
||||||
if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() {
|
if io::result(|| fs::mkdir_recursive(&result, io::UserRWX)).is_err() {
|
||||||
cond.raise((result.clone(), format!("target_file_in_workspace couldn't \
|
cond.raise((result.clone(), format!("target_file_in_workspace couldn't \
|
||||||
create the {} dir (pkgid={}, workspace={}, what={:?}, where={:?}",
|
create the {} dir (crateid={}, workspace={}, what={:?}, where={:?}",
|
||||||
subdir, pkgid.to_str(), workspace.display(), what, where)));
|
subdir, crateid.to_str(), workspace.display(), what, where)));
|
||||||
}
|
}
|
||||||
mk_output_path(what, where, pkgid, result)
|
mk_output_path(what, where, crateid, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the directory for <pkgid>'s build artifacts in <workspace>.
|
/// Return the directory for <crateid>'s build artifacts in <workspace>.
|
||||||
/// Creates it if it doesn't exist.
|
/// Creates it if it doesn't exist.
|
||||||
pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
pub fn build_pkg_id_in_workspace(crateid: &CrateId, workspace: &Path) -> Path {
|
||||||
let mut result = target_build_dir(workspace);
|
let mut result = target_build_dir(workspace);
|
||||||
result.push(&pkgid.path);
|
result.push(&crateid.path);
|
||||||
debug!("Creating build dir {} for package id {}", result.display(),
|
debug!("Creating build dir {} for package id {}", result.display(),
|
||||||
pkgid.to_str());
|
crateid.to_str());
|
||||||
fs::mkdir_recursive(&result, io::UserRWX);
|
fs::mkdir_recursive(&result, io::UserRWX);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +367,7 @@ pub fn build_pkg_id_in_workspace(pkgid: &PkgId, workspace: &Path) -> Path {
|
||||||
/// Return the output file for a given directory name,
|
/// Return the output file for a given directory name,
|
||||||
/// given whether we're building a library and whether we're building tests
|
/// given whether we're building a library and whether we're building tests
|
||||||
pub fn mk_output_path(what: OutputType, where: Target,
|
pub fn mk_output_path(what: OutputType, where: Target,
|
||||||
pkg_id: &PkgId, workspace: Path) -> Path {
|
pkg_id: &CrateId, workspace: Path) -> Path {
|
||||||
let short_name_with_version = format!("{}-{}", pkg_id.short_name,
|
let short_name_with_version = format!("{}-{}", pkg_id.short_name,
|
||||||
pkg_id.version.to_str());
|
pkg_id.version.to_str());
|
||||||
// Not local_path.dir_path()! For package foo/bar/blat/, we want
|
// Not local_path.dir_path()! For package foo/bar/blat/, we want
|
||||||
|
@ -399,22 +400,22 @@ pub fn mk_output_path(what: OutputType, where: Target,
|
||||||
output_path
|
output_path
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes files for the package `pkgid`, assuming it's installed in workspace `workspace`
|
/// Removes files for the package `crateid`, assuming it's installed in workspace `workspace`
|
||||||
pub fn uninstall_package_from(workspace: &Path, pkgid: &PkgId) {
|
pub fn uninstall_package_from(workspace: &Path, crateid: &CrateId) {
|
||||||
let mut did_something = false;
|
let mut did_something = false;
|
||||||
let installed_bin = target_executable_in_workspace(pkgid, workspace);
|
let installed_bin = target_executable_in_workspace(crateid, workspace);
|
||||||
if installed_bin.exists() {
|
if installed_bin.exists() {
|
||||||
fs::unlink(&installed_bin);
|
fs::unlink(&installed_bin);
|
||||||
did_something = true;
|
did_something = true;
|
||||||
}
|
}
|
||||||
let installed_lib = target_library_in_workspace(pkgid, workspace);
|
let installed_lib = target_library_in_workspace(crateid, workspace);
|
||||||
if installed_lib.exists() {
|
if installed_lib.exists() {
|
||||||
fs::unlink(&installed_lib);
|
fs::unlink(&installed_lib);
|
||||||
did_something = true;
|
did_something = true;
|
||||||
}
|
}
|
||||||
if !did_something {
|
if !did_something {
|
||||||
warn(format!("Warning: there don't seem to be any files for {} installed in {}",
|
warn(format!("Warning: there don't seem to be any files for {} installed in {}",
|
||||||
pkgid.to_str(), workspace.display()));
|
crateid.to_str(), workspace.display()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -429,7 +430,7 @@ fn dir_has_file(dir: &Path, file: &str) -> bool {
|
||||||
dir.join(file).exists()
|
dir.join(file).exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_dir_using_rust_path_hack(p: &PkgId) -> Option<Path> {
|
pub fn find_dir_using_rust_path_hack(p: &CrateId) -> Option<Path> {
|
||||||
let rp = rust_path();
|
let rp = rust_path();
|
||||||
for dir in rp.iter() {
|
for dir in rp.iter() {
|
||||||
// Require that the parent directory match the package ID
|
// Require that the parent directory match the package ID
|
||||||
|
|
|
@ -24,7 +24,7 @@ use extra::treemap::TreeMap;
|
||||||
use extra::getopts::groups::getopts;
|
use extra::getopts::groups::getopts;
|
||||||
use std::run::ProcessOutput;
|
use std::run::ProcessOutput;
|
||||||
use installed_packages::list_installed_packages;
|
use installed_packages::list_installed_packages;
|
||||||
use package_id::{PkgId};
|
use crate_id::{CrateId};
|
||||||
use version::{ExactRevision, NoVersion, Version, Tagged};
|
use version::{ExactRevision, NoVersion, Version, Tagged};
|
||||||
use path_util::{target_executable_in_workspace, target_test_in_workspace,
|
use path_util::{target_executable_in_workspace, target_test_in_workspace,
|
||||||
target_bench_in_workspace, make_dir_rwx,
|
target_bench_in_workspace, make_dir_rwx,
|
||||||
|
@ -59,25 +59,25 @@ fn fake_ctxt(sysroot: Path, workspace: &Path) -> BuildContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fake_pkg() -> PkgId {
|
fn fake_pkg() -> CrateId {
|
||||||
let sn = ~"bogus";
|
let sn = ~"bogus";
|
||||||
PkgId {
|
CrateId {
|
||||||
path: Path::new(sn.as_slice()),
|
path: Path::new(sn.as_slice()),
|
||||||
short_name: sn,
|
short_name: sn,
|
||||||
version: NoVersion
|
version: NoVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn git_repo_pkg() -> PkgId {
|
fn git_repo_pkg() -> CrateId {
|
||||||
PkgId {
|
CrateId {
|
||||||
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
||||||
short_name: ~"test-pkg",
|
short_name: ~"test-pkg",
|
||||||
version: NoVersion
|
version: NoVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn git_repo_pkg_with_tag(a_tag: ~str) -> PkgId {
|
fn git_repo_pkg_with_tag(a_tag: ~str) -> CrateId {
|
||||||
PkgId {
|
CrateId {
|
||||||
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
path: Path::new("mockgithub.com/catamorphism/test-pkg"),
|
||||||
short_name: ~"test-pkg",
|
short_name: ~"test-pkg",
|
||||||
version: Tagged(a_tag)
|
version: Tagged(a_tag)
|
||||||
|
@ -302,15 +302,16 @@ fn command_line_test_with_env(args: &[~str], cwd: &Path, env: Option<~[(~str, ~s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_local_package(pkgid: &PkgId) -> TempDir {
|
fn create_local_package(crateid: &CrateId) -> TempDir {
|
||||||
let (workspace, parent_dir) = mk_temp_workspace(&pkgid.path, &pkgid.version);
|
let (workspace, parent_dir) = mk_temp_workspace(&crateid.path, &crateid.version);
|
||||||
debug!("Created empty package dir for {}, returning {}", pkgid.to_str(), parent_dir.display());
|
debug!("Created empty package dir for {}, returning {}", crateid.to_str(),
|
||||||
|
parent_dir.display());
|
||||||
workspace
|
workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
|
fn create_local_package_in(crateid: &CrateId, pkgdir: &Path) -> Path {
|
||||||
|
|
||||||
let package_dir = pkgdir.join_many([~"src", pkgid.to_str()]);
|
let package_dir = pkgdir.join_many([~"src", crateid.to_str()]);
|
||||||
|
|
||||||
// Create main, lib, test, and bench files
|
// Create main, lib, test, and bench files
|
||||||
fs::mkdir_recursive(&package_dir, io::UserRWX);
|
fs::mkdir_recursive(&package_dir, io::UserRWX);
|
||||||
|
@ -329,29 +330,29 @@ fn create_local_package_in(pkgid: &PkgId, pkgdir: &Path) -> Path {
|
||||||
package_dir
|
package_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_local_package_with_test(pkgid: &PkgId) -> TempDir {
|
fn create_local_package_with_test(crateid: &CrateId) -> TempDir {
|
||||||
debug!("Dry run -- would create package {:?} with test", pkgid);
|
debug!("Dry run -- would create package {:?} with test", crateid);
|
||||||
create_local_package(pkgid) // Already has tests???
|
create_local_package(crateid) // Already has tests???
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_local_package_with_dep(pkgid: &PkgId, subord_pkgid: &PkgId) -> TempDir {
|
fn create_local_package_with_dep(crateid: &CrateId, subord_crateid: &CrateId) -> TempDir {
|
||||||
let package_dir = create_local_package(pkgid);
|
let package_dir = create_local_package(crateid);
|
||||||
create_local_package_in(subord_pkgid, package_dir.path());
|
create_local_package_in(subord_crateid, package_dir.path());
|
||||||
// Write a main.rs file into pkgid that references subord_pkgid
|
// Write a main.rs file into crateid that references subord_crateid
|
||||||
writeFile(&package_dir.path().join_many([~"src", pkgid.to_str(), ~"main.rs"]),
|
writeFile(&package_dir.path().join_many([~"src", crateid.to_str(), ~"main.rs"]),
|
||||||
format!("extern mod {};\nfn main() \\{\\}",
|
format!("extern mod {};\nfn main() \\{\\}",
|
||||||
subord_pkgid.short_name));
|
subord_crateid.short_name));
|
||||||
// Write a lib.rs file into subord_pkgid that has something in it
|
// Write a lib.rs file into subord_crateid that has something in it
|
||||||
writeFile(&package_dir.path().join_many([~"src", subord_pkgid.to_str(), ~"lib.rs"]),
|
writeFile(&package_dir.path().join_many([~"src", subord_crateid.to_str(), ~"lib.rs"]),
|
||||||
"pub fn f() {}");
|
"pub fn f() {}");
|
||||||
package_dir
|
package_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_local_package_with_custom_build_hook(pkgid: &PkgId,
|
fn create_local_package_with_custom_build_hook(crateid: &CrateId,
|
||||||
custom_build_hook: &str) -> TempDir {
|
custom_build_hook: &str) -> TempDir {
|
||||||
debug!("Dry run -- would create package {} with custom build hook {}",
|
debug!("Dry run -- would create package {} with custom build hook {}",
|
||||||
pkgid.to_str(), custom_build_hook);
|
crateid.to_str(), custom_build_hook);
|
||||||
create_local_package(pkgid)
|
create_local_package(crateid)
|
||||||
// actually write the pkg.rs with the custom build hook
|
// actually write the pkg.rs with the custom build hook
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -376,18 +377,18 @@ fn assert_executable_exists(repo: &Path, short_name: &str) {
|
||||||
|
|
||||||
fn executable_exists(repo: &Path, short_name: &str) -> bool {
|
fn executable_exists(repo: &Path, short_name: &str) -> bool {
|
||||||
debug!("executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
debug!("executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
||||||
let exec = target_executable_in_workspace(&PkgId::new(short_name), repo);
|
let exec = target_executable_in_workspace(&CrateId::new(short_name), repo);
|
||||||
exec.exists() && is_rwx(&exec)
|
exec.exists() && is_rwx(&exec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_executable_exists(repo: &Path, short_name: &str) -> bool {
|
fn test_executable_exists(repo: &Path, short_name: &str) -> bool {
|
||||||
debug!("test_executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
debug!("test_executable_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
||||||
let exec = built_test_in_workspace(&PkgId::new(short_name), repo);
|
let exec = built_test_in_workspace(&CrateId::new(short_name), repo);
|
||||||
exec.map_default(false, |exec| exec.exists() && is_rwx(&exec))
|
exec.map_default(false, |exec| exec.exists() && is_rwx(&exec))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_executable_file(p: &PkgId, workspace: &Path) {
|
fn remove_executable_file(p: &CrateId, workspace: &Path) {
|
||||||
let exec = target_executable_in_workspace(&PkgId::new(p.short_name), workspace);
|
let exec = target_executable_in_workspace(&CrateId::new(p.short_name), workspace);
|
||||||
if exec.exists() {
|
if exec.exists() {
|
||||||
fs::unlink(&exec);
|
fs::unlink(&exec);
|
||||||
}
|
}
|
||||||
|
@ -400,15 +401,15 @@ fn assert_built_executable_exists(repo: &Path, short_name: &str) {
|
||||||
fn built_executable_exists(repo: &Path, short_name: &str) -> bool {
|
fn built_executable_exists(repo: &Path, short_name: &str) -> bool {
|
||||||
debug!("assert_built_executable_exists: repo = {}, short_name = {}",
|
debug!("assert_built_executable_exists: repo = {}, short_name = {}",
|
||||||
repo.display(), short_name);
|
repo.display(), short_name);
|
||||||
let exec = built_executable_in_workspace(&PkgId::new(short_name), repo);
|
let exec = built_executable_in_workspace(&CrateId::new(short_name), repo);
|
||||||
exec.is_some() && {
|
exec.is_some() && {
|
||||||
let execname = exec.get_ref();
|
let execname = exec.get_ref();
|
||||||
execname.exists() && is_rwx(execname)
|
execname.exists() && is_rwx(execname)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_built_executable_file(p: &PkgId, workspace: &Path) {
|
fn remove_built_executable_file(p: &CrateId, workspace: &Path) {
|
||||||
let exec = built_executable_in_workspace(&PkgId::new(p.short_name), workspace);
|
let exec = built_executable_in_workspace(&CrateId::new(p.short_name), workspace);
|
||||||
match exec {
|
match exec {
|
||||||
Some(r) => fs::unlink(&r),
|
Some(r) => fs::unlink(&r),
|
||||||
None => ()
|
None => ()
|
||||||
|
@ -443,7 +444,7 @@ fn assert_built_library_exists(repo: &Path, short_name: &str) {
|
||||||
|
|
||||||
fn built_library_exists(repo: &Path, short_name: &str) -> bool {
|
fn built_library_exists(repo: &Path, short_name: &str) -> bool {
|
||||||
debug!("assert_built_library_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
debug!("assert_built_library_exists: repo = {}, short_name = {}", repo.display(), short_name);
|
||||||
let lib = built_library_in_workspace(&PkgId::new(short_name), repo);
|
let lib = built_library_in_workspace(&CrateId::new(short_name), repo);
|
||||||
lib.is_some() && {
|
lib.is_some() && {
|
||||||
let libname = lib.get_ref();
|
let libname = lib.get_ref();
|
||||||
libname.exists() && is_rwx(libname)
|
libname.exists() && is_rwx(libname)
|
||||||
|
@ -493,9 +494,9 @@ fn output_file_name(workspace: &Path, short_name: ~str) -> Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
fn touch_source_file(workspace: &Path, crateid: &CrateId) {
|
||||||
use conditions::bad_path::cond;
|
use conditions::bad_path::cond;
|
||||||
let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
|
let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
|
||||||
let contents = fs::readdir(&pkg_src_dir);
|
let contents = fs::readdir(&pkg_src_dir);
|
||||||
for p in contents.iter() {
|
for p in contents.iter() {
|
||||||
if p.extension_str() == Some("rs") {
|
if p.extension_str() == Some("rs") {
|
||||||
|
@ -513,9 +514,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
fn touch_source_file(workspace: &Path, crateid: &CrateId) {
|
||||||
use conditions::bad_path::cond;
|
use conditions::bad_path::cond;
|
||||||
let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
|
let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
|
||||||
let contents = fs::readdir(&pkg_src_dir);
|
let contents = fs::readdir(&pkg_src_dir);
|
||||||
for p in contents.iter() {
|
for p in contents.iter() {
|
||||||
if p.extension_str() == Some("rs") {
|
if p.extension_str() == Some("rs") {
|
||||||
|
@ -532,9 +533,9 @@ fn touch_source_file(workspace: &Path, pkgid: &PkgId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a comment at the end
|
/// Add a comment at the end
|
||||||
fn frob_source_file(workspace: &Path, pkgid: &PkgId, filename: &str) {
|
fn frob_source_file(workspace: &Path, crateid: &CrateId, filename: &str) {
|
||||||
use conditions::bad_path::cond;
|
use conditions::bad_path::cond;
|
||||||
let pkg_src_dir = workspace.join_many([~"src", pkgid.to_str()]);
|
let pkg_src_dir = workspace.join_many([~"src", crateid.to_str()]);
|
||||||
let mut maybe_p = None;
|
let mut maybe_p = None;
|
||||||
let maybe_file = pkg_src_dir.join(filename);
|
let maybe_file = pkg_src_dir.join(filename);
|
||||||
debug!("Trying to frob {} -- {}", pkg_src_dir.display(), filename);
|
debug!("Trying to frob {} -- {}", pkg_src_dir.display(), filename);
|
||||||
|
@ -618,7 +619,7 @@ fn test_install_valid() {
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn test_install_invalid() {
|
fn test_install_invalid() {
|
||||||
let sysroot = test_sysroot();
|
let sysroot = test_sysroot();
|
||||||
let pkgid = fake_pkg();
|
let crateid = fake_pkg();
|
||||||
let temp_workspace = TempDir::new("test").expect("couldn't create temp dir");
|
let temp_workspace = TempDir::new("test").expect("couldn't create temp dir");
|
||||||
let temp_workspace = temp_workspace.path().clone();
|
let temp_workspace = temp_workspace.path().clone();
|
||||||
let ctxt = fake_ctxt(sysroot, &temp_workspace);
|
let ctxt = fake_ctxt(sysroot, &temp_workspace);
|
||||||
|
@ -628,7 +629,7 @@ fn test_install_invalid() {
|
||||||
let pkg_src = PkgSrc::new(temp_workspace.clone(),
|
let pkg_src = PkgSrc::new(temp_workspace.clone(),
|
||||||
temp_workspace.clone(),
|
temp_workspace.clone(),
|
||||||
false,
|
false,
|
||||||
pkgid.clone());
|
crateid.clone());
|
||||||
ctxt.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything));
|
ctxt.install(pkg_src, &WhatToBuild::new(MaybeCustom, Everything));
|
||||||
};
|
};
|
||||||
assert!(result.unwrap_err()
|
assert!(result.unwrap_err()
|
||||||
|
@ -637,7 +638,7 @@ fn test_install_invalid() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_install_valid_external() {
|
fn test_install_valid_external() {
|
||||||
let temp_pkg_id = PkgId::new("foo");
|
let temp_pkg_id = CrateId::new("foo");
|
||||||
let (tempdir, _) = mk_temp_workspace(&temp_pkg_id.path,
|
let (tempdir, _) = mk_temp_workspace(&temp_pkg_id.path,
|
||||||
&temp_pkg_id.version);
|
&temp_pkg_id.version);
|
||||||
let temp_workspace = tempdir.path();
|
let temp_workspace = tempdir.path();
|
||||||
|
@ -724,7 +725,7 @@ fn test_install_git() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_package_ids_must_be_relative_path_like() {
|
fn test_crate_ids_must_be_relative_path_like() {
|
||||||
use conditions::bad_pkg_id::cond;
|
use conditions::bad_pkg_id::cond;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -738,30 +739,30 @@ fn test_package_ids_must_be_relative_path_like() {
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let whatever = PkgId::new("foo");
|
let whatever = CrateId::new("foo");
|
||||||
|
|
||||||
assert_eq!(~"foo-0.0", whatever.to_str());
|
assert_eq!(~"foo-0.0", whatever.to_str());
|
||||||
assert!("github.com/catamorphism/test-pkg-0.0" ==
|
assert!("github.com/catamorphism/test-pkg-0.0" ==
|
||||||
PkgId::new("github.com/catamorphism/test-pkg").to_str());
|
CrateId::new("github.com/catamorphism/test-pkg").to_str());
|
||||||
|
|
||||||
cond.trap(|(p, e)| {
|
cond.trap(|(p, e)| {
|
||||||
assert!(p.filename().is_none())
|
assert!(p.filename().is_none())
|
||||||
assert!("0-length pkgid" == e);
|
assert!("0-length crate_id" == e);
|
||||||
whatever.clone()
|
whatever.clone()
|
||||||
}).inside(|| {
|
}).inside(|| {
|
||||||
let x = PkgId::new("");
|
let x = CrateId::new("");
|
||||||
assert_eq!(~"foo-0.0", x.to_str());
|
assert_eq!(~"foo-0.0", x.to_str());
|
||||||
});
|
});
|
||||||
|
|
||||||
cond.trap(|(p, e)| {
|
cond.trap(|(p, e)| {
|
||||||
let abs = os::make_absolute(&Path::new("foo/bar/quux"));
|
let abs = os::make_absolute(&Path::new("foo/bar/quux"));
|
||||||
assert_eq!(p, abs);
|
assert_eq!(p, abs);
|
||||||
assert!("absolute pkgid" == e);
|
assert!("absolute crate_id" == e);
|
||||||
whatever.clone()
|
whatever.clone()
|
||||||
}).inside(|| {
|
}).inside(|| {
|
||||||
let zp = os::make_absolute(&Path::new("foo/bar/quux"));
|
let zp = os::make_absolute(&Path::new("foo/bar/quux"));
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let z = PkgId::new(zp.as_str().unwrap());
|
let z = CrateId::new(zp.as_str().unwrap());
|
||||||
assert_eq!(~"foo-0.0", z.to_str());
|
assert_eq!(~"foo-0.0", z.to_str());
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -785,7 +786,7 @@ fn test_package_version() {
|
||||||
add_git_tag(&repo_subdir, ~"0.4");
|
add_git_tag(&repo_subdir, ~"0.4");
|
||||||
|
|
||||||
// It won't pick up the 0.4 version because the dir isn't in the RUST_PATH, but...
|
// It won't pick up the 0.4 version because the dir isn't in the RUST_PATH, but...
|
||||||
let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version");
|
let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version");
|
||||||
// This should look at the prefix, clone into a workspace, then build.
|
// This should look at the prefix, clone into a workspace, then build.
|
||||||
command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg_version"],
|
command_line_test([~"install", ~"mockgithub.com/catamorphism/test_pkg_version"],
|
||||||
repo);
|
repo);
|
||||||
|
@ -837,7 +838,7 @@ fn test_package_request_version() {
|
||||||
}
|
}
|
||||||
None => false
|
None => false
|
||||||
});
|
});
|
||||||
let temp_pkg_id = PkgId::new("mockgithub.com/catamorphism/test_pkg_version#0.3");
|
let temp_pkg_id = CrateId::new("mockgithub.com/catamorphism/test_pkg_version#0.3");
|
||||||
assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join(".rust"))
|
assert!(target_executable_in_workspace(&temp_pkg_id, &repo.join(".rust"))
|
||||||
== repo.join_many([".rust", "bin", "test_pkg_version"]));
|
== repo.join_many([".rust", "bin", "test_pkg_version"]));
|
||||||
|
|
||||||
|
@ -880,7 +881,7 @@ fn rustpkg_library_target() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rustpkg_local_pkg() {
|
fn rustpkg_local_pkg() {
|
||||||
let dir = create_local_package(&PkgId::new("foo"));
|
let dir = create_local_package(&CrateId::new("foo"));
|
||||||
command_line_test([~"install", ~"foo"], dir.path());
|
command_line_test([~"install", ~"foo"], dir.path());
|
||||||
assert_executable_exists(dir.path(), "foo");
|
assert_executable_exists(dir.path(), "foo");
|
||||||
}
|
}
|
||||||
|
@ -888,7 +889,7 @@ fn rustpkg_local_pkg() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(reason="busted")]
|
#[ignore(reason="busted")]
|
||||||
fn package_script_with_default_build() {
|
fn package_script_with_default_build() {
|
||||||
let dir = create_local_package(&PkgId::new("fancy-lib"));
|
let dir = create_local_package(&CrateId::new("fancy-lib"));
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
debug!("dir = {}", dir.display());
|
debug!("dir = {}", dir.display());
|
||||||
let mut source = test_sysroot().dir_path();
|
let mut source = test_sysroot().dir_path();
|
||||||
|
@ -945,7 +946,7 @@ fn rustpkg_clean_no_arg() {
|
||||||
command_line_test([~"build"], &package_dir);
|
command_line_test([~"build"], &package_dir);
|
||||||
assert_built_executable_exists(&tmp, "foo");
|
assert_built_executable_exists(&tmp, "foo");
|
||||||
command_line_test([~"clean"], &package_dir);
|
command_line_test([~"clean"], &package_dir);
|
||||||
let res = built_executable_in_workspace(&PkgId::new("foo"), &tmp);
|
let res = built_executable_in_workspace(&CrateId::new("foo"), &tmp);
|
||||||
assert!(!res.as_ref().map_default(false, |m| m.exists()));
|
assert!(!res.as_ref().map_default(false, |m| m.exists()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,11 +1004,11 @@ fn rust_path_parse() {
|
||||||
fn test_list() {
|
fn test_list() {
|
||||||
let dir = TempDir::new("test_list").expect("test_list failed");
|
let dir = TempDir::new("test_list").expect("test_list failed");
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
let foo = PkgId::new("foo");
|
let foo = CrateId::new("foo");
|
||||||
create_local_package_in(&foo, dir);
|
create_local_package_in(&foo, dir);
|
||||||
let bar = PkgId::new("bar");
|
let bar = CrateId::new("bar");
|
||||||
create_local_package_in(&bar, dir);
|
create_local_package_in(&bar, dir);
|
||||||
let quux = PkgId::new("quux");
|
let quux = CrateId::new("quux");
|
||||||
create_local_package_in(&quux, dir);
|
create_local_package_in(&quux, dir);
|
||||||
|
|
||||||
// list doesn't output very much right now...
|
// list doesn't output very much right now...
|
||||||
|
@ -1033,9 +1034,9 @@ fn test_list() {
|
||||||
fn install_remove() {
|
fn install_remove() {
|
||||||
let dir = TempDir::new("install_remove").expect("install_remove");
|
let dir = TempDir::new("install_remove").expect("install_remove");
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
let foo = PkgId::new("foo");
|
let foo = CrateId::new("foo");
|
||||||
let bar = PkgId::new("bar");
|
let bar = CrateId::new("bar");
|
||||||
let quux = PkgId::new("quux");
|
let quux = CrateId::new("quux");
|
||||||
create_local_package_in(&foo, dir);
|
create_local_package_in(&foo, dir);
|
||||||
create_local_package_in(&bar, dir);
|
create_local_package_in(&bar, dir);
|
||||||
create_local_package_in(&quux, dir);
|
create_local_package_in(&quux, dir);
|
||||||
|
@ -1062,13 +1063,13 @@ fn install_check_duplicates() {
|
||||||
// check invariant that there are no dups in the pkg database
|
// check invariant that there are no dups in the pkg database
|
||||||
let dir = TempDir::new("install_remove").expect("install_remove");
|
let dir = TempDir::new("install_remove").expect("install_remove");
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
let foo = PkgId::new("foo");
|
let foo = CrateId::new("foo");
|
||||||
create_local_package_in(&foo, dir);
|
create_local_package_in(&foo, dir);
|
||||||
|
|
||||||
command_line_test([~"install", ~"foo"], dir);
|
command_line_test([~"install", ~"foo"], dir);
|
||||||
command_line_test([~"install", ~"foo"], dir);
|
command_line_test([~"install", ~"foo"], dir);
|
||||||
let mut contents = ~[];
|
let mut contents = ~[];
|
||||||
let check_dups = |p: &PkgId| {
|
let check_dups = |p: &CrateId| {
|
||||||
if contents.contains(p) {
|
if contents.contains(p) {
|
||||||
fail!("package {} appears in `list` output more than once", p.path.display());
|
fail!("package {} appears in `list` output more than once", p.path.display());
|
||||||
}
|
}
|
||||||
|
@ -1082,7 +1083,7 @@ fn install_check_duplicates() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_rebuilding() {
|
fn no_rebuilding() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"build", ~"foo"], workspace);
|
command_line_test([~"build", ~"foo"], workspace);
|
||||||
|
@ -1103,7 +1104,7 @@ fn no_rebuilding() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore]
|
||||||
fn no_recopying() {
|
fn no_recopying() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"install", ~"foo"], workspace);
|
command_line_test([~"install", ~"foo"], workspace);
|
||||||
|
@ -1122,8 +1123,8 @@ fn no_recopying() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn no_rebuilding_dep() {
|
fn no_rebuilding_dep() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let dep_id = PkgId::new("bar");
|
let dep_id = CrateId::new("bar");
|
||||||
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"build", ~"foo"], workspace);
|
command_line_test([~"build", ~"foo"], workspace);
|
||||||
|
@ -1141,8 +1142,8 @@ fn no_rebuilding_dep() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn do_rebuild_dep_dates_change() {
|
fn do_rebuild_dep_dates_change() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let dep_id = PkgId::new("bar");
|
let dep_id = CrateId::new("bar");
|
||||||
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"build", ~"foo"], workspace);
|
command_line_test([~"build", ~"foo"], workspace);
|
||||||
|
@ -1161,8 +1162,8 @@ fn do_rebuild_dep_dates_change() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn do_rebuild_dep_only_contents_change() {
|
fn do_rebuild_dep_only_contents_change() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let dep_id = PkgId::new("bar");
|
let dep_id = CrateId::new("bar");
|
||||||
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
let workspace = create_local_package_with_dep(&p_id, &dep_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"build", ~"foo"], workspace);
|
command_line_test([~"build", ~"foo"], workspace);
|
||||||
|
@ -1182,8 +1183,8 @@ fn do_rebuild_dep_only_contents_change() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_versions() {
|
fn test_versions() {
|
||||||
let workspace = create_local_package(&PkgId::new("foo#0.1"));
|
let workspace = create_local_package(&CrateId::new("foo#0.1"));
|
||||||
let _other_workspace = create_local_package(&PkgId::new("foo#0.2"));
|
let _other_workspace = create_local_package(&CrateId::new("foo#0.2"));
|
||||||
command_line_test([~"install", ~"foo#0.1"], workspace.path());
|
command_line_test([~"install", ~"foo#0.1"], workspace.path());
|
||||||
let output = command_line_test_output([~"list"]);
|
let output = command_line_test_output([~"list"]);
|
||||||
// make sure output includes versions
|
// make sure output includes versions
|
||||||
|
@ -1193,7 +1194,7 @@ fn test_versions() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(reason = "do not yet implemented")]
|
#[ignore(reason = "do not yet implemented")]
|
||||||
fn test_build_hooks() {
|
fn test_build_hooks() {
|
||||||
let workspace = create_local_package_with_custom_build_hook(&PkgId::new("foo"),
|
let workspace = create_local_package_with_custom_build_hook(&CrateId::new("foo"),
|
||||||
"frob");
|
"frob");
|
||||||
command_line_test([~"do", ~"foo", ~"frob"], workspace.path());
|
command_line_test([~"do", ~"foo", ~"frob"], workspace.path());
|
||||||
}
|
}
|
||||||
|
@ -1203,14 +1204,14 @@ fn test_build_hooks() {
|
||||||
#[ignore(reason = "info not yet implemented")]
|
#[ignore(reason = "info not yet implemented")]
|
||||||
fn test_info() {
|
fn test_info() {
|
||||||
let expected_info = ~"package foo"; // fill in
|
let expected_info = ~"package foo"; // fill in
|
||||||
let workspace = create_local_package(&PkgId::new("foo"));
|
let workspace = create_local_package(&CrateId::new("foo"));
|
||||||
let output = command_line_test([~"info", ~"foo"], workspace.path());
|
let output = command_line_test([~"info", ~"foo"], workspace.path());
|
||||||
assert_eq!(str::from_utf8_owned(output.output), expected_info);
|
assert_eq!(str::from_utf8_owned(output.output), expected_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uninstall() {
|
fn test_uninstall() {
|
||||||
let workspace = create_local_package(&PkgId::new("foo"));
|
let workspace = create_local_package(&CrateId::new("foo"));
|
||||||
command_line_test([~"uninstall", ~"foo"], workspace.path());
|
command_line_test([~"uninstall", ~"foo"], workspace.path());
|
||||||
let output = command_line_test([~"list"], workspace.path());
|
let output = command_line_test([~"list"], workspace.path());
|
||||||
assert!(!str::from_utf8(output.output).contains("foo"));
|
assert!(!str::from_utf8(output.output).contains("foo"));
|
||||||
|
@ -1346,7 +1347,7 @@ fn test_extern_mod_simpler() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_import_rustpkg() {
|
fn test_import_rustpkg() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
|
writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
|
||||||
|
@ -1359,7 +1360,7 @@ fn test_import_rustpkg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_macro_pkg_script() {
|
fn test_macro_pkg_script() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
|
writeFile(&workspace.join_many(["src", "foo-0.0", "pkg.rs"]),
|
||||||
|
@ -1386,7 +1387,7 @@ fn multiple_workspaces() {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let env = Some(~[(~"RUST_PATH", format!("{}:{}", a_loc.as_str().unwrap(),
|
let env = Some(~[(~"RUST_PATH", format!("{}:{}", a_loc.as_str().unwrap(),
|
||||||
b_loc.as_str().unwrap()))]);
|
b_loc.as_str().unwrap()))]);
|
||||||
let c_loc = create_local_package_with_dep(&PkgId::new("bar"), &PkgId::new("foo"));
|
let c_loc = create_local_package_with_dep(&CrateId::new("bar"), &CrateId::new("foo"));
|
||||||
command_line_test_with_env([~"install", ~"bar"], c_loc.path(), env);
|
command_line_test_with_env([~"install", ~"bar"], c_loc.path(), env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1399,7 +1400,7 @@ fn rust_path_hack_test(hack_flag: bool) {
|
||||||
make sure built files for foo are in B
|
make sure built files for foo are in B
|
||||||
make sure nothing gets built into A or A/../build[lib,bin]
|
make sure nothing gets built into A or A/../build[lib,bin]
|
||||||
*/
|
*/
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||||
|
@ -1524,8 +1525,8 @@ fn rust_path_hack_build_no_arg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rust_path_hack_build_with_dependency() {
|
fn rust_path_hack_build_with_dependency() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let dep_id = PkgId::new("dep");
|
let dep_id = CrateId::new("dep");
|
||||||
// Tests that when --rust-path-hack is in effect, dependencies get built
|
// Tests that when --rust-path-hack is in effect, dependencies get built
|
||||||
// into the destination workspace and not the source directory
|
// into the destination workspace and not the source directory
|
||||||
let work_dir = create_local_package(&foo_id);
|
let work_dir = create_local_package(&foo_id);
|
||||||
|
@ -1573,7 +1574,7 @@ fn rust_path_install_target() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sysroot_flag() {
|
fn sysroot_flag() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
// no-op sysroot setting; I'm not sure how else to test this
|
// no-op sysroot setting; I'm not sure how else to test this
|
||||||
|
@ -1589,7 +1590,7 @@ fn sysroot_flag() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_flag_build() {
|
fn compile_flag_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1606,7 +1607,7 @@ fn compile_flag_build() {
|
||||||
#[test]
|
#[test]
|
||||||
fn compile_flag_fail() {
|
fn compile_flag_fail() {
|
||||||
// --no-link shouldn't be accepted for install
|
// --no-link shouldn't be accepted for install
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1622,7 +1623,7 @@ fn compile_flag_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn notrans_flag_build() {
|
fn notrans_flag_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let flags_to_test = [~"--no-trans", ~"--parse-only",
|
let flags_to_test = [~"--no-trans", ~"--parse-only",
|
||||||
|
@ -1647,7 +1648,7 @@ fn notrans_flag_build() {
|
||||||
#[test]
|
#[test]
|
||||||
fn notrans_flag_fail() {
|
fn notrans_flag_fail() {
|
||||||
// --no-trans shouldn't be accepted for install
|
// --no-trans shouldn't be accepted for install
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let flags_to_test = [~"--no-trans", ~"--parse-only",
|
let flags_to_test = [~"--no-trans", ~"--parse-only",
|
||||||
|
@ -1668,7 +1669,7 @@ fn notrans_flag_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dash_S() {
|
fn dash_S() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1685,7 +1686,7 @@ fn dash_S() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dash_S_fail() {
|
fn dash_S_fail() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1702,7 +1703,7 @@ fn dash_S_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cfg_build() {
|
fn test_cfg_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
// If the cfg flag gets messed up, this won't compile
|
// If the cfg flag gets messed up, this won't compile
|
||||||
|
@ -1721,7 +1722,7 @@ fn test_cfg_build() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cfg_fail() {
|
fn test_cfg_fail() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
writeFile(&workspace.join_many(["src", "foo-0.0", "main.rs"]),
|
writeFile(&workspace.join_many(["src", "foo-0.0", "main.rs"]),
|
||||||
|
@ -1740,7 +1741,7 @@ fn test_cfg_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_emit_llvm_S_build() {
|
fn test_emit_llvm_S_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1758,7 +1759,7 @@ fn test_emit_llvm_S_build() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_emit_llvm_S_fail() {
|
fn test_emit_llvm_S_fail() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1778,7 +1779,7 @@ fn test_emit_llvm_S_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_emit_llvm_build() {
|
fn test_emit_llvm_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1797,7 +1798,7 @@ fn test_emit_llvm_build() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_emit_llvm_fail() {
|
fn test_emit_llvm_fail() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1818,7 +1819,7 @@ fn test_emit_llvm_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_linker_build() {
|
fn test_linker_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let matches = getopts([], optgroups());
|
let matches = getopts([], optgroups());
|
||||||
|
@ -1863,7 +1864,7 @@ fn test_build_install_flags_fail() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_optimized_build() {
|
fn test_optimized_build() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1877,7 +1878,7 @@ fn test_optimized_build() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn pkgid_pointing_to_subdir() {
|
fn crateid_pointing_to_subdir() {
|
||||||
// The actual repo is mockgithub.com/mozilla/some_repo
|
// The actual repo is mockgithub.com/mozilla/some_repo
|
||||||
// rustpkg should recognize that and treat the part after some_repo/ as a subdir
|
// rustpkg should recognize that and treat the part after some_repo/ as a subdir
|
||||||
let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir");
|
let workspace = TempDir::new("parent_repo").expect("Couldn't create temp dir");
|
||||||
|
@ -1913,9 +1914,9 @@ fn pkgid_pointing_to_subdir() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_recursive_deps() {
|
fn test_recursive_deps() {
|
||||||
let a_id = PkgId::new("a");
|
let a_id = CrateId::new("a");
|
||||||
let b_id = PkgId::new("b");
|
let b_id = CrateId::new("b");
|
||||||
let c_id = PkgId::new("c");
|
let c_id = CrateId::new("c");
|
||||||
let b_workspace = create_local_package_with_dep(&b_id, &c_id);
|
let b_workspace = create_local_package_with_dep(&b_id, &c_id);
|
||||||
let b_workspace = b_workspace.path();
|
let b_workspace = b_workspace.path();
|
||||||
writeFile(&b_workspace.join_many(["src", "c-0.0", "lib.rs"]),
|
writeFile(&b_workspace.join_many(["src", "c-0.0", "lib.rs"]),
|
||||||
|
@ -1939,7 +1940,7 @@ fn test_recursive_deps() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_install_to_rust_path() {
|
fn test_install_to_rust_path() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let second_workspace = create_local_package(&p_id);
|
let second_workspace = create_local_package(&p_id);
|
||||||
let second_workspace = second_workspace.path();
|
let second_workspace = second_workspace.path();
|
||||||
let first_workspace = mk_empty_workspace(&Path::new("p"), &NoVersion, "dest");
|
let first_workspace = mk_empty_workspace(&Path::new("p"), &NoVersion, "dest");
|
||||||
|
@ -1963,7 +1964,7 @@ fn test_install_to_rust_path() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_target_specific_build_dir() {
|
fn test_target_specific_build_dir() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1979,7 +1980,7 @@ fn test_target_specific_build_dir() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_target_specific_install_dir() {
|
fn test_target_specific_install_dir() {
|
||||||
let p_id = PkgId::new("foo");
|
let p_id = CrateId::new("foo");
|
||||||
let workspace = create_local_package(&p_id);
|
let workspace = create_local_package(&p_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let test_sys = test_sysroot();
|
let test_sys = test_sysroot();
|
||||||
|
@ -1998,7 +1999,7 @@ fn test_target_specific_install_dir() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(reason = "See #7240")]
|
#[ignore(reason = "See #7240")]
|
||||||
fn test_dependencies_terminate() {
|
fn test_dependencies_terminate() {
|
||||||
let b_id = PkgId::new("b");
|
let b_id = CrateId::new("b");
|
||||||
let workspace = create_local_package(&b_id);
|
let workspace = create_local_package(&b_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
let b_dir = workspace.join_many(["src", "b-0.0"]);
|
let b_dir = workspace.join_many(["src", "b-0.0"]);
|
||||||
|
@ -2011,7 +2012,7 @@ fn test_dependencies_terminate() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn install_after_build() {
|
fn install_after_build() {
|
||||||
let b_id = PkgId::new("b");
|
let b_id = CrateId::new("b");
|
||||||
let workspace = create_local_package(&b_id);
|
let workspace = create_local_package(&b_id);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
command_line_test([~"build", ~"b"], workspace);
|
command_line_test([~"build", ~"b"], workspace);
|
||||||
|
@ -2022,7 +2023,7 @@ fn install_after_build() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn reinstall() {
|
fn reinstall() {
|
||||||
let b = PkgId::new("b");
|
let b = CrateId::new("b");
|
||||||
let workspace = create_local_package(&b);
|
let workspace = create_local_package(&b);
|
||||||
let workspace = workspace.path();
|
let workspace = workspace.path();
|
||||||
// 1. Install, then remove executable file, then install again,
|
// 1. Install, then remove executable file, then install again,
|
||||||
|
@ -2061,8 +2062,8 @@ fn correct_package_name_with_rust_path_hack() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Set RUST_PATH to something containing only the sources for foo
|
// Set RUST_PATH to something containing only the sources for foo
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let bar_id = PkgId::new("bar");
|
let bar_id = CrateId::new("bar");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
let dest_workspace = mk_empty_workspace(&Path::new("bar"), &NoVersion, "dest_workspace");
|
||||||
|
@ -2091,7 +2092,7 @@ fn correct_package_name_with_rust_path_hack() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rustpkg_test_creates_exec() {
|
fn test_rustpkg_test_creates_exec() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
||||||
|
@ -2102,7 +2103,7 @@ fn test_rustpkg_test_creates_exec() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rustpkg_test_output() {
|
fn test_rustpkg_test_output() {
|
||||||
let workspace = create_local_package_with_test(&PkgId::new("foo"));
|
let workspace = create_local_package_with_test(&CrateId::new("foo"));
|
||||||
let output = command_line_test([~"test", ~"foo"], workspace.path());
|
let output = command_line_test([~"test", ~"foo"], workspace.path());
|
||||||
let output_str = str::from_utf8(output.output);
|
let output_str = str::from_utf8(output.output);
|
||||||
// The first two assertions are separate because test output may
|
// The first two assertions are separate because test output may
|
||||||
|
@ -2114,7 +2115,7 @@ fn test_rustpkg_test_output() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rustpkg_test_failure_exit_status() {
|
fn test_rustpkg_test_failure_exit_status() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
||||||
|
@ -2128,7 +2129,7 @@ fn test_rustpkg_test_failure_exit_status() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rustpkg_test_cfg() {
|
fn test_rustpkg_test_cfg() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
writeFile(&foo_workspace.join_many(["src", "foo-0.0", "test.rs"]),
|
||||||
|
@ -2141,7 +2142,7 @@ fn test_rustpkg_test_cfg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_rebuild_when_needed() {
|
fn test_rebuild_when_needed() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
|
let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
|
||||||
|
@ -2162,7 +2163,7 @@ fn test_rebuild_when_needed() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute
|
#[ignore] // FIXME (#10257): This doesn't work as is since a read only file can't execute
|
||||||
fn test_no_rebuilding() {
|
fn test_no_rebuilding() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
|
let test_crate = foo_workspace.join_many(["src", "foo-0.0", "test.rs"]);
|
||||||
|
@ -2196,7 +2197,7 @@ fn test_installed_read_only() {
|
||||||
writeFile(&repo_subdir.join("lib.rs"),
|
writeFile(&repo_subdir.join("lib.rs"),
|
||||||
"pub fn f() { let _x = (); }");
|
"pub fn f() { let _x = (); }");
|
||||||
add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
|
add_git_tag(&repo_subdir, ~"0.1"); // this has the effect of committing the files
|
||||||
// update pkgid to what will be auto-detected
|
// update crateid to what will be auto-detected
|
||||||
temp_pkg_id.version = ExactRevision(~"0.1");
|
temp_pkg_id.version = ExactRevision(~"0.1");
|
||||||
|
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
|
@ -2281,7 +2282,7 @@ fn test_installed_local_changes() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_7402() {
|
fn test_7402() {
|
||||||
let dir = create_local_package(&PkgId::new("foo"));
|
let dir = create_local_package(&CrateId::new("foo"));
|
||||||
let dest_workspace = TempDir::new("more_rust").expect("test_7402");
|
let dest_workspace = TempDir::new("more_rust").expect("test_7402");
|
||||||
let dest_workspace = dest_workspace.path();
|
let dest_workspace = dest_workspace.path();
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
|
@ -2295,7 +2296,7 @@ fn test_7402() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_compile_error() {
|
fn test_compile_error() {
|
||||||
let foo_id = PkgId::new("foo");
|
let foo_id = CrateId::new("foo");
|
||||||
let foo_workspace = create_local_package(&foo_id);
|
let foo_workspace = create_local_package(&foo_id);
|
||||||
let foo_workspace = foo_workspace.path();
|
let foo_workspace = foo_workspace.path();
|
||||||
let main_crate = foo_workspace.join_many(["src", "foo-0.0", "main.rs"]);
|
let main_crate = foo_workspace.join_many(["src", "foo-0.0", "main.rs"]);
|
||||||
|
@ -2329,7 +2330,7 @@ fn test_c_dependency_ok() {
|
||||||
// registers a hook to build it if it's not fresh
|
// registers a hook to build it if it's not fresh
|
||||||
// After running `build`, test that the C library built
|
// After running `build`, test that the C library built
|
||||||
|
|
||||||
let dir = create_local_package(&PkgId::new("cdep"));
|
let dir = create_local_package(&CrateId::new("cdep"));
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
||||||
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
||||||
|
@ -2352,7 +2353,7 @@ fn test_c_dependency_ok() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(reason="busted")]
|
#[ignore(reason="busted")]
|
||||||
fn test_c_dependency_no_rebuilding() {
|
fn test_c_dependency_no_rebuilding() {
|
||||||
let dir = create_local_package(&PkgId::new("cdep"));
|
let dir = create_local_package(&CrateId::new("cdep"));
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
||||||
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
||||||
|
@ -2386,7 +2387,7 @@ fn test_c_dependency_no_rebuilding() {
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore(reason="busted")]
|
#[ignore(reason="busted")]
|
||||||
fn test_c_dependency_yes_rebuilding() {
|
fn test_c_dependency_yes_rebuilding() {
|
||||||
let dir = create_local_package(&PkgId::new("cdep"));
|
let dir = create_local_package(&CrateId::new("cdep"));
|
||||||
let dir = dir.path();
|
let dir = dir.path();
|
||||||
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
writeFile(&dir.join_many(["src", "cdep-0.0", "main.rs"]),
|
||||||
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
"#[link_args = \"-lfoo\"]\nextern { fn f(); } \
|
||||||
|
@ -2407,7 +2408,7 @@ fn test_c_dependency_yes_rebuilding() {
|
||||||
assert!(c_library_path.exists());
|
assert!(c_library_path.exists());
|
||||||
|
|
||||||
// Now, make the Rust library read-only so rebuilding will fail
|
// Now, make the Rust library read-only so rebuilding will fail
|
||||||
match built_library_in_workspace(&PkgId::new("cdep"), dir) {
|
match built_library_in_workspace(&CrateId::new("cdep"), dir) {
|
||||||
Some(ref pth) => assert!(chmod_read_only(pth)),
|
Some(ref pth) => assert!(chmod_read_only(pth)),
|
||||||
None => assert_built_library_exists(dir, "cdep")
|
None => assert_built_library_exists(dir, "cdep")
|
||||||
}
|
}
|
||||||
|
@ -2425,7 +2426,7 @@ fn test_c_dependency_yes_rebuilding() {
|
||||||
fn correct_error_dependency() {
|
fn correct_error_dependency() {
|
||||||
// Supposing a package we're trying to install via a dependency doesn't
|
// Supposing a package we're trying to install via a dependency doesn't
|
||||||
// exist, we should throw a condition, and not ICE
|
// exist, we should throw a condition, and not ICE
|
||||||
let workspace_dir = create_local_package(&PkgId::new("badpkg"));
|
let workspace_dir = create_local_package(&CrateId::new("badpkg"));
|
||||||
|
|
||||||
let dir = workspace_dir.path();
|
let dir = workspace_dir.path();
|
||||||
let main_rs = dir.join_many(["src", "badpkg-0.0", "main.rs"]);
|
let main_rs = dir.join_many(["src", "badpkg-0.0", "main.rs"]);
|
||||||
|
|
|
@ -29,7 +29,7 @@ use syntax::util::small_vector::SmallVector;
|
||||||
use rustc::back::link::output_type_exe;
|
use rustc::back::link::output_type_exe;
|
||||||
use rustc::back::link;
|
use rustc::back::link;
|
||||||
use context::{in_target, StopBefore, Link, Assemble, BuildContext};
|
use context::{in_target, StopBefore, Link, Assemble, BuildContext};
|
||||||
use package_id::PkgId;
|
use crate_id::CrateId;
|
||||||
use package_source::PkgSrc;
|
use package_source::PkgSrc;
|
||||||
use workspace::pkg_parent_workspaces;
|
use workspace::pkg_parent_workspaces;
|
||||||
use path_util::{system_library, target_build_dir};
|
use path_util::{system_library, target_build_dir};
|
||||||
|
@ -52,7 +52,7 @@ static COMMANDS: &'static [&'static str] =
|
||||||
pub type ExitCode = int; // For now
|
pub type ExitCode = int; // For now
|
||||||
|
|
||||||
pub struct Pkg {
|
pub struct Pkg {
|
||||||
id: PkgId,
|
id: CrateId,
|
||||||
bins: ~[~str],
|
bins: ~[~str],
|
||||||
libs: ~[~str],
|
libs: ~[~str],
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ pub fn ready_crate(sess: session::Session,
|
||||||
|
|
||||||
pub fn compile_input(context: &BuildContext,
|
pub fn compile_input(context: &BuildContext,
|
||||||
exec: &mut workcache::Exec,
|
exec: &mut workcache::Exec,
|
||||||
pkg_id: &PkgId,
|
pkg_id: &CrateId,
|
||||||
in_file: &Path,
|
in_file: &Path,
|
||||||
workspace: &Path,
|
workspace: &Path,
|
||||||
deps: &mut DepMap,
|
deps: &mut DepMap,
|
||||||
|
@ -303,17 +303,17 @@ pub fn compile_input(context: &BuildContext,
|
||||||
addl_lib_search_paths.get().insert(p);
|
addl_lib_search_paths.get().insert(p);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Inject the pkgid attribute so we get the right package name and version
|
// Inject the crate_id attribute so we get the right package name and version
|
||||||
if !attr::contains_name(crate.attrs, "crate_id") {
|
if !attr::contains_name(crate.attrs, "crate_id") {
|
||||||
// FIXME (#9639): This needs to handle non-utf8 paths
|
// FIXME (#9639): This needs to handle non-utf8 paths
|
||||||
let pkgid_attr =
|
let crateid_attr =
|
||||||
attr::mk_name_value_item_str(@"crate_id",
|
attr::mk_name_value_item_str(@"crate_id",
|
||||||
format!("{}\\#{}",
|
format!("{}\\#{}",
|
||||||
pkg_id.path.as_str().unwrap(),
|
pkg_id.path.as_str().unwrap(),
|
||||||
pkg_id.version.to_str()).to_managed());
|
pkg_id.version.to_str()).to_managed());
|
||||||
|
|
||||||
debug!("pkgid attr: {:?}", pkgid_attr);
|
debug!("crateid attr: {:?}", crateid_attr);
|
||||||
crate.attrs.push(attr::mk_attr(pkgid_attr));
|
crate.attrs.push(attr::mk_attr(crateid_attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("calling compile_crate_from_input, workspace = {},
|
debug!("calling compile_crate_from_input, workspace = {},
|
||||||
|
@ -428,7 +428,7 @@ pub fn exe_suffix() -> ~str { ~"" }
|
||||||
// Called by build_crates
|
// Called by build_crates
|
||||||
pub fn compile_crate(ctxt: &BuildContext,
|
pub fn compile_crate(ctxt: &BuildContext,
|
||||||
exec: &mut workcache::Exec,
|
exec: &mut workcache::Exec,
|
||||||
pkg_id: &PkgId,
|
pkg_id: &CrateId,
|
||||||
crate: &Path,
|
crate: &Path,
|
||||||
workspace: &Path,
|
workspace: &Path,
|
||||||
deps: &mut DepMap,
|
deps: &mut DepMap,
|
||||||
|
@ -446,7 +446,7 @@ pub fn compile_crate(ctxt: &BuildContext,
|
||||||
|
|
||||||
struct ViewItemVisitor<'a> {
|
struct ViewItemVisitor<'a> {
|
||||||
context: &'a BuildContext,
|
context: &'a BuildContext,
|
||||||
parent: &'a PkgId,
|
parent: &'a CrateId,
|
||||||
parent_crate: &'a Path,
|
parent_crate: &'a Path,
|
||||||
sess: session::Session,
|
sess: session::Session,
|
||||||
exec: &'a mut workcache::Exec,
|
exec: &'a mut workcache::Exec,
|
||||||
|
@ -491,7 +491,7 @@ impl<'a> Visitor<()> for ViewItemVisitor<'a> {
|
||||||
debug!("Trying to install library {}, rebuilding it",
|
debug!("Trying to install library {}, rebuilding it",
|
||||||
lib_name.to_str());
|
lib_name.to_str());
|
||||||
// Try to install it
|
// Try to install it
|
||||||
let pkg_id = PkgId::new(lib_name);
|
let pkg_id = CrateId::new(lib_name);
|
||||||
// Find all the workspaces in the RUST_PATH that contain this package.
|
// Find all the workspaces in the RUST_PATH that contain this package.
|
||||||
let workspaces = pkg_parent_workspaces(&self.context.context,
|
let workspaces = pkg_parent_workspaces(&self.context.context,
|
||||||
&pkg_id);
|
&pkg_id);
|
||||||
|
@ -607,7 +607,7 @@ impl<'a> Visitor<()> for ViewItemVisitor<'a> {
|
||||||
/// try to install their targets, failing if any target
|
/// try to install their targets, failing if any target
|
||||||
/// can't be found.
|
/// can't be found.
|
||||||
pub fn find_and_install_dependencies(context: &BuildContext,
|
pub fn find_and_install_dependencies(context: &BuildContext,
|
||||||
parent: &PkgId,
|
parent: &CrateId,
|
||||||
parent_crate: &Path,
|
parent_crate: &Path,
|
||||||
sess: session::Session,
|
sess: session::Session,
|
||||||
exec: &mut workcache::Exec,
|
exec: &mut workcache::Exec,
|
||||||
|
|
|
@ -13,23 +13,23 @@
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use context::Context;
|
use context::Context;
|
||||||
use path_util::{workspace_contains_package_id, find_dir_using_rust_path_hack, default_workspace};
|
use path_util::{workspace_contains_crate_id, find_dir_using_rust_path_hack, default_workspace};
|
||||||
use path_util::rust_path;
|
use path_util::rust_path;
|
||||||
use util::option_to_vec;
|
use util::option_to_vec;
|
||||||
use package_id::PkgId;
|
use crate_id::CrateId;
|
||||||
|
|
||||||
pub fn each_pkg_parent_workspace(cx: &Context,
|
pub fn each_pkg_parent_workspace(cx: &Context,
|
||||||
pkgid: &PkgId,
|
crateid: &CrateId,
|
||||||
action: |&Path| -> bool)
|
action: |&Path| -> bool)
|
||||||
-> bool {
|
-> bool {
|
||||||
// Using the RUST_PATH, find workspaces that contain
|
// Using the RUST_PATH, find workspaces that contain
|
||||||
// this package ID
|
// this package ID
|
||||||
let workspaces = pkg_parent_workspaces(cx, pkgid);
|
let workspaces = pkg_parent_workspaces(cx, crateid);
|
||||||
if workspaces.is_empty() {
|
if workspaces.is_empty() {
|
||||||
// tjc: make this a condition
|
// tjc: make this a condition
|
||||||
fail!("Package {} not found in any of \
|
fail!("Package {} not found in any of \
|
||||||
the following workspaces: {}",
|
the following workspaces: {}",
|
||||||
pkgid.path.display(),
|
crateid.path.display(),
|
||||||
rust_path().map(|p| p.display().to_str()).to_str());
|
rust_path().map(|p| p.display().to_str()).to_str());
|
||||||
}
|
}
|
||||||
for ws in workspaces.iter() {
|
for ws in workspaces.iter() {
|
||||||
|
@ -42,12 +42,12 @@ pub fn each_pkg_parent_workspace(cx: &Context,
|
||||||
|
|
||||||
/// Given a package ID, return a vector of all of the workspaces in
|
/// Given a package ID, return a vector of all of the workspaces in
|
||||||
/// the RUST_PATH that contain it
|
/// the RUST_PATH that contain it
|
||||||
pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
|
pub fn pkg_parent_workspaces(cx: &Context, crateid: &CrateId) -> ~[Path] {
|
||||||
let rs: ~[Path] = rust_path().move_iter()
|
let rs: ~[Path] = rust_path().move_iter()
|
||||||
.filter(|ws| workspace_contains_package_id(pkgid, ws))
|
.filter(|ws| workspace_contains_crate_id(crateid, ws))
|
||||||
.collect();
|
.collect();
|
||||||
if cx.use_rust_path_hack {
|
if cx.use_rust_path_hack {
|
||||||
rs + option_to_vec(find_dir_using_rust_path_hack(pkgid))
|
rs + option_to_vec(find_dir_using_rust_path_hack(crateid))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rs
|
rs
|
||||||
|
@ -56,7 +56,7 @@ pub fn pkg_parent_workspaces(cx: &Context, pkgid: &PkgId) -> ~[Path] {
|
||||||
|
|
||||||
/// Construct a workspace and package-ID name based on the current directory.
|
/// Construct a workspace and package-ID name based on the current directory.
|
||||||
/// This gets used when rustpkg gets invoked without a package-ID argument.
|
/// This gets used when rustpkg gets invoked without a package-ID argument.
|
||||||
pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
|
pub fn cwd_to_workspace() -> Option<(Path, CrateId)> {
|
||||||
let cwd = os::getcwd();
|
let cwd = os::getcwd();
|
||||||
for path in rust_path().move_iter() {
|
for path in rust_path().move_iter() {
|
||||||
let srcpath = path.join("src");
|
let srcpath = path.join("src");
|
||||||
|
@ -64,7 +64,7 @@ pub fn cwd_to_workspace() -> Option<(Path, PkgId)> {
|
||||||
let rel = cwd.path_relative_from(&srcpath);
|
let rel = cwd.path_relative_from(&srcpath);
|
||||||
let rel_s = rel.as_ref().and_then(|p|p.as_str());
|
let rel_s = rel.as_ref().and_then(|p|p.as_str());
|
||||||
if rel_s.is_some() {
|
if rel_s.is_some() {
|
||||||
return Some((path, PkgId::new(rel_s.unwrap())));
|
return Some((path, CrateId::new(rel_s.unwrap())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use codemap::{Span, Spanned, spanned, dummy_spanned};
|
||||||
use codemap::BytePos;
|
use codemap::BytePos;
|
||||||
use diagnostic::span_handler;
|
use diagnostic::span_handler;
|
||||||
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
||||||
use pkgid::PkgId;
|
use crateid::CrateId;
|
||||||
|
|
||||||
use std::hashmap::HashSet;
|
use std::hashmap::HashSet;
|
||||||
|
|
||||||
|
@ -234,10 +234,10 @@ pub fn find_linkage_metas(attrs: &[Attribute]) -> ~[@MetaItem] {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_pkgid(attrs: &[Attribute]) -> Option<PkgId> {
|
pub fn find_crateid(attrs: &[Attribute]) -> Option<CrateId> {
|
||||||
match first_attr_value_str_by_name(attrs, "crate_id") {
|
match first_attr_value_str_by_name(attrs, "crate_id") {
|
||||||
None => None,
|
None => None,
|
||||||
Some(id) => from_str::<PkgId>(id),
|
Some(id) => from_str::<CrateId>(id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,15 +8,15 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
/// PkgIds identify crates and include the crate name and optionall a path and
|
/// CrateIds identify crates and include the crate name and optionally a path
|
||||||
/// version. In the full form, they look like relative URLs. Example:
|
/// and version. In the full form, they look like relative URLs. Example:
|
||||||
/// `github.com/mozilla/rust#std:1.0` would be a package ID with a path of
|
/// `github.com/mozilla/rust#std:1.0` would be a package ID with a path of
|
||||||
/// `gitub.com/mozilla/rust` and a crate name of `std` with a version of
|
/// `gitub.com/mozilla/rust` and a crate name of `std` with a version of
|
||||||
/// `1.0`. If no crate name is given after the hash, the name is inferred to
|
/// `1.0`. If no crate name is given after the hash, the name is inferred to
|
||||||
/// be the last component of the path. If no version is given, it is inferred
|
/// be the last component of the path. If no version is given, it is inferred
|
||||||
/// to be `0.0`.
|
/// to be `0.0`.
|
||||||
#[deriving(Clone, Eq)]
|
#[deriving(Clone, Eq)]
|
||||||
pub struct PkgId {
|
pub struct CrateId {
|
||||||
/// A path which represents the codes origin. By convention this is the
|
/// A path which represents the codes origin. By convention this is the
|
||||||
/// URL, without `http://` or `https://` prefix, to the crate's repository
|
/// URL, without `http://` or `https://` prefix, to the crate's repository
|
||||||
path: ~str,
|
path: ~str,
|
||||||
|
@ -26,7 +26,7 @@ pub struct PkgId {
|
||||||
version: Option<~str>,
|
version: Option<~str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToStr for PkgId {
|
impl ToStr for CrateId {
|
||||||
fn to_str(&self) -> ~str {
|
fn to_str(&self) -> ~str {
|
||||||
let version = match self.version {
|
let version = match self.version {
|
||||||
None => "0.0",
|
None => "0.0",
|
||||||
|
@ -40,8 +40,8 @@ impl ToStr for PkgId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for PkgId {
|
impl FromStr for CrateId {
|
||||||
fn from_str(s: &str) -> Option<PkgId> {
|
fn from_str(s: &str) -> Option<CrateId> {
|
||||||
let pieces: ~[&str] = s.splitn('#', 1).collect();
|
let pieces: ~[&str] = s.splitn('#', 1).collect();
|
||||||
let path = pieces[0].to_owned();
|
let path = pieces[0].to_owned();
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ impl FromStr for PkgId {
|
||||||
(name, version)
|
(name, version)
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(PkgId {
|
Some(CrateId {
|
||||||
path: path,
|
path: path,
|
||||||
name: name,
|
name: name,
|
||||||
version: version,
|
version: version,
|
||||||
|
@ -86,7 +86,7 @@ impl FromStr for PkgId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PkgId {
|
impl CrateId {
|
||||||
pub fn version_or_default<'a>(&'a self) -> &'a str {
|
pub fn version_or_default<'a>(&'a self) -> &'a str {
|
||||||
match self.version {
|
match self.version {
|
||||||
None => "0.0",
|
None => "0.0",
|
||||||
|
@ -97,90 +97,90 @@ impl PkgId {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bare_name() {
|
fn bare_name() {
|
||||||
let pkgid: PkgId = from_str("foo").expect("valid pkgid");
|
let crateid: CrateId = from_str("foo").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"foo");
|
assert_eq!(crateid.name, ~"foo");
|
||||||
assert_eq!(pkgid.version, None);
|
assert_eq!(crateid.version, None);
|
||||||
assert_eq!(pkgid.path, ~"foo");
|
assert_eq!(crateid.path, ~"foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn bare_name_single_char() {
|
fn bare_name_single_char() {
|
||||||
let pkgid: PkgId = from_str("f").expect("valid pkgid");
|
let crateid: CrateId = from_str("f").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"f");
|
assert_eq!(crateid.name, ~"f");
|
||||||
assert_eq!(pkgid.version, None);
|
assert_eq!(crateid.version, None);
|
||||||
assert_eq!(pkgid.path, ~"f");
|
assert_eq!(crateid.path, ~"f");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_pkgid() {
|
fn empty_crateid() {
|
||||||
let pkgid: Option<PkgId> = from_str("");
|
let crateid: Option<CrateId> = from_str("");
|
||||||
assert!(pkgid.is_none());
|
assert!(crateid.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_path() {
|
fn simple_path() {
|
||||||
let pkgid: PkgId = from_str("example.com/foo/bar").expect("valid pkgid");
|
let crateid: CrateId = from_str("example.com/foo/bar").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"bar");
|
assert_eq!(crateid.name, ~"bar");
|
||||||
assert_eq!(pkgid.version, None);
|
assert_eq!(crateid.version, None);
|
||||||
assert_eq!(pkgid.path, ~"example.com/foo/bar");
|
assert_eq!(crateid.path, ~"example.com/foo/bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_version() {
|
fn simple_version() {
|
||||||
let pkgid: PkgId = from_str("foo#1.0").expect("valid pkgid");
|
let crateid: CrateId = from_str("foo#1.0").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"foo");
|
assert_eq!(crateid.name, ~"foo");
|
||||||
assert_eq!(pkgid.version, Some(~"1.0"));
|
assert_eq!(crateid.version, Some(~"1.0"));
|
||||||
assert_eq!(pkgid.path, ~"foo");
|
assert_eq!(crateid.path, ~"foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn absolute_path() {
|
fn absolute_path() {
|
||||||
let pkgid: Option<PkgId> = from_str("/foo/bar");
|
let crateid: Option<CrateId> = from_str("/foo/bar");
|
||||||
assert!(pkgid.is_none());
|
assert!(crateid.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn path_ends_with_slash() {
|
fn path_ends_with_slash() {
|
||||||
let pkgid: Option<PkgId> = from_str("foo/bar/");
|
let crateid: Option<CrateId> = from_str("foo/bar/");
|
||||||
assert!(pkgid.is_none());
|
assert!(crateid.is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn path_and_version() {
|
fn path_and_version() {
|
||||||
let pkgid: PkgId = from_str("example.com/foo/bar#1.0").expect("valid pkgid");
|
let crateid: CrateId = from_str("example.com/foo/bar#1.0").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"bar");
|
assert_eq!(crateid.name, ~"bar");
|
||||||
assert_eq!(pkgid.version, Some(~"1.0"));
|
assert_eq!(crateid.version, Some(~"1.0"));
|
||||||
assert_eq!(pkgid.path, ~"example.com/foo/bar");
|
assert_eq!(crateid.path, ~"example.com/foo/bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn single_chars() {
|
fn single_chars() {
|
||||||
let pkgid: PkgId = from_str("a/b#1").expect("valid pkgid");
|
let crateid: CrateId = from_str("a/b#1").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"b");
|
assert_eq!(crateid.name, ~"b");
|
||||||
assert_eq!(pkgid.version, Some(~"1"));
|
assert_eq!(crateid.version, Some(~"1"));
|
||||||
assert_eq!(pkgid.path, ~"a/b");
|
assert_eq!(crateid.path, ~"a/b");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn missing_version() {
|
fn missing_version() {
|
||||||
let pkgid: PkgId = from_str("foo#").expect("valid pkgid");
|
let crateid: CrateId = from_str("foo#").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"foo");
|
assert_eq!(crateid.name, ~"foo");
|
||||||
assert_eq!(pkgid.version, None);
|
assert_eq!(crateid.version, None);
|
||||||
assert_eq!(pkgid.path, ~"foo");
|
assert_eq!(crateid.path, ~"foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn path_and_name() {
|
fn path_and_name() {
|
||||||
let pkgid: PkgId = from_str("foo/rust-bar#bar:1.0").expect("valid pkgid");
|
let crateid: CrateId = from_str("foo/rust-bar#bar:1.0").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"bar");
|
assert_eq!(crateid.name, ~"bar");
|
||||||
assert_eq!(pkgid.version, Some(~"1.0"));
|
assert_eq!(crateid.version, Some(~"1.0"));
|
||||||
assert_eq!(pkgid.path, ~"foo/rust-bar");
|
assert_eq!(crateid.path, ~"foo/rust-bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn empty_name() {
|
fn empty_name() {
|
||||||
let pkgid: PkgId = from_str("foo/bar#:1.0").expect("valid pkgid");
|
let crateid: CrateId = from_str("foo/bar#:1.0").expect("valid crateid");
|
||||||
assert_eq!(pkgid.name, ~"bar");
|
assert_eq!(crateid.name, ~"bar");
|
||||||
assert_eq!(pkgid.version, Some(~"1.0"));
|
assert_eq!(crateid.version, Some(~"1.0"));
|
||||||
assert_eq!(pkgid.path, ~"foo/bar");
|
assert_eq!(crateid.path, ~"foo/bar");
|
||||||
}
|
}
|
|
@ -47,7 +47,7 @@ pub mod fold;
|
||||||
|
|
||||||
|
|
||||||
pub mod parse;
|
pub mod parse;
|
||||||
pub mod pkgid;
|
pub mod crateid;
|
||||||
|
|
||||||
pub mod print {
|
pub mod print {
|
||||||
pub mod pp;
|
pub mod pp;
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
pub struct PkgId {
|
pub struct CrateId {
|
||||||
local_path: ~str,
|
local_path: ~str,
|
||||||
junk: ~str
|
junk: ~str
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PkgId {
|
impl CrateId {
|
||||||
fn new(s: &str) -> PkgId {
|
fn new(s: &str) -> CrateId {
|
||||||
PkgId {
|
CrateId {
|
||||||
local_path: s.to_owned(),
|
local_path: s.to_owned(),
|
||||||
junk: ~"wutevs"
|
junk: ~"wutevs"
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ impl PkgId {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_package_from_database() {
|
pub fn remove_package_from_database() {
|
||||||
let mut lines_to_use: ~[&PkgId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
|
let mut lines_to_use: ~[&CrateId] = ~[]; //~ ERROR cannot infer an appropriate lifetime
|
||||||
let push_id = |installed_id: &PkgId| {
|
let push_id = |installed_id: &CrateId| {
|
||||||
lines_to_use.push(installed_id);
|
lines_to_use.push(installed_id);
|
||||||
};
|
};
|
||||||
list_database(push_id);
|
list_database(push_id);
|
||||||
|
@ -35,11 +35,11 @@ pub fn remove_package_from_database() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_database(f: |&PkgId|) {
|
pub fn list_database(f: |&CrateId|) {
|
||||||
let stuff = ["foo", "bar"];
|
let stuff = ["foo", "bar"];
|
||||||
|
|
||||||
for l in stuff.iter() {
|
for l in stuff.iter() {
|
||||||
f(&PkgId::new(*l));
|
f(&CrateId::new(*l));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue