| 1 |
#!/usr/bin/env bash |
| 2 |
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root |
| 3 |
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
############################################### |
| 8 |
### |
| 9 |
### check for environment variables |
| 10 |
### |
| 11 |
if test -z "$GREP"; then |
| 12 |
GREP=grep |
| 13 |
fi |
| 14 |
if test -z "$SED"; then |
| 15 |
SED=sed |
| 16 |
fi |
| 17 |
|
| 18 |
if test -z "$MAKE"; then |
| 19 |
MAKE=make |
| 20 |
fi |
| 21 |
|
| 22 |
system_default_cmake="no" |
| 23 |
if test -z "$CMAKE"; then |
| 24 |
CMAKE=cmake |
| 25 |
system_default_cmake="yes" |
| 26 |
fi |
| 27 |
|
| 28 |
space=" " |
| 29 |
tab=" " |
| 30 |
BLANK="$space$tab" |
| 31 |
nl=$'\n' |
| 32 |
|
| 33 |
############################################### |
| 34 |
### |
| 35 |
### read lib |
| 36 |
### |
| 37 |
|
| 38 |
# quote parameter for passing it through the shell |
| 39 |
# the result is meant to be used inside "...", i.e. the outer quotes are _not_ |
| 40 |
# included |
| 41 |
# |
| 42 |
# you should have the identity |
| 43 |
# eval "[ x\"\$param\" = x\"$(doublequote "$param")\" ]" |
| 44 |
doublequote() |
| 45 |
{ |
| 46 |
local val="$1" |
| 47 |
local result= |
| 48 |
local token= |
| 49 |
local special= |
| 50 |
while [ -n "$val" ]; do |
| 51 |
token=${val%%[\"\$\`\\]*} |
| 52 |
val=${val#"$token"} |
| 53 |
special=${val:0:1} |
| 54 |
val=${val:1} |
| 55 |
result=$result$token${special:+\\$special} |
| 56 |
done |
| 57 |
# if the value ends in \n, protect it by appending two double-quotes so it |
| 58 |
# won't get stripped by the surrounding $(...) |
| 59 |
case $result in |
| 60 |
*"$nl") result=$result'""';; |
| 61 |
esac |
| 62 |
printf "%s" "$result" |
| 63 |
} |
| 64 |
|
| 65 |
canonicalname(){ |
| 66 |
if test $# -ne 1; then |
| 67 |
echo Usage: canonicalname path >&2 |
| 68 |
return 1 |
| 69 |
fi |
| 70 |
file="`eval echo $1`" # expand ~ |
| 71 |
if test ! -e "$file"; then |
| 72 |
echo $file: file not found >&2 |
| 73 |
return 1 |
| 74 |
fi |
| 75 |
# if this is a symlink, then follow the symlink |
| 76 |
if test -L "$file"; then |
| 77 |
fdir="`dirname \"$file\"`" |
| 78 |
flink="`readlink \"$file\"`" |
| 79 |
if test -e "$flink"; then |
| 80 |
# these are absolute links, or links in the CWD |
| 81 |
canonicalname "$flink" |
| 82 |
else |
| 83 |
canonicalname "$fdir/$flink" |
| 84 |
fi |
| 85 |
else |
| 86 |
# if this is a file, then remember the filename and |
| 87 |
# canonicalize the directory name |
| 88 |
if test -f "$file"; then |
| 89 |
fdir="`dirname \"$file\"`" |
| 90 |
fname="`basename \"$file\"`" |
| 91 |
fdir="`canonicalname \"$fdir\"`" |
| 92 |
echo "$fdir/$fname" |
| 93 |
fi |
| 94 |
# if this is a directory, then create an absolute |
| 95 |
# directory name and we are done |
| 96 |
if test -d "$file"; then |
| 97 |
(cd "$file"; pwd) |
| 98 |
fi |
| 99 |
fi |
| 100 |
} |
| 101 |
|
| 102 |
canonicalpath(){ |
| 103 |
if test $# -ne 1; then |
| 104 |
echo Usage: canonicalpath path >&2 |
| 105 |
return 1 |
| 106 |
fi |
| 107 |
dirname "`canonicalname "$1"`" |
| 108 |
} |
| 109 |
|
| 110 |
checkdebug () { |
| 111 |
while test $# -gt 0; do |
| 112 |
if test x$1 = x--debug; then |
| 113 |
echo yes |
| 114 |
return |
| 115 |
fi |
| 116 |
shift |
| 117 |
done |
| 118 |
echo no |
| 119 |
} |
| 120 |
|
| 121 |
DEBUG=`checkdebug $@` |
| 122 |
if test "x$DEBUG" = "xyes"; then |
| 123 |
set -x |
| 124 |
set -v |
| 125 |
fi |
| 126 |
|
| 127 |
|
| 128 |
onbuildfailure() { |
| 129 |
echo "Terminating $(basename "$0") due to previous errors!" >&2 |
| 130 |
exit 1 |
| 131 |
} |
| 132 |
|
| 133 |
# |
| 134 |
# for each module load the $CONTROL script part and run $command |
| 135 |
# |
| 136 |
# parameters: |
| 137 |
# $1 list of modules |
| 138 |
# $2-$* commands + parameters to execute |
| 139 |
# |
| 140 |
build_module() { |
| 141 |
local module=$1 |
| 142 |
shift |
| 143 |
while test $# -gt 0; do |
| 144 |
# get command |
| 145 |
command=$1 |
| 146 |
shift |
| 147 |
|
| 148 |
# only load other parameters |
| 149 |
load_opts NONE |
| 150 |
# get command options |
| 151 |
CMD_FLAGS= |
| 152 |
while test $# -gt 0 && test "$1" != ":"; do |
| 153 |
COMMAND=$(echo $command | tr '[:lower:]' '[:upper:]') |
| 154 |
# setup parameter list |
| 155 |
CMD_FLAGS="$CMD_FLAGS \"$(doublequote "$1")\"" |
| 156 |
shift |
| 157 |
done |
| 158 |
if test -z "$CMD_FLAGS"; then |
| 159 |
load_opts $command |
| 160 |
else |
| 161 |
# disable usage of opts file |
| 162 |
if test "x$DUNE_OPTS_FILE" != "x"; then |
| 163 |
echo "WARNING: commandline parameters will overwrite setting in opts file \"$DUNE_OPTS_FILE\"" |
| 164 |
fi |
| 165 |
fi |
| 166 |
|
| 167 |
# skip command delimiter |
| 168 |
if test "$1" = ":"; then shift; fi |
| 169 |
|
| 170 |
# actually run the commands (we already know that these are valid commands) |
| 171 |
local runcommand=run_$command |
| 172 |
|
| 173 |
# build the modules |
| 174 |
local path="$(eval "echo \$PATH_${module}")" |
| 175 |
eval echo "--- calling $command for \$NAME_${module} ---" |
| 176 |
trap onbuildfailure EXIT |
| 177 |
if ! ( |
| 178 |
set -e |
| 179 |
cd "$path" |
| 180 |
export module |
| 181 |
export ABS_BUILDDIR=$(abs_builddir $module $BUILDDIR) |
| 182 |
eval_control $runcommand "$path/$CONTROL" |
| 183 |
); then eval echo "--- Failed to build \$NAME_${module} ---"; exit 1; fi |
| 184 |
trap onfailure EXIT |
| 185 |
|
| 186 |
eval echo "--- \$NAME_${module} done ---" |
| 187 |
done |
| 188 |
} |
| 189 |
|
| 190 |
# |
| 191 |
# load command options from an opts file |
| 192 |
# the name of the opts file is stored in the global variable $DUNE_OPTS_FILE |
| 193 |
# |
| 194 |
# parameters: |
| 195 |
# $1 command |
| 196 |
# |
| 197 |
load_opts() { |
| 198 |
local command=$1 |
| 199 |
local COMMAND=$(echo $command | tr '[:lower:]' '[:upper:]') |
| 200 |
CMD_FLAGS=$(eval echo \$${COMMAND}_FLAGS) |
| 201 |
local CMD_FLAGS_FROM_FILE="" |
| 202 |
if test "$command" = "NONE"; then |
| 203 |
BUILDDIR=$DUNE_BUILDDIR |
| 204 |
if test "x$DUNE_OPTS_FILE" != "x"; then |
| 205 |
if test -z "$BUILDDIR"; then |
| 206 |
# no builddir set yet, use build dir from opts file if set |
| 207 |
# Note: if --use-buiddir is used BUILDDIR will be set already |
| 208 |
OPTS_FILE_BUILDDIR="$(eval BUILDDIR=""; . "$DUNE_OPTS_FILE"; eval echo \$BUILDDIR)" |
| 209 |
if test -n "$OPTS_FILE_BUILDDIR"; then |
| 210 |
BUILDDIR="$OPTS_FILE_BUILDDIR" |
| 211 |
fi |
| 212 |
fi |
| 213 |
if test "$system_default_cmake" = "yes"; then |
| 214 |
# We use cmake for building, but CMAKE is not yet set. |
| 215 |
# Check the opts file for it |
| 216 |
OPTS_FILE_CMAKE="$(eval CMAKE=""; . "$DUNE_OPTS_FILE"; eval echo \$CMAKE)" |
| 217 |
if test -n "$OPTS_FILE_CMAKE"; then |
| 218 |
CMAKE="$OPTS_FILE_CMAKE" |
| 219 |
fi |
| 220 |
fi |
| 221 |
fi |
| 222 |
fi |
| 223 |
if test "x$DUNE_OPTS_FILE" != "x"; then |
| 224 |
if test "$command" = "configure"; then |
| 225 |
CMAKE_FLAGS="$(. "${DUNE_OPTS_FILE}"; eval echo \$CMAKE_FLAGS)" |
| 226 |
CMAKE_FLAGS="$CMAKE_FLAGS -DDUNE_OPTS_FILE=\"$DUNE_OPTS_FILE\"" |
| 227 |
CMAKE_MODULE_PATH="$(. "$DUNE_OPTS_FILE"; eval echo \$CMAKE_MODULE_PATH)" |
| 228 |
fi |
| 229 |
CMD_FLAGS_FROM_FILE="$(eval ${COMMAND}_FLAGS=""; . "$DUNE_OPTS_FILE"; eval echo \$${COMMAND}_FLAGS)" |
| 230 |
fi |
| 231 |
if test -n "$CMD_FLAGS_FROM_FILE"; then |
| 232 |
echo "----- using default flags \$${COMMAND}_FLAGS from $DUNE_OPTS_FILE -----" |
| 233 |
CMD_FLAGS=$CMD_FLAGS_FROM_FILE |
| 234 |
elif test -n "$CMD_FLAGS"; then |
| 235 |
echo "----- using default flags \$${COMMAND}_FLAGS from environment -----" |
| 236 |
fi |
| 237 |
|
| 238 |
# if no build directory is set, use default "build-cmake" |
| 239 |
if test -z "$BUILDDIR"; then |
| 240 |
export BUILDDIR=build-cmake |
| 241 |
fi |
| 242 |
} |
| 243 |
|
| 244 |
abs_builddir() |
| 245 |
{ |
| 246 |
local m=$1 |
| 247 |
local builddir=$2 |
| 248 |
local name="$(eval echo \$NAME_$m)" |
| 249 |
local path="$(eval echo \$PATH_$m)" |
| 250 |
case $BUILDDIR in |
| 251 |
/*) |
| 252 |
echo $builddir/$name |
| 253 |
;; |
| 254 |
*) |
| 255 |
echo $path/$builddir |
| 256 |
;; |
| 257 |
esac |
| 258 |
} |
| 259 |
|
| 260 |
# Uses the current compiler to extract information about the |
| 261 |
# multiarch triplets and sets the export variable MULTIARCH_LIBDIR |
| 262 |
# according to it. |
| 263 |
# If no compiler is specified then cc or gcc is used. |
| 264 |
extract_multiarch(){ |
| 265 |
set +e #error in the multiarch detection should not be fatal. |
| 266 |
local my_cxx_compiler |
| 267 |
if test "x$MULTIARCH_LIBDIR" != "x"; then |
| 268 |
return |
| 269 |
fi |
| 270 |
load_opts "cmake" |
| 271 |
if test "x$my_cxx_compiler" == "x"; then |
| 272 |
load_opts "configure" |
| 273 |
fi |
| 274 |
my_cxx_compiler=`echo $CMD_FLAGS | $GREP CXX | $SED "s/.*CXX=[\"']\{0,1\}\([^$BLANK'\"]*\)[\"']\{0,1\}.*/\1/"` |
| 275 |
if test "x$my_cxx_compiler" == "x"; then |
| 276 |
$(which cc &>/dev/null) |
| 277 |
if test $? -eq "0"; then |
| 278 |
my_cxx_compiler=cc |
| 279 |
else |
| 280 |
my_cxx_compiler=gcc |
| 281 |
fi |
| 282 |
fi |
| 283 |
multiarch=$($my_cxx_compiler --print-multiarch 2>/dev/null) |
| 284 |
if test $? -gt 0; then |
| 285 |
for i in "target=" "Target:"; do |
| 286 |
multiarch=$($my_cxx_compiler -v 2>&1| $GREP "$i" | $SED "s/.*$i[$BLANK]*\([a-z0-9_-]*\)/\1/" | $SED "s/-[a-z]*-linux-gnu/-linux-gnu/") |
| 287 |
if test -n "$multiarch"; then break; fi |
| 288 |
done |
| 289 |
fi |
| 290 |
set -e # set to old value. |
| 291 |
export MULTIARCH_LIBDIR="lib/$multiarch" |
| 292 |
} |
| 293 |
|
| 294 |
export PREFIX_DIR="`canonicalpath "$0"`/.." |
| 295 |
|
| 296 |
# Read the modules find part |
| 297 |
. "$PREFIX_DIR/lib/dunemodules.lib" |
| 298 |
|
| 299 |
############################################### |
| 300 |
|
| 301 |
|
| 302 |
############################################### |
| 303 |
### |
| 304 |
### Commands |
| 305 |
### |
| 306 |
|
| 307 |
# check all parameter |
| 308 |
check_commands() { |
| 309 |
while test $# -gt 0; do |
| 310 |
# get command |
| 311 |
command=$1 |
| 312 |
shift |
| 313 |
# skip command options |
| 314 |
while test $# -gt 0 && test "$1" != ":"; do |
| 315 |
shift |
| 316 |
done |
| 317 |
# skip command delimiter |
| 318 |
if test "$1" = ":"; then shift; fi |
| 319 |
# test the commands |
| 320 |
if ! is_command $command; then |
| 321 |
usage |
| 322 |
echo "ERROR: unknown command \"$command\"" >&2 |
| 323 |
exit 1 |
| 324 |
fi |
| 325 |
done |
| 326 |
} |
| 327 |
|
| 328 |
# check whether the parameter is valid command or not |
| 329 |
is_command() { |
| 330 |
eval ' |
| 331 |
case "$1" in |
| 332 |
'`echo $COMMANDS | $SED -e 's/ / | /g'`') |
| 333 |
return 0 |
| 334 |
;; |
| 335 |
*) |
| 336 |
return 1 |
| 337 |
;; |
| 338 |
esac' |
| 339 |
} |
| 340 |
|
| 341 |
# list of all dunecontrol commands |
| 342 |
COMMANDS="printdeps vcsetup update cmake configure make all exec bexec status svn git" |
| 343 |
|
| 344 |
# list of dunecontrol commands for which the version check is skipped by default |
| 345 |
COMMANDSTOSKIPVERSIONCHECK="update status svn git exec bexec" |
| 346 |
|
| 347 |
# help string for the commands |
| 348 |
printdeps_HELP="print recursive dependencies of a module" |
| 349 |
vcsetup_HELP="setup version control repository (Git etc.) or working copy (SVN)" |
| 350 |
update_HELP="update all modules from their repositories" |
| 351 |
cmake_HELP="run cmake for each module" |
| 352 |
configure_HELP="${cmake_HELP}" |
| 353 |
make_HELP="build each module" |
| 354 |
all_HELP="\trun 'vcsetup', 'configure' and 'make' command for each module" |
| 355 |
exec_HELP="execute an arbitrary command in each module source directory" |
| 356 |
bexec_HELP="execute an arbitrary command in each module build directory" |
| 357 |
status_HELP="show vc status for all modules" |
| 358 |
svn_HELP="\trun svn command for each svn managed module" |
| 359 |
git_HELP="\trun git command for each git managed module" |
| 360 |
|
| 361 |
# |
| 362 |
# setup command proxies |
| 363 |
# call will be forwarded to run_default_$command |
| 364 |
# |
| 365 |
|
| 366 |
for command in $COMMANDS; do |
| 367 |
eval "run_$command () { run_default_$command; }" |
| 368 |
done |
| 369 |
|
| 370 |
# |
| 371 |
# default implementations for commands... |
| 372 |
# these can be overwritten in the $CONTROL files |
| 373 |
# |
| 374 |
|
| 375 |
run_default_exec () { bash -c "eval $CMD_FLAGS"; } |
| 376 |
|
| 377 |
run_default_bexec () { |
| 378 |
if test -d "$ABS_BUILDDIR"; then |
| 379 |
bash -c "cd \"$ABS_BUILDDIR\" && eval $CMD_FLAGS"; |
| 380 |
else |
| 381 |
eval echo "Build directory \\\"$ABS_BUILDDIR\\\" not found, skipping bexec for \$NAME_${module}" |
| 382 |
fi |
| 383 |
} |
| 384 |
|
| 385 |
run_default_status () { |
| 386 |
local verbose=0 |
| 387 |
local update="" |
| 388 |
local is_git="" |
| 389 |
local is_svn="" |
| 390 |
name="$(eval echo \$NAME_$module)" |
| 391 |
|
| 392 |
if test -e .git; then is_git=1; fi |
| 393 |
if test -d .svn; then is_svn=1; fi |
| 394 |
if test ! "$is_svn" -a ! "$is_git" ; then |
| 395 |
echo "module $name not under known version control" |
| 396 |
return |
| 397 |
fi |
| 398 |
|
| 399 |
for i in $CMD_FLAGS; do |
| 400 |
if eval test "x$i" = "x-v"; then verbose=1; fi |
| 401 |
if eval test "x$i" = "x-vv"; then verbose=2; fi |
| 402 |
if eval test "x$i" = "x-u"; then update="-u"; fi |
| 403 |
done |
| 404 |
# is out output connected to a tty? |
| 405 |
if test -t 1; then |
| 406 |
blue="\e[1m\e[34m" |
| 407 |
green="\e[1m\e[32m" |
| 408 |
red="\e[1m\e[31m" |
| 409 |
reset="\e[0m\e[0m" |
| 410 |
fi |
| 411 |
|
| 412 |
if test $verbose -eq 1; then |
| 413 |
test "$is_svn" && svn status $update | $GREP -E "^M|^A|^D|^C|^U" |
| 414 |
test "$is_git" && git status -uno |
| 415 |
elif test $verbose -eq 2; then |
| 416 |
test "$is_svn" && svn status $update |
| 417 |
test "$is_git" && git status |
| 418 |
fi |
| 419 |
|
| 420 |
|
| 421 |
if test "$is_svn" ; then |
| 422 |
changed=$(svn status | $GREP -E "^M|^A|^D" | wc -l) |
| 423 |
collisions=$(svn status | $GREP -E "^C"| wc -l) |
| 424 |
pending=$(svn status $update | $GREP -E "^...... \* " | wc -l) |
| 425 |
fi |
| 426 |
if test "$is_git" ; then |
| 427 |
changed=$(git status --porcelain | $GREP -E "^ *M|^ *A|^ *D|^ *R|^ *C" | wc -l) |
| 428 |
collisions=$(git status --porcelain | $GREP -E "^ *U"| wc -l) |
| 429 |
pending=$(git status | $GREP -E "^\# Your branch is ahead |^\# Your branch is behind " | wc -l) |
| 430 |
fi |
| 431 |
color=$green |
| 432 |
text="no changes" |
| 433 |
if [ $changed -eq 0 ]; then |
| 434 |
true |
| 435 |
elif [ $changed -eq 1 ]; then |
| 436 |
color=$blue; |
| 437 |
text="1 change" |
| 438 |
else |
| 439 |
color=$blue; |
| 440 |
text="$changed changes" |
| 441 |
fi |
| 442 |
if [ $pending -eq 0 ]; then |
| 443 |
true |
| 444 |
elif [ $pending -eq 1 ]; then |
| 445 |
color=$blue; |
| 446 |
text="$text, 1 update pending" |
| 447 |
else |
| 448 |
color=$blue; |
| 449 |
text="$text, $pending updates pending" |
| 450 |
fi |
| 451 |
if [ $collisions -eq 0 ]; then |
| 452 |
true |
| 453 |
elif [ $collisions -eq 1 ]; then |
| 454 |
color=$red |
| 455 |
text="$text, 1 collision" |
| 456 |
else |
| 457 |
color=$red |
| 458 |
text="$text, $count collisions" |
| 459 |
fi |
| 460 |
echo -e "$color[$text]$reset $name" |
| 461 |
} |
| 462 |
|
| 463 |
run_default_vcsetup() { |
| 464 |
# load user options |
| 465 |
if [ -n "$CMD_FLAGS" ]; then |
| 466 |
eval "$CMD_FLAGS" |
| 467 |
fi |
| 468 |
|
| 469 |
# Check for both a file and a directory to cope with Git submodules |
| 470 |
if [ -e .git ] ; then |
| 471 |
|
| 472 |
# Read Whitespace-Hook setting from dune.module file |
| 473 |
local SETUPGITHOOK="$($GREP -i "^[$BLANK]*Whitespace-Hook:" dune.module | cut -d ':' -f2 | eval $PARSER_TRIM | tr '[:upper:]' '[:lower:]')" |
| 474 |
|
| 475 |
if [ "x$SETUPGITHOOK" = "xyes" ]; then |
| 476 |
# we have to install the Git whitespace hook |
| 477 |
|
| 478 |
# There are several options as to what the current worktree might be backed by right now: |
| 479 |
# - a plain old repository -> copy to .git/hooks |
| 480 |
# - a submodule repository -> .git refers to the submodule repository inside the root $GIT_DIR |
| 481 |
# - a git repo worktree -> .git refers to the worktree data inside the original $GIT_DIR and we need to find |
| 482 |
# the "canonical" $GIT_DIR root |
| 483 |
# - a submodule in a worktree -> That just gets checked out again into the worktree backing store, so no worktree |
| 484 |
# dereferencing here |
| 485 |
|
| 486 |
# We try this first by trying git's built-in infrastructure, but if the user's git is too old, we fall back to |
| 487 |
# manual parsing |
| 488 |
|
| 489 |
GITHOOKPATH="$(git rev-parse --git-common-dir)" |
| 490 |
if [ $? -ne 0 -o "${GITHOOKPATH}" = "--git-common-dir" ] ; then |
| 491 |
|
| 492 |
# no worktree support from here on out |
| 493 |
|
| 494 |
GITHOOKPATH="$(git rev-parse --git-dir)" |
| 495 |
|
| 496 |
if [ $? -ne 0 -o "${GITHOOKPATH}" = "--git-dir" ] ; then |
| 497 |
|
| 498 |
# do the parsing manually |
| 499 |
|
| 500 |
if [ -f .git ] ; then |
| 501 |
# submodule -> .git contains a pointer to the repository |
| 502 |
GITHOOKPATH="$($SED 's/gitdir: //' < .git)" |
| 503 |
else |
| 504 |
# standard case, .git is the repository |
| 505 |
GITHOOKPATH=.git |
| 506 |
fi |
| 507 |
fi |
| 508 |
fi |
| 509 |
GITHOOKPATH="${GITHOOKPATH}/hooks/pre-commit" |
| 510 |
|
| 511 |
if [ -n "$DISABLEWHITESPACEHOOK" ] ; then |
| 512 |
# the user doesn't want the Git whitespace hook - deinstall it if necessary and warn the user |
| 513 |
echo "WARNING: The current module wants to install the DUNE whitespace hook, but you have disabled the hook in your options!" |
| 514 |
echo "WARNING: You will have to make sure that your commits don't introduce any trailing whitespace or indentation with tabs!" |
| 515 |
echo "WARNING: Otherwise, your commits might be rejected when trying to push them to an official repository!" |
| 516 |
|
| 517 |
if [ -e "$GITHOOKPATH" ]; then |
| 518 |
# there is a pre-commit hook, check whether it is our whitespace hook |
| 519 |
local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" |
| 520 |
if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then |
| 521 |
echo "--> Removing DUNE whitespace hook as requested by the user" |
| 522 |
rm "$GITHOOKPATH" |
| 523 |
fi |
| 524 |
fi |
| 525 |
else |
| 526 |
# standard handling of Git whitespace hook |
| 527 |
for f in dune-git-whitespace-hook git-whitespace-hook; do |
| 528 |
f="${PREFIX_DIR}/bin/${f}" |
| 529 |
if [ -e "${f}" ]; then |
| 530 |
git_whitespace_hook="${f}" |
| 531 |
break |
| 532 |
fi |
| 533 |
done |
| 534 |
if [ -z "${git_whitespace_hook:-}" ]; then |
| 535 |
echo "Did not find git-whitespace-hook." >&2 |
| 536 |
exit 1 |
| 537 |
fi |
| 538 |
if [ ! -e "$GITHOOKPATH" ]; then |
| 539 |
# there is no hook yet, we can safely install ours |
| 540 |
echo "--> Installing Git pre-commit hook to enforce whitespace policy" |
| 541 |
cp -p "${git_whitespace_hook}" "$GITHOOKPATH" |
| 542 |
else |
| 543 |
# there is already a hook, check whether it is our whitespace hook |
| 544 |
local HOOKTAG="$(eval head -n 2 \"$GITHOOKPATH\" | tail -n 1)" |
| 545 |
if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then |
| 546 |
if [ "${git_whitespace_hook}" -nt "$GITHOOKPATH" ]; then |
| 547 |
echo "--> Updating Git pre-commit hook with newer version" |
| 548 |
cp -p "${git_whitespace_hook}" "$GITHOOKPATH" |
| 549 |
fi |
| 550 |
else |
| 551 |
echo "WARNING: Existing pre-commit hook found!" |
| 552 |
echo "WARNING: Skipping installation of DUNE whitespace hook!" |
| 553 |
echo "WARNING: If you want to contribute patches to DUNE, you should make sure to call the whitespace hook" |
| 554 |
echo "WARNING: (dune-common/bin/git-whitespace-hook) from you custom pre-commit hook, otherwise your commits" |
| 555 |
echo "WARNING: might contain trailing whitespace and will not apply cleanly to the official repositories!" |
| 556 |
fi |
| 557 |
fi |
| 558 |
fi |
| 559 |
fi |
| 560 |
|
| 561 |
# Apply git configuration settings |
| 562 |
if [ -f .vcsetup/config ]; then |
| 563 |
echo -n "--> Setting Git configuration entries... " |
| 564 |
cat .vcsetup/config | while read; do |
| 565 |
# Filter out comments |
| 566 |
local COMMENT="$(echo $REPLY | $GREP '^#')" |
| 567 |
if [ ! "x$COMMENT" = "x$REPLY" ]; then |
| 568 |
# parse line into an array first to catch obvious syntax errors |
| 569 |
# like 'option value; rm -rf /' |
| 570 |
eval local GIT_ARGS=($REPLY) |
| 571 |
git config "${GIT_ARGS[@]}" |
| 572 |
fi |
| 573 |
done |
| 574 |
echo "done" |
| 575 |
fi |
| 576 |
|
| 577 |
# Apply user supplied configuration settings |
| 578 |
if [ -n "$GIT_CONFIG_FILE" ]; then |
| 579 |
if [ -f "$GIT_CONFIG_FILE" ]; then |
| 580 |
echo -n "--> Setting custom Git configuration entries from '$GIT_CONFIG_FILE'... " |
| 581 |
cat "$GIT_CONFIG_FILE" | while read; do |
| 582 |
# Filter out comments |
| 583 |
local COMMENT="$(echo $REPLY | $GREP '^#')" |
| 584 |
if [ ! "x$COMMENT" = "x$REPLY" ]; then |
| 585 |
# parse line into an array first to catch obvious syntax errors |
| 586 |
# like 'option value; rm -rf /' |
| 587 |
eval local GIT_ARGS=($REPLY) |
| 588 |
git config "${GIT_ARGS[@]}" |
| 589 |
fi |
| 590 |
done |
| 591 |
echo "done" |
| 592 |
else |
| 593 |
echo "WARNING: custom Git config file '$GIT_CONFIG_FILE' not found!" |
| 594 |
fi |
| 595 |
fi |
| 596 |
|
| 597 |
fi |
| 598 |
|
| 599 |
# Run custom setup scripts |
| 600 |
if [ -e .git -o -d .svn ]; then |
| 601 |
if [ -d .vcsetup/run.d ]; then |
| 602 |
for SCRIPT in .vcsetup/run.d/* ; do |
| 603 |
if [ -x "$SCRIPT" ]; then |
| 604 |
echo "--> Running $SCRIPT" |
| 605 |
"$SCRIPT" |
| 606 |
fi |
| 607 |
done |
| 608 |
fi |
| 609 |
fi |
| 610 |
} |
| 611 |
|
| 612 |
run_default_update () { |
| 613 |
if test -d .svn; then |
| 614 |
svn update |
| 615 |
elif test -e .git; then |
| 616 |
if test -d .git && test -d ".git/svn" && test -n "`git svn find-rev HEAD`"; then |
| 617 |
# If the current HEAD points to a SVN commit, update via git-svn |
| 618 |
git svn rebase |
| 619 |
else |
| 620 |
# Update all remotes (if any) |
| 621 |
git remote update |
| 622 |
|
| 623 |
# merge all changes fast-forward style if possible |
| 624 |
if ! git merge --ff-only FETCH_HEAD 2> /dev/null; then |
| 625 |
eval echo "\$NAME_${module} seems to be using git, and could not be" |
| 626 |
echo "updated automatically. Please update it manually." |
| 627 |
echo "(Usually, this is done via 'git svn rebase' for modules using" |
| 628 |
echo "subversion or 'git merge' for modules which use git natively." |
| 629 |
echo "Conflicts can be resolved using 'git mergetool'.)" |
| 630 |
fi |
| 631 |
fi |
| 632 |
else |
| 633 |
eval echo "WARNING: \$NAME_${module} is not under a known version control system." |
| 634 |
echo " We support svn and git." |
| 635 |
fi |
| 636 |
} |
| 637 |
|
| 638 |
run_default_cmake () { |
| 639 |
extract_multiarch |
| 640 |
|
| 641 |
# tell CMake about the build directory root when we are using an absolute build directory |
| 642 |
if [[ ${BUILDDIR} = /* ]] ; then |
| 643 |
CMAKE_PARAMS="$CMAKE_PARAMS -DDUNE_BUILD_DIRECTORY_ROOT_PATH='${BUILDDIR}'" |
| 644 |
fi |
| 645 |
|
| 646 |
# add arguments given as configure-opts to CMAKE_params |
| 647 |
CMAKE_PARAMS="$CMAKE_PARAMS $CMD_FLAGS" |
| 648 |
|
| 649 |
# get dependencies & suggestions |
| 650 |
sort_modules $module |
| 651 |
for m in $MODULES; do |
| 652 |
path="$(eval "echo \$PATH_$m")" |
| 653 |
|
| 654 |
# add other module's build dir to path |
| 655 |
if [ $module != $m ] ; then |
| 656 |
name=$(eval "echo \$NAME_$m") |
| 657 |
local m_ABS_BUILDDIR=$(abs_builddir $m $BUILDDIR) |
| 658 |
|
| 659 |
config_dir="$path" |
| 660 |
for i in $MULTIARCH_LIBDIR lib lib64 lib32; do |
| 661 |
if test -d "$path/$i/cmake/$name"; then |
| 662 |
config_dir="$path/$i/cmake/$name" |
| 663 |
break; |
| 664 |
fi |
| 665 |
done |
| 666 |
if test -d "$m_ABS_BUILDDIR"; then |
| 667 |
config_dir="$m_ABS_BUILDDIR" |
| 668 |
fi |
| 669 |
# Only add directories with CMake config files to -Dmodule_DIR |
| 670 |
# Then there is at least a chance to find packages in default locations |
| 671 |
if ls "$config_dir"/*onfig.cmake 1> /dev/null 2>&1; then |
| 672 |
CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$config_dir\"" |
| 673 |
fi |
| 674 |
fi |
| 675 |
done |
| 676 |
# create build directory if requested |
| 677 |
test -d "$ABS_BUILDDIR" || mkdir -p "$ABS_BUILDDIR" |
| 678 |
SRCDIR="$PWD" |
| 679 |
cd "$ABS_BUILDDIR" |
| 680 |
|
| 681 |
# Prevent using an empty module path |
| 682 |
if test -n "$CMAKE_MODULE_PATH"; then |
| 683 |
_MODULE_PATH="-DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\"" |
| 684 |
fi |
| 685 |
echo "$CMAKE $_MODULE_PATH $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\"" |
| 686 |
eval $CMAKE "$_MODULE_PATH $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\"" || exit 1 |
| 687 |
} |
| 688 |
|
| 689 |
run_default_configure () { |
| 690 |
# configure just forwards to cmake |
| 691 |
run_default_cmake |
| 692 |
} |
| 693 |
|
| 694 |
run_default_make () { |
| 695 |
test ! -d "$ABS_BUILDDIR" || cd "$ABS_BUILDDIR" |
| 696 |
PARAMS="$CMD_FLAGS" |
| 697 |
echo "build directory: $BUILDDIR" |
| 698 |
# prepend '--' to separate cmake and make parameters |
| 699 |
if ! $(echo "$PARAMS" | grep -q -- '--'); then |
| 700 |
PARAMS="-- $PARAMS" |
| 701 |
fi |
| 702 |
echo $CMAKE --build . "$PARAMS" |
| 703 |
eval $CMAKE --build . "$PARAMS" |
| 704 |
} |
| 705 |
|
| 706 |
run_default_all () { |
| 707 |
for cmd in vcsetup cmake make; do |
| 708 |
eval echo "--- calling $cmd for \$NAME_${module} ---" |
| 709 |
load_opts $cmd |
| 710 |
run_$cmd |
| 711 |
done |
| 712 |
} |
| 713 |
|
| 714 |
run_default_svn () { |
| 715 |
if test -d .svn; then |
| 716 |
PARAMS="$CMD_FLAGS" |
| 717 |
eval svn "$PARAMS" |
| 718 |
fi |
| 719 |
} |
| 720 |
|
| 721 |
run_default_git () { |
| 722 |
if test -e .git; then |
| 723 |
PARAMS="$CMD_FLAGS" |
| 724 |
eval git "$PARAMS" |
| 725 |
fi |
| 726 |
} |
| 727 |
|
| 728 |
############################################### |
| 729 |
### |
| 730 |
### main |
| 731 |
### |
| 732 |
|
| 733 |
onfailure() { |
| 734 |
echo "Execution of $(basename "$0") terminated due to errors!" >&2 |
| 735 |
exit 1 |
| 736 |
} |
| 737 |
|
| 738 |
usage () { |
| 739 |
( |
| 740 |
echo "Usage: $(basename "$0") [OPTIONS] COMMANDS [COMMAND-OPTIONS]" |
| 741 |
echo "" |
| 742 |
echo " Execute COMMANDS for all Dune modules found. All entries in the" |
| 743 |
echo " DUNE_CONTROL_PATH variable are scanned recursively for Dune modules." |
| 744 |
echo " If DUNE_CONTROL_PATH is empty, the current directory is scanned." |
| 745 |
echo " Dependencies are controlled by the $CONTROL files." |
| 746 |
echo "" |
| 747 |
echo "OPTIONS:" |
| 748 |
echo " -h, --help show this help" |
| 749 |
echo " --debug enable debug output of this script" |
| 750 |
echo " -v, --verbose print additional information when building up the dependency tree" |
| 751 |
echo " --module=mod apply the actions on module mod" |
| 752 |
echo " and all modules it depends on" |
| 753 |
echo " --only=mod only apply the actions on module mod" |
| 754 |
echo " and not the modules it depends on" |
| 755 |
echo " --current only apply the actions on the current module," |
| 756 |
echo " i.e. the one whose source tree we are standing in," |
| 757 |
echo " and not the modules it depends on" |
| 758 |
echo " --current-dep apply the actions on the current module," |
| 759 |
echo " and all modules it depends on" |
| 760 |
echo " --resume resume a previous run (only consider the modules" |
| 761 |
echo " not built successfully on the previous run)" |
| 762 |
echo " --skipfirst skip the first module (use with --resume)" |
| 763 |
echo " --skipversioncheck do not perform version checks when looking for other Dune modules" |
| 764 |
echo " --opts=FILE load default options from FILE" |
| 765 |
echo " --builddir=NAME make out-of-source builds in a subdir NAME." |
| 766 |
echo " This directory is created inside each module." |
| 767 |
echo " If NAME is an absolute path, the build directory " |
| 768 |
echo " is set to NAME/module-name for each module." |
| 769 |
echo " --[COMMAND]-opts=opts set options for COMMAND" |
| 770 |
echo " (this is mainly useful for the 'all' COMMAND)" |
| 771 |
echo "COMMANDS:" |
| 772 |
echo " Colon-separated list of commands. Available commands are:" |
| 773 |
printf " \`help'\tguess what :-)\n" |
| 774 |
printf " \`print'\tprint the list of modules sorted after their dependencies\n" |
| 775 |
printf " \`info'\tsame as \`print\', but including whether it is a dependency or suggestion\n" |
| 776 |
for i in $COMMANDS; do |
| 777 |
printf " \`$i'\t$(eval echo \$${i}_HELP)\n" |
| 778 |
done |
| 779 |
printf " \`export'\trun eval \`dunecontrol export\` to save the list of\n" |
| 780 |
printf " \t\tdune.module files to the DUNE_CONTROL_PATH variable\n" |
| 781 |
echo |
| 782 |
) >&2 |
| 783 |
} |
| 784 |
|
| 785 |
# create the module list |
| 786 |
create_module_list() { |
| 787 |
# try to get the resume file name from the options |
| 788 |
if test -z "$RESUME_FILE" && test -n "$DUNE_OPTS_FILE"; then |
| 789 |
export RESUME_FILE="$(eval . \"$DUNE_OPTS_FILE\"; eval echo \$RESUME_FILE)" |
| 790 |
fi |
| 791 |
|
| 792 |
if test "$RESUME_FLAG" = "yes" ; then |
| 793 |
if ! test -s "$RESUME_FILE" ; then |
| 794 |
echo "Error: No previous run to resume. Please make sure that the RESUME_FILE" |
| 795 |
echo " is the name of a writeable file (currently it is '$RESUME_FILE')" |
| 796 |
exit 1 |
| 797 |
fi |
| 798 |
|
| 799 |
export MODULES= |
| 800 |
RESUME="`cat "$RESUME_FILE"`" |
| 801 |
for a in $RESUME ; do |
| 802 |
export NAME_`fix_variable_name $a`="$a" |
| 803 |
fix_and_assign MODULE "$a" |
| 804 |
export SEARCH_MODULES="$SEARCH_MODULES $MODULE" |
| 805 |
export ONLY="$ONLY $MODULE" |
| 806 |
done |
| 807 |
fi |
| 808 |
|
| 809 |
find_modules_in_path |
| 810 |
if test "x$ONLY" != x; then |
| 811 |
export MODULES="$ONLY" |
| 812 |
elif test "x$SEARCH_MODULES" != "x"; then |
| 813 |
sort_modules $SEARCH_MODULES |
| 814 |
else |
| 815 |
sort_modules $MODULES |
| 816 |
fi |
| 817 |
|
| 818 |
if test "x$REVERSE_FLAG" = "xyes"; then |
| 819 |
export MODULES="$REVERSEMODULES" |
| 820 |
fi |
| 821 |
|
| 822 |
if test "x$SKIPFIRST" = "xyes" ; then |
| 823 |
export MODULES=`echo $MODULES " " | cut '--delimiter= ' --fields=2-` |
| 824 |
fi |
| 825 |
# warn about superseded modules: |
| 826 |
if test -n "$superseded_modules"; then |
| 827 |
# sort moules list and make it unique. |
| 828 |
superseded_modules=$(echo $superseded_modules | tr ' ' '\n'| sort -u) |
| 829 |
echo >&2 |
| 830 |
echo "The following local modules do supersede the corresponding installed ones:" >&2 |
| 831 |
echo "$superseded_modules" >&2 |
| 832 |
echo >&2 |
| 833 |
fi |
| 834 |
} |
| 835 |
|
| 836 |
# print the module list |
| 837 |
print_module_list() { |
| 838 |
DELIM=$1 |
| 839 |
shift |
| 840 |
while test -n "$2"; do |
| 841 |
echo -n "$(eval echo \$NAME_$1)$DELIM" |
| 842 |
shift |
| 843 |
done |
| 844 |
echo -n "$(eval echo \$NAME_$1)" |
| 845 |
} |
| 846 |
|
| 847 |
trap onfailure EXIT |
| 848 |
|
| 849 |
# clear variables |
| 850 |
export SEARCH_MODULES="" |
| 851 |
export MODULES="" |
| 852 |
export ONLY="" |
| 853 |
export RESUME_FLAG=no |
| 854 |
export REVERSE_FLAG=no |
| 855 |
export SKIPFIRST=no |
| 856 |
export DUNE_CONTROL_VERBOSE=no |
| 857 |
|
| 858 |
# parse commandline parameters |
| 859 |
while test $# -gt 0; do |
| 860 |
# get option |
| 861 |
command=$1 |
| 862 |
option=$1 |
| 863 |
|
| 864 |
# get args |
| 865 |
set +e |
| 866 |
# stolen from configure... |
| 867 |
# when no option is set, this returns an error code |
| 868 |
arg=`expr "x$option" : 'x[^=]*=\(.*\)'` |
| 869 |
set -e |
| 870 |
|
| 871 |
# switch |
| 872 |
case "$option" in |
| 873 |
--opts=*) |
| 874 |
if test "x$arg" = "x"; then |
| 875 |
usage |
| 876 |
echo "ERROR: Parameter for --opts is missing" >&2 |
| 877 |
echo >&2 |
| 878 |
exit 1; |
| 879 |
fi |
| 880 |
DUNE_OPTS_FILE=`canonicalname $arg` |
| 881 |
if ! test -r "$DUNE_OPTS_FILE"; then |
| 882 |
usage |
| 883 |
echo "ERROR: could not read opts file \"$DUNE_OPTS_FILE\"" >&2 |
| 884 |
echo >&2 |
| 885 |
exit 1; |
| 886 |
fi |
| 887 |
;; |
| 888 |
--*-opts=*) |
| 889 |
optcmd=`expr "x$option=" : 'x--\([^-]*\)-opts=.*'` |
| 890 |
if is_command $optcmd; then |
| 891 |
COMMAND=`echo $optcmd | tr '[:lower:]' '[:upper:]'` |
| 892 |
export ${COMMAND}_FLAGS="$arg" |
| 893 |
else |
| 894 |
usage |
| 895 |
echo "ERROR: unknown option \"$option\"" >&2 |
| 896 |
exit 1 |
| 897 |
fi |
| 898 |
;; |
| 899 |
-h|--help) |
| 900 |
command=help |
| 901 |
break |
| 902 |
;; |
| 903 |
-p|--print) |
| 904 |
command=print |
| 905 |
break |
| 906 |
;; |
| 907 |
--module=*) |
| 908 |
if test "x$arg" = "x"; then |
| 909 |
usage |
| 910 |
echo "ERROR: Parameter for --module is missing" >&2 |
| 911 |
echo >&2 |
| 912 |
exit 1; |
| 913 |
fi |
| 914 |
for a in `echo $arg | tr ',' ' '`; do |
| 915 |
export NAME_`fix_variable_name $a`="$a" |
| 916 |
fix_and_assign MODULE "$a" |
| 917 |
export SEARCH_MODULES="$SEARCH_MODULES $MODULE" |
| 918 |
done |
| 919 |
;; |
| 920 |
--only=*) |
| 921 |
if test "x$arg" = "x"; then |
| 922 |
usage |
| 923 |
echo "ERROR: Parameter for --only is missing" >&2 |
| 924 |
echo >&2 |
| 925 |
exit 1; |
| 926 |
fi |
| 927 |
for a in `echo $arg | tr ',' ' '`; do |
| 928 |
export NAME_`fix_variable_name $a`="$a" |
| 929 |
fix_and_assign MODULE "$a" |
| 930 |
export SEARCH_MODULES="$SEARCH_MODULES $MODULE" |
| 931 |
export ONLY="$ONLY $MODULE" |
| 932 |
done |
| 933 |
;; |
| 934 |
--builddir=*) |
| 935 |
export DUNE_BUILDDIR=$arg |
| 936 |
;; |
| 937 |
--no-builddir) |
| 938 |
export DUNE_BUILDDIR="" |
| 939 |
;; |
| 940 |
--skipversioncheck) |
| 941 |
export SKIPVERSIONCHECK=yes |
| 942 |
;; |
| 943 |
--current) |
| 944 |
while ! test -f $CONTROL; do |
| 945 |
cd .. |
| 946 |
if test "$OLDPWD" = "$PWD"; then |
| 947 |
echo "You are not inside the source tree of a DUNE module." >&2 |
| 948 |
exit -1 |
| 949 |
fi |
| 950 |
done; |
| 951 |
parse_control $PWD/$CONTROL |
| 952 |
fix_and_assign MODULE "$module" |
| 953 |
export SEARCH_MODULES="$SEARCH_MODULES $MODULE" |
| 954 |
export ONLY="$ONLY $MODULE" |
| 955 |
;; |
| 956 |
--current-dep) |
| 957 |
while ! test -f $CONTROL; do |
| 958 |
cd .. |
| 959 |
if test "$OLDPWD" = "$PWD"; then |
| 960 |
echo "You are not inside the source tree of a DUNE module." >&2 |
| 961 |
exit -1 |
| 962 |
fi |
| 963 |
done; |
| 964 |
parse_control $PWD/$CONTROL |
| 965 |
fix_and_assign MODULE "$module" |
| 966 |
export SEARCH_MODULES="$SEARCH_MODULES $MODULE" |
| 967 |
;; |
| 968 |
--resume) |
| 969 |
export RESUME_FLAG="yes" |
| 970 |
;; |
| 971 |
--reverse) |
| 972 |
export REVERSE_FLAG="yes" |
| 973 |
;; |
| 974 |
--skipfirst) |
| 975 |
export SKIPFIRST=yes |
| 976 |
;; |
| 977 |
-v|--verbose) |
| 978 |
export DUNE_CONTROL_VERBOSE=yes |
| 979 |
;; |
| 980 |
--debug) true ;; # ignore this option, it is handled right at the beginning |
| 981 |
--*) |
| 982 |
usage |
| 983 |
echo "ERROR: Unknown option \`$option'" >&2 |
| 984 |
echo >&2 |
| 985 |
exit 1 |
| 986 |
;; |
| 987 |
*) |
| 988 |
break |
| 989 |
;; |
| 990 |
esac |
| 991 |
|
| 992 |
shift |
| 993 |
done |
| 994 |
|
| 995 |
extract_multiarch |
| 996 |
|
| 997 |
# create PKG_CONFIG_PATH for installed dune modules |
| 998 |
for i in $MULTIARCH_LIBDIR lib64 lib32 lib; do |
| 999 |
if test -d "$PREFIX_DIR/$i/pkgconfig"; then |
| 1000 |
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/$i/pkgconfig" |
| 1001 |
fi |
| 1002 |
done |
| 1003 |
|
| 1004 |
# we assume there should be a command... |
| 1005 |
if test "x$command" = "x"; then |
| 1006 |
usage |
| 1007 |
exit 1 |
| 1008 |
fi |
| 1009 |
|
| 1010 |
case "$command" in |
| 1011 |
print) |
| 1012 |
create_module_list |
| 1013 |
eval "print_module_list ' ' $MODULES" |
| 1014 |
echo >&2 |
| 1015 |
;; |
| 1016 |
info) |
| 1017 |
create_module_list |
| 1018 |
echo $SORTEDMODULES_INFO |
| 1019 |
;; |
| 1020 |
export) |
| 1021 |
create_module_list |
| 1022 |
DUNE_CONTROL_PATH="" |
| 1023 |
for mod in $MODULES; do |
| 1024 |
path="$(eval echo \$PATH_$mod)" |
| 1025 |
name=$(eval echo \$NAME_$mod) |
| 1026 |
if test -f "$path/dune.module"; then |
| 1027 |
export DUNE_CONTROL_PATH="$DUNE_CONTROL_PATH:$path/dune.module" |
| 1028 |
else |
| 1029 |
if test -f "$path/lib/dunecontrol/$name/dune.module"; then |
| 1030 |
export DUNE_CONTROL_PATH="$DUNE_CONTROL_PATH:$path/lib/dunecontrol/$name/dune.module" |
| 1031 |
else |
| 1032 |
echo "ERROR: while creating list of dune.module files" >&2 |
| 1033 |
echo " couldn't find dune.module file for $name in $path" >&2 |
| 1034 |
echo >&2 |
| 1035 |
exit 1 |
| 1036 |
fi |
| 1037 |
fi |
| 1038 |
done |
| 1039 |
echo export DUNE_CONTROL_PATH=$(echo $DUNE_CONTROL_PATH | $SED -e 's/^://') |
| 1040 |
;; |
| 1041 |
printdeps) |
| 1042 |
find_modules_in_path |
| 1043 |
if test "x$SEARCH_MODULES" == "x"; then |
| 1044 |
echo "ERROR: printdeps requires an explicit --module=... parameter" >&2 |
| 1045 |
exit 1 |
| 1046 |
fi |
| 1047 |
mainmod=`echo $SEARCH_MODULES` |
| 1048 |
name=`eval echo \\${NAME_$mainmod}` |
| 1049 |
echo "dependencies for $name" |
| 1050 |
### DEPENDENCIES |
| 1051 |
sort_modules $mainmod |
| 1052 |
for mod in $SORTEDMODULES_DEPS; do |
| 1053 |
eval echo "\" \$NAME_${mod} (required)\"" |
| 1054 |
done |
| 1055 |
for mod in $SORTEDMODULES_SUGS; do |
| 1056 |
eval echo "\" \$NAME_${mod} (suggested)\"" |
| 1057 |
done |
| 1058 |
;; |
| 1059 |
unexport) |
| 1060 |
echo export DUNE_CONTROL_PATH="" |
| 1061 |
;; |
| 1062 |
help) |
| 1063 |
usage |
| 1064 |
;; |
| 1065 |
*) |
| 1066 |
set -e |
| 1067 |
# skip version check if command is in according list |
| 1068 |
if grep -q "$1" <<<"$COMMANDSTOSKIPVERSIONCHECK" ; then |
| 1069 |
export SKIPVERSIONCHECK=yes; |
| 1070 |
fi |
| 1071 |
check_commands "$@" |
| 1072 |
create_module_list |
| 1073 |
NAMES="" |
| 1074 |
BUILDMODULES="" |
| 1075 |
for mod in $MODULES; do |
| 1076 |
if test "$(eval echo \$INST_$mod)" != "yes"; then |
| 1077 |
NAMES="$NAMES$(eval echo \$NAME_$mod) " |
| 1078 |
BUILDMODULES="$BUILDMODULES$mod " |
| 1079 |
fi |
| 1080 |
done |
| 1081 |
echo "--- going to build $NAMES ---" |
| 1082 |
if test -n "$RESUME_FILE"; then |
| 1083 |
# write all modules to the resume file |
| 1084 |
for mod in $MODULES ; do |
| 1085 |
echo "$mod" |
| 1086 |
done > "$RESUME_FILE" |
| 1087 |
fi |
| 1088 |
|
| 1089 |
for mod in $BUILDMODULES; do |
| 1090 |
build_module "$mod" "$@" |
| 1091 |
|
| 1092 |
if test -n "$RESUME_FILE"; then |
| 1093 |
# remove the current module from the resume file |
| 1094 |
modules_togo=`cat "$RESUME_FILE"` |
| 1095 |
for mod_togo in $modules_togo ; do |
| 1096 |
if test "$mod_togo" != "$mod" ; then |
| 1097 |
echo "$mod_togo" |
| 1098 |
fi |
| 1099 |
done > "$RESUME_FILE" |
| 1100 |
fi |
| 1101 |
done |
| 1102 |
echo "--- done ---" |
| 1103 |
;; |
| 1104 |
esac |
| 1105 |
|
| 1106 |
trap - EXIT |