Skip to content

Commit a51cf8f

Browse files
committed
---
yaml --- r: 92172 b: refs/heads/auto c: fce4a17 h: refs/heads/master v: v3
1 parent ee0e2b3 commit a51cf8f

File tree

21 files changed

+433
-125
lines changed

21 files changed

+433
-125
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 52b835c5e7a68b32a8f0532f178c150d09be200d
16+
refs/heads/auto: fce4a174b9ffff71a66feecd9f4960f17fc9c331
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/back/archive.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
4242
}
4343
let o = Process::new(ar, args.as_slice(), opts).finish_with_output();
4444
if !o.status.success() {
45-
sess.err(format!("{} failed with: {}", ar, o.status));
45+
sess.err(format!("{} {} failed with: {}", ar, args.connect(" "),
46+
o.status));
4647
sess.note(format!("stdout ---\n{}", str::from_utf8(o.output)));
4748
sess.note(format!("stderr ---\n{}", str::from_utf8(o.error)));
4849
sess.abort_if_errors();
@@ -88,16 +89,34 @@ impl Archive {
8889

8990
/// Adds all of the contents of the rlib at the specified path to this
9091
/// archive.
91-
pub fn add_rlib(&mut self, rlib: &Path) {
92-
let name = rlib.filename_str().unwrap().split('-').next().unwrap();
93-
self.add_archive(rlib, name, [METADATA_FILENAME]);
92+
///
93+
/// This ignores adding the bytecode from the rlib, and if LTO is enabled
94+
/// then the object file also isn't added.
95+
pub fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool) {
96+
let object = format!("{}.o", name);
97+
let bytecode = format!("{}.bc", name);
98+
let mut ignore = ~[METADATA_FILENAME, bytecode.as_slice()];
99+
if lto {
100+
ignore.push(object.as_slice());
101+
}
102+
self.add_archive(rlib, name, ignore);
94103
}
95104

96105
/// Adds an arbitrary file to this archive
97106
pub fn add_file(&mut self, file: &Path) {
98107
run_ar(self.sess, "r", None, [&self.dst, file]);
99108
}
100109

110+
/// Removes a file from this archive
111+
pub fn remove_file(&mut self, file: &str) {
112+
run_ar(self.sess, "d", None, [&self.dst, &Path::new(file)]);
113+
}
114+
115+
pub fn files(&self) -> ~[~str] {
116+
let output = run_ar(self.sess, "t", None, [&self.dst]);
117+
str::from_utf8(output.output).lines().map(|s| s.to_owned()).collect()
118+
}
119+
101120
fn add_archive(&mut self, archive: &Path, name: &str, skip: &[&str]) {
102121
let loc = TempDir::new("rsar").unwrap();
103122

@@ -109,11 +128,17 @@ impl Archive {
109128
// The reason for this is that archives are keyed off the name of the
110129
// files, so if two files have the same name they will override one
111130
// another in the archive (bad).
131+
//
132+
// We skip any files explicitly desired for skipping, and we also skip
133+
// all SYMDEF files as these are just magical placeholders which get
134+
// re-created when we make a new archive anyway.
112135
let files = fs::readdir(loc.path());
113136
let mut inputs = ~[];
114137
for file in files.iter() {
115138
let filename = file.filename_str().unwrap();
116139
if skip.iter().any(|s| *s == filename) { continue }
140+
if filename.contains(".SYMDEF") { continue }
141+
117142
let filename = format!("r-{}-{}", name, filename);
118143
let new_filename = file.with_filename(filename);
119144
fs::rename(file, &new_filename);

0 commit comments

Comments
 (0)