Skip to content

Commit

Permalink
Modified the meson build declaration to (#19)
Browse files Browse the repository at this point in the history
- support to optionally create a static library
- allow the binary to use the non system library (libjose.so) when buildng a debug version

Co-authored-by: Claude Robitaille <[email protected]>
  • Loading branch information
hdholm and clauderobi authored Feb 16, 2024
1 parent 523af86 commit 8739c9a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 17 deletions.
7 changes: 6 additions & 1 deletion cmd/meson.build
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
rpath = ''
if buildtype == 'debug' or buildtype == 'debugoptimized'
rpath = libjose_build_dir
endif
executable(meson.project_name(),
'jose.c', 'jose.h',
'b64/b64.h',
Expand All @@ -23,5 +27,6 @@ executable(meson.project_name(),
'fmt.c',

dependencies: libjose_dep,
install: true
install: true,
install_rpath: rpath
)
55 changes: 40 additions & 15 deletions lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ if not cc.links(code, args: flags, name: '-Wl,--version-script=...')
flags = [ '-export-symbols-regex=^jose_.*' ]
endif

libjose_lib = shared_library('jose',
libjose_build_dir = meson.current_build_dir()
libjose_src = [
'misc.c', 'misc.h',
'cfg.c',
'io.c',
Expand Down Expand Up @@ -37,17 +38,41 @@ libjose_lib = shared_library('jose',
'openssl/pbes2.c',
'openssl/rsa.c',
'openssl/rsaes.c',
'openssl/rsassa.c',

include_directories: incdir,
dependencies: [zlib, jansson, libcrypto, threads],
version: '0.0.0',
link_args: flags,
install: true
)

libjose_dep = declare_dependency(
include_directories: incdir,
dependencies: jansson,
link_with: libjose_lib
)
'openssl/rsassa.c'
]

if build_dynamic
libjose_lib = shared_library('jose',
libjose_src,

include_directories: incdir,
dependencies: [zlib, jansson, libcrypto, threads],
version: '0.0.0',
link_args: flags,
install: true
)


libjose_dep = declare_dependency(
include_directories: incdir,
dependencies: jansson,
link_with: libjose_lib
)
endif

# Define the static library using same sources and dependencies as libjose_lib
if build_static
libjose_static = static_library('jose_static',
libjose_src,

include_directories: incdir,
dependencies: [zlib, jansson, libcrypto, threads],
)

# Declare the dependency for the static library
libjose_static_dep = declare_dependency(
include_directories: incdir,
dependencies: jansson,
link_with: libjose_static
)
endif
15 changes: 14 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ project('jose', 'c', license: 'APL2',
meson_version: '>=0.47.0',
)

buildtype = get_option('buildtype')
build_static = get_option('build_static')
build_dynamic = get_option('build_dynamic')

licensedir = join_paths(get_option('prefix'), 'share', 'licenses', meson.project_name())
if host_machine.system() == 'freebsd'
licensedir += '-'+meson.project_version()
Expand Down Expand Up @@ -53,14 +57,23 @@ subdir('tests')

install_data(licenses, install_dir: licensedir)


libraries = []
if build_dynamic
libraries += libjose_lib
endif
if build_static
libraries += libjose_static
endif

pkg = import('pkgconfig')
pkg.generate(
description: 'Library for managing JOSE objects',
version: meson.project_version(),
filebase: meson.project_name(),
name: 'José Library',
libraries_private: [ zlib, libcrypto ],
libraries: libjose_lib,
libraries: libraries,
requires: jansson,
)

Expand Down
3 changes: 3 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
option('docs', type: 'feature', description: 'Whether to build asciidoc manpages')
option('build_static', type: 'boolean', description: 'Build static library', value: false)
option('build_dynamic', type: 'boolean', description: 'Build dynamic library', value: true)

0 comments on commit 8739c9a

Please sign in to comment.