Skip to content

Commit

Permalink
Refactored build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucionisaau committed Sep 15, 2023
1 parent ca2d7a0 commit 15cc83a
Show file tree
Hide file tree
Showing 19 changed files with 681 additions and 253 deletions.
100 changes: 1 addition & 99 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -66,104 +66,6 @@ ForEachMacros:
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"[a-zA-Z0-9_]*\.'
Priority: 1
SortPriority: 1
- Regex: '^"testutils/'
Priority: 2
SortPriority: 2
- Regex: '^"tron/'
Priority: 2
SortPriority: 3
- Regex: '^"fmi/'
Priority: 2
SortPriority: 4
- Regex: '^"verifier/'
Priority: 2
SortPriority: 5
- Regex: '^"cora/'
Priority: 2
SortPriority: 6
- Regex: '^"tiga/'
Priority: 2
SortPriority: 7
- Regex: '^"statmc/'
Priority: 2
SortPriority: 8
- Regex: '^"xmltrace/'
Priority: 2
SortPriority: 9
- Regex: '^"pipeline/'
Priority: 2
SortPriority: 10
- Regex: '^"protocol/'
Priority: 2
SortPriority: 11
- Regex: '^"storage/'
Priority: 2
SortPriority: 12
- Regex: '^"system/'
Priority: 2
SortPriority: 13
- Regex: '^"dbm/'
Priority: 2
SortPriority: 14
- Regex: '^"cdd/'
Priority: 2
SortPriority: 15
- Regex: '^"polyhedra/'
Priority: 2
SortPriority: 16
- Regex: '^"tracer/'
Priority: 2
SortPriority: 17
- Regex: '^"utap/'
Priority: 2
SortPriority: 18
- Regex: '^"io/'
Priority: 2
SortPriority: 19
- Regex: '^"formats/'
Priority: 2
SortPriority: 20
- Regex: '^"base/'
Priority: 2
SortPriority: 21
- Regex: '^"hash/'
Priority: 2
SortPriority: 22
- Regex: '^"debug/'
Priority: 2
SortPriority: 23
- Regex: '^<libstrategy/'
Priority: 3
SortPriority: 24
- Regex: '^<licensing/'
Priority: 3
SortPriority: 25
- Regex: '^<prlearn/'
Priority: 3
SortPriority: 26
- Regex: '^<ap_'
Priority: 3
SortPriority: 27
- Regex: '^<libxml/'
Priority: 3
SortPriority: 28
- Regex: '^<doctest/'
Priority: 3
SortPriority: 30
- Regex: '^<boost/'
Priority: 3
SortPriority: 30
- Regex: '^<[a-bd-z0-9][a-z0-9_]*(\.[a-z]*)?>$'
Priority: 4
SortPriority: 31
- Regex: '^<c'
Priority: 4
SortPriority: 32
#IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
Expand Down Expand Up @@ -216,7 +118,7 @@ RawStringFormats:
- ParseTextProtoOrDie
CanonicalDelimiter: ''
ReflowComments: true
SortIncludes: true
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
Expand Down
102 changes: 70 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,88 @@ on:
branches: [ main ]

