Skip to content

Commit bbbfcd8

Browse files
author
Roberto Di Remigio
committed
First version of cloc/Python/CMake infrastructure working.
I am not extracting any information from cloc's output right now.
1 parent 4035c5f commit bbbfcd8

File tree

15 files changed

+110
-0
lines changed

15 files changed

+110
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ file(COPY ${PROJECT_BINARY_DIR}/update_gh-pages.py
163163
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
164164
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
165165

166+
configure_file(${PROJECT_SOURCE_DIR}/tools/counter.py.in counter.py)
167+
file(COPY ${PROJECT_BINARY_DIR}/counter.py
168+
DESTINATION ${PROJECT_BINARY_DIR}/bin
169+
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
170+
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
171+
166172
# To be includes as system headers
167173
include_directories(SYSTEM
168174
${EIGEN3_INCLUDE_DIR}

cmake/GenericMacros.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ macro(write_to_Includer headers_list)
6767
file(APPEND "${PROJECT_BINARY_DIR}/include/Includer.hpp" "#include \"${header}\"\n")
6868
endforeach()
6969
endmacro()
70+
71+
macro(write_to_cloc_list list_of_sources)
72+
get_filename_component(lib ${CMAKE_CURRENT_SOURCE_DIR} NAME)
73+
if(EXISTS "${PROJECT_BINARY_DIR}/cloc_lists/cloc_list-${lib}")
74+
file(REMOVE "${PROJECT_BINARY_DIR}/cloc_lists/cloc_list-${lib}")
75+
endif()
76+
foreach(source ${list_of_sources})
77+
file(APPEND "${PROJECT_BINARY_DIR}/cloc_lists/cloc_list-${lib}" "${PROJECT_SOURCE_DIR}/src/${lib}/${source}\n")
78+
endforeach()
79+
endmacro()

src/cavity/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ get_cpp_sources(sources_list)
1616
# If you want to remove some sources specify them explictly here
1717
list(REMOVE_ITEM sources_list "")
1818

19+
# Write list of files to be passed to cloc for counting lines of code.
20+
# Only files that are actually compiled are counted.
21+
set(to_count "${sources_list}" "${headers_list}")
22+
write_to_cloc_list("${to_count}")
23+
1924
# Build static library
2025
add_library(cavity STATIC ${sources_list})
2126
set(libs_to_merge cavity ${libs_to_merge} PARENT_SCOPE)

src/green/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ get_cpp_sources(sources_list)
1717
# If you want to remove some sources specify them explictly here
1818
list(REMOVE_ITEM sources_list "")
1919

20+
# Write list of files to be passed to cloc for counting lines of code.
21+
# Only files that are actually compiled are counted.
22+
set(to_count "${sources_list}" "${headers_list}")
23+
write_to_cloc_list("${to_count}")
24+
2025
# Build static library
2126
add_library(green STATIC ${sources_list})
2227
set(libs_to_merge green ${libs_to_merge} PARENT_SCOPE)

src/interface/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ get_cpp_sources(sources_list)
1010
# If you want to remove some sources specify them explictly here
1111
list(REMOVE_ITEM sources_list "")
1212

13+
# Write list of files to be passed to cloc for counting lines of code.
14+
# Only files that are actually compiled are counted.
15+
set(to_count "${sources_list}" "${headers_list}")
16+
write_to_cloc_list("${to_count}")
17+
1318
# Build static library
1419
add_library(interface STATIC ${sources_list})
1520
set(libs_to_merge interface ${libs_to_merge} PARENT_SCOPE)

src/metal/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ get_fortran_sources(sources_list)
44
# If you want to remove some sources specify them explictly here
55
list(REMOVE_ITEM sources_list "")
66

7+
# Write list of files to be passed to cloc for counting lines of code.
8+
# Only files that are actually compiled are counted.
9+
set(to_count "${sources_list}" "${headers_list}")
10+
write_to_cloc_list("${to_count}")
11+
712
# Build static library
813
add_library(metal STATIC ${sources_list})
914
set(libs_to_merge metal ${libs_to_merge} PARENT_SCOPE)

src/operators_diagonal/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ get_cpp_sources(sources_list)
1717
# If you want to remove some sources specify them explictly here
1818
list(REMOVE_ITEM sources_list "")
1919

20+
# Write list of files to be passed to cloc for counting lines of code.
21+
# Only files that are actually compiled are counted.
22+
set(to_count "${sources_list}" "${headers_list}")
23+
write_to_cloc_list("${to_count}")
24+
2025
# Build static library
2126
add_library(operators_diagonal STATIC ${sources_list})
2227
set(libs_to_merge operators_diagonal ${libs_to_merge} PARENT_SCOPE)

src/pedra/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ get_fortran_sources(sources_list)
44
# If you want to remove some sources specify them explictly here
55
list(REMOVE_ITEM sources_list "")
66

7+
# Write list of files to be passed to cloc for counting lines of code.
8+
# Only files that are actually compiled are counted.
9+
set(to_count "${sources_list}" "${headers_list}")
10+
write_to_cloc_list("${to_count}")
11+
712
# Build static library
813
add_library(pedra STATIC ${sources_list})
914
set(libs_to_merge pedra ${libs_to_merge} PARENT_SCOPE)

src/pwl/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ get_c_sources(sources_list)
1010
# If you want to remove some sources specify them explictly here
1111
list(REMOVE_ITEM sources_list "main_pwl.c")
1212

13+
# Write list of files to be passed to cloc for counting lines of code.
14+
# Only files that are actually compiled are counted.
15+
set(to_count "${sources_list}" "${headers_list}")
16+
write_to_cloc_list("${to_count}")
17+
1318
# Override global compiler flags to avoid choking stdout with warnings
1419
set_pwl_compiler_flags()
1520
# Build static library

src/solver/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ get_cpp_sources(sources_list)
1515
# If you want to remove some sources specify them explictly here
1616
list(REMOVE_ITEM sources_list "")
1717

18+
# Write list of files to be passed to cloc for counting lines of code.
19+
# Only files that are actually compiled are counted.
20+
set(to_count "${sources_list}" "${headers_list}")
21+
write_to_cloc_list("${to_count}")
22+
1823
# Build static library
1924
add_library(solver STATIC ${sources_list})
2025
set(libs_to_merge solver ${libs_to_merge} PARENT_SCOPE)

0 commit comments

Comments
 (0)