annotate build.sh @ 786:8b5ea56e7507

Teach build.sh not to rebuild static compilers if they're already there.
author Rob Landley <rob@landley.net>
date Sun, 05 Jul 2009 23:38:49 -0500
parents 5ed920fc2ea5
children dee27a32b160
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
96
137ba51ee993 Delete output directories on re-run, teach build to log and build multiple
Rob Landley <rob@landley.net>
parents: 93
diff changeset
1 #!/bin/bash
137ba51ee993 Delete output directories on re-run, teach build to log and build multiple
Rob Landley <rob@landley.net>
parents: 93
diff changeset
2
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
3 # If run with no arguments, list architectures.
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
4
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
5 ARCH="$1"
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
6
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
7 if [ $# -ne 1 ]
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
8 then
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
9 echo "Usage: $0 ARCH"
744
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 719
diff changeset
10 . sources/include.sh
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 719
diff changeset
11 read_arch_dir
759adf5a0fe9 Refactor so include.sh mostly just sets environment variables. Move read_arch_dir to function and call it explicitly (no more need for $NO_ARCH). Make blank_tempdir a function, called explicitly by stages when needed, with some sanity checks. Insert prerequisite tests to later stages so they can detect failure early and provide an explicit erro rmessage, and have those tests happen before blanking $WORK dir, to preserve debugging info. Make buildall.sh depend on prerequisite tests rather than trying to avoid calling later stages (and thus do flow control from asynchronous context). Add FAIL_QUIET option so buildall.sh doesn't spam the log with the new prerequisite error messages.
Rob Landley <rob@landley.net>
parents: 719
diff changeset
12
118
85582f847bd6 When run with no arguments, exit after showing usage message.
Rob Landley <rob@landley.net>
parents: 114
diff changeset
13 exit 1
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
14 fi
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
15
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
16 # Download source code and build host tools.
108
b66d638a3844 Build User Mode Linux and have that do the ext2 packaging (for now, anyway).
Rob Landley <rob@landley.net>
parents: 105
diff changeset
17
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
18 ./download.sh || exit 1
262
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
19
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
20 # host-tools populates one directory with every command the build needs,
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
21 # so we can ditch the old $PATH afterwards.
b2e353ae7566 Have host-tools populate build/host with 1) toybox, 2) all the remaining
Rob Landley <rob@landley.net>
parents: 186
diff changeset
22
186
f8dac531cbb5 Use shell builtin time instead of /usr/bin version not everybody has.
Rob Landley <rob@landley.net>
parents: 184
diff changeset
23 time ./host-tools.sh || exit 1
114
304fd441e6a4 Re-teach build.sh to build more than one architecture in sequence.
Rob Landley <rob@landley.net>
parents: 108
diff changeset
24
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
25 not_already()
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
26 {
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
27 if [ -f "build/$1-$ARCH.tar.bz2" ]
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
28 then
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
29 echo "=== Skipping $1-$ARCH (already there)"
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
30 return 1
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
31 fi
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
32
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
33 return 0
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
34 }
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
35
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
36 echo "=== Building ARCH $1"
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
37
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
38 # Do we need to build the cross compiler?
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
39
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
40 # This version is --disable shared, doesn't include uClibc++, and is
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
41 # dynamically linked against the host's shared libraries.
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
42
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
43 if not_already cross-compiler
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
44 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
45 # If we need to build cross compiler, assume root filesystem is stale.
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
46
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
47 rm -rf "build/root-filesystem-$ARCH.tar.bz2"
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
48 time ./cross-compiler.sh "$ARCH" || exit 1
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
49 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
50
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
51 # Optionally, we can build a statically linked compiler via canadian cross.
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
52
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
53 # We don't autodetect the host because i686 is more portable (running on
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
54 # both 64 and 32 bit hosts), but x86_64 is (slightly) faster on a 64 bit host.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
55
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
56 if [ ! -z "$STATIC_CROSS_COMPILER_HOST" ] && not_already cross-static
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
57 then
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
58
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
59 # These are statically linked against uClibc on the host (for portability),
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
60 # built --with-shared, and have uClibc++ installed.
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
61
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
62 # To build each of these we need two existing cross compilers: one for
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
63 # the host (to build the executables) and one for the target (to build
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
64 # the libraries).
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
65
785
5ed920fc2ea5 Bugfix, missed a variable rename.
Rob Landley <rob@landley.net>
parents: 784
diff changeset
66 BUILD_STATIC=1 FROM_ARCH="$STATIC_CROSS_COMPILER_HOST" NATIVE_TOOLCHAIN=only \
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
67 STAGE_NAME=cross-static ./root-filesystem.sh "$ARCH"
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
68
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
69 # Replace the dynamic cross compiler with the static one so the rest of
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
70 # the build uses the new one.
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
71
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
72 rm -rf "build/cross-compiler-$ARCH" &&
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
73 ln -s "cross-static-$ARCH" "build/cross-compiler-$ARCH" || exit 1
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
74 fi
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
75
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
76 # Optionally, we can build a static native compiler. (The one in
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
77 # root-filesystem is dynamically linked against uClibc, this one can
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
78 # presumably be untarred and run on any appropriate host system.)
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
79
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
80 if [ ! -z "$BUILD_STATIC_NATIVE_COMPILER" ] && not_already native-compiler
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
81 then
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
82
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
83 # Build static native compilers for each target, possibly in parallel
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
84
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
85 BUILD_STATIC=1 NATIVE_TOOLCHAIN=only STAGE_NAME=native-compiler \
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
86 ./root-filesystem.sh "$ARCH"
784
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
87 fi
037488e9889d New build.sh that actually uses the new infrastructure, if STATIC_CROSS_COMPILER_HOST or BUILD_STATIC_NATIVE_COMPILER are set.
Rob Landley <rob@landley.net>
parents: 781
diff changeset
88
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
89 # Do we need to build the root filesystem?
539
85979aa53fde Teach build.sh not to rerun build stages we already have the result of.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
90
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
91 if not_already root-filesystem
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
92 then
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
93
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
94 # If we need to build root filesystem, assume system image is stale.
539
85979aa53fde Teach build.sh not to rerun build stages we already have the result of.
Rob Landley <rob@landley.net>
parents: 503
diff changeset
95
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
96 rm -rf "build/system-image-$ARCH.tar.bz2"
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
97 time ./root-filesystem.sh "$ARCH" || exit 1
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
98 fi
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
99
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
100 if not_already system-image
781
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
101 then
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
102 time ./system-image.sh $1 || exit 1
d8c780ed3686 Simplify build.sh to take exactly one argument. (Otherwise use buildall.sh.)
Rob Landley <rob@landley.net>
parents: 744
diff changeset
103 fi
786
8b5ea56e7507 Teach build.sh not to rebuild static compilers if they're already there.
Rob Landley <rob@landley.net>
parents: 785
diff changeset
104