[PATCH v2] Add more checks for headers and libraries in the meson build
Tulio Magno Quites Machado Filho
tuliom@ascii.art.br
Mon Jun 23 21:55:14 GMT 2025
From: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
Changes since v1:
- Dropped changes from annocheck.
--- 8< ---
gcc-plugin depends on plugin.h.
clang-plugin depends on libraries clang-cpp and LLVM.
llvm-plugin depends on library LLVM.
---
clang-plugin/meson.build | 5 +++++
gcc-plugin/meson.build | 19 ++++++++++++++++++-
llvm-plugin/meson.build | 4 ++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/clang-plugin/meson.build b/clang-plugin/meson.build
index 0c415db..5240a76 100644
--- a/clang-plugin/meson.build
+++ b/clang-plugin/meson.build
@@ -6,6 +6,11 @@ clang = find_program('clang++')
search_dirs = run_command(clang , '--print-search-dirs', check: true).stdout().strip()
install_dir = search_dirs.split('\n')[1].split(':')[1].replace('=', '').strip()
+# Use the default c++ compiler just to find if the needed libraries are
+# installed.
+cxx.find_library('LLVM')
+cxx.find_library('clang-cpp')
+
clang_plugin = custom_target(
'annobin-for-clang.so',
input: 'annobin.cpp',
diff --git a/gcc-plugin/meson.build b/gcc-plugin/meson.build
index e0ee998..b234369 100644
--- a/gcc-plugin/meson.build
+++ b/gcc-plugin/meson.build
@@ -55,6 +55,23 @@ endif
# using GCC, even if the environment wants another compiler.
gxx = find_program('g++')
plugin_dev_path = run_command(gxx, '-print-file-name=plugin', check: true).stdout().strip()
+
+# Use the default c++ compiler just to find if the needed dependencies are
+# installed.
+plugin_inc_path = join_paths(plugin_dev_path, 'include')
+fs = import('fs')
+if not fs.is_dir(plugin_inc_path)
+ error(
+ 'Could not find ',
+ plugin_inc_path,
+ '\nAre the development files for GCC plugins installed?',
+ )
+endif
+inc = include_directories(plugin_inc_path)
+if not cxx.has_header('plugin.h', include_directories: inc)
+ error('Could not find GCC\'s plugin.h')
+endif
+
gcc_plugin = custom_target(
'annobin.so',
input: ['annobin.cc', target_plugin],
@@ -68,7 +85,7 @@ gcc_plugin = custom_target(
'-DHAVE_CONFIG_H',
'-I' + join_paths(meson.current_source_dir(), '..'),
'-I' + join_paths(meson.current_build_dir(), '..'),
- '-I' + join_paths(plugin_dev_path, 'include'),
+ '-I' + join_paths(plugin_inc_path),
'-o', '@OUTPUT@',
]
)
diff --git a/llvm-plugin/meson.build b/llvm-plugin/meson.build
index 17930b3..317f046 100644
--- a/llvm-plugin/meson.build
+++ b/llvm-plugin/meson.build
@@ -6,6 +6,10 @@ clang = find_program('clang++')
search_dirs = run_command(clang , '--print-search-dirs', check: true).stdout().strip()
install_dir = search_dirs.split('\n')[1].split(':')[1].replace('=', '').strip()
+# Use the default c++ compiler just to find if the needed libraries are
+# installed.
+cxx.find_library('LLVM')
+
llvm_plugin = custom_target(
'annobin-for-llvm.so',
input: 'annobin.cpp',
--
2.49.0
More information about the Annobin
mailing list