diff mbox series

[ndctl,03/37] build: Add tags

Message ID 164298552547.3021641.2951502977152843738.stgit@dwillia2-desk3.amr.corp.intel.com
State New, archived
Headers show
Series cxl: Full topology enumeration | expand

Commit Message

Dan Williams Jan. 24, 2022, 12:52 a.m. UTC
Copy the systemd approach to generating tags with a file listing from git.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 meson.build |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/meson.build b/meson.build
index b22fb2e57f6b..68f3d0ceff1c 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