From 10d93fe4e74d25de5d9d9ef50c6d7bbbbb0d67ba Mon Sep 17 00:00:00 2001 From: Emily Boudreaux Date: Thu, 11 Jun 2026 11:01:05 -0400 Subject: [PATCH] build(meson): more robust python build --- .gitignore | 2 ++ build-config/quill/meson.build | 2 +- meson.build | 32 ++++++++++++++++++++++++-------- meson_options.txt | 3 +-- src/logging/meson.build | 6 +----- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 141f25e..d785063 100644 --- a/.gitignore +++ b/.gitignore @@ -86,3 +86,5 @@ output/ .idea/ scratch/ + +subprojects/.wraplock \ No newline at end of file diff --git a/build-config/quill/meson.build b/build-config/quill/meson.build index 8cb2440..378a8fc 100644 --- a/build-config/quill/meson.build +++ b/build-config/quill/meson.build @@ -21,5 +21,5 @@ if get_option('default_library') != 'static' - install_subdir(quill_headers, install_dir: vendor_logging_header_install_dir) + install_subdir(quill_headers, install_dir: vendor_header_dir) endif diff --git a/meson.build b/meson.build index f713e42..afe28ac 100644 --- a/meson.build +++ b/meson.build @@ -18,18 +18,34 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # *********************************************************************** # -project('liblogging', 'cpp', version: 'v1.1.5', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') +project('liblogging', 'cpp', version: 'v1.1.6', default_options: ['cpp_std=c++23'], meson_version: '>=1.5.0') # Add default visibility for all C++ targets add_project_arguments('-fvisibility=default', language: 'cpp') -logging_header_install_dir = get_option('header_install_dir') != '' \ - ? get_option('header_install_dir') / 'fourdst' / 'logging' \ - : get_option('includedir') / 'fourdst' / 'logging' +if get_option('build_python') + local_py_install = import('python').find_installation('python3', pure: false) + fourdst_pkg = local_py_install.get_install_dir() / 'fourdst' + logging_libdir = fourdst_pkg / 'lib' + logging_header_install_dir = fourdst_pkg / 'include' / 'fourdst' / 'logging' -vendor_logging_header_install_dir = get_option('header_install_dir') != '' \ - ? get_option('header_install_dir') / 'fourdst' / 'vendor' \ - : get_option('includedir') / 'fourdst' / 'vendor' + vendor_lib_dir = fourdst_pkg / 'lib' / 'vendor' + vendor_header_dir = fourdst_pkg / 'include' / 'fourdst' / 'vendor' + + message('Installing liblogging in python mode. Install locations are...') +else + logging_libdir = get_option('libdir') + logging_header_install_dir = get_option('includedir') / 'fourdst' / 'logging' + + vendor_lib_dir = get_option('libdir') / 'fourdst' / 'vendor' + vendor_header_dir = get_option('includedir') / 'fourdst' / 'vendor' + + message('Installing liblogging in non python (normal) mode. Install locations are...') +endif +message(' Package Libraries: ' + logging_libdir) +message(' Package Headers: ' + logging_header_install_dir) +message(' Vendor Libraries: ' + vendor_lib_dir) +message(' Vendor Headers: ' + vendor_header_dir) subdir('build-config') subdir('src') @@ -44,7 +60,7 @@ endif if get_option('pkg_config') message('Generating pkg-config file for liblogging...') - vendor_inc_flags = '-I' + vendor_logging_header_install_dir + vendor_inc_flags = '-I' + get_option('prefix') / vendor_header_dir pkg = import('pkgconfig') pkg.generate( name: 'liblogging', diff --git a/meson_options.txt b/meson_options.txt index 4897f41..247ed76 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,5 +1,4 @@ option('pkg_config', type: 'boolean', value: true, description: 'generate pkg-config file for liblogging (fourdst_liblogging.pc)') option('build_tests', type: 'boolean', value: true, description: 'generate unit tests (uses gtest)') option('build_examples', type: 'boolean', value: true, description: 'generate example programs') -option('lib_install_dir', type: 'string', value: '', description: 'Override install dir for the shared library (used by the fourdst umbrella to place libs inside the Python package in wheel builds). Empty = default libdir.') -option('header_install_dir', type: 'string', value: '', description: 'Override the header install root (used by the fourdst umbrella to place headers inside the Python package in wheel builds). Empty = default includedir.') +option('build_python', type: 'boolean', value: false, description: 'Build in python mode. Note that this does not generate a wheel; rather, this is the appropriate option to turn on when packaging this component inside of a wheel.') diff --git a/src/logging/meson.build b/src/logging/meson.build index 8bd7c36..7334545 100644 --- a/src/logging/meson.build +++ b/src/logging/meson.build @@ -26,16 +26,12 @@ dependencies = [ quill_dep, ] -logging_lib_install_dir = get_option('lib_install_dir') != '' \ - ? get_option('lib_install_dir') \ - : get_option('libdir') - liblogging = library('logging', logging_sources, include_directories: include_directories('include'), cpp_args: ['-fvisibility=default'], install : true, - install_dir: logging_lib_install_dir, + install_dir: logging_libdir, dependencies: dependencies )