anitazha / rpms / ndctl

Forked from rpms/ndctl a year ago
Clone
Blob Blame History Raw
From 6dafb0baf8fda14f25e0a764fe8f89d8a4727b0c Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Sun, 23 Jan 2022 16:52:05 -0800
Subject: [PATCH 089/217] build: Add tags

Copy the systemd approach to generating tags with a file listing from git.

Link: https://lore.kernel.org/r/164298552547.3021641.2951502977152843738.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 meson.build | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/meson.build b/meson.build
index b22fb2e..68f3d0c 100644
--- a/meson.build
+++ b/meson.build
@@ -82,6 +82,7 @@ project_source_root = meson.current_source_dir()
 # Cleanup the leftover config.h files to avoid conflicts with the meson
 # generated config.h
 git = find_program('git', required : false)
+env = find_program('env')
 if git.found()
   run_command('clean_config.sh',
     env : 'GIT_DIR=@0@/.git'.format(project_source_root),
@@ -111,6 +112,24 @@ else
   )
 endif
 
+if git.found()
+  all_files = run_command(
+    env, '-u', 'GIT_WORK_TREE',
+    git, '--git-dir=@0@/.git'.format(project_source_root),
+         'ls-files', ':/*.[ch]',
+    check : false)
+  if all_files.returncode() == 0
+    all_files = files(all_files.stdout().split())
+    custom_target(
+            'tags',
+            output : 'tags',
+            command : [env, 'etags', '-o', '@0@/TAGS'.format(project_source_root)] + all_files)
+    run_target(
+            'ctags',
+            command : [env, 'ctags', '-o', '@0@/tags'.format(project_source_root)] + all_files)
+  endif
+endif
+
 versiondep = declare_dependency(
   compile_args: ['-include', 'version.h'],
   sources: version_h
-- 
2.27.0