diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-05-09 15:28:09 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-05-09 20:46:16 +0200 |
| commit | d4e54e9f35d532062533f1d369c159810b01d224 (patch) | |
| tree | 7046ff72a41a8b0ad2e40e1d4aa3b191d03f6380 /tools | |
| parent | 8650b70e06408d394c1708846b6fc2d86cf14079 (diff) | |
Add mechanisms to reformant and check code style (#128)
Use an internal version of astyle (astyle 3.0). Scripts taken from QGIS.
astyle.options from https://github.com/uclouvain/openjpeg/issues/128
scripts/prepare-commit.sh can be used locally to automatically reformat
edited files.
Travis-CI will run scripts/verify-indentation.sh to verify committed files.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/ctest_scripts/travis-ci.cmake | 12 | ||||
| -rwxr-xr-x | tools/travis-ci/install.sh | 4 | ||||
| -rwxr-xr-x | tools/travis-ci/run.sh | 19 |
3 files changed, 35 insertions, 0 deletions
diff --git a/tools/ctest_scripts/travis-ci.cmake b/tools/ctest_scripts/travis-ci.cmake index f8c50e5b..f1e78952 100644 --- a/tools/ctest_scripts/travis-ci.cmake +++ b/tools/ctest_scripts/travis-ci.cmake @@ -91,6 +91,13 @@ else() set(BUILD_TESTING "FALSE") endif(NOT "$ENV{OPJ_CI_SKIP_TESTS}" STREQUAL "1") + +if("$ENV{OPJ_CI_CHECK_STYLE}" STREQUAL "1") + set(BUILD_ASTYLE "TRUE") +else() + set(BUILD_ASTYLE "FALSE") +endif("$ENV{OPJ_CI_CHECK_STYLE}" STREQUAL "1") + # Options set( CACHE_CONTENTS " @@ -100,6 +107,9 @@ CMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} # Warning level CMAKE_C_FLAGS:STRING= ${CCFLAGS_ARCH} ${CCFLAGS_WARNING} +# For astyle +CMAKE_CXX_FLAGS:STRING= ${CCFLAGS_ARCH} + # Use to activate the test suite BUILD_TESTING:BOOL=${BUILD_TESTING} @@ -112,6 +122,8 @@ OPJ_DATA_ROOT:PATH=$ENV{PWD}/data # jpylyzer is available with on GitHub: https://github.com/openpreserve/jpylyzer JPYLYZER_EXECUTABLE=$ENV{PWD}/jpylyzer/jpylyzer.${JPYLYZER_EXT} +# Enable astyle +WITH_ASTYLE:BOOL=${BUILD_ASTYLE} " ) #--------------------- diff --git a/tools/travis-ci/install.sh b/tools/travis-ci/install.sh index b1921844..2664eb03 100755 --- a/tools/travis-ci/install.sh +++ b/tools/travis-ci/install.sh @@ -115,3 +115,7 @@ if [ "${OPJ_CI_SKIP_TESTS:-}" != "1" ]; then fi fi fi + +if [ "${OPJ_CI_CHECK_STYLE:-}" == "1" ]; then + pip install --user autopep8 +fi diff --git a/tools/travis-ci/run.sh b/tools/travis-ci/run.sh index 35d2473e..950a0ee9 100755 --- a/tools/travis-ci/run.sh +++ b/tools/travis-ci/run.sh @@ -30,6 +30,16 @@ if [ "${OPJ_CI_ABI_CHECK:-}" == "1" ]; then exit 0 fi +if [ "${OPJ_CI_CC:-}" != "" ]; then + export CC=${OPJ_CI_CC} + echo "Using ${CC}" +fi + +if [ "${OPJ_CI_CXX:-}" != "" ]; then + export CXX=${OPJ_CI_CXX} + echo "Using ${CXX}" +fi + # Set-up some variables if [ "${OPJ_CI_BUILD_CONFIGURATION:-}" == "" ]; then export OPJ_CI_BUILD_CONFIGURATION=Release #default @@ -191,6 +201,15 @@ fi # ignore ctest exit code & parse this ourselves set +x + + +if [ "${OPJ_CI_CHECK_STYLE:-}" == "1" ]; then + export OPJSTYLE=${PWD}/scripts/opjstyle + export PATH=${HOME}/.local/bin:${PATH} + scripts/verify-indentation.sh +fi + + # Deployment if needed #--------------------- if [ "${TRAVIS_TAG:-}" != "" ]; then |
