Skip to contentSkip to conversation

libtracefs: Add trace_sql.bash for tracefs_sql() bash completions

PATCH Superseded Steven Rostedt 1 participant 1 message Apr 10, 2025

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtracefs: Add trace_sql.bash for tracefs_sql() bash completions

From: "Steven Rostedt (Google)" <[email protected]>

trace-cmd and the internal sqlhist programs can take SQL input to be passed into the tracefs_sql() function. This can be a bit complex, so create a bash completion script that uses trace-cmd to allow for tab completions on a bash command line to fill in the next commands.

This should simplify creating bash completions as well as make some shortcuts known.

---
 Makefile             |   5 +-
 meson.build          |   1 +
 scripts/utils.mk     |   8 +
 src/meson.build      |   4 +
 src/tracefs_sql.bash | 351 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 368 insertions(+), 1 deletion(-)
 create mode 100644 src/tracefs_sql.bash
Makefile +4 -1
index 6e80226..49a5477 100644
@@ -300,7 +300,10 @@ install_libs: libs install_pkgconfig
 	$(Q)$(call do_install,$(src)/include/tracefs.h,$(includedir_SQ),644)
 	$(Q)$(call install_ld_config)
 
-install: install_libs
+install_bash_completion: force
+	$(Q)$(call do_install_data,$(src)/src/tracefs_sql.bash,$(BASH_COMPLETE_DIR))
+
+install: install_libs install_bash_completion
 
 install_pkgconfig: $(PKG_CONFIG_FILE)
 	$(Q)$(call , $(PKG_CONFIG_FILE)) \
meson.build +1 -0
index 2258ca0..04cedb1 100644
@@ -21,6 +21,7 @@ threads_dep = dependency('threads', required: true)
 cunit_dep = dependency('cunit', required : false)
 
 prefixdir = get_option('prefix')
+datadir = join_paths(prefixdir, get_option('datadir'))
 bindir = join_paths(prefixdir, get_option('bindir'))
 mandir = join_paths(prefixdir, get_option('mandir'))
 htmldir = join_paths(prefixdir, get_option('htmldir'))
scripts/utils.mk +8 -0
index 4d0f8bc..379d47f 100644
@@ -187,6 +187,14 @@ define do_install
 	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
+define do_install_data
+	$(print_install)				\
+	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
+	fi;						\
+	$(INSTALL) -m 644 $1 '$(DESTDIR_SQ)$2'
+endef
+
 define do_install_pkgconfig_file
 	if [ -n "${pkgconfig_dir}" ]; then 					\
 		$(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); 	\
src/meson.build +4 -0
index 31fd9ed..202df9d 100644
@@ -63,3 +63,7 @@ pkg.generate(
 libtracefs_dep = declare_dependency(
     include_directories: ['.'],
     link_with: libtracefs)
+
+install_data(
+    'tracefs_sql.bash',
+    install_dir: datadir + '/bash-completion/completions')
src/tracefs_sql.bash new file +351 -0

351 lines not on this page · raw message

Signature · 1 line
2.47.2