1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Build
|
4 | #
|
5 | # Usage:
|
6 | # soil/cpp-build.sh
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | #REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
|
13 | #source soil/common.sh
|
14 |
|
15 | OILS_VERSION=$(head -n 1 oil-version.txt)
|
16 | OILS_TRANSLATOR=${OILS_TRANSLATOR:-mycpp}
|
17 |
|
18 | build-like-ninja() {
|
19 | local tar=_release/oils-for-unix.tar
|
20 |
|
21 | if test -f build.ninja; then
|
22 | # Just use Ninja
|
23 |
|
24 | local -a targets=()
|
25 | for variant in "$@"; do
|
26 | targets+=( _bin/cxx-$variant/{oils-for-unix,osh,ysh} )
|
27 | done
|
28 | ninja "${targets[@]}"
|
29 |
|
30 | elif test -f $tar; then
|
31 | # Build out of the tarball, but put in WHERE NINJA would have put it
|
32 |
|
33 | local tmp=_tmp/native-tar-test # like oil-tar-test
|
34 |
|
35 | # Don't defeat SKIP_REBUILD
|
36 | #rm -r -f $tmp
|
37 |
|
38 | mkdir -p $tmp
|
39 | pushd $tmp
|
40 |
|
41 | if ! test -d oils-for-unix-$OILS_VERSION; then
|
42 | tar -x < ../../$tar
|
43 | fi
|
44 |
|
45 | # Leaving out version
|
46 | pushd oils-for-unix-$OILS_VERSION
|
47 |
|
48 | ./configure
|
49 |
|
50 | for variant in "$@"; do
|
51 | time _build/oils.sh '' $variant $OILS_TRANSLATOR SKIP_REBUILD
|
52 | done
|
53 |
|
54 | popd
|
55 | popd
|
56 |
|
57 | # Hack: copy to NInja location. So the interface is the same.
|
58 | for variant in "$@"; do
|
59 | local out_bin_dir
|
60 | local tar_bin_dir
|
61 | case $OILS_TRANSLATOR in
|
62 | mycpp)
|
63 | out_bin_dir=_bin/cxx-$variant
|
64 | tar_bin_dir=_bin/cxx-$variant-sh
|
65 | ;;
|
66 | *)
|
67 | out_bin_dir=_bin/cxx-$variant/$OILS_TRANSLATOR
|
68 | tar_bin_dir=_bin/cxx-$variant-sh/$OILS_TRANSLATOR
|
69 | ;;
|
70 | esac
|
71 | mkdir -v -p $out_bin_dir
|
72 | cp -v \
|
73 | $tmp/oils-for-unix-$OILS_VERSION/$tar_bin_dir/{oils-for-unix,osh,ysh} \
|
74 | $out_bin_dir
|
75 | done
|
76 |
|
77 | else
|
78 | echo "Expected either build.ninja or $tar"
|
79 | exit 1
|
80 | fi
|
81 | }
|
82 |
|
83 | "$@"
|