2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # This a simple script to make building/testing Mojo components easier (on
9 # TODO(vtl): Maybe make the test runner smart and not run unchanged test
11 # TODO(vtl) Maybe also provide a way to pass command-line arguments to the test
16 Usage: $(basename "$0") [command|option ...]
18 command should be one of:
20 test - Run unit tests (does not build).
21 perftest - Run perf tests (does not build).
22 pytest - Run Python unit tests.
23 gyp - Run gyp for mojo (does not sync).
24 gypall - Run gyp for all of chromium (does not sync).
25 sync - Sync using gclient (does not run gyp).
26 show-bash-alias - Outputs an appropriate bash alias for mojob. In bash do:
27 \$ eval \`mojo/tools/mojob.sh show-bash-alias\`
29 option (which will only apply to following commands) should be one of:
30 Build/test options (specified before build/test/perftest):
31 --debug - Build/test in Debug mode.
32 --release - Build/test in Release mode.
33 --debug-and-release - Build/test in both Debug and Release modes (default).
34 Compiler options (specified before gyp):
35 --clang - Use clang (default).
38 --shared Build components as shared libraries (default).
39 --static Build components as static libraries.
41 --use-goma - Use goma if \$GOMA_DIR is set or \$HOME/goma exists (default).
42 --no-use-goma - Do not use goma.
44 Note: It will abort on the first failure (if any).
49 echo "Building in out/$1 ..."
50 if [ "$GOMA" = "auto" -a -v GOMA_DIR
]; then
51 ninja
-j 1000 -l 100 -C "out/$1" mojo ||
exit 1
53 ninja
-C "out/$1" mojo ||
exit 1
58 echo "Running unit tests in out/$1 ..."
59 mojo
/tools
/test_runner.py mojo
/tools
/data
/unittests
"out/$1" \
60 mojob_test_successes ||
exit 1
64 echo "Running perf tests in out/$1 ..."
65 "out/$1/mojo_public_system_perftests" ||
exit 1
69 python mojo
/tools
/run_mojo_python_tests.py ||
exit 1
73 local gyp_defines
="$(make_gyp_defines)"
74 echo "Running gyp for mojo with GYP_DEFINES=$gyp_defines ..."
75 GYP_DEFINES
="$gyp_defines" build
/gyp_chromium mojo
/mojo.gyp ||
exit 1
79 local gyp_defines
="$(make_gyp_defines)"
80 echo "Running gyp for everything with GYP_DEFINES=$gyp_defines ..."
81 GYP_DEFINES
="$gyp_defines" build
/gyp_chromium ||
exit 1
85 # Note: sync only (with hooks, but no gyp-ing).
86 GYP_CHROMIUM_NO_ACTION
=1 gclient sync ||
exit 1
89 # Valid values: Debug, Release, or Debug_and_Release.
90 BUILD_TEST_TYPE
=Debug_and_Release
92 test "$BUILD_TEST_TYPE" = Debug
-o "$BUILD_TEST_TYPE" = Debug_and_Release
95 test "$BUILD_TEST_TYPE" = Release
-o "$BUILD_TEST_TYPE" = Debug_and_Release
98 # Valid values: clang or gcc.
100 # Valid values: shared or static.
102 # Valid values: auto or disabled.
106 # Always include these options.
107 options
+=("use_aura=1")
118 options
+=("component=shared_library")
121 options
+=("component=static_library")
126 if [ -v GOMA_DIR
]; then
127 options
+=("use_goma=1" "gomadir=\"${GOMA_DIR}\"")
129 options
+=("use_goma=0")
133 options
+=("use_goma=0")
139 set_goma_dir_if_necessary
() {
140 if [ "$GOMA" = "auto" -a ! -v GOMA_DIR
]; then
141 if [ -d "${HOME}/goma" ]; then
142 GOMA_DIR
="${HOME}/goma"
147 start_goma_if_necessary
() {
148 if [ "$GOMA" = "auto" -a -v GOMA_DIR
]; then
149 "${GOMA_DIR}/goma_ctl.py" ensure_start
153 # We're in src/mojo/tools. We want to get to src.
154 cd "$(realpath "$
(dirname "$0")")/../.."
156 if [ $# -eq 0 ]; then
163 # Commands -----------------------------------------------------------------
169 set_goma_dir_if_necessary
170 start_goma_if_necessary
171 should_do_Debug
&& do_build Debug
172 should_do_Release
&& do_build Release
175 should_do_Debug
&& do_unittests Debug
176 should_do_Release
&& do_unittests Release
179 should_do_Debug
&& do_perftests Debug
180 should_do_Release
&& do_perftests Release
186 set_goma_dir_if_necessary
190 set_goma_dir_if_necessary
197 # You want to type something like:
199 # '"$(pwd | sed '"'"'s/\(.*\/src\).*/\1/'"'"')/mojo/tools/mojob.sh"'
200 # This is quoting hell, so we simply escape every non-alphanumeric
202 echo alias\ mojob\
=\'\"\$\
(pwd\ \|\
sed\
\'\"\'\"\'s\
/\\\
(\.\
*\\\
/src
\\\
)\
203 \.\
*\
/\\1\
/\'\"\'\"\'\
)\
/mojo\
/tools\
/mojob\.sh
\"\'
205 # Options ------------------------------------------------------------------
207 BUILD_TEST_TYPE
=Debug
210 BUILD_TEST_TYPE
=Release
213 BUILD_TEST_TYPE
=Debug_and_Release
234 echo "Unknown command \"${arg}\". Try \"$(basename "$0") help\"."