Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@ on:
branches: ["main"]

jobs:
format-check:
name: Format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++ programs
uses: jidicula/clang-format-action@v4.11.0
with:
clang-format-version: '14'
debug-build:
runs-on: ubuntu-latest
steps:
Expand All @@ -38,9 +29,9 @@ jobs:
pip install -r ${{github.workspace}}/docs/requirements.txt
- name: Restore snapshot data cache
id: restore-cache-snapshots-debug
uses: actions/cache/restore@v4
uses: actions/cache@v4
with:
path: test/snapshots
path: ${{github.workspace}}/test/snapshots
key: snapshots-${{ env.snapshot_version }}
- name: Configure
run: >
Expand All @@ -53,13 +44,6 @@ jobs:
-DTT_SANITIZE=ON
-DTT_BUILD_DOCS=ON
-DTT_DOWNLOAD_SNAPSHOTS=1
- name: Save snapshot data cache
if: steps.restore-cache-snapshots-debug.outputs.cache-hit != 'true'
id: save-cache-snapshots-debug
uses: actions/cache/save@v4
with:
path: ${{github.workspace}}/build/debug/test/snapshots/
key: snapshots-${{ env.snapshot_version }}
- name: Build library
run: cmake --build ${{github.workspace}}/build/debug --config Debug
- name: Test
Expand Down Expand Up @@ -127,11 +111,10 @@ jobs:
echo "CMAKE_GENERATOR=Ninja" >> "$env:GITHUB_ENV" &&
echo "CMAKE_CONFIGURATION_TYPES=Release" >> "$env:GITHUB_ENV"
- name: Restore snapshot data cache
if: matrix.os == 'ubuntu-latest'
id: restore-cache-snapshots-release
uses: actions/cache/restore@v4
uses: actions/cache@v4
with:
path: test/snapshots
path: ${{github.workspace}}/test/snapshots
key: snapshots-${{ env.snapshot_version }}
- name: Configure static library
run: >
Expand All @@ -144,13 +127,6 @@ jobs:
--profiling-format=google-trace
--profiling-output ${{matrix.os}}_${{matrix.c_compiler}}_config_profile.json
-DTT_DOWNLOAD_SNAPSHOTS=1
- name: Save snapshot data cache
if: matrix.os == 'ubuntu-latest' && steps.restore-cache-snapshots-release.outputs.cache-hit != 'true'
id: save-cache-snapshots-release
uses: actions/cache/save@v4
with:
path: ${{github.workspace}}/build/static/test/snapshots/
key: snapshots-${{ env.snapshot_version }}
- name: Build static library
run: cmake --build ${{github.workspace}}/build/static --config Release
- name: Test static library
Expand Down
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ add_library(topotoolbox
reconstruct.c
excesstopography.c
graphflood/gf_utils.c
graphflood/gf_utils.h
graphflood/sfgraph.c
graphflood/pq_maxheap.h
graphflood/pq_priority_flood.h
graphflood/priority_flood_standalone.c
graphflood/queue_pit.h
graphflood/gf_flowacc.c
graphflood/graphflood.c
flow_routing.c
Expand All @@ -23,10 +27,15 @@ add_library(topotoolbox
knickpoints.c
swaths.c
helpers/priority_queue.c
helpers/priority_queue.h
helpers/dijkstra.c
helpers/dijkstra.h
helpers/polyline.c
helpers/polyline.h
helpers/stat_func.c
helpers/stat_func.h
helpers/deque.c
helpers/deque.h
)

# Define the include directory
Expand Down Expand Up @@ -79,4 +88,4 @@ endif()
#
# This is used in the root CMakeLists.txt to install topotoolbox.h to
# the appropriate location.
set_target_properties(topotoolbox PROPERTIES PUBLIC_HEADER ${topotoolbox_SOURCE_DIR}/include/topotoolbox.h)
set_target_properties(topotoolbox PROPERTIES PUBLIC_HEADER ${topotoolbox_SOURCE_DIR}/include/topotoolbox.h)
54 changes: 49 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ OPTION(TT_SANITIZE "Build with AddressSanitizer" OFF)

# add_executable defines the executable program that CTest will run.
# Include any necessary files that must be compiled in this command.
add_executable(versioninfo versioninfo.cpp utils.c)
add_executable(versioninfo versioninfo.cpp)

# Link the executable to topotoolbox.
target_link_libraries(versioninfo PRIVATE topotoolbox)
Expand All @@ -31,7 +31,7 @@ set_tests_properties(versioninfo PROPERTIES ENVIRONMENT_MODIFICATION
# TEST : random_dem
#
# Runs libtopotoolbox functions on randomly generated DEMs.
add_executable(random_dem random_dem.cpp utils.c)
add_executable(random_dem random_dem.cpp utils.c utils.h profiler.h)
if(TT_SANITIZE AND NOT MSVC)
# Set up the AddressSanitizer flags.
target_compile_options(random_dem PRIVATE "$<$<CONFIG:DEBUG>:-fsanitize=address>")
Expand All @@ -45,7 +45,7 @@ set_tests_properties(random_dem PROPERTIES ENVIRONMENT_MODIFICATION
# TEST : excesstopography
#
# Runs the excesstopography functions on randomly generated DEMs.
add_executable(excesstopography excesstopography.cpp utils.c)
add_executable(excesstopography excesstopography.cpp utils.c utils.h)
if(TT_SANITIZE AND NOT MSVC)
# Set up the AddressSanitizer flags.
target_compile_options(excesstopography PRIVATE "$<$<CONFIG:DEBUG>:-fsanitize=address>")
Expand Down Expand Up @@ -123,7 +123,7 @@ elseif(TT_DOWNLOAD_SNAPSHOTS)
snapshot_data
URL https://github.com/TopoToolbox/snapshot_data/releases/download/${TT_SNAPSHOT_VERSION}/snapshot_data.tar.gz
URL_HASH SHA256=${TT_SNAPSHOT_HASH}
SOURCE_DIR snapshots/data/
SOURCE_DIR ${TT_SNAPSHOT_DATA_PATH}
DOWNLOAD_EXTRACT_TIMESTAMP false)
FetchContent_MakeAvailable(snapshot_data)
set(TT_SNAPSHOT_DIR ${snapshot_data_SOURCE_DIR})
Expand All @@ -138,7 +138,7 @@ endif()

include(FindGDAL)
if(GDAL_FOUND AND TT_SNAPSHOT_DIR)
add_executable(snapshot snapshot.cpp utils.c)
add_executable(snapshot snapshot.cpp utils.c utils.h profiler.h)
if(TT_SANITIZE AND NOT MSVC)
# Set up the AddressSanitizer flags.
target_compile_options(snapshot PRIVATE "$<$<CONFIG:DEBUG>:-fsanitize=address>")
Expand All @@ -149,3 +149,47 @@ if(GDAL_FOUND AND TT_SNAPSHOT_DIR)
set_tests_properties(snapshot PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<$<BOOL:${WIN32}>:$<TARGET_FILE_DIR:topotoolbox>>")
endif()

# TEST: clang-format
#
# Runs clang format to verify formatting of code

OPTION(TT_FORMAT_CHECK "Check code formatting with clang-format" ON)

find_program(CLANG_FORMAT_EXE clang-format)
if (TT_FORMAT_CHECK AND CLANG_FORMAT_EXE)
message(STATUS "Found clang-format at ${CLANG_FORMAT_EXE}")

set(FORMAT_TARGETS
topotoolbox
versioninfo
random_dem
excesstopography
filters
swaths
polyline)

if (TARGET snapshot)
list(APPEND FORMAT_TARGETS snapshot)
endif()

set(ALL_SOURCES)

foreach(FORMAT_TARGET ${FORMAT_TARGETS})
get_target_property(TARGET_SOURCES ${FORMAT_TARGET} SOURCES)
get_target_property(TARGET_SOURCE_DIR ${FORMAT_TARGET} SOURCE_DIR)
foreach (source ${TARGET_SOURCES})
if(IS_ABSOLUTE ${source})
list(APPEND ALL_SOURCES ${source})
else()
list(APPEND ALL_SOURCES ${TARGET_SOURCE_DIR}/${source})
endif()
endforeach()
endforeach()
list(REMOVE_DUPLICATES ALL_SOURCES)

add_test(NAME clang-format
COMMAND ${CLANG_FORMAT_EXE} -n -Werror ${ALL_SOURCES} ${CMAKE_SOURCE_DIR}/include/topotoolbox.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()
Loading