-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement infrastructure for the souped-up build command #792
Changes from all commits
e3f60a7
82e65c3
019d515
34ace11
f888b4b
15f1040
5ae2846
9cca8c5
f4790de
d712fdd
d9066f6
87ad442
4358288
6391536
a0d499e
3b21f7a
cde3b1e
8960dd1
bf30c8c
a5c868a
f62d6c6
2a17e9e
800d9eb
92b07cb
2833358
85a96e4
c05442a
5e29a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,8 @@ pub struct Manifest { | |
targets: Vec<Target>, | ||
target_dir: Path, | ||
doc_dir: Path, | ||
build: Vec<String>, | ||
build: Vec<String>, // TODO: deprecated, remove | ||
links: Option<String>, | ||
warnings: Vec<String>, | ||
exclude: Vec<String>, | ||
metadata: ManifestMetadata, | ||
|
@@ -59,7 +60,7 @@ pub struct SerializedManifest { | |
targets: Vec<Target>, | ||
target_dir: String, | ||
doc_dir: String, | ||
build: Option<Vec<String>>, | ||
build: Option<Vec<String>>, // TODO: deprecated, remove | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
} | ||
|
||
impl<E, S: Encoder<E>> Encodable<S, E> for Manifest { | ||
|
@@ -73,6 +74,7 @@ impl<E, S: Encoder<E>> Encodable<S, E> for Manifest { | |
targets: self.targets.clone(), | ||
target_dir: self.target_dir.display().to_string(), | ||
doc_dir: self.doc_dir.display().to_string(), | ||
// TODO: deprecated, remove | ||
build: if self.build.len() == 0 { None } else { Some(self.build.clone()) }, | ||
}.encode(s) | ||
} | ||
|
@@ -131,8 +133,9 @@ pub struct Profile { | |
doctest: bool, | ||
doc: bool, | ||
dest: Option<String>, | ||
plugin: bool, | ||
for_host: bool, | ||
harness: bool, // whether to use the test harness (--test) | ||
custom_build: bool, | ||
} | ||
|
||
impl Profile { | ||
|
@@ -146,8 +149,9 @@ impl Profile { | |
test: false, | ||
doc: false, | ||
dest: None, | ||
plugin: false, | ||
for_host: false, | ||
doctest: false, | ||
custom_build: false, | ||
harness: true, | ||
} | ||
} | ||
|
@@ -219,8 +223,13 @@ impl Profile { | |
self.doctest | ||
} | ||
|
||
pub fn is_plugin(&self) -> bool { | ||
self.plugin | ||
pub fn is_custom_build(&self) -> bool { | ||
self.custom_build | ||
} | ||
|
||
/// Returns true if the target must be built for the host instead of the target. | ||
pub fn is_for_host(&self) -> bool { | ||
self.for_host | ||
} | ||
|
||
pub fn get_opt_level(&self) -> uint { | ||
|
@@ -282,15 +291,22 @@ impl Profile { | |
self | ||
} | ||
|
||
pub fn plugin(mut self, plugin: bool) -> Profile { | ||
self.plugin = plugin; | ||
/// Sets whether the `Target` must be compiled for the host instead of the target platform. | ||
pub fn for_host(mut self, for_host: bool) -> Profile { | ||
self.for_host = for_host; | ||
self | ||
} | ||
|
||
pub fn harness(mut self, harness: bool) -> Profile { | ||
self.harness = harness; | ||
self | ||
} | ||
|
||
/// Sets whether the `Target` is a custom build script. | ||
pub fn custom_build(mut self, custom_build: bool) -> Profile { | ||
self.custom_build = custom_build; | ||
self | ||
} | ||
} | ||
|
||
impl<H: hash::Writer> hash::Hash<H> for Profile { | ||
|
@@ -302,7 +318,7 @@ impl<H: hash::Writer> hash::Hash<H> for Profile { | |
codegen_units, | ||
debug, | ||
rpath, | ||
plugin, | ||
for_host, | ||
ref dest, | ||
harness, | ||
|
||
|
@@ -313,8 +329,10 @@ impl<H: hash::Writer> hash::Hash<H> for Profile { | |
env: _, | ||
test: _, | ||
doctest: _, | ||
|
||
custom_build: _, | ||
} = *self; | ||
(opt_level, codegen_units, debug, rpath, plugin, dest, harness).hash(into) | ||
(opt_level, codegen_units, debug, rpath, for_host, dest, harness).hash(into) | ||
} | ||
} | ||
|
||
|
@@ -366,16 +384,17 @@ impl Show for Target { | |
impl Manifest { | ||
pub fn new(summary: Summary, targets: Vec<Target>, | ||
target_dir: Path, doc_dir: Path, | ||
build: Vec<String>, exclude: Vec<String>, | ||
build: Vec<String>, exclude: Vec<String>, links: Option<String>, | ||
metadata: ManifestMetadata) -> Manifest { | ||
Manifest { | ||
summary: summary, | ||
targets: targets, | ||
target_dir: target_dir, | ||
doc_dir: doc_dir, | ||
build: build, | ||
build: build, // TODO: deprecated, remove | ||
warnings: Vec::new(), | ||
exclude: exclude, | ||
links: links, | ||
metadata: metadata, | ||
} | ||
} | ||
|
@@ -416,6 +435,10 @@ impl Manifest { | |
self.build.as_slice() | ||
} | ||
|
||
pub fn get_links(&self) -> Option<&str> { | ||
self.links.as_ref().map(|s| s.as_slice()) | ||
} | ||
|
||
pub fn add_warning(&mut self, s: String) { | ||
self.warnings.push(s) | ||
} | ||
|
@@ -466,6 +489,18 @@ impl Target { | |
} | ||
} | ||
|
||
/// Builds a `Target` corresponding to the `build = "build.rs"` entry. | ||
pub fn custom_build_target(name: &str, src_path: &Path, profile: &Profile, | ||
metadata: Option<Metadata>) -> Target { | ||
Target { | ||
kind: BinTarget, | ||
name: name.to_string(), | ||
src_path: src_path.clone(), | ||
profile: profile.clone(), | ||
metadata: metadata, | ||
} | ||
} | ||
|
||
pub fn example_target(name: &str, src_path: &Path, profile: &Profile) -> Target { | ||
Target { | ||
kind: ExampleTarget, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ pub struct Compilation { | |
/// | ||
/// This is currently used to drive some entries which are added to the | ||
/// LD_LIBRARY_PATH as appropriate. | ||
// TODO: deprecated, remove | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this TODO correct, @alexcrichton? I.e. should I PR the removal of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh dear that's a good question, this PR is... quite old though! I vaguely remember placing this on a few things throughout Cargo I've wished I deleted at the time and then never got to, but removing this would be good if it's not actually used in Cargo today! (or if it's actually used just remove the comment) |
||
pub native_dirs: HashMap<PackageId, Path>, | ||
|
||
/// Root output directory (for the local package's artifacts) | ||
|
@@ -43,7 +44,7 @@ impl Compilation { | |
pub fn new(pkg: &Package) -> Compilation { | ||
Compilation { | ||
libraries: HashMap::new(), | ||
native_dirs: HashMap::new(), | ||
native_dirs: HashMap::new(), // TODO: deprecated, remove | ||
root_output: Path::new("/"), | ||
deps_output: Path::new("/"), | ||
tests: Vec::new(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the stability markers not work here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now these are actually just markers of what to remove once we remove the old system of build cmd, not necessarily for deprecated functionality itself.