@@ -25,19 +25,31 @@ index 0000000..e161e91
25
25
+ path = "../liblibc"
26
26
diff --git a/src/liballoc/build.rs b/src/liballoc/build.rs
27
27
new file mode 100644
28
- index 0000000..13da524
28
+ index 0000000..7fb1260
29
29
--- /dev/null
30
30
+++ b/src/liballoc/build.rs
31
- @@ -0,0 +1,196 @@
31
+ @@ -0,0 +1,208 @@
32
32
+ #![allow(dead_code)]
33
33
+
34
34
+ use std::fs::File;
35
35
+ use std::io::Read;
36
36
+ use std::ops::Range;
37
37
+ use std::path::{Path, PathBuf};
38
- + use std::process::Command;
38
+ + use std::process::{ Command, ExitStatus} ;
39
39
+ use std::{env, fs, iter};
40
40
+
41
+ + trait StatusOrPanic {
42
+ + fn status_or_panic(&mut self) -> ExitStatus;
43
+ + }
44
+ +
45
+ + impl StatusOrPanic for Command {
46
+ + fn status_or_panic(&mut self) -> ExitStatus {
47
+ + self.status().unwrap_or_else(|_| {
48
+ + panic!("error: failed to execute {:?}", self)
49
+ + })
50
+ + }
51
+ + }
52
+ +
41
53
+ fn main() {
42
54
+ let ref ctxt = Ctxt::new().unwrap();
43
55
+
@@ -204,14 +216,14 @@ index 0000000..13da524
204
216
+ .arg(format!("RANLIB={} s", ar))
205
217
+ .arg(format!("CPPFLAGS=-I {}", ctxt.src().join("../rt/").display()))
206
218
+ .arg("EXTRA_CFLAGS=-g1 -ffunction-sections -fdata-sections")
207
- + .status().unwrap ().success()
219
+ + .status_or_panic ().success()
208
220
+ }
209
221
+
210
222
+ assert! {
211
223
+ Command::new("make")
212
224
+ .arg("-C").arg(dst)
213
225
+ .arg(if dynamic { "build_lib_shared" } else { "build_lib_static" })
214
- + .status().unwrap ().success()
226
+ + .status_or_panic ().success()
215
227
+ }
216
228
+
217
229
+ if dynamic {
@@ -378,10 +390,10 @@ index 0000000..cb7a399
378
390
+ path = "../librustc_unicode"
379
391
diff --git a/src/libstd/build.rs b/src/libstd/build.rs
380
392
new file mode 100644
381
- index 0000000..13400eb
393
+ index 0000000..5f03064
382
394
--- /dev/null
383
395
+++ b/src/libstd/build.rs
384
- @@ -0,0 +1,308 @@
396
+ @@ -0,0 +1,320 @@
385
397
+ #![allow(dead_code)]
386
398
+
387
399
+ extern crate gcc;
@@ -391,9 +403,21 @@ index 0000000..13400eb
391
403
+ use std::io::{Read, Write};
392
404
+ use std::ops::{Range, RangeTo};
393
405
+ use std::path::{Path, PathBuf};
394
- + use std::process::Command;
406
+ + use std::process::{ Command, ExitStatus} ;
395
407
+ use std::{env, iter};
396
408
+
409
+ + trait StatusOrPanic {
410
+ + fn status_or_panic(&mut self) -> ExitStatus;
411
+ + }
412
+ +
413
+ + impl StatusOrPanic for Command {
414
+ + fn status_or_panic(&mut self) -> ExitStatus {
415
+ + self.status().unwrap_or_else(|_| {
416
+ + panic!("error: failed to execute {:?}", self)
417
+ + })
418
+ + }
419
+ + }
420
+ +
397
421
+ fn main() {
398
422
+ let ref ctxt = Ctxt::new().unwrap();
399
423
+
@@ -575,7 +599,7 @@ index 0000000..13400eb
575
599
+ .env("CFLAGS", cflags.connect(" "))
576
600
+ .arg(format!("--target={}", ctxt.target()))
577
601
+ .arg(format!("--host={}", ctxt.host()))
578
- + .status().unwrap ().success()
602
+ + .status_or_panic ().success()
579
603
+ }
580
604
+
581
605
+ let mut options = OpenOptions::new();
@@ -592,7 +616,7 @@ index 0000000..13400eb
592
616
+ Command::new("make")
593
617
+ .arg(format!("INCDIR={}", src.display()))
594
618
+ .arg("-C").arg(build_dir)
595
- + .status().unwrap ().success()
619
+ + .status_or_panic ().success()
596
620
+ }
597
621
+
598
622
+ fs::copy(build_dir.join(".libs/libbacktrace.a"), dst.join("libbacktrace.a")).unwrap();
@@ -613,7 +637,7 @@ index 0000000..13400eb
613
637
+ .arg("-relocation-model=pic")
614
638
+ .arg("-o").arg(dst.join("rust_try.o"))
615
639
+ .arg(src.join("../rt/rust_try.ll"))
616
- + .status().unwrap ().success()
640
+ + .status_or_panic ().success()
617
641
+ }
618
642
+
619
643
+ let mut cmd = Command::new(ctxt.cc());
@@ -626,7 +650,7 @@ index 0000000..13400eb
626
650
+ .arg(src.join(format!("../rt/arch/{}/record_sp.S", ctxt.arch())))
627
651
+ .arg("-c")
628
652
+ .arg("-o").arg(dst.join("record_sp.o"))
629
- + .status().unwrap ().success()
653
+ + .status_or_panic ().success()
630
654
+ }
631
655
+
632
656
+ assert! {
@@ -635,7 +659,7 @@ index 0000000..13400eb
635
659
+ .arg(dst.join("librustrt_native.a"))
636
660
+ .arg(dst.join("rust_try.o"))
637
661
+ .arg(dst.join("record_sp.o"))
638
- + .status().unwrap ().success()
662
+ + .status_or_panic ().success()
639
663
+ }
640
664
+
641
665
+ println!("cargo:rustc-link-lib=static=rustrt_native");
@@ -653,15 +677,15 @@ index 0000000..13400eb
653
677
+ .arg(format!("-triple={}", ctxt.target()))
654
678
+ .arg("-o").arg(dst.join("morestack.o"))
655
679
+ .arg(ctxt.src().join(format!("../rt/arch/{}/morestack.S", ctxt.arch())))
656
- + .status().unwrap ().success()
680
+ + .status_or_panic ().success()
657
681
+ }
658
682
+
659
683
+ assert! {
660
684
+ Command::new(ctxt.ar())
661
685
+ .arg("crus")
662
686
+ .arg(dst.join("libmorestack.a"))
663
687
+ .arg(dst.join("morestack.o"))
664
- + .status().unwrap ().success()
688
+ + .status_or_panic ().success()
665
689
+ }
666
690
+ }
667
691
+
@@ -685,7 +709,7 @@ index 0000000..13400eb
685
709
+ .arg(format!("ProjObjRoot={}", build_dir.display()))
686
710
+ .arg(format!("TargetTriple={}", ctxt.target()))
687
711
+ .arg("triple-builtins")
688
- + .status().unwrap ().success()
712
+ + .status_or_panic ().success()
689
713
+ }
690
714
+
691
715
+ fs::copy(build_dir.join("triple/builtins/libcompiler_rt.a"), dst.join("libcompiler-rt.a")).unwrap();
0 commit comments