1 | #!/bin/sh
|
2 | #
|
3 | # __FILE_COMMENT__
|
4 | #
|
5 | # For usage, run:
|
6 | #
|
7 | # _build/oils.sh --help
|
8 |
|
9 | . build/ninja-rules-cpp.sh
|
10 |
|
11 | show_help() {
|
12 | cat <<'EOF'
|
13 | Compile the oils-for-unix source into an executable.
|
14 |
|
15 | Usage:
|
16 | _build/oils.sh COMPILER? VARIANT? TRANSLATOR? SKIP_REBUILD?
|
17 |
|
18 | COMPILER: 'cxx' for system compiler, 'clang' or custom one [default cxx]
|
19 | VARIANT: 'dbg' or 'opt' [default opt]
|
20 | TRANSLATOR: 'mycpp' or 'mycpp-souffle' [default mycpp]
|
21 | SKIP_REBUILD: if non-empty, checks if the output exists before building
|
22 |
|
23 | Environment variable respected:
|
24 |
|
25 | OILS_PARALLEL_BUILD=
|
26 | BASE_CXXFLAGS= # See build/ninja-rules-cpp.sh for details
|
27 | CXXFLAGS=
|
28 | OILS_CXX_VERBOSE=
|
29 |
|
30 | EOF
|
31 | }
|
32 |
|
33 | parse_flags() {
|
34 | while true; do
|
35 | # ${1:-} needed for set -u
|
36 | case "${1:-}" in
|
37 | '')
|
38 | break
|
39 | ;;
|
40 | --help)
|
41 | show_help
|
42 | exit 0
|
43 | ;;
|
44 | *)
|
45 | die "Invalid argument '$1'"
|
46 | ;;
|
47 | esac
|
48 | shift
|
49 | done
|
50 | }
|
51 |
|
52 |
|
53 | OILS_PARALLEL_BUILD=${OILS_PARALLEL_BUILD:-1}
|
54 |
|
55 | _compile_one() {
|
56 | local src=$4
|
57 |
|
58 | echo "CXX $src"
|
59 |
|
60 | # Delegate to function in build/ninja-rules-cpp.sh
|
61 | if test "${_do_fork:-}" = 1; then
|
62 | compile_one "$@" & # we will wait later
|
63 | else
|
64 | compile_one "$@"
|
65 | fi
|
66 | }
|