Makefile: Fix cscope issues on MacOS and soft links
PATCH 1/1 Makefile: Fix cscope issues on MacOS and soft links
This patch fixes actually two issues with 'make cscope'.
Firstly, it fixes the command for MacOS "find" command as MacOS will append the full path of "$(SRC_PATH)/" before each found entry, then after the final "./" replacement trick it'll look like (e.g., "qapi/qmp-dispatch.c"):
/qapi/qmp-dispatch.c
Which will point to the root directory instead.
Fix it by simply remove the "/" in "$(SRC_PATH)/" of "find-src-path", then it'll work for at least both Linux and MacOS.
The other OS-independent issue is to start proactively ignoring soft links when generating tags, otherwise by default on master branch we'll see this error when "make cscope":
cscope: cannot find file subprojects/libvhost-user/include/atomic.h
This patch should fix the two issues altogether.
--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
@@ -229,7 +229,8 @@ distclean: clean rm -f linux-headers/asm rm -Rf .sdk -find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \) +find-src-path = find "$(SRC_PATH)" -path "$(SRC_PATH)/meson" -prune -o \ + -type l -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \) .PHONY: ctags ctags:
Signature · 1 line
2.31.1
Quoted 31 lines · Peter Xu
This patch fixes actually two issues with 'make cscope'.
Firstly, it fixes the command for MacOS "find" command as MacOS will append the full path of "$(SRC_PATH)/" before each found entry, then after the final "./" replacement trick it'll look like (e.g., "
qapi/qmp-dispatch.c"):/qapi/qmp-dispatch.c
Which will point to the root directory instead.
Fix it by simply remove the "/" in "$(SRC_PATH)/" of "find-src-path", then it'll work for at least both Linux and MacOS.
The other OS-independent issue is to start proactively ignoring soft links when generating tags, otherwise by default on master branch we'll see this error when "make cscope":
cscope: cannot find file
subprojects/libvhost-user/include/atomic.hThis patch should fix the two issues altogether.
Signed-off-by Peter Xu <[email protected]>--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +0
-0
Makefile distclean: clean · line 233
Quoted 6 lines
Makefile +2
-1@@ -229,7 +229,8 @@ distclean: clean rm -f linux-headers/asm rm -Rf .sdk -find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \) +find-src-path = find "$(SRC_PATH)" -path "$(SRC_PATH)/meson" -prune -o \ + -type l -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \)
The second half of the change causes my "make gtags" to descend down build directories and complain about unindexed files.
Quoted 2 lines
Makefile +0
-0.PHONY: ctags ctags:
Signature · 1 line
Alex Bennée
Hi, Alex,
Quoted 37 lines · Alex Bennée
Quoted 34 lines · Peter Xu
This patch fixes actually two issues with 'make cscope'.
Firstly, it fixes the command for MacOS "find" command as MacOS will append the full path of "$(SRC_PATH)/" before each found entry, then after the final "./" replacement trick it'll look like (e.g., "
qapi/qmp-dispatch.c"):/qapi/qmp-dispatch.c
Which will point to the root directory instead.
Fix it by simply remove the "/" in "$(SRC_PATH)/" of "find-src-path", then it'll work for at least both Linux and MacOS.
The other OS-independent issue is to start proactively ignoring soft links when generating tags, otherwise by default on master branch we'll see this error when "make cscope":
cscope: cannot find file
subprojects/libvhost-user/include/atomic.hThis patch should fix the two issues altogether.
Signed-off-by Peter Xu <[email protected]>--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +0
-0@@ -229,7 +229,8 @@ distclean: clean rm -f linux-headers/asm rm -Rf .sdk
Quoted 6 lines
Makefile distclean: clean · line 233
Quoted 3 lines
Makefile +2
-1-find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \) +find-src-path = find "$(SRC_PATH)" -path "$(SRC_PATH)/meson" -prune -o \ + -type l -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \)The second half of the change causes my "make gtags" to descend down build directories and complain about unindexed files.
Would this help?
---8<---
Makefile +1 -1
@@ -251,7 +251,7 @@ gtags: "GTAGS", "Remove old $@ files") $(call quiet-command, \ (cd $(SRC_PATH) && \ - $(find-src-path) | gtags -f -), \ + $(find-src-path) -print | gtags -f -), \ "GTAGS", "Re-index $(SRC_PATH)") .PHONY: TAGS
---8<---
For some reason, "make gtags" didn't use "-print" as the last expression. My understanding is when expression is not specified, then it's default will be "-print". However for some reason it acts like that when "-print" is not there all the "-prone" expressions are not really behaving. Above does work for me, but frankly I don't really know enough on how "find" works here.
If you agree, I can repost a v2 with that squashed.
Thanks,
Signature · 1 line
Peter Xu
Quoted 65 lines · Peter Xu
Hi, Alex,
Quoted 37 lines · Alex Bennée
Quoted 34 lines · Peter Xu
This patch fixes actually two issues with 'make cscope'.
Firstly, it fixes the command for MacOS "find" command as MacOS will append the full path of "$(SRC_PATH)/" before each found entry, then after the final "./" replacement trick it'll look like (e.g., "
qapi/qmp-dispatch.c"):/qapi/qmp-dispatch.c
Which will point to the root directory instead.
Fix it by simply remove the "/" in "$(SRC_PATH)/" of "find-src-path", then it'll work for at least both Linux and MacOS.
The other OS-independent issue is to start proactively ignoring soft links when generating tags, otherwise by default on master branch we'll see this error when "make cscope":
cscope: cannot find file
subprojects/libvhost-user/include/atomic.hThis patch should fix the two issues altogether.
Signed-off-by Peter Xu <[email protected]>--- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Makefile +0
-0@@ -229,7 +229,8 @@ distclean: clean rm -f linux-headers/asm rm -Rf .sdkQuoted 6 lines
Makefile distclean: clean · line 233
Quoted 3 lines
Makefile +2
-1-find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \) +find-src-path = find "$(SRC_PATH)" -path "$(SRC_PATH)/meson" -prune -o \ + -type l -prune -o \( -name "*.[chsS]" -o -name "*.[ch].inc" \)The second half of the change causes my "make gtags" to descend down build directories and complain about unindexed files.
Would this help?
---8<---
Makefile +1
-2@@ -251,7 +251,7 @@ gtags: "GTAGS", "Remove old $@ files") $(call quiet-command, \ (cd $(SRC_PATH) && \ - $(find-src-path) | gtags -f -), \ + $(find-src-path) -print | gtags -f -), \ "GTAGS", "Re-index $(SRC_PATH)") .PHONY: TAGS ---8<---
Quoted 7 lines
For some reason, "make gtags" didn't use "-print" as the last expression. My understanding is when expression is not specified, then it's default will be "-print". However for some reason it acts like that when "-print" is not there all the "-prone" expressions are not really behaving. Above does work for me, but frankly I don't really know enough on how "find" works here.
If you agree, I can repost a v2 with that squashed.
That seems to fix it. I think it's down to the interaction of the expressions but I agree find can be a bit inscrutable at times.
Quoted 2 lines
Thanks,
Signature · 1 line
Alex Bennée