OILS / build / native.sh View on Github | oils.pub

117 lines, 61 significant
1#!/usr/bin/env bash
2#
3# Build oils-for-unix.
4#
5# Usage:
6# build/native.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12REPO_ROOT=$(cd "$(dirname $0)/.."; pwd) # tsv-lib.sh uses this
13source build/common.sh # log
14source build/dev-shell.sh # python2
15
16# Demo for the oils-for-unix tarball.
17# Notes:
18# - Does not rely on Ninja, which is for the dev build
19# - It shouldn't require 'objcopy'
20# - TODO: do this in the Soil 'cpp' task
21
22tarball-demo() {
23 translator=${1:-mycpp}
24 mkdir -p _bin
25
26 ./configure
27
28 time _build/oils.sh --translator "$translator" --skip-rebuild
29
30 local bin
31 case $translator in
32 mycpp)
33 bin=_bin/cxx-opt-sh/oils-for-unix.stripped
34 ;;
35 *)
36 bin=_bin/cxx-opt-sh/$translator/oils-for-unix.stripped
37 ;;
38 esac
39
40 ls -l $bin
41
42 echo
43 echo "You can now run $bin. Example:"
44 echo
45
46 set -o xtrace
47
48 # TODO: Use symlink
49 $bin osh -n -c 'echo "hello $name"'
50}
51
52measure-build-times() {
53 local variant=${1:-opt}
54
55 mkdir -p _bin
56
57 ./configure
58
59 local out_tsv=_tmp/time-tarball-$variant.tsv
60
61 # Header for functions in build/ninja-rules-cpp.sh
62 benchmarks/time_.py --tsv --out $out_tsv --rusage --print-header --field verb --field out
63
64 time TIME_TSV_OUT=$out_tsv _build/oils.sh --variant "$variant"
65
66 echo
67 cat $out_tsv
68}
69
70#
71# Ninja Wrappers
72#
73
74oils-demo() {
75 local osh=${1:-bin/osh}
76
77 export PYTHONPATH='.:vendor/'
78
79 echo 'echo hi' | bin/osh_parse.py
80 bin/osh_parse.py -c 'ls -l'
81
82 # Same functionality in bin/oils-for-unix
83 echo 'echo hi' | $osh
84 $osh -n -c 'ls -l'
85 echo ---
86 # ast format is none
87 $osh --ast-format none -n -c 'ls -l'
88
89 echo '-----'
90
91 # Now test some more exotic stuff
92 $osh -c '(( a = 1 + 2 * 3 )); echo $a'
93
94 $osh -c \
95 'echo "hello"x $$ ${$} $((1 + 2 * 3)) {foo,bar}@example.com'
96
97 $osh -c 'for x in 1 2 3; do echo $x; done'
98}
99
100soil-run() {
101 local osh=_bin/cxx-asan+gcalways/osh
102 local ysh=_bin/cxx-asan+gcalways/ysh
103
104 ninja $osh $ysh
105 echo
106
107 $osh --version
108 echo
109
110 oils-demo $osh
111
112 # Regression for pnode::PNode* rooting bug in spec/ysh-bugs, which only
113 # manifests with _bin/cxx-asan+gcalways/ysh
114 $ysh -c 'var x = 42; echo $x'
115}
116
117"$@"