[PATCH 0/2] Makefile: Add cscope support

57 views
Skip to first unread message

Tan En De

unread,
Dec 18, 2023, 10:34:36 AM12/18/23
to xvisor...@googlegroups.com, Tan En De
This series is to add cscope support, so that running `make cscope` will
generate/update cscope files used for source code browsing.
The cscope files will be removed along during `make distclean`.

Tan En De (2):
Makefile: Improve dependency files inclusion logic
Makefile: Add cscope support

Makefile | 26 ++++++++++++++++++++++----
1 file changed, 22 insertions(+), 4 deletions(-)

--
2.34.1

Tan En De

unread,
Dec 18, 2023, 10:34:48 AM12/18/23
to xvisor...@googlegroups.com, Tan En De
Introduce a new variable `NO_DEP_TARGETS` to improve the readability of
the logic deciding when to `-include $(deps-y)` in the Makefile.

Signed-off-by: Tan En De <ende...@starfivetech.com>
---
Makefile | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 415c0bc6..1984408c 100644
--- a/Makefile
+++ b/Makefile
@@ -443,10 +443,11 @@ $(build_dir)/%.xo: $(build_dir)/%.o

# Include built-in and module objects dependency files
# Dependency files should only be included after default Makefile rule
-# They should not be included for any "xxxconfig" or "xxxclean" rule
-all-deps-1 = $(if $(findstring config,$(MAKECMDGOALS)),,$(deps-y))
-all-deps-2 = $(if $(findstring clean,$(MAKECMDGOALS)),,$(all-deps-1))
--include $(all-deps-2)
+# They should not be included for any "xxxconfig", "xxxclean", or "cscope" rule
+NO_DEP_TARGETS := %config %clean cscope
+ifeq ($(filter $(NO_DEP_TARGETS),$(MAKECMDGOALS)),)
+ -include $(deps-y)
+endif

# Rule for "make clean"
.PHONY: clean
--
2.34.1

Tan En De

unread,
Dec 18, 2023, 10:34:52 AM12/18/23
to xvisor...@googlegroups.com, Tan En De
Add cscope support so that running `make cscope` will generate/update
cscope files used for source code browsing. The cscope files will be
removed along during `make distclean`.

Signed-off-by: Tan En De <ende...@starfivetech.com>
---
Makefile | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index 1984408c..e7a3e5c9 100644
--- a/Makefile
+++ b/Makefile
@@ -481,6 +481,8 @@ ifeq ($(install_dir),$(CURDIR)/install)
$(V)rm -rf $(install_dir)
endif
$(V)$(MAKE) -C $(src_dir)/tools/openconf clean
+ $(if $(V), @echo " (rm) $(CURDIR)/cscope*")
+ $(V)rm -f $(CURDIR)/cscope*

# Include config file rules
-include $(CONFIG_FILE).cmd
@@ -512,3 +514,18 @@ savedefconfig:
$(V)$(MAKE) -C tools/openconf defconfig
./tools/openconf/conf -D $(src_dir)/arch/$(ARCH)/configs/$@ $(OPENCONF_INPUT)
./tools/openconf/conf -s $(OPENCONF_INPUT)
+
+.PHONY: cscope
+SUPPORTED_ARCHS := arm x86 riscv
+IGNORED_ARCHS := $(if $(CONFIG_ARCH),$(filter-out $(CONFIG_ARCH),$(SUPPORTED_ARCHS)),)
+cscope:
+ $(V)find $(CURDIR) \
+ $(foreach IGNORED_ARCH,$(IGNORED_ARCHS),-not -path '$(CURDIR)/*/$(IGNORED_ARCH)/*') \
+ $(if $(findstring arm,$(IGNORED_ARCHS)),-not -path '$(CURDIR)/*/arm32/*' -not -path '$(CURDIR)/*/arm64/*',) \
+ -name "*.[chS]" -print > $(CURDIR)/cscope.files
+ifneq ("$(wildcard $(OPENCONF_TMPDIR)/$(OPENCONF_AUTOHEADER))","")
+ $(V)echo "$(OPENCONF_TMPDIR)/$(OPENCONF_AUTOHEADER)" >> $(CURDIR)/cscope.files
+else
+ $(warning cscope will be partially complete, please consider trying again after "make menuconfig".)
+endif
+ $(V)cscope -bkq -i $(CURDIR)/cscope.files -f $(CURDIR)/cscope.out
--
2.34.1

Anup Patel

unread,
Jan 5, 2024, 6:35:13 AM1/5/24
to xvisor...@googlegroups.com, Tan En De
On Mon, Dec 18, 2023 at 9:04 PM Tan En De <ende...@gmail.com> wrote:
>
> Introduce a new variable `NO_DEP_TARGETS` to improve the readability of
> the logic deciding when to `-include $(deps-y)` in the Makefile.
>
> Signed-off-by: Tan En De <ende...@starfivetech.com>

LGTM.

Reviewed-by: Anup Patel <an...@brainfault.org>

Applied this patch to the xvisor-next tree.

Thanks,
Anup

> ---
> Makefile | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 415c0bc6..1984408c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -443,10 +443,11 @@ $(build_dir)/%.xo: $(build_dir)/%.o
>
> # Include built-in and module objects dependency files
> # Dependency files should only be included after default Makefile rule
> -# They should not be included for any "xxxconfig" or "xxxclean" rule
> -all-deps-1 = $(if $(findstring config,$(MAKECMDGOALS)),,$(deps-y))
> -all-deps-2 = $(if $(findstring clean,$(MAKECMDGOALS)),,$(all-deps-1))
> --include $(all-deps-2)
> +# They should not be included for any "xxxconfig", "xxxclean", or "cscope" rule
> +NO_DEP_TARGETS := %config %clean cscope
> +ifeq ($(filter $(NO_DEP_TARGETS),$(MAKECMDGOALS)),)
> + -include $(deps-y)
> +endif
>
> # Rule for "make clean"
> .PHONY: clean
> --
> 2.34.1
>
> --
> You received this message because you are subscribed to the Google Groups "Xvisor Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to xvisor-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/xvisor-devel/20231218153359.176-2-ende.tan%40starfivetech.com.
Reply all
Reply to author
Forward
0 new messages