-
-
Notifications
You must be signed in to change notification settings - Fork 145
/
bin.sh
executable file
·111 lines (91 loc) · 2.02 KB
/
bin.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
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
#
# Manage the bin/ directory.
#
# Usage:
# devtools/bin.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
# New name is ysh!
# TODO:
# - remove the 'oil' everywhere
# - translation should be 'ysh-translate'. Later 'ysh-format'
readonly OIL_OVM_NAMES=(oil ysh osh oshc tea sh true false readlink)
# TODO: probably delete this
# For osh-dbg.
ovm-snippet() {
local name=$1
echo '#!/bin/sh'
echo 'exec _bin/oil.ovm-dbg '$name' "$@"'
}
# For running spec tests quickly.
make-osh-dbg() {
local out=_bin/osh-dbg
ovm-snippet osh > $out
chmod +x $out
}
sh-prefix() {
cat << 'EOF'
#!/bin/sh
REPO_ROOT=$(cd "$(dirname $0)/.."; pwd)
EOF
}
make-osh-eval() {
local out=bin/osh_eval
{ sh-prefix
echo 'PYTHONPATH=$REPO_ROOT:$REPO_ROOT/vendor exec $REPO_ROOT/bin/osh_eval.py "$@"'
} > $out
chmod +x $out
echo "Wrote $out"
}
#
# Shell Stubs
#
sh-snippet() {
local wrapped=$1 # e.g. oil.py
local action=$2 # e.g. osh
sh-prefix
echo 'PYTHONPATH=$REPO_ROOT:$REPO_ROOT/vendor exec $REPO_ROOT/bin/'$wrapped' '$action' "$@"'
}
# A snippet that sets PYTHONPATH for bin/oil.py and runs it with the right
# action.
oil-dev-snippet() {
local action=$1
sh-snippet oil.py $action
}
opy-dev-snippet() {
local action=$1
sh-snippet opy_.py $action
}
make-src-stubs() {
### bin/ is for running with the Python interpreter.
mkdir -p bin
for link in "${OIL_OVM_NAMES[@]}"; do
# bin/ shell wrapper
oil-dev-snippet $link > bin/$link
chmod +x bin/$link
echo "Wrote bin/$link"
done
make-osh-dbg
make-osh-eval
}
make-ovm-links() {
### _bin/ is for running with OVM app bundles.
mkdir -p _bin
for link in "${OIL_OVM_NAMES[@]}"; do
# _bin/ symlink
ln -s -f --verbose oil.ovm _bin/$link
done
}
make-cpp-links() {
for link in "${OIL_OVM_NAMES[@]}"; do
# Skip oil in favor of ysh.
if test $link != 'oil'; then
# TODO: do this in Ninja?
# Also to cxx-opt/oils_cpp.stripped
ln -s -f --verbose oils_cpp _bin/cxx-dbg/$link
fi
done
}
"$@"