Skip to content

Commit 2391019

Browse files
Merge pull request #5 from BestITUserEUW/feature/explicit-exports-msvc
Feature/explicit exports msvc
2 parents fc0e4da + bedc1e5 commit 2391019

20 files changed

Lines changed: 100 additions & 77 deletions

.github/workflows/linux.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,12 @@ jobs:
6666
include:
6767
- name: "ASan"
6868
extra-flags: "-DORYX_CHRON_SANITIZE_ADDRESS=ON"
69+
- name: "TSan"
70+
extra-flags: "-DORYX_CHRON_SANITIZE_THREAD=ON" # Not doing much right now
6971
- name: "Optimized Build"
7072
extra-flags: "-DCMAKE_CXX_FLAGS=-O3"
73+
- name: "Shared Build"
74+
extra-flags: "-DORYX_CHRON_BUILD_SHARED_LIBS=ON"
7175

7276
name: "${{ github.job }} ${{ matrix.name }}"
7377
runs-on: ubuntu-latest

.github/workflows/windows.yaml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,33 @@ name: windows
22

33
on: [push, pull_request]
44

5-
env:
6-
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
7-
85
jobs:
96
windows-msvc:
107
runs-on: windows-latest
8+
strategy:
9+
matrix:
10+
shared: [OFF, ON]
11+
name: "Windows MSVC ${{ matrix.shared == 'ON' && 'shared' || 'static' }}"
1112
steps:
1213
- name: Checkout
1314
uses: actions/checkout@v4
1415
with:
1516
submodules: recursive
1617
fetch-depth: 0
18+
1719
- name: Export GitHub Actions cache environment variables
1820
uses: actions/github-script@v7
1921
with:
2022
script: |
2123
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
2224
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
25+
2326
- uses: ilammy/msvc-dev-cmd@v1
27+
2428
- name: Compile
2529
run: |
26-
cmake -B build -DORYX_CHRON_BUILD_TESTS=ON -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
30+
cmake -B build -DORYX_CHRON_BUILD_TESTS=ON -DORYX_CHRON_BUILD_SHARED_LIBS=${{ matrix.shared }} -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release
2731
cmake --build build
32+
2833
- name: Run tests
29-
run: |
30-
.\build\Debug\chron-cpp_tests --success
34+
run: .\build\Debug\chron-cpp_tests

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ endif()
2929

3030
if (ORYX_CHRON_BUILD_SHARED_LIBS)
3131
add_library(${PROJECT_NAME} SHARED)
32+
target_compile_definitions(${PROJECT_NAME} PUBLIC ORYX_CHRON_BUILD_SHARED_LIBS)
3233
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
3334
else()
3435
add_library(${PROJECT_NAME} STATIC)
@@ -40,6 +41,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
4041
target_compile_options(${PROJECT_NAME}
4142
PRIVATE
4243
/W4
44+
PUBLIC
45+
$<$<BOOL:${ORYX_CHRON_BUILD_SHARED_LIBS}>:/wd4251>
4346
)
4447
else()
4548
target_compile_options(${PROJECT_NAME}

include/oryx/chron/chrono_types.hpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

include/oryx/chron/clock.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
#include <mutex>
55
#include <chrono>
66

7-
#include <oryx/chron/traits.hpp>
8-
#include <oryx/chron/chrono_types.hpp>
7+
#include "common.hpp"
8+
#include "traits.hpp"
99

1010
namespace oryx::chron {
1111

12-
class UTCClock {
12+
class ORYX_CHRON_API UTCClock {
1313
public:
1414
auto Now() const -> TimePoint { return Clock::now(); }
1515
auto UtcOffset(TimePoint) const -> std::chrono::seconds { return std::chrono::seconds(0); }
1616
};
1717

18-
class LocalClock {
18+
class ORYX_CHRON_API LocalClock {
1919
public:
2020
auto Now() const -> TimePoint {
2121
auto now = Clock::now();
@@ -25,7 +25,7 @@ class LocalClock {
2525
auto UtcOffset(TimePoint now) const -> std::chrono::seconds;
2626
};
2727

28-
class TzClock {
28+
class ORYX_CHRON_API TzClock {
2929
public:
3030
auto Now() const -> TimePoint {
3131
auto now = Clock::now();

include/oryx/chron/common.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#pragma once
2+
3+
#include <chrono>
4+
5+
#ifdef ORYX_CHRON_BUILD_SHARED_LIBS
6+
#ifdef _WIN32
7+
#ifdef chron_cpp_EXPORTS
8+
#define ORYX_CHRON_API __declspec(dllexport)
9+
#else
10+
#define ORYX_CHRON_API __declspec(dllimport)
11+
#endif
12+
#else
13+
#define ORYX_CHRON_API __attribute__((visibility("default")))
14+
#endif
15+
#else
16+
#define ORYX_CHRON_API
17+
#endif
18+
19+
namespace oryx::chron {
20+
21+
using Clock = std::chrono::system_clock;
22+
using TimePoint = std::chrono::time_point<Clock>;
23+
using Duration = Clock::duration;
24+
25+
} // namespace oryx::chron

include/oryx/chron/details/any_of.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#include <cstdint>
44
#include <set>
55

6-
#include <oryx/chron/details/to_underlying.hpp>
7-
86
namespace oryx::chron::details {
97

108
namespace traits {

include/oryx/chron/details/null_mutex.hpp

Lines changed: 0 additions & 15 deletions
This file was deleted.

include/oryx/chron/null_mutex.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include "traits.hpp"
4+
5+
namespace oryx::chron {
6+
7+
class NullMutex {
8+
public:
9+
void lock() noexcept {}
10+
void unlock() noexcept {}
11+
};
12+
13+
static_assert(traits::BasicLockable<NullMutex>);
14+
15+
} // namespace oryx::chron

include/oryx/chron/parser.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#pragma once
22

3-
#include <optional>
43
#include <mutex>
4+
#include <string_view>
5+
#include <optional>
6+
#include <functional>
57
#include <algorithm>
68

7-
#include <oryx/chron/details/null_mutex.hpp>
8-
9+
#include "common.hpp"
910
#include "chron_data.hpp"
1011
#include "traits.hpp"
12+
#include "null_mutex.hpp"
1113

1214
namespace oryx::chron {
1315

14-
struct ExpressionParser {
16+
struct ORYX_CHRON_API ExpressionParser {
1517
auto operator()(std::string_view cron_expression) const -> std::optional<ChronData>;
1618
};
1719

18-
template <traits::BasicLockable MutexType = details::NullMutex>
20+
template <traits::BasicLockable MutexType = NullMutex>
1921
class CachedExpressionParser : ExpressionParser {
2022
public:
2123
using Pair = std::pair<std::size_t, ChronData>;

0 commit comments

Comments
 (0)