-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_parser_threaded_dmd.sh
More file actions
executable file
·97 lines (83 loc) · 2.75 KB
/
build_parser_threaded_dmd.sh
File metadata and controls
executable file
·97 lines (83 loc) · 2.75 KB
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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOST_OS="$(uname -s)"
case "$HOST_OS" in
Darwin)
HOST_GENERATED_DIR="osx"
HOST_DMD_BIN_SUBDIR="bin"
;;
Linux)
HOST_GENERATED_DIR="linux"
HOST_DMD_BIN_SUBDIR="bin64"
;;
*)
echo "Unsupported host OS for this helper: $HOST_OS" >&2
exit 2
;;
esac
DMD_REPO="${DMD_REPO:-$SCRIPT_DIR/external/dmd}"
HOST_DMD="${HOST_DMD:-$SCRIPT_DIR/.locald/dmd-nightly/$HOST_GENERATED_DIR/$HOST_DMD_BIN_SUBDIR/dmd}"
BUILD_MODE="${BUILD_MODE:-debug}"
HOST_DFLAGS="${HOST_DFLAGS:--version=ParserParallelPrototype}"
PARSER_DMD_REF="${PARSER_DMD_REF:-4faeee39cf33c1e3491b7e1da83a71111f05606f}"
PARSER_PATCH="${PARSER_PATCH:-$SCRIPT_DIR/patches/external_dmd_parser_parallel_prototype.patch}"
PARSER_PREPARE_SCRIPT="${PARSER_PREPARE_SCRIPT:-$SCRIPT_DIR/prepare_parser_prototype_dmd.sh}"
usage() {
cat <<EOF
Usage: $(basename "$0") [options]
Builds a DMD binary with the ParserParallelPrototype version flag enabled.
The source checkout is auto-prepared at a pinned upstream DMD commit before build.
Options:
--dmd-repo <path> DMD repo root (default: external/dmd)
--host-dmd <path> Host compiler path (default: .locald/dmd-nightly/osx/bin/dmd)
--build-mode <name> Build mode passed to make BUILD=<name> (default: debug)
--host-dflags <flags> HOST_DFLAGS value (default: -version=ParserParallelPrototype)
--help Show this help
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--dmd-repo) DMD_REPO="$2"; shift 2 ;;
--host-dmd) HOST_DMD="$2"; shift 2 ;;
--build-mode) BUILD_MODE="$2"; shift 2 ;;
--host-dflags) HOST_DFLAGS="$2"; shift 2 ;;
--help) usage; exit 0 ;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 1
;;
esac
done
if [[ "$DMD_REPO" != /* ]]; then
DMD_REPO="$(cd "$DMD_REPO" && pwd)"
fi
if [[ "$HOST_DMD" != /* ]]; then
HOST_DMD="$(cd "$(dirname "$HOST_DMD")" && pwd)/$(basename "$HOST_DMD")"
fi
if [[ ! -d "$DMD_REPO" ]]; then
echo "DMD repo not found: $DMD_REPO" >&2
exit 2
fi
if [[ ! -x "$HOST_DMD" ]]; then
echo "Host DMD not executable: $HOST_DMD" >&2
exit 2
fi
if [[ -x "$PARSER_PREPARE_SCRIPT" ]]; then
"$PARSER_PREPARE_SCRIPT" \
--repo-dir "$DMD_REPO" \
--ref "$PARSER_DMD_REF" \
--patch "$PARSER_PATCH" >&2
fi
make -C "$DMD_REPO" dmd \
HOST_DMD="$HOST_DMD" \
HOST_DFLAGS="$HOST_DFLAGS" \
BUILD="$BUILD_MODE" \
-j2 >&2
BIN_PATH="$DMD_REPO/generated/$HOST_GENERATED_DIR/$BUILD_MODE/64/dmd"
if [[ ! -x "$BIN_PATH" ]]; then
echo "Build completed but binary not found at: $BIN_PATH" >&2
exit 3
fi
echo "$BIN_PATH"