Skip to content

Commit 5131953

Browse files
Generate .lib files when building shared on Windows; Bumped to version 0.4.0 (#86)
1 parent 86884f3 commit 5131953

34 files changed

Lines changed: 271 additions & 160 deletions

.github/workflows/linux-cxx20-conan.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: linux-cxx20-conan
22

33
on: [push, pull_request]
44

5+
56
jobs:
67
linux:
78
strategy:
@@ -35,6 +36,9 @@ jobs:
3536
compiler-version: 12
3637
link: "shared"
3738
name: "${{ github.job }} (${{ matrix.compiler }}-${{ matrix.compiler-version }}-${{ matrix.link }})"
39+
concurrency:
40+
group: ci-${{ github.ref }}-${{ github.job }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-${{ matrix.link }}
41+
cancel-in-progress: true
3842
runs-on: ubuntu-latest
3943
steps:
4044
- name: Checkout

.github/workflows/linux-cxx20-vcpkg.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: linux-cxx20-vcpkg
22

33
on: [push, pull_request]
44

5+
56
env:
67
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
78

@@ -60,6 +61,9 @@ jobs:
6061
compiler-version: 14
6162
db: mysql
6263
name: "${{ github.job }} (${{ matrix.compiler }}-${{ matrix.compiler-version }}-${{ matrix.db }})"
64+
concurrency:
65+
group: ci-${{ github.ref }}-${{ github.job }}-${{ matrix.compiler }}-${{ matrix.compiler-version }}-${{ matrix.db }}
66+
cancel-in-progress: true
6367
runs-on: ubuntu-latest
6468
steps:
6569
- name: Checkout

.github/workflows/macos-cxx20-conan.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: macos-cxx20-conan
22

33
on: [push, pull_request]
44

5+
56
jobs:
67
macos-clang:
78
strategy:
@@ -17,6 +18,9 @@ jobs:
1718
- os: "macos-13"
1819
link: "shared"
1920
name: "${{ github.job }} (${{ matrix.os }}-${{ matrix.link }})"
21+
concurrency:
22+
group: ci-${{ github.ref }}-${{ github.job }}-${{ matrix.os }}-${{ matrix.link }}
23+
cancel-in-progress: true
2024
runs-on: ${{ matrix.os }}
2125
steps:
2226
- name: Checkout

.github/workflows/macos-cxx20-vcpkg.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: macos-cxx20-vcpkg
22

33
on: [push, pull_request]
44

5+
56
env:
67
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
78

@@ -24,6 +25,9 @@ jobs:
2425
- os: "macos-13"
2526
db: mysql
2627
name: "${{ github.job }} (${{ matrix.os }}-${{ matrix.db }})"
28+
concurrency:
29+
group: ci-${{ github.ref }}-${{ github.job }}-${{ matrix.os }}-${{ matrix.db }}
30+
cancel-in-progress: true
2731
runs-on: ${{ matrix.os }}
2832
steps:
2933
- name: Checkout

.github/workflows/windows-cxx20-vcpkg.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ jobs:
1414
- db: postgres
1515
- db: sqlite
1616
- db: mysql
17+
- db: headers
1718
name: "(windows-${{ matrix.db }})"
19+
concurrency:
20+
group: ci-${{ github.ref }}-windows-${{ matrix.db }}
21+
cancel-in-progress: true
1822
runs-on: windows-latest
1923
steps:
2024
- name: Checkout
@@ -30,21 +34,27 @@ jobs:
3034
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
3135
- uses: ilammy/msvc-dev-cmd@v1
3236
- uses: lukka/run-vcpkg@v11
37+
- name: Compile
38+
if: matrix.db == 'headers'
39+
run: |
40+
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DSQLGEN_CHECK_HEADERS=ON
41+
cmake --build build --config Release -j4
3342
- name: Compile
3443
if: matrix.db == 'postgres'
3544
run: |
36-
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_SQLITE3=OFF -DSQLGEN_BUILD_DRY_TESTS_ONLY=ON
45+
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_SQLITE3=OFF -DSQLGEN_BUILD_DRY_TESTS_ONLY=ON -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-windows-release
3746
cmake --build build --config Release -j4
3847
- name: Compile
3948
if: matrix.db == 'sqlite'
4049
run: |
41-
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_CHECK_HEADERS=ON
50+
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_POSTGRES=OFF -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-windows-release
4251
cmake --build build --config Release -j4
4352
- name: Compile
4453
if: matrix.db == 'mysql'
4554
run: |
46-
cmake -S . -B build -G Ninja -DCMAKE_CXX_STANDARD=20 -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_MYSQL=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_SQLITE3=OFF -DSQLGEN_BUILD_DRY_TESTS_ONLY=ON
55+
cmake -S . -B build -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release -DSQLGEN_BUILD_TESTS=ON -DSQLGEN_MYSQL=ON -DSQLGEN_POSTGRES=OFF -DSQLGEN_SQLITE3=OFF -DSQLGEN_BUILD_DRY_TESTS_ONLY=ON -DBUILD_SHARED_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-windows-release
4756
cmake --build build --config Release -j4
4857
- name: Run tests
58+
if: matrix.db != 'headers'
4959
run: |
5060
ctest --test-dir build --output-on-failure

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
*.out
3232
*.app
3333

34+
.cache/
3435
build/
3536
vcpkg_installed/
3637
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
cmake_minimum_required(VERSION 3.23)
22

3+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
4+
35
option(SQLGEN_BUILD_SHARED "Build shared library" ${BUILD_SHARED_LIBS})
46

57
option(SQLGEN_MYSQL "Enable MySQL support" OFF)
@@ -43,7 +45,7 @@ if (SQLGEN_USE_VCPKG)
4345
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")
4446
endif ()
4547

46-
project(sqlgen VERSION 0.3.0 LANGUAGES CXX)
48+
project(sqlgen VERSION 0.4.0 LANGUAGES CXX)
4749

4850
if (SQLGEN_BUILD_SHARED)
4951
add_library(sqlgen SHARED)
@@ -52,10 +54,30 @@ else()
5254
add_library(sqlgen STATIC)
5355
endif()
5456

57+
add_library(sqlgen::sqlgen ALIAS sqlgen)
58+
5559
if (MSVC)
56-
target_compile_options(sqlgen PRIVATE $<$<CONFIG:Debug>:-Wall>)
60+
target_compile_options(sqlgen PRIVATE
61+
$<$<CONFIG:Debug>:
62+
-Wall
63+
>
64+
$<$<CONFIG:Release>:
65+
-DNDEBUG
66+
>
67+
)
5768
else()
58-
target_compile_options(sqlgen PRIVATE $<$<CONFIG:Debug>:-Wall -Wextra>)
69+
target_compile_options(sqlgen PRIVATE
70+
$<$<CONFIG:Debug>:
71+
-Wall -Wextra -Wpedantic -Wshadow -Wconversion
72+
>
73+
$<$<CONFIG:Release>:
74+
-DNDEBUG
75+
>
76+
)
77+
endif()
78+
79+
if (SQLGEN_BUILD_SHARED)
80+
target_compile_definitions(sqlgen PUBLIC SQLGEN_BUILD_SHARED)
5981
endif()
6082

6183
set(SQLGEN_SOURCES
@@ -114,9 +136,11 @@ set_target_properties(sqlgen PROPERTIES LINKER_LANGUAGE CXX)
114136
target_sources(sqlgen PRIVATE ${SQLGEN_SOURCES})
115137

116138
if (SQLGEN_BUILD_TESTS)
139+
add_library(sqlgen_tests_crt INTERFACE)
140+
target_link_libraries(sqlgen_tests_crt INTERFACE sqlgen GTest::gtest_main)
141+
117142
enable_testing()
118143
find_package(GTest CONFIG REQUIRED)
119-
set(SQLGEN_GTEST_LIB sqlgen GTest::gtest_main)
120144
add_subdirectory(tests)
121145
endif ()
122146

include/sqlgen.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "sqlgen/Flatten.hpp"
66
#include "sqlgen/ForeignKey.hpp"
77
#include "sqlgen/Iterator.hpp"
8-
#include "sqlgen/IteratorBase.hpp"
98
#include "sqlgen/JSON.hpp"
109
#include "sqlgen/Literal.hpp"
1110
#include "sqlgen/Pattern.hpp"
@@ -44,6 +43,7 @@
4443
#include "sqlgen/read.hpp"
4544
#include "sqlgen/rollback.hpp"
4645
#include "sqlgen/select_from.hpp"
46+
#include "sqlgen/sqlgen_api.hpp"
4747
#include "sqlgen/to.hpp"
4848
#include "sqlgen/update.hpp"
4949
#include "sqlgen/where.hpp"

include/sqlgen/Iterator.hpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <memory>
66
#include <ranges>
77

8-
#include "IteratorBase.hpp"
98
#include "Ref.hpp"
109
#include "Result.hpp"
1110
#include "internal/batch_size.hpp"
@@ -15,23 +14,19 @@
1514
namespace sqlgen {
1615

1716
/// An input_iterator that returns the underlying type.
18-
template <class T>
17+
template <class T, class UnderlyingIteratorT>
1918
class Iterator {
2019
public:
2120
using difference_type = std::ptrdiff_t;
2221
using value_type = Result<T>;
2322

2423
struct End {
25-
bool operator==(const Iterator<T>& _it) const noexcept {
26-
return _it == *this;
27-
}
24+
bool operator==(const Iterator& _it) const noexcept { return _it == *this; }
2825

29-
bool operator!=(const Iterator<T>& _it) const noexcept {
30-
return _it != *this;
31-
}
26+
bool operator!=(const Iterator& _it) const noexcept { return _it != *this; }
3227
};
3328

34-
Iterator(const Ref<IteratorBase>& _it)
29+
Iterator(const Ref<UnderlyingIteratorT>& _it)
3530
: current_batch_(get_next_batch(_it)), it_(_it), ix_(0) {}
3631

3732
~Iterator() = default;
@@ -46,7 +41,7 @@ class Iterator {
4641

4742
bool operator!=(const End& _end) const noexcept { return !(*this == _end); }
4843

49-
Iterator<T>& operator++() noexcept {
44+
Iterator& operator++() noexcept {
5045
++ix_;
5146
if (ix_ >= current_batch_->size() && !it_->end()) {
5247
current_batch_ = get_next_batch(it_);
@@ -59,7 +54,7 @@ class Iterator {
5954

6055
private:
6156
static Ref<std::vector<Result<T>>> get_next_batch(
62-
const Ref<IteratorBase>& _it) noexcept {
57+
const Ref<UnderlyingIteratorT>& _it) noexcept {
6358
using namespace std::ranges::views;
6459
return _it->next(SQLGEN_BATCH_SIZE)
6560
.transform([](auto str_vec) {
@@ -74,7 +69,7 @@ class Iterator {
7469
Ref<std::vector<Result<T>>> current_batch_;
7570

7671
/// The underlying database iterator.
77-
Ref<IteratorBase> it_;
72+
Ref<UnderlyingIteratorT> it_;
7873

7974
/// The current index in the current batch.
8075
size_t ix_;

include/sqlgen/IteratorBase.hpp

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

0 commit comments

Comments
 (0)