Skip to content

Commit

Permalink
Meson simplifications, remove python dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Nov 28, 2024
1 parent b0d14ad commit a31d4a1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 54 deletions.
3 changes: 3 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
V=$(grep ^SDBVER config.mk | cut -d = -f2)
meson rewrite kwargs set project / version "$V"
4 changes: 2 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SDBVER=2.0.1

PREFIX?=/usr
BINDIR=${PREFIX}/bin
LIBDIR=${PREFIX}/lib
Expand All @@ -6,8 +8,6 @@ INCDIR=${PREFIX}/include
VAPIDIR=${DATADIR}/vala/vapi/
MANDIR=${DATADIR}/man/man1

SDBVER=2.0.1

BUILD_MEMCACHE=0

INSTALL?=install
Expand Down
79 changes: 27 additions & 52 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
project('sdb', 'c', meson_version: '>=0.60.0')
project('sdb', 'c', meson_version : '>=0.60.0', version : '2.0.1')

py3_exe = import('python').find_installation('python3')
pkgconfig_mod = import('pkgconfig')

version_cmd = '''from sys import argv
with open(argv[1]) as fd:
for line in fd:
if line.startswith('SDBVER='):
version_tuple = line.split('=')[1]
print(version_tuple)
break
'''
sdb_version = '0.0.1'
config_mk = files('config.mk')[0]
r = run_command(py3_exe, '-c', version_cmd, config_mk)
if r.returncode() == 0
sdb_version = r.stdout().strip()
else
warning('Cannot determine SDB version')
endif
message('SDB version = ' + sdb_version)

sdb_version = meson.project_version()

is_windows = host_machine.system() == 'windows' ? true: false

Expand Down Expand Up @@ -63,8 +45,7 @@ libsdb_sources = [
'src/text.c'
]

# . = b/version.h
sdb_inc = include_directories(['.', 'include'])
sdb_inc = include_directories(['include'])
rpath_lib = ''
rpath_exe = ''
if get_option('local') and get_option('default_library') == 'shared'
Expand Down Expand Up @@ -93,14 +74,22 @@ else
link_with = libsdb.get_static_lib()
endif

#link_with = libsdb.get_shared_lib()

sdb_dep = declare_dependency(
link_with: [link_with],
include_directories: sdb_inc
)

if not meson.is_subproject()
sdb_exe = executable('sdb', join_paths('src','entry.c'),
include_directories: sdb_inc,
link_with: [link_with],
install: not meson.is_subproject(),
install_rpath: rpath_exe,
implicit_include_directories: false
)

if meson.is_subproject()
install_man([join_paths('src','sdb.1')])
else
include_files = [
'include/sdb/buffer.h',
'include/sdb/cdb.h',
Expand All @@ -125,15 +114,20 @@ if not meson.is_subproject()
'include/sdb/msvc_stdatomic.h',
]
install_headers(include_files, subdir: 'sdb')
endif

sdb_exe = executable('sdb', join_paths('src','entry.c'),
include_directories: sdb_inc,
link_with: [link_with],
install: not meson.is_subproject(),
install_rpath: rpath_exe,
implicit_include_directories: false
)
make_exe = find_program('make', required: false)
if make_exe.found()
test('run tests', make_exe,
args: 'test',
env: ['BASEDIR=' + meson.current_build_dir()],
workdir: join_paths(meson.current_build_dir(), '..'),
depends: [sdb_exe, libsdb]
)
endif

subdir(join_paths('test','bench'))
subdir(join_paths('test','unit'))
endif

if meson.is_cross_build()
sdb_native_exe = executable('sdb_native', join_paths('src','entry.c'),
Expand All @@ -146,10 +140,6 @@ else
sdb_native_exe = sdb_exe
endif

if not meson.is_subproject()
install_man([join_paths('src','sdb.1')])
endif

pkgconfig_mod.generate(
name: 'sdb',
filebase: 'sdb',
Expand All @@ -159,18 +149,3 @@ pkgconfig_mod.generate(
version: sdb_version,
url: 'https://github.com/radareorg/sdb'
)

if not meson.is_subproject()
make_exe = find_program('make', required: false)
if make_exe.found()
test('run tests', make_exe,
args: 'test',
env: ['BASEDIR=' + meson.current_build_dir()],
workdir: join_paths(meson.current_build_dir(), '..'),
depends: [sdb_exe, libsdb]
)
endif

subdir(join_paths('test','bench'))
subdir(join_paths('test','unit'))
endif
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
option('enable_tests', type: 'boolean', value: true, description: 'Build unit tests in test/unit')
option('local', type: 'boolean', value: false, description: 'Adds support for local/side-by-side installation (sets rpath if needed)')
# RESERVED option('default_library', type: 'string', value: 'shared', description: 'Specify shared or static')

0 comments on commit a31d4a1

Please sign in to comment.