Skip to content

Commit

Permalink
build/cmake: love/hate
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Jun 27, 2023
1 parent 40d9cdc commit c8a8b8e
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 196 deletions.
36 changes: 20 additions & 16 deletions build/build
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,28 @@ SANITIZERS=(
'tsan'
'ubsan'
'msan'
# Commented sanitizers do not reliably work yet.
# @todo Continue checking. Always.
# 'stacksan'
# 'dataflowsan'
# 'kcfisan'
# 'cfisan'
)

TESTS=(
'test_watch_targets'
'test_concurrent_watch_targets'
'test_new_directories'
'test_simple'
)

BENCHES=(
'bench_concurrent_watch_targets'
)
TESTS=wtr.test_watcher
# mapfile -t TESTS < <(\
# find ../src/test_watcher \
# -name 'test_*.cpp' \
# -type f \
# -print0 \
# | sed 's/\.cpp//g' \
# | xargs basename)

mapfile -t BENCHES < <(\
find ../src/bench_watcher \
-name 'bench_*.cpp' \
-type f \
-print0 \
| sed 's/\.cpp//g' \
| xargs basename)

# The `build::build` function will append to this list
# whenever it produces an artifact.
Expand Down Expand Up @@ -361,12 +365,12 @@ build::build() {

for TEST in "${TESTS[@]}"
do
this_artifact="$OUT_PLATFORM_DIR/test/$S/wtr.test_watcher.$TEST"
this_artifact="$OUT_PLATFORM_DIR/test/$S/$TEST"
cmake \
--build "$this_out_dir" \
--config Debug \
-j8 \
--target "wtr.test_watcher.$TEST" \
--target "$TEST" \
&& ARTIFACTS+=("$this_artifact")
ok=$((ok + $?))
done
Expand Down Expand Up @@ -456,8 +460,8 @@ build::run::test() {
done <<< "$(\
find "$OUT_PLATFORM_DIR" \
-type f \
-name "wtr.test_watcher.$TEST" \
-or -name "wtr.test_watcher.$TEST.exe"\
-name "$TEST" \
-or -name "$TEST.exe"\
2> /dev/null)"
done
fi
Expand Down

This file was deleted.

36 changes: 26 additions & 10 deletions build/in/cmake/wtr.bench_watcher.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# [dependencies]
include(CTest)
include(FetchContent)
FetchContent_Declare(
Expand All @@ -8,13 +7,30 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(snitch)

# [target definitions]
set(BENCH_PROJECT_NAME "wtr.bench_watcher")
set(BENCH_CONCURRENT_WATCH_TARGETS_SOURCES "${WTR_WATCHER_ROOT_SOURCE_DIR}/src/bench_watcher/bench_concurrent_watch_targets/bench_concurrent_watch_targets.cpp")
set(BENCH_LINK_LIBRARIES "${LINK_LIBRARIES}" "snitch::snitch")
set(BENCH_COMPILE_OPTIONS "${COMPILE_OPTIONS}")
set(BENCH_LINK_OPTIONS "${LINK_OPTIONS}")
set(BENCH_INCLUDE_PATH "${INCLUDE_PATH}")
function(WTR_ADD_BENCH_TARGET TITLE SRCS COMPILE_OPTIONS LINK_OPTIONS INCLUDE_PATH LINK_LIBRARIES)
set(RUNTIME_TEST_FILES "${SRCS}")
add_executable("wtr.bench_watcher.${TITLE}" "${SRCS}")
set_property(TARGET "wtr.bench_watcher.${TITLE}" PROPERTY CXX_STANDARD 20)
target_compile_options("wtr.bench_watcher.${TITLE}" PRIVATE "${COMPILE_OPTIONS}")
target_link_options("wtr.bench_watcher.${TITLE}" PRIVATE "${LINK_OPTIONS}")
target_include_directories("wtr.bench_watcher.${TITLE}" PRIVATE "${INCLUDE_PATH}")
target_link_libraries("wtr.bench_watcher.${TITLE}" PRIVATE "${LINK_LIBRARIES}")
if(APPLE)
set_property(
TARGET "wtr.bench_watcher.${TITLE}"
PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.wtr.watcher.${TITLE}")
endif()
install(TARGETS "wtr.bench_watcher.${TITLE}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
BUNDLE DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endfunction()

wtr_add_bench_target(
"bench_concurrent_watch_targets"
"${WTR_WATCHER_ROOT_SOURCE_DIR}/src/bench_watcher/bench_concurrent_watch_targets.cpp"
"${COMPILE_OPTIONS}"
"${LINK_OPTIONS}"
"${INCLUDE_PATH}"
"${LINK_LIBRARIES};snitch::snitch")

# [targets]
include("${BENCH_PROJECT_NAME}.bench_concurrent_watch_targets")
52 changes: 37 additions & 15 deletions build/in/cmake/wtr.test_watcher.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,41 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(snitch)

# [test target definitions]
set(TEST_PROJECT_NAME "wtr.test_watcher")
set(TEST_CONCURRENT_WATCH_TARGETS_SOURCES "${WTR_WATCHER_ROOT_SOURCE_DIR}/src/test_watcher/test_concurrent_watch_targets/test_concurrent_watch_targets.cpp")
set(TEST_WATCH_TARGETS_SOURCES "${WTR_WATCHER_ROOT_SOURCE_DIR}/src/test_watcher/test_watch_targets/test_watch_targets.cpp")
set(TEST_NEW_DIRECTORIES_SOURCES "${WTR_WATCHER_ROOT_SOURCE_DIR}/src/test_watcher/test_new_directories/test_new_directories.cpp")
set(TEST_SIMPLE_SOURCES "${WTR_WATCHER_ROOT_SOURCE_DIR}/src/test_watcher/test_simple/test_simple.cpp")
set(TEST_LINK_LIBRARIES "${LINK_LIBRARIES}" "snitch::snitch")
set(TEST_COMPILE_OPTIONS "${COMPILE_OPTIONS}")
set(TEST_LINK_OPTIONS "${LINK_OPTIONS}")
set(TEST_INCLUDE_PATH "${INCLUDE_PATH}")
function(WTR_ADD_TEST_TARGET TEST_PROJECT_NAME SRCS COMPILE_OPTIONS LINK_OPTIONS INCLUDE_PATH LINK_LIBRARIES)
set(RUNTIME_TEST_FILES "${SRCS}")
add_executable("${TEST_PROJECT_NAME}" "${SRCS}")
set_property(TARGET "${TEST_PROJECT_NAME}" PROPERTY CXX_STANDARD 20)
target_compile_options("${TEST_PROJECT_NAME}" PRIVATE "${COMPILE_OPTIONS}")
target_link_options("${TEST_PROJECT_NAME}" PRIVATE "${LINK_OPTIONS}")
target_include_directories("${TEST_PROJECT_NAME}" PRIVATE "${INCLUDE_PATH}")
target_link_libraries("${TEST_PROJECT_NAME}" PRIVATE "${LINK_LIBRARIES}")
if(APPLE)
set_property(
TARGET "${TEST_PROJECT_NAME}"
PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "org.${TEST_PROJECT_NAME}")
endif()
# install(TARGETS "${TEST_PROJECT_NAME}"
# LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
# BUNDLE DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
# PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endfunction()

set(TEST_PROJECT_NAME "test_watcher")

set(TEST_SET
"test_concurrent_watch_targets"
"test_watch_targets"
"test_new_directories"
"test_simple")
list(TRANSFORM TEST_SET PREPEND
"${WTR_WATCHER_ROOT_SOURCE_DIR}/src/${TEST_PROJECT_NAME}/")
list(TRANSFORM TEST_SET APPEND ".cpp")

wtr_add_test_target(
"wtr.${TEST_PROJECT_NAME}"
"${TEST_SET}"
"${COMPILE_OPTIONS}"
"${LINK_OPTIONS}"
"${INCLUDE_PATH}"
"${LINK_LIBRARIES};snitch::snitch")

# [test targets]
include("${TEST_PROJECT_NAME}.test_watch_targets")
include("${TEST_PROJECT_NAME}.test_concurrent_watch_targets")
include("${TEST_PROJECT_NAME}.test_new_directories")
include("${TEST_PROJECT_NAME}.test_simple")

This file was deleted.

31 changes: 0 additions & 31 deletions build/in/cmake/wtr.test_watcher.test_new_directories.cmake

This file was deleted.

31 changes: 0 additions & 31 deletions build/in/cmake/wtr.test_watcher.test_simple.cmake

This file was deleted.

31 changes: 0 additions & 31 deletions build/in/cmake/wtr.test_watcher.test_watch_targets.cmake

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c8a8b8e

Please sign in to comment.