diff options
author | Rechi <Rechi@users.noreply.github.com> | 2019-06-13 14:22:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-13 14:22:31 +0200 |
commit | 97c25611798a5f0272bd98c8dfe36d59dea0bb61 (patch) | |
tree | adff5b5a4b2f2e6c57b43f8bc06268b6f773ece5 | |
parent | 78bef3bfe6bc1b41eee18ca9596641613423cfb3 (diff) | |
parent | 40da2b6ef0dbee65ddf90cdb375b1ad5bf5e772b (diff) |
Merge pull request #16270 from Rechi/swig/fomat
[swig] format generated files with clang-format
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/modules/FindClangFormat.cmake | 11 | ||||
-rw-r--r-- | xbmc/interfaces/swig/CMakeLists.txt | 4 |
3 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c061b25df..54e9bd7d49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,7 @@ set(optional_deps Alsa CAP CCache CEC + ClangFormat DBus LCMS2 LircClient diff --git a/cmake/modules/FindClangFormat.cmake b/cmake/modules/FindClangFormat.cmake new file mode 100644 index 0000000000..7220d31623 --- /dev/null +++ b/cmake/modules/FindClangFormat.cmake @@ -0,0 +1,11 @@ +#.rst: +# FindClangFormat +# ---------- +# Finds clang-format + +find_program(CLANG_FORMAT_EXECUTABLE clang-format) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ClangFormat REQUIRED_VARS CLANG_FORMAT_EXECUTABLE) + +mark_as_advanced(CLANG_FORMAT_EXECUTABLE) diff --git a/xbmc/interfaces/swig/CMakeLists.txt b/xbmc/interfaces/swig/CMakeLists.txt index f3a0b0f84d..fc738219e5 100644 --- a/xbmc/interfaces/swig/CMakeLists.txt +++ b/xbmc/interfaces/swig/CMakeLists.txt @@ -11,11 +11,15 @@ function(generate_file file) endif() set(CPP_FILE ${file}.cpp) + if(CLANGFORMAT_FOUND) + set(CLANG_FORMAT_COMMAND COMMAND ${CLANG_FORMAT_EXECUTABLE} ARGS -i ${CPP_FILE}) + endif() add_custom_command(OUTPUT ${CPP_FILE} COMMAND ${SWIG_EXECUTABLE} ARGS -w401 -c++ -o ${file}.xml -xml -I${CMAKE_SOURCE_DIR}/xbmc -xmllang python ${CMAKE_CURRENT_SOURCE_DIR}/../swig/${file} COMMAND ${Java_JAVA_EXECUTABLE} ARGS -cp "${classpath}" groovy.ui.GroovyMain ${CMAKE_SOURCE_DIR}/tools/codegenerator/Generator.groovy ${file}.xml ${CMAKE_CURRENT_SOURCE_DIR}/../python/PythonSwig.cpp.template ${file}.cpp > ${devnull} + ${CLANG_FORMAT_COMMAND} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../swig/${file} ${CMAKE_CURRENT_SOURCE_DIR}/../python/PythonSwig.cpp.template) set(SOURCES ${SOURCES} "${CPP_FILE}" PARENT_SCOPE) endfunction() |