Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Github Actions config #523

Merged
merged 4 commits into from
Nov 14, 2023
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
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Hana CI

permissions:
contents: read

on: pull_request

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
xcode-version: latest-stable
- os: macos-latest
compiler: llvm
# - os: macos-latest
# compiler: gcc
# - os: windows-latest
# compiler: llvm
- os: ubuntu-latest
compiler: llvm
# - os: ubuntu-latest
# compiler: gcc

steps:
- name: Setup build environment
uses: aminya/setup-cpp@v1
with:
vcvarsall: ${{ contains(matrix.os, 'windows') }}
cmake: true
ninja: true

- name: Setup compiler
uses: aminya/setup-cpp@v1
if: ${{ matrix.compiler }}
with:
compiler: ${{ matrix.compiler }}

- name: Install Xcode
uses: maxim-lobanov/setup-xcode@v1
if: ${{ matrix.xcode-version }}
with:
xcode-version: ${{ matrix.xcode-version }}

- name: Checkout source code
uses: actions/checkout@v3

- name: Configure CMake
run: mkdir build && cmake -S . -B build -G Ninja

- name: Run the tests
run: cmake --build build --target check
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ function(boost_hana_set_test_properties target)
if (NOT MSVC)
setflag(BOOST_HANA_HAS_FDIAGNOSTICS_COLOR -fdiagnostics-color)
setflag(BOOST_HANA_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0)
setflag(BOOST_HANA_HAS_PEDANTIC -pedantic)
setflag(BOOST_HANA_HAS_WALL -Wall)
setflag(BOOST_HANA_HAS_WERROR -Werror)
setflag(BOOST_HANA_HAS_WEXTRA -Wextra)
Expand Down
2 changes: 2 additions & 0 deletions include/boost/hana/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ Distributed under the Boost Software License, Version 1.0.

#elif defined(__clang__) && defined(_MSC_VER) // Clang-cl (Clang for Windows)

# define BOOST_HANA_CONFIG_CLANG_CL
# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION( \
__clang_major__, __clang_minor__, __clang_patchlevel__)

#elif defined(__clang__) && defined(__apple_build_version__) // Apple's Clang

# define BOOST_HANA_CONFIG_APPLE_CLANG
# if __apple_build_version__ >= 6020049
# define BOOST_HANA_CONFIG_CLANG BOOST_HANA_CONFIG_VERSION(3, 6, 0)
# endif
Expand Down
15 changes: 10 additions & 5 deletions include/boost/hana/experimental/type_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,23 @@ namespace boost { namespace hana { namespace experimental {

// Note: We substract the null terminator from the string sizes below.
template <typename T>
constexpr cstring type_name_impl2() {

#if defined(__clang__)
constexpr auto type_name_impl2() {
#if defined(BOOST_HANA_CONFIG_CLANG)
constexpr char const* pretty_function = __PRETTY_FUNCTION__;
constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1;
constexpr std::size_t prefix_size = sizeof("auto boost::hana::experimental::detail::type_name_impl2() [T = ") - 1;
constexpr std::size_t suffix_size = sizeof("]") - 1;
#elif defined(BOOST_HANA_CONFIG_GCC)
constexpr char const* pretty_function = __PRETTY_FUNCTION__;
constexpr std::size_t total_size = sizeof(__PRETTY_FUNCTION__) - 1;
constexpr std::size_t prefix_size = sizeof("cstring boost::hana::experimental::detail::type_name_impl2() [T = ") - 1;
constexpr std::size_t prefix_size = sizeof("constexpr auto boost::hana::experimental::detail::type_name_impl2() [with T = ") - 1;
constexpr std::size_t suffix_size = sizeof("]") - 1;
#else
#error "No support for this compiler."
#endif

return {pretty_function + prefix_size, total_size - prefix_size - suffix_size};
cstring s{pretty_function + prefix_size, total_size - prefix_size - suffix_size};
return s;
}

template <typename T, std::size_t ...i>
Expand Down
11 changes: 0 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ if (NOT Boost_FOUND)
list(APPEND EXCLUDED_PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST})
endif()

# On Windows, Clang-cl emulates a MSVC bug that causes EBO not to be applied
# properly. We disable the tests that check for EBO.
if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
list(APPEND EXCLUDED_UNIT_TESTS
"detail/ebo.cpp"
"issues/github_202.cpp"
"pair/empty_storage.cpp"
"tuple/empty_member.cpp"
)
endif()


##############################################################################
# Generate tests that include each public header.
Expand Down
4 changes: 2 additions & 2 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ project boost/hana :

rule hana-all-tests {
local toolset =
<toolset>clang:<cxxflags>"-std=c++1y -pedantic -Wall -Wextra"
<toolset>darwin:<cxxflags>"-std=c++1y -pedantic -Wall -Wextra"
<toolset>clang:<cxxflags>"-std=c++1y -Wall -Wextra"
<toolset>darwin:<cxxflags>"-std=c++1y -Wall -Wextra"
[ requires
cxx14_constexpr
cxx14_decltype_auto
Expand Down
3 changes: 2 additions & 1 deletion test/detail/ebo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ template <typename ...Bases> struct __declspec(empty_bases) inherit : Bases... {
template <typename ...Bases> struct inherit : Bases... { };
#endif

#ifndef BOOST_HANA_CONFIG_CLANG_CL // MSVC doesn't implement EBO in all cases
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>>), "");
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>>), "");
static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>, ebo<idx<2>, empty<2>>>), "");

#endif

int main() {
// Test default-construction
Expand Down
6 changes: 6 additions & 0 deletions test/issues/github_202.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)

#include <boost/hana/config.hpp>

#ifndef BOOST_HANA_CONFIG_CLANG_CL // EBO is not well supported on Windows

#include <boost/hana/integral_constant.hpp>
#include <boost/hana/pair.hpp>
#include <boost/hana/tuple.hpp>
Expand All @@ -23,4 +27,6 @@ static_assert(
sizeof(hana::tuple<Vector, Vector, Vector, Vector>)
, "");

#endif // BOOST_HANA_CONFIG_CLANG_CL

int main() { }