Skip to content

Commit

Permalink
Handle multiple projects (#21)
Browse files Browse the repository at this point in the history
* handles multiple projects
* try feature re-run failed tests
  • Loading branch information
psycofdj committed May 5, 2017
1 parent 7f96b8a commit 384112d
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 120 deletions.
3 changes: 1 addition & 2 deletions src/XTDMakeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ include(xtdmake_set_default)
include(xtdmake_find_program)
include(xtdmake_find_python_module)


message(STATUS "Found module XTDMake : TRUE")

function(xtdmake_init)
function(xtdmake_init project dir)
set(multiValueArgs )
set(oneValueArgs StaticShared DocRule DocCoverageRule CppcheckRule ClocRule Tracking Cppunit CheckRule CovRule MemcheckRule Reports)
set(options )
Expand Down
21 changes: 12 additions & 9 deletions src/check/FindCheckRule.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
add_custom_target(check)
add_custom_target(check-verbose)
add_custom_target(check-clean)

xtdmake_find_program(Xsltproc
NAMES xsltproc
DOC "rendering xslt stylehseets"
Expand All @@ -18,10 +22,6 @@ else()
endif()


add_custom_target(check)
add_custom_target(check-verbose)
add_custom_target(check-clean)

set(CheckRule_FOUND 1)
set(CheckRule_DEFAULT_ARGS "" CACHE STRING "CheckRule default unit-test binary parameter template")
set(CheckRule_DEFAULT_ENV "" CACHE STRING "CheckRule default unit-test binary environment template")
Expand Down Expand Up @@ -77,7 +77,7 @@ function(add_check_test module name)
"${multiValueArgs}"
${ARGN})

set(CheckRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/check/${module}")
set(CheckRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/check/${module}")

list(GET __x_COMMAND 0 l_bin)
list(REMOVE_AT __x_COMMAND 0)
Expand Down Expand Up @@ -123,7 +123,7 @@ function(add_check module)

configure_file(${XTDMake_HOME}/check/cmakevars.h.in ${CheckRule_CMAKEVARS_NAME})

set(CheckRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/check/${module}")
set(CheckRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/check/${module}")

if (NOT CheckRule_NO_DEFAULT_ARGS)
xtdmake_eval(l_args "${CheckRule_DEFAULT_ARGS}")
Expand Down Expand Up @@ -170,7 +170,7 @@ function(add_check module)
if (CMAKE_VERSION VERSION_LESS 2.8.12)
include_directories(BEFORE ${CheckRule_INCLUDES} ${Cppunit_INCLUDE_DIR})
else()
target_include_directories(${c_name_clean} BEFORE
target_include_directories(${c_name_clean} BEFORE
PUBLIC ${CheckRule_INCLUDES} ${Cppunit_INCLUDE_DIR})
endif()
target_link_libraries(${c_name_clean} ${CheckRule_LINKS} ${Cppunit_LIBRARY})
Expand Down Expand Up @@ -224,8 +224,10 @@ function(add_check module)

add_custom_target(${module}-check-run-forced
COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/testing
COMMAND ${CheckRule_ENV} ctest --timeout ${CheckRule_TIMEOUT} -j ${CheckRule_JOBS} -T Test -R "\\(${l_test_regex}\\)" || true
COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/testing)
COMMAND rm -f ${CheckRule_OUTPUT}/check-success
COMMAND ${CheckRule_ENV} ctest --timeout ${CheckRule_TIMEOUT} -j ${CheckRule_JOBS} -T Test -R "\\(${l_test_regex}\\)" && touch ${CheckRule_OUTPUT}/check-success || true
COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/testing
)

add_custom_target(${module}-check-run-verbose
COMMAND $(MAKE) ${module}-check-build
Expand All @@ -241,6 +243,7 @@ function(add_check module)
${CheckRule_OUTPUT}/tests.xml
${CheckRule_OUTPUT}/index.html
${CheckRule_OUTPUT}/status.json
${CheckRule_OUTPUT}/check-success
DEPENDS
${l_target_list}
${XTDMake_HOME}/check/stylesheet.xsl
Expand Down
10 changes: 6 additions & 4 deletions src/check/cmakevars.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#define TOP_SRCDIR "@CMAKE_SOURCE_DIR@"
#define SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@"
#define TOP_BUILDDIR "@PROJECT_BINARY_DIR@"
#define BUILDDIR "@CMAKE_CURRENT_BINARY_DIR@"
#define TOP_SRCDIR "@CMAKE_SOURCE_DIR@"
#define SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@"
#define TOP_BUILDDIR "@PROJECT_BINARY_DIR@"
#define BUILDDIR "@CMAKE_CURRENT_BINARY_DIR@"
#define PROJECT_SOURCE_DIR "@PROJECT_SOURCE_DIR@"
#define PROJECT_BINARY_DIR "@PROJECT_BINARY_DIR@"

7 changes: 4 additions & 3 deletions src/cloc/FindClocRule.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
add_custom_target(cloc)
add_custom_target(cloc-clean)

xtdmake_find_program(Cloc
NAMES cloc
DOC "cloc code line counting tool"
Expand Down Expand Up @@ -29,8 +32,6 @@ set(ClocRule_DEFAULT_INPUT "\${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRI
set(ClocRule_DEFAULT_FILE_PATTERNS "*.cc;*.hh;*.hxx" CACHE STRING "ClocRule default list of wildcard patterns to search in INPUT directories")
set(ClocRule_DEFAULT_MIN_PERCENT "30" CACHE STRING "ClocRule default mimunim comment percent to consider task successful")

add_custom_target(cloc)
add_custom_target(cloc-clean)

if (NOT ClocRule_FOUND)
function(add_cloc module)
Expand All @@ -56,7 +57,7 @@ else()
xtdmake_set_default(ClocRule MIN_PERCENT)
xtdmake_set_default_if_exists(ClocRule INPUT)

set(ClocRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/cloc/${module}")
set(ClocRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/cloc/${module}")
set(ClocRule_DEPENDS "")
foreach(c_dir ${ClocRule_INPUT})
foreach(c_pattern ${ClocRule_FILE_PATTERNS})
Expand Down
4 changes: 2 additions & 2 deletions src/coverage/FindCovRule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ else()
"${multiValueArgs}"
${ARGN})

set(CovRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/coverage/${module}")
set(CovRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/coverage/${module}")
xtdmake_set_default(CovRule EXCLUDE_PATTERNS)
xtdmake_set_default(CovRule MIN_PERCENT)

Expand All @@ -77,7 +77,7 @@ else()
${l_test_list}
${XTDMake_HOME}/coverage/coverage.sh
COMMAND
CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
PROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
Lcov_EXECUTABLE="${Lcov_EXECUTABLE}"
module="${module}"
Expand Down
10 changes: 5 additions & 5 deletions src/coverage/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ function lock
l_timeout=900
echo "[${module}-cov] acquiring cov lock..."
while true; do
if [ ! -f "${CMAKE_BINARY_DIR}/cov.lock" ]; then
echo -n "$$" > ${CMAKE_BINARY_DIR}/cov.lock
if [ ! -f "${PROJECT_BINARY_DIR}/cov.lock" ]; then
echo -n "$$" > ${PROJECT_BINARY_DIR}/cov.lock
break;
else
l_pid=$(cat "${CMAKE_BINARY_DIR}/cov.lock")
l_pid=$(cat "${PROJECT_BINARY_DIR}/cov.lock")
kill -0 "${l_pid}" 2>/dev/null || {
rm -f ${CMAKE_BINARY_DIR}/cov.lock
rm -f ${PROJECT_BINARY_DIR}/cov.lock
}
fi
l_timeout=$((l_timeout - 1))
Expand All @@ -29,7 +29,7 @@ function lock
function unlock
{
echo "[${module}-cov] releasing cov lock..."
rm -f ${CMAKE_BINARY_DIR}/cov.lock
rm -f ${PROJECT_BINARY_DIR}/cov.lock
echo "[${module}-cov] cov lock released"
}

Expand Down
7 changes: 4 additions & 3 deletions src/cppcheck/FindCppcheckRule.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
add_custom_target(cppcheck)
add_custom_target(cppcheck-clean)

xtdmake_find_program(Cppcheck
NAMES cppcheck
DOC "cppcheck static code anylyser tool"
Expand Down Expand Up @@ -29,8 +32,6 @@ endif()
set(CppcheckRule_DEFAULT_INPUT "\${CMAKE_CURRENT_SOURCE_DIR}/src" CACHE STRING "CppcheckRule default list of source directories relative to CMAKE_CURRENT_SOURCE_DIR")
set(CppcheckRule_DEFAULT_FILE_PATTERNS "*.cc;*.hh;*.hxx" CACHE STRING "CppcheckRule default list of wildcard patterns to search in INPUT directories")

add_custom_target(cppcheck)
add_custom_target(cppcheck-clean)
if(NOT CppcheckRule_FOUND)
function(add_cppcheck module)
add_custom_target(${module}-cppcheck
Expand All @@ -54,7 +55,7 @@ else()
xtdmake_set_default(CppcheckRule FILE_PATTERNS)
xtdmake_set_default_if_exists(CppcheckRule INPUT)

set(CppcheckRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/cppcheck/${module}")
set(CppcheckRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/cppcheck/${module}")
set(CppcheckRule_DEPENDS "")
foreach(c_dir ${CppcheckRule_INPUT})
foreach(c_pattern ${CppcheckRule_FILE_PATTERNS})
Expand Down
7 changes: 4 additions & 3 deletions src/doc-coverage/FindDocCoverageRule.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
add_custom_target(doc-coverage)
add_custom_target(doc-coverage-clean)

xtdmake_find_program(Genhtml
NAMES genhtml
DOC "Html report generation tool"
Expand Down Expand Up @@ -32,8 +35,6 @@ set(DocCoverageRule_DEFAULT_PREFIX "\${CMAKE_CURRENT_SOURCE_DIR}/src"
set(DocCoverageRule_DEFAULT_MIN_PERCENT "30" CACHE STRING "DocCoverageRule default mimunim coverage percentage to consider task successful")


add_custom_target(doc-coverage)
add_custom_target(doc-coverage-clean)
if (NOT DocCoverageRule_FOUND)
function(add_doc_coverage module)
add_custom_target(${module}-doc-coverage
Expand Down Expand Up @@ -67,7 +68,7 @@ else()
string(REPLACE ";" "," DocCoverageRule_SCOPE "${DocCoverageRule_SCOPE}")

get_target_property(DocCoverageRule_DOXYGEN_OUTPUT ${module}-doc OUTPUT_DIR)
set(DocCoverageRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/doc-coverage/${module}")
set(DocCoverageRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/doc-coverage/${module}")

add_custom_command(
COMMENT "Generating ${module} documentation coverage informations"
Expand Down
8 changes: 5 additions & 3 deletions src/doc/FindDocRule.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
add_custom_target(doc)
add_custom_target(doc-clean)

xtdmake_find_program(Doxygen
NAMES doxygen
DOC "Source documentation generation tool"
Expand Down Expand Up @@ -46,8 +49,7 @@ set(DocRule_DEFAULT_CALL_GRAPHS "YES"
set(DocRule_DEFAULT_CONFIGURE_TEMPLATE "" CACHE STRING "DocRule default value of CONFIGURE_TEMPLATE option")


add_custom_target(doc)
add_custom_target(doc-clean)

if (NOT DocRule_FOUND)
function(add_doc module)
add_custom_target(${module}-doc
Expand All @@ -69,7 +71,7 @@ else()
${ARGN})

set(DocRule_MODULE "${module}")
set(DocRule_OUTPUT "${CMAKE_BINARY_DIR}/reports/doc/${module}")
set(DocRule_OUTPUT "${PROJECT_BINARY_DIR}/reports/doc/${module}")

# use default value argument if needed
xtdmake_set_default(DocRule FILE_PATTERNS)
Expand Down

0 comments on commit 384112d

Please sign in to comment.