From b5f7e475e8b8e49bafe1cea10c2c541e4b03a6b3 Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:16:45 +0900 Subject: [PATCH 1/2] Use Iris for common components --- .github/workflows/ci.yml | 2 +- .gitmodules | 3 + CMakeLists.txt | 109 ++---------------- include/iris/config.hpp | 51 -------- include/iris/core/type_traits.hpp | 38 ------ include/iris/x4/core/action.hpp | 1 + include/iris/x4/core/action_context.hpp | 1 + include/iris/x4/core/container_appender.hpp | 4 +- include/iris/x4/core/context.hpp | 2 +- .../iris/x4/core/detail/parse_alternative.hpp | 1 + .../x4/core/detail/parse_into_container.hpp | 1 + .../iris/x4/core/detail/parse_sequence.hpp | 1 + include/iris/x4/core/expectation.hpp | 1 + include/iris/x4/core/move_to.hpp | 2 +- include/iris/x4/core/parser.hpp | 1 + include/iris/x4/core/skip_over.hpp | 1 + include/iris/x4/rule.hpp | 2 +- modules/iris | 1 + test/CMakeLists.txt | 57 +-------- test/x4/CMakeLists.txt | 27 +---- 20 files changed, 38 insertions(+), 268 deletions(-) create mode 100644 .gitmodules delete mode 100644 include/iris/config.hpp delete mode 100644 include/iris/core/type_traits.hpp create mode 160000 modules/iris diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5218d23cd..9ef562e88 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -249,7 +249,7 @@ jobs: path: ${{ steps.env-info.outputs.BOOST_ROOT }}/libs/iris_x4/build/_deps # Adapt CMP0168; enable caching in CI - # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_UPDATES_DISCONNECTED + # https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_FULLY_DISCONNECTED - name: Setup Cached CMake Dependencies id: deps-info shell: bash diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..14a72fec5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "modules/iris"] + path = modules/iris + url = https://github.com/iris-cpp/iris.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c449447a..4e71049a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright 2020 Peter Dimov -# Copyright 2025 Nana Sakisaka +# Copyright 2025-2026 Nana Sakisaka # # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt @@ -7,38 +7,22 @@ cmake_minimum_required(VERSION 3.30) if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE - "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - CACHE STRING "" - ) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") endif() project(iris_x4 VERSION 1.0.0 LANGUAGES CXX) # ----------------------------------------------------------------- -# Global settings -# Handle with care, keep these to the ones that can't be -# accomplished by target-specific settings. - -set(CMAKE_COLOR_DIAGNOSTICS ON) -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - -option(IRIS_X4_REMOVE_MINSIZEREL_CONFIG "Remove rarely used MinSizeRel config" ON) +# Load Iris +# This sets many basic settings and common targets automatically. -if(MSVC) - if(IRIS_X4_REMOVE_MINSIZEREL_CONFIG OR PROJECT_IS_TOP_LEVEL) - list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES MinSizeRel) - endif() +if(PROJECT_IS_TOP_LEVEL) + include(CTest) # sets BUILD_TESTING endif() +add_subdirectory(modules/iris) -# ----------------------------------------------------------------- -# Create common base targets - -# Private component; do not depend on this. -add_library(_iris_x4_cxx_common INTERFACE) -set_target_properties(_iris_x4_cxx_common PROPERTIES CXX_EXTENSIONS OFF) # ----------------------------------------------------------------- # Create the main X4 target @@ -55,71 +39,15 @@ if(MSVC) # "${PROJECT_SOURCE_DIR}/iris_x4.natvis" # TODO ) + target_link_libraries(iris_x4 PUBLIC Iris::Iris) + else() add_library(iris_x4 INTERFACE) + target_link_libraries(iris_x4 INTERFACE Iris::Iris) endif() add_library(Iris::X4 ALIAS iris_x4) set_target_properties(iris_x4 PROPERTIES CXX_EXTENSIONS OFF) -target_link_libraries(iris_x4 INTERFACE _iris_x4_cxx_common) - - -# ----------------------------------------------------------------- -# Configure C++ version - -# Set minimal C++ version explicitly; avoid "/std:c++latest" -set(IRIS_X4_CXX_FEATURE cxx_std_23) -if(MSVC) - if(CMAKE_CXX_STANDARD EQUAL 23) - set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "/std:c++23preview") - set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "/std:c++23preview") - target_compile_options(_iris_x4_cxx_common INTERFACE /std:c++23preview) - target_compile_options(iris_x4 PRIVATE /std:c++23preview) # Set strict version for dummy.cpp - else() - # may become /std:c++latest only on this case - target_compile_features(_iris_x4_cxx_common INTERFACE ${IRIS_X4_CXX_FEATURE}) - target_link_libraries(iris_x4 PRIVATE _iris_x4_cxx_common) # Virtually sets `/std:c++latest` for dummy.cpp - endif() -else() # Non-MSVC - target_compile_features(_iris_x4_cxx_common INTERFACE ${IRIS_X4_CXX_FEATURE}) # Sets appropriate `-std=c++XX` -endif() -unset(IRIS_X4_CXX_FEATURE) - - -# ----------------------------------------------------------------- -# Advanced compile/link settings - -if(MSVC) - # Don't set too strict flags for this! They must go to `iris_x4_cxx_test`. - # ABI-dependent configurations MUST be set here. - target_compile_definitions( - _iris_x4_cxx_common - INTERFACE UNICODE _UNICODE - ) - target_compile_options( - _iris_x4_cxx_common - INTERFACE - /EHsc /MP /utf-8 /Zc:preprocessor /permissive- - # $<$:/fsanitize=address> # TODO - ) - target_link_options( - _iris_x4_cxx_common - INTERFACE - # $<$:/INCREMENTAL:NO> # TODO - ) - -else() - target_compile_options( - _iris_x4_cxx_common - INTERFACE - # $<$:-fsanitize=undefined,address> # TODO - ) - target_link_options( - _iris_x4_cxx_common - INTERFACE - # $<$:-fsanitize=undefined,address> # TODO - ) -endif() # ----------------------------------------------------------------- @@ -188,17 +116,8 @@ foreach(dep IN LISTS iris_x4_boost_deps) add_subdirectory(../${dep} build_deps/${dep}) endforeach() -# find_package(...) -# target_link_libraries(iris_x4 INTERFACE ...) - -# TODO: link Iris::iris - foreach(dep IN LISTS iris_x4_boost_deps) - target_link_libraries( - iris_x4 - INTERFACE - Boost::${dep} - ) + target_link_libraries(iris_x4 INTERFACE Boost::${dep}) endforeach() @@ -227,14 +146,10 @@ target_include_directories( # ----------------------------------------------------------------- # Test -if(PROJECT_IS_TOP_LEVEL) - include(CTest) -endif() - if(BUILD_TESTING) add_subdirectory(test) - if(MSVC) + if(MSVC AND PROJECT_IS_TOP_LEVEL) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Iris::X4) endif() endif() diff --git a/include/iris/config.hpp b/include/iris/config.hpp deleted file mode 100644 index 03c683b5b..000000000 --- a/include/iris/config.hpp +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef IRIS_X4_CONFIG_HPP -#define IRIS_X4_CONFIG_HPP - -/*============================================================================= - Copyright (c) 2025 Nana Sakisaka - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -#include - -#define IRIS_STRINGIZE_I(x) #x -#define IRIS_STRINGIZE(x) IRIS_STRINGIZE_I(x) - -#define IRIS_CONCAT_I_I(a, b) a##b -#define IRIS_CONCAT_I(a, b) IRIS_CONCAT_I_I(a, b) -#define IRIS_CONCAT(a, b) IRIS_CONCAT_I(a, b) - -#if _MSC_VER -# include -# pragma warning(default: CPPCORECHECK_LIFETIME_WARNINGS) -#endif - -// - -#if _MSC_VER && _MSC_VER < 1929 // VS 2019 v16.9 or before -# error "Too old MSVC version; we don't support this because it leads to ODR violation regarding the existence of [[(msvc::)no_unique_address]]" -#endif - -#if _MSC_VER && __INTELLISENSE__ // Memory Layout view shows wrong layout without this workaround -# define IRIS_NO_UNIQUE_ADDRESS [[msvc::no_unique_address, no_unique_address]] - -#elif _MSC_VER // normal MSVC -# define IRIS_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] - -#else // other compilers -# define IRIS_NO_UNIQUE_ADDRESS [[no_unique_address]] -#endif - -#ifndef IRIS_LIFETIMEBOUND -# ifdef __clang__ -# define IRIS_LIFETIMEBOUND [[clang::lifetimebound]] -# elifdef _MSC_VER -# define IRIS_LIFETIMEBOUND [[msvc::lifetimebound]] -# else -# define IRIS_LIFETIMEBOUND -# endif -#endif - -#endif diff --git a/include/iris/core/type_traits.hpp b/include/iris/core/type_traits.hpp deleted file mode 100644 index a85b0f8fa..000000000 --- a/include/iris/core/type_traits.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef IRIS_CORE_TYPE_TRAITS_HPP -#define IRIS_CORE_TYPE_TRAITS_HPP - -/*============================================================================= - Copyright (c) 2025 Nana Sakisaka - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -=============================================================================*/ - -#include - -#include - -namespace iris { - -template class TT> -struct is_ttp_specialization_of : std::false_type {}; - -template class TT, class... Ts> -struct is_ttp_specialization_of, TT> : std::true_type {}; - -template class TT> -inline constexpr bool is_ttp_specialization_of_v = is_ttp_specialization_of::value; - - -template class TT> -struct is_nttp_specialization_of : std::false_type {}; - -template class TT, auto... Ts> -struct is_nttp_specialization_of, TT> : std::true_type {}; - -template class TT> -inline constexpr bool is_nttp_specialization_of_v = is_nttp_specialization_of::value; - -} // iris - -#endif diff --git a/include/iris/x4/core/action.hpp b/include/iris/x4/core/action.hpp index a24be8ef3..2ff18f209 100644 --- a/include/iris/x4/core/action.hpp +++ b/include/iris/x4/core/action.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include #include diff --git a/include/iris/x4/core/action_context.hpp b/include/iris/x4/core/action_context.hpp index c41d3a470..847c0651f 100644 --- a/include/iris/x4/core/action_context.hpp +++ b/include/iris/x4/core/action_context.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include namespace iris::x4 { diff --git a/include/iris/x4/core/container_appender.hpp b/include/iris/x4/core/container_appender.hpp index 06ee7d709..1631d021e 100644 --- a/include/iris/x4/core/container_appender.hpp +++ b/include/iris/x4/core/container_appender.hpp @@ -1,7 +1,9 @@ #ifndef IRIS_X4_CORE_CONTAINER_APPENDER_HPP #define IRIS_X4_CORE_CONTAINER_APPENDER_HPP -#include +#include +#include + #include #include diff --git a/include/iris/x4/core/context.hpp b/include/iris/x4/core/context.hpp index 410045329..61feb651d 100644 --- a/include/iris/x4/core/context.hpp +++ b/include/iris/x4/core/context.hpp @@ -10,7 +10,7 @@ =============================================================================*/ #include -#include +#include #include diff --git a/include/iris/x4/core/detail/parse_alternative.hpp b/include/iris/x4/core/detail/parse_alternative.hpp index b442239ae..925516025 100644 --- a/include/iris/x4/core/detail/parse_alternative.hpp +++ b/include/iris/x4/core/detail/parse_alternative.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include #include diff --git a/include/iris/x4/core/detail/parse_into_container.hpp b/include/iris/x4/core/detail/parse_into_container.hpp index 344d091fc..1ec5a1af4 100644 --- a/include/iris/x4/core/detail/parse_into_container.hpp +++ b/include/iris/x4/core/detail/parse_into_container.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include #include diff --git a/include/iris/x4/core/detail/parse_sequence.hpp b/include/iris/x4/core/detail/parse_sequence.hpp index 10dd0181b..a2194e3bd 100644 --- a/include/iris/x4/core/detail/parse_sequence.hpp +++ b/include/iris/x4/core/detail/parse_sequence.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include #include diff --git a/include/iris/x4/core/expectation.hpp b/include/iris/x4/core/expectation.hpp index 49ad14afa..6cd3d7b67 100644 --- a/include/iris/x4/core/expectation.hpp +++ b/include/iris/x4/core/expectation.hpp @@ -10,6 +10,7 @@ =============================================================================*/ #include + #include // for `x4::what` #include diff --git a/include/iris/x4/core/move_to.hpp b/include/iris/x4/core/move_to.hpp index 3e287b5e7..d763f44ee 100644 --- a/include/iris/x4/core/move_to.hpp +++ b/include/iris/x4/core/move_to.hpp @@ -11,7 +11,7 @@ =============================================================================*/ #include -#include +#include #include #include diff --git a/include/iris/x4/core/parser.hpp b/include/iris/x4/core/parser.hpp index 98e74dcf0..d72bca9ca 100644 --- a/include/iris/x4/core/parser.hpp +++ b/include/iris/x4/core/parser.hpp @@ -11,6 +11,7 @@ ==============================================================================*/ #include + #include #include #include diff --git a/include/iris/x4/core/skip_over.hpp b/include/iris/x4/core/skip_over.hpp index 05bba2364..ebae70783 100644 --- a/include/iris/x4/core/skip_over.hpp +++ b/include/iris/x4/core/skip_over.hpp @@ -11,6 +11,7 @@ ==============================================================================*/ #include + #include #include #include diff --git a/include/iris/x4/rule.hpp b/include/iris/x4/rule.hpp index f18f3da80..1014f1dcd 100644 --- a/include/iris/x4/rule.hpp +++ b/include/iris/x4/rule.hpp @@ -11,7 +11,7 @@ ==============================================================================*/ #include -#include +#include #include #include diff --git a/modules/iris b/modules/iris new file mode 160000 index 000000000..0a7c23166 --- /dev/null +++ b/modules/iris @@ -0,0 +1 @@ +Subproject commit 0a7c2316613f79399f63ce5e54d7f22be5f78245 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1d0ea98cc..3d351e5f2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,59 +1,8 @@ -# Copyright 2025 Nana Sakisaka +# Copyright 2025-2026 Nana Sakisaka # # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt -# For X4-specific tests. -add_library(iris_x4_cxx_test INTERFACE) -set_target_properties(iris_x4_cxx_test PROPERTIES CXX_EXTENSIONS OFF) -target_link_libraries(iris_x4_cxx_test INTERFACE _iris_x4_cxx_common) - -# For external libraries. Excludes strict warning, etc. -add_library(iris_x4_cxx_external INTERFACE) -set_target_properties(iris_x4_cxx_external PROPERTIES CXX_EXTENSIONS OFF) -target_link_libraries(iris_x4_cxx_external INTERFACE _iris_x4_cxx_common) - -if(MSVC) - target_compile_options( - iris_x4_cxx_test - INTERFACE /W4 /analyze /analyze:external- - ) - target_compile_options( - iris_x4_cxx_external - INTERFACE /analyze- - ) - -else() # non-MSVC - target_compile_options( - iris_x4_cxx_test - INTERFACE - -Wall -Wextra -pedantic - ) +if(PROJECT_IS_TOP_LEVEL) + add_subdirectory(x4) endif() - -# -------------------------------------------- - -# https://github.com/catchorg/Catch2/blob/devel/docs/configuration.md -set(CATCH_CONFIG_FAST_COMPILE ON) -set(CATCH_CONFIG_NO_USE_BUILTIN_CONSTANT_P ON) - -include(FetchContent) -FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2 - GIT_TAG v3.10.0 - GIT_SHALLOW ON -) -FetchContent_MakeAvailable(Catch2) - -set_target_properties(Catch2 PROPERTIES CXX_EXTENSIONS OFF) -target_compile_definitions(Catch2 PUBLIC DO_NOT_USE_WMAIN) -target_link_libraries(Catch2 PRIVATE iris_x4_cxx_external) -target_link_libraries(Catch2WithMain PRIVATE iris_x4_cxx_external) - -target_link_libraries(iris_x4_cxx_test INTERFACE Catch2::Catch2WithMain) - -# -------------------------------------------- - -add_subdirectory(x4) - diff --git a/test/x4/CMakeLists.txt b/test/x4/CMakeLists.txt index 87b8da656..bc4f18fe6 100644 --- a/test/x4/CMakeLists.txt +++ b/test/x4/CMakeLists.txt @@ -1,25 +1,15 @@ -# Copyright 2025 Nana Sakisaka +# Copyright 2025-2026 Nana Sakisaka # # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt function(x4_define_test_headers test_name) - target_sources( - x4_${test_name}_test - PRIVATE FILE_SET HEADERS FILES - ${ARGN} - ) + iris_define_test_headers(x4_${test_name} PRIVATE FILE_SET HEADERS FILES ${ARGN}) endfunction() function(x4_define_test test_name) - # message("test_name: ${test_name}, sources: ${ARGN}") - add_executable(x4_${test_name}_test ${ARGN}) - x4_define_test_headers(${test_name} test.hpp) - - set_target_properties( - x4_${test_name}_test - PROPERTIES CXX_EXTENSIONS OFF - ) + iris_define_test(x4_${test_name} ${ARGN}) + target_link_libraries(x4_${test_name}_test PRIVATE Iris::X4) if(MSVC) # Prevent "Warning: Conflicting entries detected" error @@ -31,15 +21,6 @@ function(x4_define_test test_name) # target_sources(x4_${test_name}_test PRIVATE cpp.hint) endif() - - target_link_libraries( - x4_${test_name}_test - PRIVATE Iris::X4 iris_x4_cxx_test - ) - add_test( - NAME x4_${test_name}_test - COMMAND x4_${test_name}_test --colour-mode=ansi - ) endfunction() function(x4_define_tests) From b942cab57ae5c476365e8a9948db85fe1a281f39 Mon Sep 17 00:00:00 2001 From: Nana Sakisaka <1901813+saki7@users.noreply.github.com> Date: Wed, 4 Feb 2026 19:21:32 +0900 Subject: [PATCH 2/2] Checkout submodules --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ef562e88..727445222 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -104,6 +104,8 @@ jobs: steps: - uses: actions/checkout@v5 + with: + submodules: recursive - name: Initialize Ubuntu if: matrix.os.name == 'ubuntu'