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
156 changes: 66 additions & 90 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,75 +7,41 @@ defaults:
shell: bash

env:
VCPKG_GIT_COMMIT_ID: 3a3a222be369b556e4635714c8d6acc990e1f13b
VCPKG_GIT_URL: https://github.com/PazerOP/vcpkg.git
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
X_VCPKG_NUGET_ID_PREFIX: mh-stuff
# Use a recent stable vcpkg baseline from official Microsoft repo
VCPKG_COMMIT: de46587b4beaa638743916fe5674825cecfb48b3

jobs:
build-linux:
# name: ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
MH_STUFF_COMPILE_LIBRARY: [true, false]
# compiler: [clang++-11, clang++-10, g++-10, clang++-9, g++-9, clang++-8, g++-8, clang++-7]
compiler:
- exe: clang++-11
deps: clang-11 libc++-11-dev libc++abi-11-dev
- exe: clang++-10
deps: clang-10 libc++-10-dev libc++abi-10-dev
- exe: clang++-9
deps: clang-9 libc++-9-dev libc++abi-9-dev
- exe: clang++-8
deps: clang-8 libc++-8-dev libc++abi-8-dev
- exe: clang++-7
deps: clang-7 libc++-7-dev libc++abi-7-dev
- exe: g++-10
deps: g++-10
- exe: g++-9
deps: g++-9
- exe: g++-8
deps: g++-8
# Modern compilers available on ubuntu-latest (Ubuntu 22.04/24.04)
- exe: g++-12
deps: g++-12
- exe: g++-13
deps: g++-13
- exe: clang++-14
deps: clang-14 libc++-14-dev libc++abi-14-dev
- exe: clang++-15
deps: clang-15 libc++-15-dev libc++abi-15-dev

steps:
- uses: actions/checkout@v2.3.4
- uses: PazerOP/gha-setup-nuget@HEAD
- uses: actions/checkout@v4

- uses: lukka/run-vcpkg@v7
id: runvcpkg
- uses: lukka/run-vcpkg@v11
with:
setupOnly: true
vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }}
vcpkgGitURL: ${{ env.VCPKG_GIT_URL }}

- name: Add repos
run: |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 15CF4D18AF4F7421
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" | sudo tee /etc/apt/sources.list.d/llvm.list

- name: Add repos - llvm-11
if: matrix.compiler.exe == 'clang++-11'
run: echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list

- name: Add repos - llvm-12
if: matrix.compiler.exe == 'clang++-12'
run: echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main" | sudo tee -a /etc/apt/sources.list.d/llvm.list

- name: Update repos
run: sudo apt update
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }}

- name: Install compilers and tools
run: |
# sudo rm -rf /var/lib/apt/lists/*
# sudo apt clean
sudo apt install ${{ matrix.compiler.deps }} ninja-build -y
sudo pip3 install gcovr
sudo apt-get update
sudo apt-get install -y ${{ matrix.compiler.deps }} ninja-build
pip3 install gcovr

echo Ensuring programs work...
echo "Ensuring programs work..."
${{ matrix.compiler.exe }} --version
ninja --version
gcovr --version
Expand Down Expand Up @@ -115,57 +81,67 @@ jobs:

