forked from oils-for-unix/oils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnative.sh
executable file
·102 lines (70 loc) · 1.63 KB
/
native.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/env bash
#
# Build oils-for-unix.
#
# Usage:
# build/native.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
# Demo for the oils-for-unix tarball.
# Notes:
# - Does not rely on Ninja, which is for the dev build
# - It shouldn't require 'objcopy'
# - TODO: do this in the Soil 'cpp' task
tarball-demo() {
mkdir -p _bin
./configure
time _build/oils.sh '' '' SKIP_REBUILD
local bin=_bin/cxx-opt-sh/oils-for-unix.stripped
ls -l $bin
echo
echo "You can now run $bin. Example:"
echo
set -o xtrace
# TODO: Use symlink
$bin osh -n -c 'echo "hello $name"'
}
measure-build-times() {
local variant=${1:-opt}
mkdir -p _bin
./configure
local out_tsv=_tmp/time-tarball-$variant.tsv
# Header for functions in build/ninja-rules-cpp.sh
benchmarks/time_.py --tsv --out $out_tsv --rusage --print-header --field verb --field out
time TIME_TSV_OUT=$out_tsv _build/oils.sh '' $variant
echo
cat $out_tsv
}
#
# Ninja Wrappers
#
oil-slice-demo() {
export PYTHONPATH='.:vendor/'
echo 'echo hi' | bin/osh_parse.py
bin/osh_parse.py -c 'ls -l'
local osh=${1:-bin/osh}
# Same functionality in bin/oils-for-unix
echo 'echo hi' | $osh
$osh -n -c 'ls -l'
echo ---
# ast format is none
$osh --ast-format none -n -c 'ls -l'
echo '-----'
# Now test some more exotic stuff
$osh -c '(( a = 1 + 2 * 3 )); echo $a'
$osh -c \
'echo "hello"x $$ ${$} $((1 + 2 * 3)) {foo,bar}@example.com'
$osh -c 'for x in 1 2 3; do echo $x; done'
}
soil-run() {
local bin=_bin/cxx-asan/osh
ninja $bin
echo
echo "Built $bin"
echo
$bin --version
echo
oil-slice-demo $bin
}
"$@"