OILS / soil / cpp-tarball.sh View on Github | oils.pub

133 lines, 68 significant
1#!/usr/bin/env bash
2#
3# Build the tarball
4#
5# Usage:
6# soil/cpp-tarball.sh
7
8
9# Notes:
10# soil-benchmarks/ # uses ninja in $REPO_ROOT
11# soil-benchmarks2/ # uses build-like-ninja, which copies
12# # _tmp/native-tar-test/ to $REPO_ROOT
13# uftrace
14# gc-cachegrind
15# soil-benchmarks3/ # TODO: use same scheme as benchmarks2
16# osh-parser
17# osh-runtime
18
19set -o nounset
20set -o pipefail
21set -o errexit
22
23source build/dev-shell.sh # python2 for gen-shell-build
24
25#REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
26#source soil/common.sh
27
28OILS_VERSION=$(head -n 1 oils-version.txt)
29OILS_TRANSLATOR=${OILS_TRANSLATOR:-mycpp}
30
31build-like-ninja() {
32 ### Build a list of variants with either Ninja or the tarball
33 # The tarball build copies from _bin/cxx-$variant-sh/ -> _bin/cxx-$variant,
34 # to be consistent
35 # And it passes --skip-rebuild
36
37 local tar=_release/oils-for-unix.tar
38
39 if test -f build.ninja; then
40 # Just use Ninja
41
42 local -a targets=()
43
44 for variant in "$@"; do
45 # TODO: clean this code up!
46 case "$OILS_TRANSLATOR" in
47 mycpp)
48 targets+=( _bin/cxx-$variant/{osh,ysh} )
49 ;;
50 mycpp-souffle)
51 targets+=( _bin/cxx-$variant/mycpp-souffle/{osh,ysh} )
52 ;;
53 *)
54 echo "Invalid translator: $OILS_TRANSLATOR" >&2
55 exit 1
56 esac
57 done
58
59 ninja "${targets[@]}"
60
61 elif test -f $tar; then
62 # Build out of the tarball, but put in WHERE NINJA would have put it
63
64 local tmp=_tmp/native-tar-test # like oil-tar-test
65
66 # Don't defeat SKIP_REBUILD
67 #rm -r -f $tmp
68
69 mkdir -p $tmp
70 pushd $tmp
71
72 if ! test -d oils-for-unix-$OILS_VERSION; then
73 tar -x < ../../$tar
74 fi
75
76 # Leaving out version
77 pushd oils-for-unix-$OILS_VERSION
78
79 ./configure
80
81 for variant in "$@"; do
82 time _build/oils.sh \
83 --variant "$variant" --translator "$OILS_TRANSLATOR" --skip-rebuild
84 done
85
86 popd
87 popd
88
89 # Hack: copy to Ninja location. So the interface is the same.
90 for variant in "$@"; do
91 local out_bin_dir
92 local tar_bin_dir
93 case $OILS_TRANSLATOR in
94 mycpp)
95 out_bin_dir=_bin/cxx-$variant
96 tar_bin_dir=_bin/cxx-$variant-sh
97 ;;
98 *)
99 out_bin_dir=_bin/cxx-$variant/$OILS_TRANSLATOR
100 tar_bin_dir=_bin/cxx-$variant-sh/$OILS_TRANSLATOR
101 ;;
102 esac
103
104 mkdir -v -p $out_bin_dir
105 cp -v \
106 $tmp/oils-for-unix-$OILS_VERSION/$tar_bin_dir/{oils-for-unix,osh,ysh} \
107 $out_bin_dir
108 done
109
110 else
111 echo "Expected either build.ninja or $tar"
112 exit 1
113 fi
114}
115
116benchmark-build() {
117 ### Binaries tested by osh-runtime, osh-parser, ...
118
119 #devtools/release-native.sh gen-shell-build # _build/oils.sh
120
121 # generate C++ and _build/oils.sh
122 devtools/release-native.sh make-tar
123
124 # Now build 3 binaries - with that same code
125 # TODO: It would be nice to do this faster. The tarball should check
126 # timestamps
127
128 _build/oils.sh --skip-rebuild
129 _build/oils.sh --translator mycpp-souffle --skip-rebuild
130 build/static-oils.sh
131}
132
133"$@"