Merged with master

This commit is contained in:
Pierre Proske 2023-03-06 19:01:20 +11:00
commit b736d0a759
6 changed files with 386 additions and 296 deletions

View File

@ -44,7 +44,7 @@ jobs:
} }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: submodule - name: submodule
run: git submodule update --init --recursive run: git submodule update --init --recursive
- name: extra_path - name: extra_path

80
.github/workflows/meson.yaml vendored Normal file
View File

@ -0,0 +1,80 @@
name: meson
on: [push, pull_request]
jobs:
build:
name: (Meson) ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {
name: "Windows Latest MSVC",
os: windows-latest,
cc: "cl", cxx: "cl",
extra_path: "",
requires_msvc: true,
}
- {
name: "Windows Latest MinGW",
os: windows-latest,
cc: "gcc", cxx: "g++",
extra_path: "C:\\ProgramData\\chocolatey\\lib\\mingw\\tools\\install\\mingw64\\bin",
}
- {
name: "Windows Latest Clang",
os: windows-latest,
cc: "clang", cxx: "clang++", c_ld: "lld-link", cxx_ld: "lld-link",
extra_path: "",
}
- {
name: "Ubuntu Latest GCC",
os: ubuntu-latest,
cc: "gcc", cxx: "g++",
extra_path: ""
}
- {
name: "Ubuntu Latest Clang",
os: ubuntu-latest,
cc: "clang", cxx: "clang++", c_ld: "lld", cxx_ld: "lld",
extra_path: ""
}
- {
name: "macOS Latest Clang",
os: macos-latest,
cc: "clang", cxx: "clang++",
extra_path: ""
}
steps:
- uses: actions/checkout@v3
# use msvc-dev-cmd to setup the environment for MSVC if needed
- name: setup MSVC
if: matrix.config.requires_msvc
uses: ilammy/msvc-dev-cmd@v1
- name: extra_path
shell: bash
run: echo "${{matrix.config.extra_path}}" >> $GITHUB_PATH
- name: install prerequisites
run: |
# asuming that python and pip are already installed
pip3 install meson ninja
- name: setup meson project
env: # set proper compilers and linkers for meson
CC: ${{matrix.config.cc}}
CXX: ${{matrix.config.cxx}}
C_LD: ${{matrix.config.c_ld}}
CXX_LD: ${{matrix.config.cxx_ld}}
run: |
# setup the build directory with tests and examples enabled
meson setup builddir -DSQLITECPP_BUILD_TESTS=true -DSQLITECPP_BUILD_EXAMPLES=true --force-fallback-for=sqlite3
- name: build meson project
run: |
# build the project
meson compile -C builddir
- name: test
run: |
# run the tests
meson test -C builddir

View File

@ -27,7 +27,7 @@ jobs:
} }
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: configure - name: configure
shell: cmake -P {0} shell: cmake -P {0}
run: | run: |

View File

