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

131 lines, 65 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 *)
51 # mycpp-souffle, mycpp-nosouffle
52 targets+=( _bin/cxx-$variant/$OILS_TRANSLATOR/{osh,ysh} )
53 ;;
54 esac
55 done
56
57 ninja "${targets[@]}"
58
59 elif test -f $tar; then
60 # Build out of the tarball, but put in WHERE NINJA would have put it
61
62 local tmp=_tmp/native-tar-test # like oil-tar-test
63
64 # Don't defeat SKIP_REBUILD
65 #rm -r -f $tmp
66
67 mkdir -p $tmp
68 pushd $tmp
69
70 if ! test -d oils-for-unix-$OILS_VERSION; then
71 tar -x < ../../$tar
72 fi
73
74 # Leaving out version
75 pushd oils-for-unix-$OILS_VERSION
76
77 ./configure
78
79 for variant in "$@"; do
80 time _build/oils.sh \
81 --variant "$variant" --translator "$OILS_TRANSLATOR" --skip-rebuild
82 done
83
84 popd
85 popd
86
87 # Hack: copy to Ninja location. So the interface is the same.
88 for variant in "$@"; do
89 local out_bin_dir
90 local tar_bin_dir
91 case $OILS_TRANSLATOR in
92 mycpp)
93 out_bin_dir=_bin/cxx-$variant
94 tar_bin_dir=_bin/cxx-$variant-sh
95 ;;
96 *)
97 out_bin_dir=_bin/cxx-$variant/$OILS_TRANSLATOR
98 tar_bin_dir=_bin/cxx-$variant-sh/$OILS_TRANSLATOR
99 ;;
100 esac
101
102 mkdir -v -p $out_bin_dir
103 cp -v \
104 $tmp/oils-for-unix-$OILS_VERSION/$tar_bin_dir/{oils-for-unix,osh,ysh} \
105 $out_bin_dir
106 done
107
108 else
109 echo "Expected either build.ninja or $tar"
110 exit 1
111 fi
112}
113
114benchmark-build() {
115 ### Binaries tested by osh-runtime, osh-parser, ...
116
117 #devtools/release-native.sh gen-shell-build # _build/oils.sh
118
119 # generate C++ and _build/oils.sh
120 devtools/release-native.sh make-tar
121
122 # Now build 3 binaries - with that same code
123 # TODO: It would be nice to do this faster. The tarball should check
124 # timestamps
125
126 _build/oils.sh --skip-rebuild
127 _build/oils.sh --translator mycpp-nosouffle --skip-rebuild
128 build/static-oils.sh
129}
130
131"$@"