From 56be77ac5094089322cef30ed5816ce25e41d9e6 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Sat, 17 Aug 2024 20:58:04 -0400 Subject: [PATCH] build: switch to Meson --- extensions/dataframes/meson.build | 45 ++++++++++++++++++++++++ hipo4/meson.build | 57 +++++++++++++++++++++++++++++++ meson.build | 46 +++++++++++++++++++++++++ meson.options | 1 + subprojects/lz4.wrap | 12 +++++++ 5 files changed, 161 insertions(+) create mode 100644 extensions/dataframes/meson.build create mode 100644 hipo4/meson.build create mode 100644 meson.build create mode 100644 meson.options create mode 100644 subprojects/lz4.wrap diff --git a/extensions/dataframes/meson.build b/extensions/dataframes/meson.build new file mode 100644 index 0000000..782ee3e --- /dev/null +++ b/extensions/dataframes/meson.build @@ -0,0 +1,45 @@ +dataframe_headers = files('RHipoDS.hxx') +dataframe_sources = files('RHipoDS.cxx') +dataframe_linkdef = files('RHipoDS_LinkDef.h') + +# ROOT stuff +ROOT_config = find_program('root-config') +ROOT_cling = find_program('rootcling') +ROOT_libdir = run_command(ROOT_config, '--libdir', check: true).stdout().strip() +ROOT_incdir = run_command(ROOT_config, '--incdir', check: true).stdout().strip() +ROOT_inc = include_directories(ROOT_incdir) + +# generate ROOT dictionary +dataframe_dict = 'HipoDataFrame_Dict.cxx' +dataframe_lib_file = meson.current_build_dir() / 'libHipoDataFrame.so' # FIXME: file extension is platform dependent +dataframe_dict_tgt = custom_target( + 'HipoDataFrameDict', + input: dataframe_headers + hipo_headers + hipo_sources + [ dataframe_linkdef ], + output: [ dataframe_dict ], + command: [ + ROOT_cling, + '-v2', + '-f', meson.current_build_dir() / dataframe_dict, + '-s', dataframe_lib_file, + '-rml', fs.name(dataframe_lib_file), + '-rmf', fs.parent(dataframe_lib_file) / fs.stem(dataframe_lib_file) + '.rootmap', + lz4_preproc_def, + '-I' + ROOT_incdir, + '-I' + hipo_incdir, + ] + dataframe_sources + dataframe_linkdef, +) + +# library +dataframe_lib = library( + 'HipoDataFrame', + dataframe_sources + [ dataframe_dict_tgt[0] ], + include_directories: [ hipo_inc, ROOT_inc ], + link_with: [ hipo_lib ], + link_args: [ '-L' + ROOT_libdir, '-lCore', '-lROOTDataFrame', '-lROOTVecOps'], + build_rpath: ROOT_libdir, + cpp_args: [ '-Wno-sign-compare' ], # FIXME: fix these warnings + install: true +) +install_headers(dataframe_headers, subdir: meson.project_name()) +project_libs += dataframe_lib + diff --git a/hipo4/meson.build b/hipo4/meson.build new file mode 100644 index 0000000..2c6307e --- /dev/null +++ b/hipo4/meson.build @@ -0,0 +1,57 @@ +hipo_sources = files( + 'bank.cpp', + 'datastream.cpp', + 'dictionary.cpp', + 'event.cpp', + 'fusion.cpp', + 'node.cpp', + 'parser.cpp', + 'reader.cpp', + 'recordbuilder.cpp', + 'record.cpp', + 'tuple.cpp', + 'utils.cpp', + 'wrapper.cpp', + 'writer.cpp', +) +hipo_headers = files( + 'bank.h', + 'datastream.h', + 'dictionary.h', + 'event.h', + 'fizika.h', + 'fusion.h', + 'hipoexceptions.h', + 'json.h', + 'jsonutil.h', + 'node.h', + 'parser.h', + 'reaction.h', + 'reader.h', + 'recordbuilder.h', + 'record.h', + 'tuple.h', + 'twig.h', + 'utils.h', + 'writer.h', +) + +hipo_lib = library( + meson.project_name(), + hipo_sources, + dependencies: [lz4_dep], + cpp_args: [ # FIXME: fix the warnings; they are suppressed by these args + '-Wno-sign-compare', + '-Wno-unused-variable', + '-Wno-unused-but-set-variable', + '-Wno-misleading-indentation', + '-Wno-format', + ], + install: true +) + +install_headers(hipo_headers, subdir: meson.project_name()) +project_libs += hipo_lib + +hipo_incdir = meson.current_source_dir() +hipo_inc = include_directories('.') diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..eb38087 --- /dev/null +++ b/meson.build @@ -0,0 +1,46 @@ +project( + 'hipo4', + 'cpp', + meson_version: '>=1.2', + default_options: { + 'cpp_std': 'c++17', + 'buildtype': 'release', + 'libdir': 'lib', + 'default_library': 'both', + 'pkgconfig.relocatable': 'true', + }, + version: '4.2.0', +) + +# modules +fs = import('fs') +pkg = import('pkgconfig') + +# dependencies +lz4_dep = dependency('liblz4', method: 'pkg-config', version: '>=1.9', fallback: ['lz4', 'liblz4']) +ROOT_dep = dependency('ROOT', method: 'cmake', version: '>=6.28', required: false) + +# preprocessor +lz4_preproc_def = '-D__LZ4__' +add_project_arguments(lz4_preproc_def, language: ['cpp']) + +# main project builds +project_libs = [] +subdir('hipo4') + +# extensions +if(get_option('dataframes')) + if(ROOT_dep.found()) + subdir('extensions' / 'dataframes') + else + warning('ROOT dependency not found; dataframes extension will NOT be built') + endif +endif + +# packaging +pkg.generate( + name: meson.project_name(), + description: 'High Performance Output Data format for experimental Physics', + libraries: project_libs, + requires: [ lz4_dep ], +) diff --git a/meson.options b/meson.options new file mode 100644 index 0000000..276ff08 --- /dev/null +++ b/meson.options @@ -0,0 +1 @@ +option('dataframes', type: 'boolean', value: true, description: 'install HIPO dataframes extension') diff --git a/subprojects/lz4.wrap b/subprojects/lz4.wrap new file mode 100644 index 0000000..7708a4a --- /dev/null +++ b/subprojects/lz4.wrap @@ -0,0 +1,12 @@ +[wrap-file] +directory = lz4-1.9.4 +source_url = https://github.com/lz4/lz4/archive/v1.9.4.tar.gz +source_filename = lz4-1.9.4.tgz +source_hash = 0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b +patch_filename = lz4_1.9.4-2_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/lz4_1.9.4-2/get_patch +patch_hash = 4f33456cce986167d23faf5d28a128e773746c10789950475d2155a7914630fb +wrapdb_version = 1.9.4-2 + +[provide] +liblz4 = liblz4_dep