@ -6,9 +6,9 @@ example2_srcs = files(
example2_args = [] example2_args = []
sqlitecpp_demo2_exe = executable('SQLITECPP_sample_demo1', sqlitecpp_demo2_exe = executable('SQLITECPP_sample_demo2',
sqlitecpp_sample2_srcs, sqlitecpp_sample2_srcs,
dependencies: sqlitecpp_dep, dependencies: sqlitecpp_dep,
# inherit the default options from sqlitecpp # inherit the default options from sqlitecpp
override_options: sqlitecpp_opts, override_options: sqlitecpp_opts,
cpp_args: example2_args) cpp_args: example2_args)

View File

@ -1,291 +1,301 @@
project( project(
'SQLiteCpp', 'cpp', 'SQLiteCpp', 'cpp',
# SQLiteCpp requires C++11 support # SQLiteCpp requires C++11 support
default_options: ['cpp_std=c++11', 'warning_level=3'], default_options: ['cpp_std=c++11', 'warning_level=3'],
license: 'MIT', license: 'MIT',
version: '3.2.1', version: '3.2.1',
) )
cxx = meson.get_compiler('cpp') cxx = meson.get_compiler('cpp')
## at best we might try to test if this code compiles ## at best we might try to test if this code compiles
## testing for compilers or platforms is not reliable enough ## testing for compilers or platforms is not reliable enough
## example: native clang on windows or mingw in windows ## example: native clang on windows or mingw in windows
unix_like_code = ''' unix_like_code = '''
#if defined(unix) || defined(__unix__) || defined(__unix) #if defined(unix) || defined(__unix__) || defined(__unix)
// do nothing // do nothing
#else #else
# error "Non Unix-like OS" # error "Non Unix-like OS"
#endif #endif
''' '''
unix_like = cxx.compiles(unix_like_code, name : 'unix like environment') unix_like = cxx.compiles(unix_like_code, name : 'unix like environment')
mingw_64_env_code = ''' mingw_64_env_code = '''
#if defined(__MINGW64__) #if defined(__MINGW64__)
// do nothing // do nothing
#else #else
# error "Non MinGW-W64 environment" # error "Non MinGW-W64 environment"
#endif #endif
''' '''
mingw_64_env = cxx.compiles(mingw_64_env_code, name : 'MinGW-W64 environment') mingw_64_env = cxx.compiles(mingw_64_env_code, name : 'MinGW-W64 environment')
thread_dep = dependency('threads') thread_dep = dependency('threads')
# sqlite3 support # sqlite3 support
sqlite3_dep = dependency( sqlite3_dep = dependency(
'sqlite3', 'sqlite3',
fallback: ['sqlite3', 'sqlite3_dep'] fallback: ['sqlite3', 'sqlite3_dep']
) )
sqlitecpp_incl = [ sqlitecpp_incl = [
include_directories('include') include_directories('include')
] ]
sqlitecpp_srcs = files( sqlitecpp_srcs = files(
'src/Backup.cpp', 'src/Backup.cpp',
'src/Column.cpp', 'src/Column.cpp',
'src/Database.cpp', 'src/Database.cpp',
'src/Exception.cpp', 'src/Exception.cpp',
'src/Savepoint.cpp', 'src/Savepoint.cpp',
'src/Statement.cpp', 'src/Statement.cpp',
'src/Transaction.cpp', 'src/Transaction.cpp',
) )
sqlitecpp_args = cxx.get_supported_arguments( sqlitecpp_args = cxx.get_supported_arguments(
# included in meson by default # included in meson by default
# -Wall # -Wall
# included when warning_level=3 # included when warning_level=3
#'-Wextra', #'-Wextra',
#'-Wpedantic', #'-Wpedantic',
'-Wswitch-enum', '-Wswitch-enum',
'-Wshadow', '-Wshadow',
'-Wno-long-long', '-Wno-long-long',
) )
sqlitecpp_link = [] sqlitecpp_link = []
sqlitecpp_deps = [ sqlitecpp_deps = [
sqlite3_dep, sqlite3_dep,
thread_dep, thread_dep,
] ]
## used to override the default sqlitecpp options like cpp standard ## used to override the default sqlitecpp options like cpp standard
sqlitecpp_opts = [] sqlitecpp_opts = []
## used to set required macros when using sqlitecpp
sqlitecpp_dep_args = [] ## used to set required macros when using sqlitecpp
sqlitecpp_dep_args = []
## tests
## tests
sqlitecpp_test_srcs = files(
'tests/Column_test.cpp', sqlitecpp_test_srcs = files(
'tests/Database_test.cpp', 'tests/Column_test.cpp',
'tests/Savepoint_test.cpp', 'tests/Database_test.cpp',
'tests/Statement_test.cpp', 'tests/Savepoint_test.cpp',
'tests/Backup_test.cpp', 'tests/Statement_test.cpp',
'tests/Transaction_test.cpp', 'tests/Backup_test.cpp',
'tests/VariadicBind_test.cpp', 'tests/Transaction_test.cpp',
'tests/Exception_test.cpp', 'tests/VariadicBind_test.cpp',
'tests/ExecuteMany_test.cpp', 'tests/Exception_test.cpp',
) 'tests/ExecuteMany_test.cpp',
sqlitecpp_test_args = [] )
sqlitecpp_test_args = []
## samples
## samples
sqlitecpp_sample1_srcs = files(
'examples/example1/main.cpp', sqlitecpp_sample1_srcs = files(
) 'examples/example1/main.cpp',
sqlitecpp_sample2_srcs = files( )
'examples/example2/src/main.cpp', sqlitecpp_sample2_srcs = files(
) 'examples/example2/src/main.cpp',
)
## using MSVC headers requires c++14, if not will show an error on xstddef as:
## 'auto' return without trailing return type; deduced return types are a C++14 extension ## using MSVC headers requires c++14, if not will show an error on xstddef as:
if host_machine.system() == 'windows' ## 'auto' return without trailing return type; deduced return types are a C++14 extension
message('[WINDOWS] using c++14 standard') if host_machine.system() == 'windows'
sqlitecpp_opts += [ message('[WINDOWS] using c++14 standard')
'cpp_std=c++14', sqlitecpp_opts += [
] 'cpp_std=c++14',
endif ]
# Options relative to SQLite and SQLiteC++ functions endif
# Options relative to SQLite and SQLiteC++ functions
if get_option('SQLITE_ENABLE_COLUMN_METADATA')
sqlitecpp_args += [ if get_option('SQLITE_ENABLE_COLUMN_METADATA')
'-DSQLITE_ENABLE_COLUMN_METADATA', sqlitecpp_args += [
] '-DSQLITE_ENABLE_COLUMN_METADATA',
endif ]
endif
if get_option('SQLITE_ENABLE_ASSERT_HANDLER')
sqlitecpp_args += [ if get_option('SQLITE_ENABLE_ASSERT_HANDLER')
'-DSQLITE_ENABLE_ASSERT_HANDLER', sqlitecpp_args += [
] '-DSQLITE_ENABLE_ASSERT_HANDLER',
endif ]
endif
if get_option('SQLITE_HAS_CODEC')
sqlitecpp_args += [ if get_option('SQLITE_HAS_CODEC')
'-DSQLITE_HAS_CODEC', sqlitecpp_args += [
] '-DSQLITE_HAS_CODEC',
endif ]
endif
if get_option('SQLITE_USE_LEGACY_STRUCT')
sqlitecpp_args += [ if get_option('SQLITE_USE_LEGACY_STRUCT')
'-DSQLITE_USE_LEGACY_STRUCT', sqlitecpp_args += [
] '-DSQLITE_USE_LEGACY_STRUCT',
endif ]
endif
## C++17 disable the support for std::filesystem (by default off)
if get_option('SQLITECPP_DISABLE_STD_FILESYSTEM') ## C++17 disable the support for std::filesystem (by default off)
sqlitecpp_cxx_flags += ['-DSQLITECPP_DISABLE_STD_FILESYSTEM'] if get_option('SQLITECPP_DISABLE_STD_FILESYSTEM')
endif sqlitecpp_cxx_flags += ['-DSQLITECPP_DISABLE_STD_FILESYSTEM']
endif
## get the user option for the SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL
disable_sqlitecpp_expanded_sql = get_option('SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL') ## get the user option for the SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL
disable_sqlitecpp_expanded_sql = get_option('SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL')
## Disable the use of sqlite3_expanded_sql (from sqlite3 3.14.0)
if disable_sqlitecpp_expanded_sql ## Disable the use of sqlite3_expanded_sql (from sqlite3 3.14.0)
sqlitecpp_args += ['-DSQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL'] if disable_sqlitecpp_expanded_sql
endif sqlitecpp_args += ['-DSQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL']
endif
## stack protection hardening
if get_option('SQLITECPP_USE_STACK_PROTECTION') ## stack protection hardening
## if is on MinGW-W64 give a warning that is not supported if get_option('SQLITECPP_USE_STACK_PROTECTION')
if mingw_64_env ## if is on MinGW-W64 give a warning that is not supported
message('warning: SQLiteCpp does not support stack protection on MinGW-W64') if mingw_64_env
message('warning: this could lead to a crash on the application') message('warning: SQLiteCpp does not support stack protection on MinGW-W64')
message('warning: you can disable this warning by setting SQLITECPP_USE_STACK_PROTECTOR to false') message('warning: this could lead to a crash on the application')
else message('warning: you can disable this warning by setting SQLITECPP_USE_STACK_PROTECTOR to false')
sqlitecpp_args += ['-fstack-protector'] else
endif sqlitecpp_args += ['-fstack-protector']
endif endif
endif
## enable ommit load extension
if get_option('SQLITE_OMIT_LOAD_EXTENSION') ## enable ommit load extension
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION'] if get_option('SQLITE_OMIT_LOAD_EXTENSION')
## check if running on OSX sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
elif host_machine.system() == 'darwin' and sqlite3_dep.found() ## check if running on OSX
sqlite3_load_extension_support = cxx.links( elif host_machine.system() == 'darwin' and sqlite3_dep.found()
''' ## check if sqlite3 is the one bundled with OSX
#include <sqlite3.h> if sqlite3_dep.type_name() != 'internal'
int main() { message('warning: Detected non-internal SQLite3 in OSX, check if it supports load extension')
sqlite3_enable_load_extension(0, 0); sqlite3_load_extension_support = cxx.links(
return 0; '''
} #include <sqlite3.h>
''', int main() {
name: 'sqlite3_load_extension', sqlite3_enable_load_extension(0, 0);
dependencies: [sqlite3_dep]) return 0;
if not sqlite3_load_extension_support }
message('warning: Detected bundled SQLite3 in OSX, but it does not support load extension') ''',
message('warning: SQLiteCpp will be built without load extension support') name: 'sqlite3_load_extension',
message('warning: You can disable this warning by setting SQLITE_OMIT_LOAD_EXTENSION to false') dependencies: [sqlite3_dep])
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION'] if not sqlite3_load_extension_support
endif message('warning: Detected bundled SQLite3 in OSX, but it does not support load extension')
endif message('warning: SQLiteCpp will be built without load extension support')
message('warning: You can disable this warning by setting SQLITE_OMIT_LOAD_EXTENSION to false')
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
endif
if unix_like endif
sqlitecpp_args += [ endif
# -fPIC is included by default in meson
# 'fPIC',
]
# add dl dependency if unix_like
libdl_dep = cxx.find_library('dl') sqlitecpp_args += [
sqlitecpp_deps += [ # -fPIC is included by default in meson
libdl_dep, # 'fPIC',
] ]
endif # add dl dependency
libdl_dep = cxx.find_library('dl')
if get_option('b_coverage') sqlitecpp_deps += [
# Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered" libdl_dep,
sqlitecpp_args += [ ]
'-fkeep-inline-functions', endif
'-fkeep-static-functions',
] if get_option('b_coverage')
endif # Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered"
sqlitecpp_args += [
sqlitecpp_static_args = sqlitecpp_args '-fkeep-inline-functions',
sqlitecpp_static_dep_args = sqlitecpp_dep_args '-fkeep-static-functions',
# if windows and shared library ]
if host_machine.system() == 'windows' and get_option('default_library') == 'shared' endif
# compile with SQLITECPP_COMPILE_DLL and SQLITECPP_DLL_EXPORT=1
sqlitecpp_args += [ sqlitecpp_static_args = sqlitecpp_args
'-DSQLITECPP_COMPILE_DLL', sqlitecpp_static_dep_args = sqlitecpp_dep_args
'-DSQLITECPP_DLL_EXPORT',
] # if windows and shared library
sqlitecpp_dep_args += [ if host_machine.system() == 'windows' and get_option('default_library') == 'shared'
# we just need to define SQLITECPP_COMPILE_DLL # compile with SQLITECPP_COMPILE_DLL and SQLITECPP_DLL_EXPORT=1
'-DSQLITECPP_COMPILE_DLL', sqlitecpp_args += [
] '-DSQLITECPP_COMPILE_DLL',
endif '-DSQLITECPP_DLL_EXPORT',
]
libsqlitecpp = library( sqlitecpp_dep_args += [
'sqlitecpp', # we just need to define SQLITECPP_COMPILE_DLL
sqlitecpp_srcs, '-DSQLITECPP_COMPILE_DLL',
include_directories: sqlitecpp_incl, ]
cpp_args: sqlitecpp_args, endif
dependencies: sqlitecpp_deps,
# override the default options
override_options: sqlitecpp_opts, libsqlitecpp = library(
install: true, 'sqlitecpp',
# API version for SQLiteCpp shared library. sqlitecpp_srcs,
version: '0',) include_directories: sqlitecpp_incl,
cpp_args: sqlitecpp_args,
if get_option('SQLITECPP_BUILD_TESTS') dependencies: sqlitecpp_deps,
# for the unit tests we need to link against a static version of SQLiteCpp # override the default options
if get_option('default_library') == 'static' override_options: sqlitecpp_opts,
# we do not need to recomplile the library install: true,
libsqlitecpp_static = libsqlitecpp # API version for SQLiteCpp shared library.
else version: '0',)
libsqlitecpp_static = static_library(
'sqlitecpp_static',
sqlitecpp_srcs,
include_directories: sqlitecpp_incl, if get_option('SQLITECPP_BUILD_TESTS')
cpp_args: sqlitecpp_static_args, # for the unit tests we need to link against a static version of SQLiteCpp
dependencies: sqlitecpp_deps, if get_option('default_library') == 'static'
# override the default options # we do not need to recomplile the library
override_options: sqlitecpp_opts,) libsqlitecpp_static = libsqlitecpp
endif else
endif libsqlitecpp_static = static_library(
'sqlitecpp_static',
install_subdir( sqlitecpp_srcs,
'include/SQLiteCpp', include_directories: sqlitecpp_incl,
install_dir: get_option('includedir')) cpp_args: sqlitecpp_static_args,
dependencies: sqlitecpp_deps,
sqlitecpp_dep = declare_dependency( # override the default options
include_directories: sqlitecpp_incl, override_options: sqlitecpp_opts,)
link_with: libsqlitecpp, endif
compile_args: sqlitecpp_dep_args, endif
)
if get_option('SQLITECPP_BUILD_TESTS') install_subdir(
## make the dependency static so the unit tests can link against it 'include/SQLiteCpp',
sqlitecpp_static_dep = declare_dependency( install_dir: get_option('includedir'))
include_directories: sqlitecpp_incl,
link_with: libsqlitecpp_static, sqlitecpp_dep = declare_dependency(
compile_args: sqlitecpp_static_dep_args, include_directories: sqlitecpp_incl,
) link_with: libsqlitecpp,
endif compile_args: sqlitecpp_dep_args,
)
if get_option('SQLITECPP_BUILD_TESTS') if get_option('SQLITECPP_BUILD_TESTS')
gtest_dep = dependency( ## make the dependency static so the unit tests can link against it
'gtest', ## (mainly for windows as the symbols are not exported by default)
main : true, sqlitecpp_static_dep = declare_dependency(
fallback: ['gtest', 'gtest_main_dep']) include_directories: sqlitecpp_incl,
sqlitecpp_test_dependencies = [ link_with: libsqlitecpp_static,
gtest_dep, compile_args: sqlitecpp_static_dep_args,
sqlitecpp_dep, )
sqlite3_dep, endif
]
if get_option('SQLITECPP_BUILD_TESTS')
testexe = executable('testexe', sqlitecpp_test_srcs, gtest_dep = dependency(
dependencies: sqlitecpp_test_dependencies, 'gtest',
cpp_args: sqlitecpp_test_args, main : true,
# override the default options fallback: ['gtest', 'gtest_main_dep'])
override_options: sqlitecpp_opts,) sqlitecpp_test_dependencies = [
gtest_dep,
test_args = [] sqlitecpp_dep,
sqlite3_dep,
test('sqlitecpp unit tests', testexe, args: test_args) ]
endif
if get_option('SQLITECPP_BUILD_EXAMPLES') testexe = executable('testexe', sqlitecpp_test_srcs,
subdir('examples') dependencies: sqlitecpp_test_dependencies,
endif cpp_args: sqlitecpp_test_args,
# override the default options
pkgconfig = import('pkgconfig') override_options: sqlitecpp_opts,)
pkgconfig.generate(
libsqlitecpp, test_args = []
description: 'a smart and easy to use C++ SQLite3 wrapper.',
version: meson.project_version(), test('sqlitecpp unit tests', testexe, args: test_args)
) endif
if get_option('SQLITECPP_BUILD_EXAMPLES')
subdir('examples')
endif
pkgconfig = import('pkgconfig')
pkgconfig.generate(
libsqlitecpp,
description: 'a smart and easy to use C++ SQLite3 wrapper.',
version: meson.project_version(),
)

View File

@ -1,7 +1,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3"> <package format="3">
<name>SQLiteCpp</name> <name>SQLiteCpp</name>
<version>3.1.1</version> <version>3.2.1</version>
<description>A smart and easy to use C++ SQLite3 wrapper.</description> <description>A smart and easy to use C++ SQLite3 wrapper.</description>
<maintainer email="sebastien.rombauts@gmail.com">Sébastien Rombauts</maintainer> <maintainer email="sebastien.rombauts@gmail.com">Sébastien Rombauts</maintainer>