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 Release and Debug perf tests (does not build).
22 gyp - Run gyp for mojo (does not sync), with clang.
23 sync - Sync using gclient (does not run gyp).
24 show-bash-alias - Outputs an appropriate bash alias for mojob. In bash do:
25 \$ eval \`mojo/tools/mojob.sh show-bash-alias\`
27 option (which will only apply to following commands) should be one of:
28 Build/test options (specified before build/test/perftest):
29 --debug - Build/test in Debug mode.
30 --release - Build/test in Release mode.
31 --debug-and-release - Build/test in both Debug and Release modes (default).
32 Compiler options (specified before gyp):
33 --clang - Use clang (default).
36 --shared Build components as shared libraries (default).
37 --static Build components as static libraries.
39 Note: It will abort on the first failure (if any).
44 echo "Building in out/$1 ..."
45 ninja
-C "out/$1" mojo ||
exit 1
49 echo "Running unit tests in out/$1 ..."
50 "out/$1/mojo_system_unittests" ||
exit 1
51 "out/$1/mojo_public_unittests" ||
exit 1
52 "out/$1/mojo_bindings_test" ||
exit 1
53 "out/$1/mojo_js_bindings_unittests" ||
exit 1
57 echo "Running perf tests in out/$1 ..."
58 "out/$1/mojo_public_perftests" ||
exit 1
62 local gyp_defines
="$(make_gyp_defines)"
63 echo "Running gyp with GYP_DEFINES=$gyp_defines ..."
64 GYP_DEFINES
="$gyp_defines" build
/gyp_chromium mojo
/mojo.gyp
67 # Valid values: Debug, Release, or Debug_and_Release.
68 BUILD_TEST_TYPE
=Debug_and_Release
70 test "$BUILD_TEST_TYPE" = Debug
-o "$BUILD_TEST_TYPE" = Debug_and_Release
73 test "$BUILD_TEST_TYPE" = Release
-o "$BUILD_TEST_TYPE" = Debug_and_Release
76 # Valid values: clang or gcc.
78 # Valid values: shared or static.
82 # Always include these options.
83 options
+=("use_aura=1")
94 options
+=("component=shared_library")
97 options
+=("component=static_library")
103 # We're in src/mojo/tools. We want to get to src.
104 cd "$(realpath "$
(dirname "$0")")/../.."
106 if [ $# -eq 0 ]; then
113 # Commands -----------------------------------------------------------------
119 should_do_Debug
&& do_build Debug
120 should_do_Release
&& do_build Release
123 should_do_Debug
&& do_unittests Debug
124 should_do_Release
&& do_unittests Release
127 should_do_Debug
&& do_perftests Debug
128 should_do_Release
&& do_perftests Release
134 # Note: sync only, no gyp-ing.
135 gclient sync
--nohooks
138 # You want to type something like:
140 # '"$(pwd | sed '"'"'s/\(.*\/src\).*/\1/'"'"')/mojo/tools/mojob.sh"'
141 # This is quoting hell, so we simply escape every non-alphanumeric
143 echo alias\ mojob\
=\'\"\$\
(pwd\ \|\
sed\
\'\"\'\"\'s\
/\\\
(\.\
*\\\
/src
\\\
)\
144 \.\
*\
/\\1\
/\'\"\'\"\'\
)\
/mojo\
/tools\
/mojob\.sh
\"\'
146 # Options ------------------------------------------------------------------
148 BUILD_TEST_TYPE
=Debug
151 BUILD_TEST_TYPE
=Release
154 BUILD_TEST_TYPE
=Debug_and_Release
169 echo "Unknown command \"${arg}\". Try \"$(basename "$0") help\"."