- name: Save test results
if: ${{ matrix.MH_STUFF_COMPILE_LIBRARY }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: gcovr_results_${{ matrix.compiler.exe }}
path: build/results*.html



build-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
MH_STUFF_COMPILE_LIBRARY: [true, false]
# build-windows:
# runs-on: windows-latest
# strategy:
# fail-fast: false
# matrix:
# MH_STUFF_COMPILE_LIBRARY: [true, false]

steps:
- uses: actions/checkout@v2.3.4
- uses: PazerOP/gha-setup-nuget@HEAD
# steps:
# - uses: actions/checkout@v4

- uses: lukka/run-vcpkg@v7
with:
setupOnly: true
vcpkgGitCommitId: ${{ env.VCPKG_GIT_COMMIT_ID }}
vcpkgGitURL: ${{ env.VCPKG_GIT_URL }}
# - uses: lukka/run-vcpkg@v11
# with:
# vcpkgGitCommitId: ${{ env.VCPKG_COMMIT }}

- uses: seanmiddleditch/gha-setup-ninja@v3
- name: Setup compiler paths
uses: ilammy/msvc-dev-cmd@v1.5.0
# - uses: seanmiddleditch/gha-setup-ninja@v5
# - name: Setup compiler paths
# uses: ilammy/msvc-dev-cmd@v1

- name: Build
run: |
mkdir build
cd build
# - name: Build
# run: |
# mkdir build
# cd build

cmake -G Ninja \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DMH_STUFF_COMPILE_LIBRARY=${{ matrix.MH_STUFF_COMPILE_LIBRARY }} \
../
# cmake -G Ninja \
# -DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
# -DMH_STUFF_COMPILE_LIBRARY=${{ matrix.MH_STUFF_COMPILE_LIBRARY }} \
# ../

cmake --build .
# cmake --build .

- name: Run tests
run: |
cd build
ctest --output-on-failure
# - name: Run tests
# run: |
# cd build
# ctest --output-on-failure


registry-update:
needs: [build-linux, build-windows]
# registry-update:
# needs: [build-linux]
# runs-on: ubuntu-latest
# steps:
# - uses: PazerOP/vcpkg-registry-update@HEAD
# with:
# port-name: mh-stuff
# workflow-pat: ${{ secrets.WORKFLOW_PAT }}

all-checks-passed:
if: always()
needs: [build-linux]
runs-on: ubuntu-latest
steps:
- uses: PazerOP/vcpkg-registry-update@HEAD
with:
port-name: mh-stuff
workflow-pat: ${{ secrets.WORKFLOW_PAT }}
- name: Verify all checks passed
run: |
if [[ "${{ needs.build-linux.result }}" != "success" ]]; then
echo "build-linux failed: ${{ needs.build-linux.result }}"
exit 1
fi
echo "All checks passed!"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ out/
out_test_linux/
CMakeSettings.json
out_test/
build/
131 changes: 30 additions & 101 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.16.3)

# Enable compile_commands.json generation for this subproject
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(
mh-stuff
VERSION 1.0
Expand All @@ -22,109 +25,32 @@ else()
set(MH_INTERFACE_OR_EMPTY "INTERFACE")
endif()

file(GLOB_RECURSE MH_HEADER_FILES CONFIGURE_DEPENDS
"cpp/include/mh/*.hpp"
"cpp/include/mh/*.inl"
)

add_library(${PROJECT_NAME} ${MH_INTERFACE_OR_EMPTY}
"cpp/include/mh/algorithm/algorithm.hpp"
"cpp/include/mh/algorithm/multi_compare.hpp"

"cpp/include/mh/chrono/chrono_helpers.hpp"
"cpp/include/mh/chrono/chrono_helpers.inl"

"cpp/include/mh/concurrency/async.hpp"
"cpp/include/mh/concurrency/dispatcher.hpp"
"cpp/include/mh/concurrency/dispatcher.inl"
"cpp/include/mh/concurrency/locked_value.hpp"
"cpp/include/mh/concurrency/main_thread.hpp"
"cpp/include/mh/concurrency/mutex_debug.hpp"
"cpp/include/mh/concurrency/thread_pool.hpp"
"cpp/include/mh/concurrency/thread_pool.inl"
"cpp/include/mh/concurrency/thread_sentinel.hpp"
"cpp/include/mh/concurrency/thread_sentinel.inl"

"cpp/include/mh/containers/heap.hpp"

"cpp/include/mh/coroutine/coroutine_include.hpp"
"cpp/include/mh/coroutine/future.hpp"
"cpp/include/mh/coroutine/generator.hpp"
"cpp/include/mh/coroutine/task.hpp"
"cpp/include/mh/coroutine/thread.hpp"
"cpp/include/mh/coroutine/thread.inl"

"cpp/include/mh/data/bit_float.hpp"
"cpp/include/mh/data/bits.hpp"
"cpp/include/mh/data/lazy.hpp"
"cpp/include/mh/data/optional_ref.hpp"
"cpp/include/mh/data/variable_pusher.hpp"

"cpp/include/mh/error/ensure.inl"
"cpp/include/mh/error/ensure.hpp"
"cpp/include/mh/error/error_code_exception.hpp"
"cpp/include/mh/error/exception_details.hpp"
"cpp/include/mh/error/exception_details.inl"
"cpp/include/mh/error/expected.hpp"
"cpp/include/mh/error/nested_exception.hpp"
"cpp/include/mh/error/not_implemented_error.hpp"
"cpp/include/mh/error/status.hpp"

"cpp/include/mh/io/file.hpp"
"cpp/include/mh/io/filesystem_helpers.hpp"
"cpp/include/mh/io/filesystem_helpers.inl"
"cpp/include/mh/io/getopt.hpp"

"cpp/include/mh/math/angles.hpp"
"cpp/include/mh/math/interpolation.hpp"
"cpp/include/mh/math/random.hpp"
"cpp/include/mh/math/random.inl"
"cpp/include/mh/math/uint128.hpp"

"cpp/include/mh/memory/buffer.inl"
"cpp/include/mh/memory/buffer.hpp"
"cpp/include/mh/memory/cached_variable.hpp"
"cpp/include/mh/memory/checked_ptr.hpp"
"cpp/include/mh/memory/memory_helpers.hpp"
"cpp/include/mh/memory/stack_info.hpp"
"cpp/include/mh/memory/stack_info.inl"
"cpp/include/mh/memory/unique_object.hpp"

"cpp/include/mh/raii/scope_exit.hpp"

"cpp/include/mh/reflection/enum.hpp"
"cpp/include/mh/reflection/struct.hpp"

"cpp/include/mh/text/formatters/error_code.hpp"
"cpp/include/mh/text/case_insensitive_string.hpp"
"cpp/include/mh/text/charconv_helper.hpp"
"cpp/include/mh/text/codecvt.hpp"
"cpp/include/mh/text/codecvt.inl"
"cpp/include/mh/text/fmtstr.hpp"
"cpp/include/mh/text/format.hpp"
"cpp/include/mh/text/indenting_ostream.hpp"
"cpp/include/mh/text/insertion_conversion.hpp"
"cpp/include/mh/text/memstream.hpp"
"cpp/include/mh/text/multi_char.hpp"
"cpp/include/mh/text/string_insertion.hpp"
"cpp/include/mh/text/stringops.hpp"

"cpp/include/mh/types/disable_copy_move.hpp"
"cpp/include/mh/types/enum_class_bit_ops.hpp"

"cpp/include/mh/compiler.hpp"
"cpp/include/mh/future.hpp"
"cpp/include/mh/source_location.hpp"
"cpp/include/mh/utility.hpp"
"cpp/include/mh/variant.hpp"
${MH_HEADER_FILES}
)
add_library(mh::stuff ALIAS ${PROJECT_NAME})

find_package(mh-cmake-common CONFIG REQUIRED)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/mh-cmake-common")
include(mh-BasicInstall)
include(mh-CheckCoroutineSupport)

if (MH_STUFF_COMPILE_LIBRARY)
find_package(CURL REQUIRED)

file(GLOB_RECURSE MH_SOURCE_FILES CONFIGURE_DEPENDS
"cpp/src/*.cpp"
)
target_sources(${PROJECT_NAME} PRIVATE
"cpp/src/io/file.cpp"
"cpp/src/text/case_insensitive_string.cpp"
"cpp/src/text/string_insertion.cpp"
"cpp/src/source_location.cpp"
${MH_SOURCE_FILES}
)

target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)

