add docker compilation to travis (#3433)

* add docker compilation to travis

add new matrix entry in .travis.yml for compiling on 18.04
add Dockerfile in .ci to build ubuntu 18.04 inside docker
remove release entry for uvuntu 16.04 to not conflict
refactor .travis.yml
refactor travis-comile.sh
merge travis-dependencies.sh into the travis.yml
remove travis-dependencies.sh

* enable debugging on travis-compile.sh

* set ubuntu16 buildtype to "Debug"

set buildtype Debug for as requirement for "test"
add --debug and --release flags to travis-compile.sh

* make output prettier

edit the format warning message and clangify.sh output

* fix clangify.sh

fix --cf-version flag
fix directory argument parsing
add directory parsing details to --help
add examples to --help
This commit is contained in:
ebbit1q 2018-11-16 15:44:22 +01:00 committed by ctrlaltca
parent f70699d3de
commit 72ed98e404
5 changed files with 206 additions and 105 deletions

View file

@ -4,13 +4,8 @@
# Never, ever, should this recieve a path with a newline in it. Don't bother proofing it for that.
# use script dir and return on exit
current=$PWD
function cleanup {
cd $current
}
trap cleanup EXIT
cd "${BASH_SOURCE%/*}/"
# go to the project root directory, this file should be located in the project root directory
cd "${BASH_SOURCE%/*}/" || exit 2 # could not find path, this could happen with special links etc.
# defaults
include=("common" \
@ -44,14 +39,19 @@ while [[ $@ ]]; do
;;
'-h'|'--help')
cat <<EOM
A bash script to format your code using clang-format.
If no options are given, all dirty files are edited in place.
If <dir>s are given, all source files in those directories are checked, recursively.
A bash script to automatically format your code using clang-format.
USAGE: $0 [option] [-b[ranch] <git branch or object>] [<dir> ...]
If no options are given, all dirty source files are edited in place.
If <dir>s are given, all source files in those directories of the project root
path are formatted. To only format changed files in these directories use the
--branch option in combination. <dir> has to be a path relative to the project
root path or a full path inside $PWD.
. can not be specified as a dir, if you really want to format everything use */.
USAGE: $0 [option] [--branch <git branch or object>] [<dir> ...]
DEFAULTS:
Default includes are:
Current includes are:
${include[@]/%/
}
Default excludes are:
@ -62,7 +62,8 @@ OPTIONS:
Compare to this git branch and format only files that differ.
If unspecified it defaults to origin/master.
To not compare to a branch this has to be explicitly set to "".
When not comparing to a branch git will not be used at all and all valid files will be parsed.
When not comparing to a branch, git will not be used at all and every
source file in the entire project will be parsed.
-c, --color-diff
Display a colored diff. Implies --diff.
@ -80,11 +81,23 @@ OPTIONS:
-t, --test
Do not edit files in place. Set exit code to 1 if changes are required.
--cf-version
Print the version of clang-format being used before continuing.
EXIT CODES:
0 on a successful format or if no files require formatting.
1 if a file requires formatting.
2 if given incorrect arguments.
3 if clang-format could not be found.
EXAMPLES:
$0 --test \$PWD || echo "code requires formatting"
Tests if the source files in the current directory are correctly
formatted and prints an error message if formatting is required.
$0 --branch $USER/patch-2 ${include[0]}
Formats all changed files compared to the git branch "$USER/patch-2"
in the directory ${include[0]}.
EOM
exit 0
;;
@ -96,24 +109,31 @@ EOM
mode=code
shift
;;
'--cf-version')
print_version=1
shift
;;
'--')
shift
;;
*)
include=() # empty includes
while [[ $@ ]]; do
if [[ -d $1 ]]; then
include+=("$1")
shift
else
echo "error in parsing arguments of $0: $1 is not a directory" >&2
if next_dir=$(cd "$1" && pwd); then
if [[ ${next_dir#$PWD/} == /* ]]; then
echo "error in parsing arguments of $0: $next_dir is not in $PWD" >&2
exit 2 # input error
elif ! [[ $set_include ]]; then
include=() # remove default includes
set_include=1
fi
done
include+=("${next_dir#$PWD/}")
else
echo "error in parsing arguments of $0: $PWD/$1 is not a directory" >&2
exit 2 # input error
fi
if ! [[ $set_branch ]]; then
unset branch # unset branch if not set explicitly
fi
break
shift
;;
esac
done
@ -152,6 +172,9 @@ if ! [[ $names ]]; then
exit 0 # nothing to format means format is successful!
fi
# optionally print version
[[ $print_version ]] && $cf_cmd -version
# format
case $mode in
diff)