blob: e0804d1ef656f98b6bd27c800c66d5a204c0f763 (
plain)
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
#!/bin/bash
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This a simple script to make building/testing Mojo components easier (on
# Linux).
# TODO(vtl): Maybe make the test runner smart and not run unchanged test
# binaries.
# TODO(vtl) Maybe also provide a way to pass command-line arguments to the test
# binaries.
do_help() {
cat << EOF
Usage: $(basename "$0") [command|option ...]
command should be one of:
build - Build.
test - Run unit tests (does not build).
perftest - Run perf tests (does not build).
pytest - Run Python unit tests.
gyp - Run gyp for mojo (does not sync).
gypall - Run gyp for all of chromium (does not sync).
sync - Sync using gclient (does not run gyp).
show-bash-alias - Outputs an appropriate bash alias for mojob. In bash do:
\$ eval \`mojo/tools/mojob.sh show-bash-alias\`
option (which will only apply to following commands) should be one of:
Build/test options (specified before build/test/perftest):
--debug - Build/test in Debug mode.
--release - Build/test in Release mode.
--debug-and-release - Build/test in both Debug and Release modes (default).
Compiler options (specified before gyp):
--clang - Use clang (default).
--gcc - Use gcc.
Component options:
--shared Build components as shared libraries (default).
--static Build components as static libraries.
Use goma:
--use-goma - Use goma if \$GOMA_DIR is set or \$HOME/goma exists (default).
--no-use-goma - Do not use goma.
Note: It will abort on the first failure (if any).
EOF
}
do_build() {
echo "Building in out/$1 ..."
if [ "$GOMA" = "auto" -a -v GOMA_DIR ]; then
ninja -j 1000 -l 100 -C "out/$1" mojo || exit 1
else
ninja -C "out/$1" mojo || exit 1
fi
}
do_unittests() {
echo "Running unit tests in out/$1 ..."
mojo/tools/test_runner.py mojo/tools/data/unittests "out/$1" \
mojob_test_successes || exit 1
}
do_perftests() {
echo "Running perf tests in out/$1 ..."
"out/$1/mojo_public_system_perftests" || exit 1
}
do_pytests() {
python mojo/tools/run_mojo_python_tests.py || exit 1
}
do_gyp() {
local gyp_defines="$(make_gyp_defines)"
echo "Running gyp for mojo with GYP_DEFINES=$gyp_defines ..."
GYP_DEFINES="$gyp_defines" build/gyp_chromium mojo/mojo.gyp || exit 1
}
do_gypall() {
local gyp_defines="$(make_gyp_defines)"
echo "Running gyp for everything with GYP_DEFINES=$gyp_defines ..."
GYP_DEFINES="$gyp_defines" build/gyp_chromium || exit 1
}
do_sync() {
# Note: sync only (with hooks, but no gyp-ing).
GYP_CHROMIUM_NO_ACTION=1 gclient sync || exit 1
}
# Valid values: Debug, Release, or Debug_and_Release.
BUILD_TEST_TYPE=Debug_and_Release
should_do_Debug() {
test "$BUILD_TEST_TYPE" = Debug -o "$BUILD_TEST_TYPE" = Debug_and_Release
}
should_do_Release() {
test "$BUILD_TEST_TYPE" = Release -o "$BUILD_TEST_TYPE" = Debug_and_Release
}
# Valid values: clang or gcc.
COMPILER=clang
# Valid values: shared or static.
COMPONENT=shared
# Valid values: auto or disabled.
GOMA=auto
make_gyp_defines() {
local options=()
# Always include these options.
options+=("use_aura=1")
case "$COMPILER" in
clang)
options+=("clang=1")
;;
gcc)
options+=("clang=0")
;;
esac
case "$COMPONENT" in
shared)
options+=("component=shared_library")
;;
static)
options+=("component=static_library")
;;
esac
case "$GOMA" in
auto)
if [ -v GOMA_DIR ]; then
options+=("use_goma=1" "gomadir=\"${GOMA_DIR}\"")
else
options+=("use_goma=0")
fi
;;
disabled)
options+=("use_goma=0")
;;
esac
echo "${options[*]}"
}
set_goma_dir_if_necessary() {
if [ "$GOMA" = "auto" -a ! -v GOMA_DIR ]; then
if [ -d "${HOME}/goma" ]; then
GOMA_DIR="${HOME}/goma"
fi
fi
}
start_goma_if_necessary() {
if [ "$GOMA" = "auto" -a -v GOMA_DIR ]; then
"${GOMA_DIR}/goma_ctl.py" ensure_start
fi
}
# We're in src/mojo/tools. We want to get to src.
cd "$(realpath "$(dirname "$0")")/../.."
if [ $# -eq 0 ]; then
do_help
exit 0
fi
for arg in "$@"; do
case "$arg" in
# Commands -----------------------------------------------------------------
help|--help)
do_help
exit 0
;;
build)
set_goma_dir_if_necessary
start_goma_if_necessary
should_do_Debug && do_build Debug
should_do_Release && do_build Release
;;
test)
should_do_Debug && do_unittests Debug
should_do_Release && do_unittests Release
;;
perftest)
should_do_Debug && do_perftests Debug
should_do_Release && do_perftests Release
;;
pytest)
do_pytests
;;
gyp)
set_goma_dir_if_necessary
do_gyp
;;
gypall)
set_goma_dir_if_necessary
do_gypall
;;
sync)
do_sync
;;
show-bash-alias)
# You want to type something like:
# alias mojob=\
# '"$(pwd | sed '"'"'s/\(.*\/src\).*/\1/'"'"')/mojo/tools/mojob.sh"'
# This is quoting hell, so we simply escape every non-alphanumeric
# character.
echo alias\ mojob\=\'\"\$\(pwd\ \|\ sed\ \'\"\'\"\'s\/\\\(\.\*\\\/src\\\)\
\.\*\/\\1\/\'\"\'\"\'\)\/mojo\/tools\/mojob\.sh\"\'
;;
# Options ------------------------------------------------------------------
--debug)
BUILD_TEST_TYPE=Debug
;;
--release)
BUILD_TEST_TYPE=Release
;;
--debug-and-release)
BUILD_TEST_TYPE=Debug_and_Release
;;
--clang)
COMPILER=clang
;;
--gcc)
COMPILER=gcc
;;
--shared)
COMPONENT=shared
;;
--static)
COMPONENT=static
;;
--use-goma)
GOMA=auto
;;
--no-use-goma)
GOMA=disabled
;;
*)
echo "Unknown command \"${arg}\". Try \"$(basename "$0") help\"."
exit 1
;;
esac
done
|