Improve meson.build files

FossilOrigin-Name: da6b5c90d4fae43b05b79b391bc53e391ce491867776a1ac3fb84c6de1a57359
This commit is contained in:
Jonathan Schleifer 2024-08-06 21:56:55 +00:00
parent e1c01cfd01
commit cbd238001b
5 changed files with 44 additions and 36 deletions

View file

@ -1,2 +1 @@
build build
ObjSQLite3.oc

View file

@ -8,23 +8,32 @@ project('ObjSQLite3', 'objc',
objfw_dep = dependency('objfw') objfw_dep = dependency('objfw')
sqlite3_dep = dependency('sqlite3') sqlite3_dep = dependency('sqlite3')
incdir = include_directories(['src', 'src/exceptions']) incdir = include_directories('src', 'src/exceptions')
subdir('src')
subdir('tests')
# Meson unfortunately does not allow access to the flags of sqlite3_dep. # Meson unfortunately does not allow access to the flags of sqlite3_dep.
pkgconfig = find_program('pkg-config') pkgconfig = find_program('pkg-config')
sqlite3_cflags = run_command([pkgconfig, '--cflags', 'sqlite3'], check: true) sqlite3_cflags = run_command(
sqlite3_libs = run_command([pkgconfig, '--libs', 'sqlite3'], check: true) [pkgconfig, '--cflags', 'sqlite3'],
check: true).stdout().strip()
sqlite3_libs = run_command(
[pkgconfig, '--libs', 'sqlite3'],
check: true).stdout().strip()
objfwconfig = find_program('objfw-config')
packages_dir = run_command(
[objfwconfig, '--packages-dir'],
check: true).stdout().strip()
configure_file( configure_file(
input: 'ObjSQLite3.oc.in', input: 'ObjSQLite3.oc.in',
output: 'ObjSQLite3.oc', output: 'ObjSQLite3.oc',
configuration: { configuration: {
'libdir': get_option('prefix') / get_option('libdir'), 'libdir': get_option('prefix') / get_option('libdir'),
'SQLITE3_CPPFLAGS': sqlite3_cflags.stdout().strip(), 'SQLITE3_CPPFLAGS': sqlite3_cflags,
'SQLITE3_LIBS': sqlite3_libs.stdout().strip(), 'SQLITE3_LIBS': sqlite3_libs,
}, },
install: true, install: true,
install_dir: get_option('libdir') / 'objfw-config') install_dir: packages_dir)
subdir('src')
subdir('tests')

View file

@ -0,0 +1,9 @@
exceptions_sources = files(
'SL3BindObjectFailedException.m',
'SL3ClearBindingsFailedException.m',
'SL3Exception.m',
'SL3ExecuteStatementFailedException.m',
'SL3OpenFailedException.m',
'SL3PrepareStatementFailedException.m',
'SL3ResetStatementFailedException.m',
)

View file

@ -1,31 +1,22 @@
objsqlite3 = library('objsqlite3', fs = import('fs')
[
subdir('exceptions')
sources = files(
'SL3Connection.m', 'SL3Connection.m',
'SL3PreparedStatement.m', 'SL3PreparedStatement.m',
'exceptions/SL3BindObjectFailedException.m', )
'exceptions/SL3ClearBindingsFailedException.m',
'exceptions/SL3Exception.m', objsqlite3 = library('objsqlite3',
'exceptions/SL3ExecuteStatementFailedException.m', sources + exceptions_sources,
'exceptions/SL3OpenFailedException.m',
'exceptions/SL3PrepareStatementFailedException.m',
'exceptions/SL3ResetStatementFailedException.m',
],
include_directories: incdir, include_directories: incdir,
objc_args: ['-DSL3_PUBLIC_IVARS'], objc_args: ['-DSL3_PUBLIC_IVARS'],
dependencies: [objfw_dep, sqlite3_dep], dependencies: [objfw_dep, sqlite3_dep],
install: true) install: true)
install_headers( headers = ['ObjSQLite3.h']
[ foreach source: sources + exceptions_sources
'ObjSQLite3.h', headers += fs.replace_suffix(source.full_path(), '.h')
'SL3Connection.h', endforeach
'SL3PreparedStatement.h',
'exceptions/SL3BindObjectFailedException.h', install_headers(headers, subdir: 'ObjSQLite3')
'exceptions/SL3ClearBindingsFailedException.h',
'exceptions/SL3Exception.h',
'exceptions/SL3ExecuteStatementFailedException.h',
'exceptions/SL3OpenFailedException.h',
'exceptions/SL3PrepareStatementFailedException.h',
'exceptions/SL3ResetStatementFailedException.h',
],
subdir: 'ObjSQLite3')

View file

@ -1,5 +1,5 @@
testexe = executable('tests', 'Tests.m', testexe = executable('tests', 'Tests.m',
dependencies: [objfw_dep], dependencies: objfw_dep,
link_with: objsqlite3, link_with: objsqlite3,
include_directories: incdir) include_directories: incdir)
test('ObjSQLite3 tests', testexe) test('ObjSQLite3 tests', testexe)