OILS / soil / cpp-tarball.sh View on Github | oilshell.org

84 lines, 51 significant
1#!/usr/bin/env bash
2#
3# Build
4#
5# Usage:
6# soil/cpp-build.sh
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12#REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
13#source soil/common.sh
14
15OILS_VERSION=$(head -n 1 oil-version.txt)
16OILS_TRANSLATOR=${OILS_TRANSLATOR:-mycpp}
17
18build-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 \
52 --variant "$variant" --translator "$OILS_TRANSLATOR" --skip-rebuild
53 done
54
55 popd
56 popd
57
58 # Hack: copy to NInja location. So the interface is the same.
59 for variant in "$@"; do
60 local out_bin_dir
61 local tar_bin_dir
62 case $OILS_TRANSLATOR in
63 mycpp)
64 out_bin_dir=_bin/cxx-$variant
65 tar_bin_dir=_bin/cxx-$variant-sh
66 ;;
67 *)
68 out_bin_dir=_bin/cxx-$variant/$OILS_TRANSLATOR
69 tar_bin_dir=_bin/cxx-$variant-sh/$OILS_TRANSLATOR
70 ;;
71 esac
72 mkdir -v -p $out_bin_dir
73 cp -v \
74 $tmp/oils-for-unix-$OILS_VERSION/$tar_bin_dir/{oils-for-unix,osh,ysh} \
75 $out_bin_dir
76 done
77
78 else
79 echo "Expected either build.ninja or $tar"
80 exit 1
81 fi
82}
83
84"$@"