jobs:
format:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Format
- name: Formatting
run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror
build-linux:
runs-on: ubuntu-latest
env:
TARGET: x86_64-linux
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/${{ env.TARGET }}.cmake
CMAKE_BUILD_TYPE: Debug
CTEST_OUTPUT_ON_FAILURE: 1
steps:
- uses: actions/checkout@v2
- name: Get dependencies
run: sudo apt-get update && sudo apt-get install libboost-all-dev doctest-dev && ./getlibs.sh
- name: Build and test
run: |
export CTEST_OUTPUT_ON_FAILURE=1
cmake -DTESTING=yes . -B build
cmake --build build
(cd build ; ctest)
- uses: actions/checkout@v2
- name: Build without getlibs
run: |
BUILD=build-$TARGET-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
- name: Get dependencies
run: CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
- name: Build with getlibs
run: |
BUILD=build-$TARGET-libs-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
build-win:
runs-on: ubuntu-latest
env:
TARGET: x86_64-w64-mingw32
WINARCH: win64
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/${{ env.TARGET }}.cmake
CMAKE_BUILD_TYPE: Debug
CTEST_OUTPUT_ON_FAILURE: 1
steps:
- uses: actions/checkout@v2
- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt
- uses: actions/checkout@v2
- name: Install toolchain
run: |
sudo apt-get -qqy update
sudo apt-get -qqy install cmake make g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
CMAKE_TOOLCHAIN_FILE="$(pwd)/toolchains/x86_64-w64-mingw32.cmake" ./getlibs.sh
- name: Build and test
run: |
export CTEST_OUTPUT_ON_FAILURE=1
cmake -DSTATIC=yes -DTESTING=yes -DCMAKE_TOOLCHAIN_FILE=toolchains/x86_64-w64-mingw32.cmake . -B build
cmake --build build
(cd build ; ctest)
WINEPATH=$(${{ github.workspace }}/winepath-for ${{ env.TARGET }})
echo "WINEPATH=$WINEPATH" >> $GITHUB_ENV
- name: Build without getlibs
run: |
BUILD=build-$TARGET-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD -DSTATIC=yes
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
- name: Get dependencies
run:
CMAKE_BUILD_TYPE=Release ./getlibs.sh $TARGET
- name: Build with getlibs
run: |
BUILD=build-$TARGET-libs-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD -DSTATIC=yes
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
build-macos:
runs-on: macos-latest
env:
TARGET: x86_64-darwin
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cmake/toolchain/${{ env.TARGET }}.cmake
CMAKE_BUILD_TYPE: Debug
CTEST_OUTPUT_ON_FAILURE: 1
steps:
- uses: actions/checkout@v2
- name: Get dependencies
run: brew install boost doctest && ./getlibs.sh
- name: Build and test
run: |
export CTEST_OUTPUT_ON_FAILURE=1
cmake -DTESTING=yes . -B build
cmake --build build
(cd build ; ctest)
- uses: actions/checkout@v2
- name: Build without getlibs
run: |
BUILD=build-$TARGET-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
- name: Get dependencies
run: CMAKE_BUILD_TYPE=Release ./getlibs.sh
- name: Build with getlibs
run: |
BUILD=build-$TARGET-libs-$CMAKE_BUILD_TYPE
cmake -S . -B $BUILD
cmake --build $BUILD --config $CMAKE_BUILD_TYPE
(cd $BUILD ; ctest -C $CMAKE_BUILD_TYPE)
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ build*
cmake-build*

# Getlibs
/libs
/libs-i686-linux
/libs-x86_64-w64-mingw32
/libs-i686-w64-mingw32
local

# Prerequisites
*.d
Expand Down
43 changes: 17 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@ project(UCDD VERSION 0.2.1 LANGUAGES CXX C)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

option(TESTING "Unit tests" OFF)
option(ASAN "Address Sanitizer" OFF)
option(UCDD_WITH_TESTS "UCDD Unit tests" ON)
include(cmake/sanitizer.cmake)

cmake_policy(SET CMP0048 NEW) # project() command manages VERSION variables
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(MULTI_TERMINAL 1)
CONFIGURE_FILE("src/config.h.cmake" "include/cdd/config.h")

