Skip to content

eBPF-based security platform

build: add tags and cscope targets

Jiri Olsabf0f0b6215ce
diff --git a/.gitignore b/.gitignore
index 434f900d..dba1f448 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,10 @@
+# Source indexes (make tags, make cscope)
+/tags
+/cscope.files
+/cscope.out
+/cscope.in.out
+/cscope.po.out
+
# Build artefacts
/build/
/shirudo
diff --git a/Documentation/contribute/code/developer-guide.rst b/Documentation/contribute/code/developer-guide.rst
index 092276a8..8dc3bc2b 100644
--- a/Documentation/contribute/code/developer-guide.rst
+++ b/Documentation/contribute/code/developer-guide.rst
@@ -328,10 +328,14 @@ Other make targets
- Renders the documentation and serves it on
``http://127.0.0.1:8000``. See
:doc:`/contribute/documentation/writing-docs`.
+ * - ``make tags``, ``make cscope``
+ - Index the C sources, untracked ones and the generated
+ ``vendor/linux/vmlinux.h`` included, for an editor: ``tags`` with
+ ctags, ``cscope.files`` and ``cscope.out`` with cscope.
* - ``make clean``, ``make distclean``
- Remove the build products, and with ``distclean`` also
``config.mk``, the target dependencies and the vendored libbpf
- build.
+ build and the source indexes.
* - ``make help``, ``make -C testing help``
- List the targets.
diff --git a/Makefile b/Makefile
index b5381c1a..ad315e77 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ export prefix exec_prefix bindir libexecdir sharedir libdir mandir completionsdi
systemdunitdir udevrulesdir dracutmodulesdir SHIRUDO_TARGET_PKG_CONFIG_PATH \
SHIRUDO_TARGET_STATIC_LIBDIR
-.PHONY: all help target target-deps target-deps-clean shirudo-target target-config shirudo-build docs bpf-deps install install-target install-operator clean distclean config tests proofs proofs-cbmc proofs-lean4 sparse
+.PHONY: all help target target-deps target-deps-clean shirudo-target target-config shirudo-build docs bpf-deps install install-target install-operator clean distclean config tests proofs proofs-cbmc proofs-lean4 sparse tags cscope
all: config
+$(Q)$(MAKE) -f Makefile.shirudo PROFILE=operator CONFIG_MK=config.mk all
@@ -90,6 +90,7 @@ help:
' Build: make, make target, make target-deps, make bpf-deps, make install' \
' Local stack: make stack-up, make oci, make telemetry, make vm, make stack-down' \
' Checks: make sparse' \
+ ' Source index: make tags (ctags), make cscope' \
' Install roles: make install-target, make install-operator' \
' Package: make -C packaging help' \
' Tests: make tests (all of them), make -C testing help' \
@@ -109,6 +110,23 @@ docs:
tests:
+$(Q)$(MAKE) -C testing
+# The C sources of the tree, untracked ones included, and the generated
+# vmlinux.h that the BPF code reads its kernel types from.
+TAGS_FILES = { git ls-files --cached --others --exclude-standard -- '*.[ch]' 2>/dev/null || \
+ find . -path ./build -prune -o -name '*.[ch]' -print; } | sort -u; \
+ [ ! -f vendor/linux/vmlinux.h ] || echo vendor/linux/vmlinux.h
+
+tags:
+ @printf ' GEN tags\n'
+ $(Q)rm -f tags
+ $(Q)($(TAGS_FILES)) | ctags -L - -f tags
+
+cscope:
+ @printf ' GEN cscope\n'
+ $(Q)rm -f cscope.files cscope.out cscope.in.out cscope.po.out
+ $(Q)($(TAGS_FILES)) > cscope.files
+ $(Q)cscope -b -q -k -i cscope.files
+
proofs: proofs-cbmc proofs-lean4
proofs-cbmc:
@@ -146,6 +164,7 @@ clean:
distclean: clean
$(Q)rm -f config.mk
+ $(Q)rm -f tags cscope.files cscope.out cscope.in.out cscope.po.out
+$(Q)$(MAKE) -f Makefile.target-deps TARGET_DEPS_DIR="$(TARGET_DEPS_DIR)" clean
$(Q)$(MAKE) -f Makefile.shirudo distclean