-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
431 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Our style is based on the Google style | ||
# https://google.github.io/styleguide/cppguide.html | ||
BasedOnStyle: Google | ||
|
||
# we use left pointer alignment | ||
DerivePointerAlignment: false | ||
PointerAlignment: Left | ||
|
||
IndentWidth: 4 | ||
ColumnLimit : 110 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
image: nkx1231/root6-geant4-garfield:0.4 | ||
|
||
stages: | ||
- pre-build | ||
- build | ||
- loadRESTLibs | ||
- process | ||
|
||
before_script: | ||
- export USER="connector" | ||
|
||
clang-format: | ||
stage: pre-build | ||
script: | ||
- echo "**$CRONJOB**" | ||
- echo "**$CI_SERVER_HOST**" | ||
- cd ${CI_PROJECT_DIR}/pipeline/clang-format/ | ||
- ./clangformattest.sh | ||
# We execute only at a schedulled pipeline that defines CRONJOB variable | ||
only: | ||
variables: | ||
- $CRONJOB | ||
|
||
validateLibrary: | ||
stage: pre-build | ||
script: | ||
- python pipeline/validateLibrary.py . | ||
except: | ||
variables: | ||
- $CRONJOB == "YES" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#!/bin/bash | ||
|
||
# If the first argument is just '-', do not replace the files | ||
# instead print the result to stdout. | ||
|
||
sed_i="-i .bak" | ||
testername=/tmp/sed_tester.$$.tmp | ||
touch $testername | ||
rm -f $testername.bak | ||
sed ${sed_i} -e '' $testername > /dev/null 2>&1 | ||
result=$? | ||
if [ -e $testername.bak ] ; then | ||
sed_i='-i ""' | ||
else | ||
sed_i='-i ' | ||
fi | ||
|
||
macros=( | ||
__host__ | ||
__device__ | ||
VECCORE_ATT_HOST | ||
VECCORE_ATT_DEVICE | ||
VECCORE_ATT_HOST_DEVICE | ||
VECCORE_FORCE_INLINE | ||
VECCORE_FORCE_NOINLINE | ||
VECGEOM_CUDA_HEADER_HOST | ||
VECGEOM_CUDA_HEADER_DEVICE | ||
VECGEOM_CUDA_HEADER_BOTH | ||
VECGEOM_FORCE_INLINE | ||
) | ||
|
||
patternFrom="" | ||
patternTo="" | ||
|
||
if [ "-" = "$1" ] ; then | ||
shift; | ||
|
||
for file in $@; do | ||
cat $file | eval sed -n -e '" | ||
# if the first line copy the pattern to the hold buffer | ||
1h | ||
# if not the first line then append the pattern to the hold buffer | ||
1!H | ||
# if the last line then ... | ||
$ { | ||
# copy from the hold to the pattern buffer | ||
g | ||
# do the search and replace | ||
${patternFrom} | ||
p | ||
}"' | clang-format | clang-format | eval sed -n -e '" | ||
# if the first line copy the pattern to the hold buffer | ||
1h | ||
# if not the first line then append the pattern to the hold buffer | ||
1!H | ||
# if the last line then ... | ||
$ { | ||
# copy from the hold to the pattern buffer | ||
g | ||
# do the search and replace | ||
${patternTo} | ||
p | ||
}"' | ||
done | ||
else | ||
# Shorten the macro and move them out of the way so that they have | ||
# no effect on line length calculation. | ||
for file in $@; do | ||
eval sed ${sed_i} -n -e '" | ||
# if the first line copy the pattern to the hold buffer | ||
1h | ||
# if not the first line then append the pattern to the hold buffer | ||
1!H | ||
# if the last line then ... | ||
$ { | ||
# copy from the hold to the pattern buffer | ||
g | ||
# do the search and replace | ||
${patternFrom} | ||
p | ||
}"' '"${file}"' | ||
done | ||
|
||
clang-format -i "$@" | ||
# Run clang-format a 2nd time, this stabilizes some of the comment positioning. | ||
clang-format -i "$@" | ||
|
||
# Put back the macros. | ||
for file in $@; do | ||
eval sed ${sed_i} -n -e '" | ||
# if the first line copy the pattern to the hold buffer | ||
1h | ||
# if not the first line then append the pattern to the hold buffer | ||
1!H | ||
# if the last line then ... | ||
$ { | ||
# copy from the hold to the pattern buffer | ||
g | ||
# do the search and replace | ||
${patternTo} | ||
p | ||
}"' '"${file}"' | ||
done | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
## Javier Galan got this script from | ||
## https://gitlab.cern.ch/VecGeom/VecGeom/commit/8c723ded243dbfaac59d372b524366db4577a728 | ||
|
||
# | ||
# This is running a clang-format test | ||
# by doing a filtering step and then analysing | ||
# the result of applying ./scripts/clang-format-and-fix-macros.sh | ||
# | ||
|
||
# check that we are in a clean state in order to prevent accidential | ||
# changes | ||
cleanstate=`git status | grep "modified"` | ||
if ! [[ -z $cleanstate ]]; then | ||
echo "Script must be applied on a clean git state" | ||
return 0 | ||
fi | ||
|
||
|
||
cd ../../ | ||
find . \( -name '*.h' -or -name '*.cxx' -or -name '*.cc' -or -name '*.C' \) -print0 | xargs -0 clang-format -i | ||
|
||
# check if something was modified | ||
notcorrectlist=`git status | grep "modified"` | ||
if [[ -z $notcorrectlist ]]; then | ||
echo "Excellent. **VERY GOOD FORMATTING!** :thumbsup:" | ||
exit 0; | ||
else | ||
echo "The following files have clang-format problems (showing patches)"; | ||
for f in $notcorrectlist; do | ||
echo $f | ||
#git diff $f | ||
done | ||
|
||
#We now repair commiting | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "clang runner" | ||
git config --global push.default simple | ||
git remote set-url --push origin [email protected]:rest-for-physics/rawlib.git | ||
git add -u | ||
git commit -m "Pipeline clang-format automatic execution" | ||
git status | ||
echo "git push origin HEAD:master" | ||
git push origin HEAD:master | ||
echo "Clang-format should have generated a commit to fix code formatting" | ||
echo "This validation should be solved in the next run." | ||
exit 0; | ||
fi | ||
|
||
# cleanup changes in git | ||
git reset HEAD --hard | ||
|
||
exit 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
# This script reformats source files using the clang-format utility. | ||
# Set the list of source directories on the "for" line below. | ||
# | ||
# The file .clang-format in this directory specifies the formatting parameters. | ||
# | ||
# Files are changed in-place, so make sure you don't have anything open in an | ||
# editor, and you may want to commit before formatting in case of awryness. | ||
# | ||
# Note that clang-format is not included with OS X or Xcode; you must | ||
# install it yourself. There are multiple ways to do this: | ||
# | ||
# - If you use Xcode, install the ClangFormat-Xcode plugin. See instructions at | ||
# <https://github.com/travisjeffery/ClangFormat-Xcode/>. | ||
# After installation, the executable can be found at | ||
# $HOME/Library/Application Support/Alcatraz/Plug-ins/ClangFormat/bin/clang-format. | ||
# | ||
# - Download an LLVM release from <http://llvm.org/releases/download.html>. | ||
# For OS X, use the pre-built binaries for "Darwin". | ||
# | ||
# - Build the LLVM tools from source. See the documentation at <http://llvm.org>. | ||
|
||
# Change this if your clang-format executable is somewhere else | ||
CLANG_FORMAT="clang-format" | ||
|
||
if [ $# -eq 0 ]; then | ||
echo ' ' | ||
echo 'This script formats the source directory /path/to/source/' | ||
echo 'given as the only argument. Only .cxx and .h files will be ' | ||
echo 'reformatted.' | ||
echo ' ' | ||
echo 'The formatting will consider the .clang-format file closer to' | ||
echo 'the source directory given. ' | ||
echo ' ' | ||
echo 'Usage : ./reformat-clang.sh /path/to/source/' | ||
echo ' ' | ||
echo 'Use carefully! :)' | ||
|
||
exit 1 | ||
fi | ||
|
||
pathNow=$PWD | ||
|
||
for DIRECTORY in $1 | ||
do | ||
echo "Formatting code under $DIRECTORY/" | ||
cd $DIRECTORY | ||
find . \( -name '*.h' -or -name '*.cxx' -or -name '*.cc' -or -name '*.C' \) -print0 | xargs -0 "$CLANG_FORMAT" -i | ||
cd $pathNow | ||
echo "DONE!" | ||
done |
Oops, something went wrong.