if(CMAKE_TOOLCHAIN_FILE)
get_filename_component(TARGET ${CMAKE_TOOLCHAIN_FILE} NAME_WLE)
set(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs-${TARGET}")
else(CMAKE_TOOLCHAIN_FILE)
set(LIBS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs")
endif(CMAKE_TOOLCHAIN_FILE)
message(STATUS "Using libs in ${LIBS_DIR}")
if (UCDD_WITH_TESTS)
include(cmake/doctest.cmake)
enable_testing()
endif (UCDD_WITH_TESTS)

set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${LIBS_DIR}")
find_package(xxHash 0.8.0 REQUIRED COMPONENTS xxhash PATHS ${LIBS_DIR}/xxHash)
find_package(UUtils 1.1.1 REQUIRED PATHS ${LIBS_DIR}/UUtils)
find_package(UDBM 2.0.11 REQUIRED PATHS ${LIBS_DIR}/UDBM)
include(cmake/xxhash.cmake)
include(cmake/UUtils.cmake)
include(cmake/UDBM.cmake)

include_directories(
PRIVATE
Expand All @@ -42,23 +41,15 @@ if(STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")
endif(STATIC)

if (ASAN)
add_compile_options(-fno-omit-frame-pointer -fsanitize=address)
add_link_options(-fno-omit-frame-pointer -fsanitize=address)
message(STATUS "Using Address Sanitizer")
endif(ASAN)

add_subdirectory("src")

if(TESTING)
enable_testing()
if (UCDD_WITH_TESTS)
add_subdirectory("test")
endif(TESTING)
endif(UCDD_WITH_TESTS)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/UCDDConfigVersion.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY SameMajorVersion)
write_basic_package_version_file(${PROJECT_BINARY_DIR}/UCDDConfigVersion.cmake VERSION ${PACKAGE_VERSION} COMPATIBILITY SameMajorVersion)

install(DIRECTORY include DESTINATION .)
install(TARGETS UCDD EXPORT UCDDConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT UCDDConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UCDD)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/UCDDConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UCDD )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cdd/config.h DESTINATION include/cdd/)
install(FILES ${PROJECT_BINARY_DIR}/UCDDConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/UCDD)
install(FILES ${PROJECT_BINARY_DIR}/include/cdd/config.h DESTINATION include/cdd/)
32 changes: 32 additions & 0 deletions cmake/UDBM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
find_package(UDBM 2.0.13 QUIET)

if (UDBM_FOUND)
message(STATUS "Found UDBM: ${UDBM_DIR}")
else(UDBM_FOUND)
message(STATUS "Failed to find UDBM, going to compile from source.")
if (FIND_FATAL)
message(FATAL_ERROR "Failed to find UDBM with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
endif(FIND_FATAL)
include(FetchContent)
set(UDBM_WITH_TESTS OFF CACHE BOOL "UDBM tests")
FetchContent_Declare(
UDBM
GIT_REPOSITORY https://github.com/UPPAALModelChecker/UDBM.git
GIT_TAG v2.0.13
GIT_SHALLOW TRUE # get only the last commit version
GIT_PROGRESS TRUE # show progress of download
# FIND_PACKAGE_ARGS NAMES doctest
USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator
USES_TERMINAL_CONFIGURE ON
USES_TERMINAL_BUILD ON
USES_TERMINAL_INSTALL ON
)
FetchContent_GetProperties(UDBM)
if (udbm_POPULATED)
message(STATUS "Found populated UUtils: ${uutils_SOURCE_DIR}")
else (udbm_POPULATED)
FetchContent_Populate(UDBM)
add_subdirectory(${udbm_SOURCE_DIR} ${udbm_BINARY_DIR} EXCLUDE_FROM_ALL)
message(STATUS "Got UDBM: ${udbm_SOURCE_DIR}")
endif (udbm_POPULATED)
endif(UDBM_FOUND)
33 changes: 33 additions & 0 deletions cmake/UUtils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
find_package(UUtils 2.0.5 COMPONENTS base hash debug QUIET)

if (UUtils_FOUND)
message(STATUS "Found UUtils: ${UUtils_DIR}")
else(UUtils_FOUND)
message(STATUS "Failed to find UUtils, going to compile from source.")
if (FIND_FATAL)
message(FATAL_ERROR "Failed to find UUtils with CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
endif(FIND_FATAL)
include(FetchContent)
set(UUtils_WITH_TESTS OFF CACHE BOOL "UUtils tests")
set(UUtils_WITH_BENCHMARKS OFF CACHE BOOL "UUtils benchmarks")
FetchContent_Declare(
UUtils
GIT_REPOSITORY https://github.com/UPPAALModelChecker/UUtils.git
GIT_TAG v2.0.5
GIT_SHALLOW TRUE # get only the last commit version
GIT_PROGRESS TRUE # show progress of download
# FIND_PACKAGE_ARGS NAMES doctest
USES_TERMINAL_DOWNLOAD TRUE # show progress in ninja generator
USES_TERMINAL_CONFIGURE ON
USES_TERMINAL_BUILD ON
USES_TERMINAL_INSTALL ON
)
FetchContent_GetProperties(UUtils)
if (uutils_POPULATED)
message(STATUS "Found populated UUtils: ${uutils_SOURCE_DIR}")
else (uutils_POPULATED)
FetchContent_Populate(UUtils)
add_subdirectory(${uutils_SOURCE_DIR} ${uutils_BINARY_DIR} EXCLUDE_FROM_ALL)
message(STATUS "Got UUtils: ${uutils_SOURCE_DIR}")
endif (uutils_POPULATED)
endif(UUtils_FOUND)
Loading

0 comments on commit 15cc83a

Please sign in to comment.