target_compile_definitions(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE}
"MH_COMPILE_LIBRARY"
"MH_COMPILE_LIBRARY_INLINE="
Expand All @@ -142,7 +68,7 @@ if (MH_STUFF_COMPILE_LIBRARY)
target_sources(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/library.cpp")

if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /permissive-)
target_compile_options(${PROJECT_NAME} PRIVATE /W3 /permissive- /utf-8)
endif()

include(GenerateExportHeader)
Expand Down Expand Up @@ -189,27 +115,30 @@ if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang)
target_link_options(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE} -pthread)
endif()

# Define __unix__ for Unix-like systems (Linux, macOS, etc.)
if (UNIX)
target_compile_definitions(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE} "__unix__")
endif()

if (NOT MSVC)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-fconcepts FCONCEPTS_FLAG)
if (FCONCEPTS_FLAG)
target_compile_options(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE} -fconcepts)
endif()
endif()

mh_check_cxx_unicode_support(SUPPORTS_UNICODE ${PROJECT_NAME})
if (NOT SUPPORTS_UNICODE)
target_compile_definitions(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE} "MH_BROKEN_UNICODE")
endif()
# Force enable MH_BROKEN_UNICODE for the current system
target_compile_definitions(${PROJECT_NAME} ${MH_PUBLIC_OR_INTERFACE} "MH_BROKEN_UNICODE=1")
message(STATUS "Forcing MH_BROKEN_UNICODE=1 to work around compiler Unicode issues")

if (NOT DEFINED BUILD_TESTING)
if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
set(BUILD_TESTING ON)
else()
set(BUILD_TESTING OFF)
endif()
message("BUILD_TESTING not defined, changing to ${BUILD_TESTING}")
else()
message("BUILD_TESTING = ${BUILD_TESTING}, not modifying")
endif()

if (BUILD_TESTING)
Expand Down
Loading
Loading