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 239 240 241 242 243 244 245 246 247 248 249 250
|
#!/bin/bash
export SOURCE_DIR="$(dirname "$0")"
if test -z "$BUILD_DIR"; then
BUILD_DIR="$SOURCE_DIR"
fi
export BUILD_DIR
source_top_dir="$SOURCE_DIR/../.."
source_top_dir=$(cd -P "$source_top_dir" 2>/dev/null || cd "$source_top_dir"; pwd)
build_top_dir="$(dirname "$(dirname "$BUILD_DIR")")"
build_top_dir=$(cd -P "$build_top_dir" 2>/dev/null || cd "$build_top_dir"; pwd)
# For backward compatibility
: ${NO_BUILD:=$NO_MAKE}
if [ "${NO_BUILD}" != "yes" ]; then
echo "${build_top_dir}/build.ninja"
if [ -f "${build_top_dir}/build.ninja" ]; then
ninja -C "${build_top_dir}" || exit 1
else
MAKE_ARGS=
n_processors=1
case $(uname) in
Linux)
n_processors="$(nproc)"
;;
Darwin)
n_processors="$(/usr/sbin/sysctl -n hw.ncpu)"
;;
*)
:
;;
esac
if [ ${n_processors} -gt 1 ]; then
MAKE_ARGS="${MAKE_ARGS} -j${n_processors}"
fi
make -C $build_top_dir ${MAKE_ARGS} > /dev/null || exit 1
fi
fi
. "${build_top_dir}/config.sh"
GRN_GGML_BACKENDS_DIR="$build_top_dir/bin"
export GRN_GGML_BACKENDS_DIR
GRN_PLUGINS_DIR="$source_top_dir/plugins"
GRN_PLUGINS_PATH="$build_top_dir/plugins"
export GRN_PLUGINS_DIR
export GRN_PLUGINS_PATH
GRN_RUBY_SCRIPTS_DIR="$source_top_dir/lib/mrb/scripts"
export GRN_RUBY_SCRIPTS_DIR
case `uname` in
Linux|*BSD)
# llama-cpp
LD_LIBRARY_PATH="$build_top_dir/bin:$LD_LIBRARY_PATH"
# libgroonga
LD_LIBRARY_PATH="$build_top_dir/lib/.libs:$LD_LIBRARY_PATH"
LD_LIBRARY_PATH="$build_top_dir/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH
;;
Darwin)
# llama-cpp
DYLD_LIBRARY_PATH="$build_top_dir/bin:$DYLD_LIBRARY_PATH"
# libgroonga
DYLD_LIBRARY_PATH="$build_top_dir/lib/.libs:$DYLD_LIBRARY_PATH"
DYLD_LIBRARY_PATH="$build_top_dir/lib:$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH
;;
*)
:
;;
esac
if grntest --version > /dev/null 2>&1; then
grntest=(grntest)
else
if test -z "$RUBY"; then
exit 1
fi
if ! type bundle > /dev/null 2>&1; then
$RUBY -S gem install bundler
fi
grntest_dir="$SOURCE_DIR/grntest"
if ! test -d "$grntest_dir"; then
grntest_dir="$BUILD_DIR/grntest"
git clone --depth 1 https://github.com/groonga/grntest.git "$grntest_dir"
(cd "$grntest_dir" && bundle install)
fi
(cd "$grntest_dir";
if [ "Gemfile" -nt "Gemfile.lock" ]; then
$RUBY -S bundle update
fi)
groonga_command_dir="$SOURCE_DIR/groonga-command"
if ! test -d "$groonga_command_dir"; then
groonga_command_dir="$BUILD_DIR/groonga-command"
fi
if ! test -d "$groonga_command_dir"; then
git clone --depth 1 \
https://github.com/groonga/groonga-command.git \
"$groonga_command_dir"
fi
groonga_command_parser_dir="$SOURCE_DIR/groonga-command-parser"
if ! test -d "$groonga_command_parser_dir"; then
groonga_command_parser_dir="$BUILD_DIR/groonga-command-parser"
fi
if ! test -d "$groonga_command_parser_dir"; then
git clone --depth 1 \
https://github.com/groonga/groonga-command-parser.git \
"$groonga_command_parser_dir"
fi
gqtp_dir="$SOURCE_DIR/gqtp"
if ! test -d "$gqtp_dir"; then
gqtp_dir="$BUILD_DIR/gqtp"
fi
if ! test -d "$gqtp_dir"; then
git clone --depth 1 \
https://github.com/ranguba/gqtp.git \
"$gqtp_dir"
fi
groonga_client_dir="$SOURCE_DIR/groonga-client"
if ! test -d "$groonga_client_dir"; then
groonga_client_dir="$BUILD_DIR/groonga-client"
fi
if ! test -d "$groonga_client_dir"; then
git clone --depth 1 \
https://github.com/ranguba/groonga-client.git \
"$groonga_client_dir"
fi
groonga_log_dir="$SOURCE_DIR/groonga-log"
if ! test -d "$groonga_log_dir"; then
groonga_log_dir="$BUILD_DIR/groonga-log"
fi
if ! test -d "$groonga_log_dir"; then
git clone --depth 1 \
https://github.com/groonga/groonga-log.git \
"$groonga_log_dir"
fi
groonga_query_log_dir="$SOURCE_DIR/groonga-query-log"
if ! test -d "$groonga_query_log_dir"; then
groonga_query_log_dir="$BUILD_DIR/groonga-query-log"
fi
if ! test -d "$groonga_query_log_dir"; then
git clone --depth 1 \
https://github.com/groonga/groonga-query-log.git \
"$groonga_query_log_dir"
fi
grntest=(
$RUBY
-I "$grntest_dir/lib"
-I "$groonga_command_dir/lib"
-I "$groonga_command_parser_dir/lib"
-I "$gqtp_dir/lib"
-I "$groonga_client_dir/lib"
-I "$groonga_log_dir/lib"
-I "$groonga_query_log_dir/lib"
"$grntest_dir/bin/grntest"
)
fi
have_targets="false"
use_gdb="false"
use_rr="false"
use_valgrind="false"
benchmark_mode="false"
next_argument_is_long_option_value="false"
for argument in "$@"; do
case "$argument" in
--*=*)
;;
--keep-database|--stop-on-failure|--no-*|--version|--help)
# no argument options
;;
--gdb)
# no argument options
use_gdb="true"
;;
--rr)
# no argument options
use_rr="true"
;;
--valgrind)
# no argument options
use_valgrind="true"
;;
--benchmark)
# no argument options
benchmark_mode="true"
;;
--*)
next_argument_is_long_option_value="true"
continue
;;
-*)
;;
*)
if test "$next_argument_is_long_option_value" != "true"; then
have_targets="true"
fi
;;
esac
next_argument_is_long_option_value="false"
done
grntest_options=()
if test "$use_gdb" = "true" -o \
"$use_rr" = "true" -o \
"$use_valgrind" = "true"; then
grntest_options+=("--n-workers" "1")
grntest_options+=("--reporter" "stream")
fi
if test "$CI" = "true"; then
grntest_options+=("--reporter" "mark")
fi
grntest_options+=("$@")
if test "$have_targets" != "true"; then
if test "$benchmark_mode" = "true"; then
grntest_options+=("${SOURCE_DIR}/suite_benchmark")
else
grntest_options+=("${SOURCE_DIR}/suite")
fi
fi
tmpfs_candidates=("/dev/shm" "/run/shm")
for tmpfs in "${tmpfs_candidates[@]}"; do
if test -d $tmpfs -a -w $tmpfs; then
rm -rf "tmp"
ln -s $tmpfs "tmp"
fi
done
export TZ=Asia/Tokyo
"${grntest[@]}" \
--groonga "$GROONGA" \
--groonga-httpd "$GROONGA_HTTPD" \
--groonga-suggest-create-dataset "$GROONGA_SUGGEST_CREATE_DATASET" \
--base-directory "$SOURCE_DIR" \
"${grntest_options[@]}"
|