Skip to content

Commit 4c164b2

Browse files
committed
add more debug code
1 parent 099c462 commit 4c164b2

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

README.org

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* cpputils-cmake.el (v0.4.19)
1+
* cpputils-cmake.el (v0.4.20)
22
cpputils-cmake gives you *perfect* syntax check (Flymake) and IntelliSense/code-completion if you use [[http://www.cmake.org][CMake]].
33

44
It does all the dirty setup *automatically* for following plugins and commands,

cpputils-cmake-pkg.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
(define-package "cpputils-cmake" "0.4.19"
1+
(define-package "cpputils-cmake" "0.4.20"
22
"Easy real time C++ syntax check and intellisense if you use CMake")

cpputils-cmake.el

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
;; Author: Chen Bin <chenbin.sh@gmail.com>
55
;; URL: http://github.com/redguardtoo/cpputils-cmake
66
;; Keywords: CMake IntelliSense Flymake Flycheck
7-
;; Version: 0.4.19
7+
;; Version: 0.4.20
88

99
;; This file is not part of GNU Emacs.
1010

@@ -111,6 +111,7 @@ For example:
111111
(defun cppcm-parent-dir (d) (file-name-directory (directory-file-name d)))
112112

113113
(defun cppcm--query-var-from-lines (lines REGEX)
114+
(if cppcm-debug (message "cppcm-proj-max-dir-level called"))
114115
(let (v)
115116
(catch 'brk
116117
(dolist (l lines)
@@ -128,6 +129,7 @@ For example:
128129

129130
(defun cppcm-query-var-from-last-matched-line (f re)
130131
"get the last matched line"
132+
(if cppcm-debug (message "cppcm-query-var-from-last-matched-line called"))
131133
(let (vlist lines)
132134
(setq lines (cppcm-readlines f))
133135
(dolist (l lines)
@@ -192,9 +194,11 @@ For example:
192194
(defun cppcm-get-dirs ()
193195
"search from current directory to the parent to locate build directory
194196
return (found possible-build-dir build-dir src-dir)"
197+
(if cppcm-debug "cppcm-get-dirs called")
195198
(let ((crt-proj-dir (file-name-as-directory (file-name-directory buffer-file-name)))
196199
(i 0)
197200
found
201+
rlt
198202
build-dir
199203
src-dir
200204
possible-build-dir)
@@ -219,7 +223,9 @@ return (found possible-build-dir build-dir src-dir)"
219223
(setq src-dir (cppcm-get-root-source-dir build-dir))
220224
(setq cppcm-src-dir src-dir)
221225
))
222-
(list found possible-build-dir build-dir src-dir)))
226+
(setq rlt (list found possible-build-dir build-dir src-dir))
227+
(if cppcm-debug "(cppcm-get-dirs)=%s" rlt)
228+
rlt))
223229

224230
(defun cppcm--contains-variable-name (VALUE start)
225231
(string-match "\$\{\\([^}]+\\)\}" VALUE start))
@@ -247,7 +253,7 @@ return (found possible-build-dir build-dir src-dir)"
247253
rlt))
248254

249255
(defun cppcm-guess-var (var lines)
250-
"get the value of var from lines"
256+
"get the value of VAR from LINES"
251257
(let (rlt
252258
value
253259
REGEX
@@ -258,7 +264,7 @@ return (found possible-build-dir build-dir src-dir)"
258264
(t
259265
(setq REGEX (concat "\s*set(\s*" var "\s+\\([^ ]+\\)\s*)" ))
260266
))
261-
;; if rlt contains ${, then we first de-compose the rlt into a list:
267+
;; if rlt contains "${", we first de-compose the rlt into a list:
262268
;; TODO else we just return the value
263269
(setq value (cppcm--query-var-from-lines lines REGEX))
264270
(cond
@@ -318,6 +324,7 @@ White space here is any of: space, tab, emacs newline (line feed, ASCII 10)."
318324
;; I don't consider the win32 environment because cmake support Visual Studio
319325
;; @return full path of executable and we are sure it exists
320326
(defun cppcm-guess-exe-full-path (exe-dir tgt)
327+
(if cppcm-debug (message "cppcm-proj-max-dir-level called => %s %s" exe-dir tgt))
321328
(let (p
322329
base-exe-name
323330
(type (car tgt))
@@ -365,6 +372,10 @@ White space here is any of: space, tab, emacs newline (line feed, ASCII 10)."
365372
(defun cppcm-handle-one-executable (root-src-dir build-dir src-dir tgt)
366373
"Find information for current executable. My create Makefile for flymake.
367374
Require the project be compiled successfully at least once."
375+
376+
(if cppcm-debug (message "cppcm-handle-one-executable called")
377+
root-src-dir build-dir src-dir tgt)
378+
368379
(let (flag-make
369380
base-dir
370381
mk
@@ -391,8 +402,10 @@ Require the project be compiled successfully at least once."
391402
executable
392403
".dir/flags.make"
393404
))
405+
(if cppcm-debug (message "flag-make=%s" flag-make))
394406
;; try to guess the executable file full path
395407
(setq exe-full-path (cppcm-guess-exe-full-path exe-dir tgt))
408+
(if cppcm-debug (message "exe-full-path=%s" exe-full-path))
396409

397410
(when exe-full-path
398411
(puthash (cppcm--exe-hashkey base-dir) exe-full-path cppcm-hash)
@@ -428,6 +441,7 @@ Require the project be compiled successfully at least once."
428441
))
429442

430443
(defun cppcm-scan-info-from-cmake(root-src-dir src-dir build-dir)
444+
(if cppcm-debug (message "cppcm-scan-info-from-cmake called => %s %s %s" root-src-dir src-dir build-dir))
431445
(let ((base src-dir)
432446
cm
433447
subdir
@@ -437,10 +451,12 @@ Require the project be compiled successfully at least once."
437451

438452
;; search all the subdirectory for CMakeLists.txt
439453
(setq cm (cppcm--cmakelists-dot-txt src-dir))
454+
(if cppcm-debug (message "CMakeLists.txt=%s" cm))
440455

441456
;; open CMakeLists.txt and find
442457
(when (file-exists-p cm)
443458
(setq possible-targets (cppcm-query-targets cm))
459+
(if cppcm-debug (message "possible-targets=%s" possible-targets))
444460

445461
(dolist (tgt possible-targets)
446462
;; if the target is ${VAR_NAME}, we need query CMakeLists.txt to find actual value
@@ -467,6 +483,7 @@ Require the project be compiled successfully at least once."
467483
))))
468484

469485
(defun cppcm--guess-dir-containing-cmakelists-dot-txt (&optional src-dir)
486+
(if cppcm-debug (message "cppcm--guess-dir-containing-cmakelists-dot-txt called => %s" src-dir))
470487
(let ((i 0)
471488
dir
472489
found)
@@ -485,10 +502,12 @@ Require the project be compiled successfully at least once."
485502
(setq i (+ i 1)))
486503
(unless found
487504
(setq dir nil))
505+
(if cppcm-debug (message "dir=%s" dir))
488506
dir))
489507

490508
;;;###autoload
491509
(defun cppcm-get-exe-path-current-buffer ()
510+
(if cppcm-debug (message "cppcm-get-exe-path-current-buffer called"))
492511
(interactive)
493512
(let (exe-path
494513
dir)
@@ -508,6 +527,9 @@ Require the project be compiled successfully at least once."
508527

509528
(defun cppcm-set-c-flags-current-buffer ()
510529
(interactive)
530+
531+
(if cppcm-debug (message "cppcm-set-c-flags-current-buffer called"))
532+
511533
(let ((dir (cppcm--guess-dir-containing-cmakelists-dot-txt))
512534
c-compiling-flags-list
513535
c-flags
@@ -517,6 +539,8 @@ Require the project be compiled successfully at least once."
517539
(setq c-compiling-flags-list (gethash (cppcm--flags-hashkey dir) cppcm-hash))
518540
;; please note the "-I" are always wrapped by double quotes
519541
;; for example: -I"/usr/src/include"
542+
(if cppcm-debug (message "c-compiling-flags-list=%s" c-compiling-flags-list))
543+
520544
(setq c-flags (nth 0 c-compiling-flags-list))
521545
(setq c-defines (nth 1 c-compiling-flags-list))
522546

@@ -556,7 +580,7 @@ Require the project be compiled successfully at least once."
556580
;;;###autoload
557581
(defun cppcm-version ()
558582
(interactive)
559-
(message "0.4.19"))
583+
(message "0.4.20"))
560584

561585
;;;###autoload
562586
(defun cppcm-compile (&optional prefix)
@@ -589,6 +613,7 @@ by customize `cppcm-compile-list'."
589613
(let (dirs )
590614
(when buffer-file-name
591615
(setq dirs (cppcm-get-dirs))
616+
(if cppcm-debug (message "(cppcm-get-dirs)=%s" dirs))
592617
(cond
593618
((car dirs)
594619
;; looks normal, we find buid-dir and soure-dir

pkg.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#pkg=cpputils-cmake-`date +%Y%m%d.%H%M`
3-
pkg=cpputils-cmake-0.4.19
3+
pkg=cpputils-cmake-0.4.20
44
mkdir $pkg
55
cp README.org $pkg
66
cp *.el $pkg

0 commit comments

Comments
 (0)