OILS / opy / common.sh View on Github | oilshell.org

63 lines, 38 significant
1#!/usr/bin/env bash
2#
3# Common functions.
4# NOTE: The module that sources this must initialize THIS_DIR.
5#
6# Usage:
7# ./common.sh <function name>
8
9set -o nounset
10set -o pipefail
11set -o errexit
12
13# Used by scripts/release.sh too.
14readonly OSH_BYTERUN=opy/_tmp/repo-with-opy/bin/osh-byterun
15
16log() {
17 echo "$@" >&2
18}
19
20die() {
21 log "FATAL: $@"
22 exit 1
23}
24
25opy_() {
26 PYTHONPATH=$THIS_DIR $THIS_DIR/../bin/opy_.py "$@"
27}
28
29# NOTES:
30# - Exclude _devbuild/cpython-full, but include _devbuild/gen.
31# - must exclude opy/testdata/, because some of it can't be compiled
32# Has some similarity to test/lint.sh, but not the same.
33oil-python-sources() {
34 local repo_root=$1
35 local fmt=${2:-'%P\n'}
36
37 # mycpp: exclude Python 3 sources
38 find $repo_root \
39 -name _tmp -a -prune -o \
40 -name _cache -a -prune -o \
41 -name _chroot -a -prune -o \
42 -name _clone -a -prune -o \
43 -name _deps -a -prune -o \
44 -name _regtest -a -prune -o \
45 -name mycpp -a -prune -o \
46 -name pea -a -prune -o \
47 -name yaks -a -prune -o \
48 -name testdata -a -prune -o \
49 -name Python-2.7.13 -a -prune -o \
50 -name py-yajl -a -prune -o \
51 -name '*.py' -a -printf "$fmt"
52
53 # TODO: move type-annotated files to pea/, and get rid of py3_parse.py hack
54}
55
56opyc-run() {
57 ../bin/opyc run "$@"
58}
59
60opyc-compile() {
61 ../bin/opyc compile "$@"
62}
63