unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: eric@siege-engine.com, emacs-devel@gnu.org, miles@gnu.org
Subject: Re: CEDET calls cpp -E -dM -x c++ /dev/null
Date: Fri, 3 Jul 2009 13:22:44 +0200	[thread overview]
Message-ID: <e01d8a50907030422h2a6f7ebaj9f88a5fbed6d17f6@mail.gmail.com> (raw)
In-Reply-To: <83my7m2jly.fsf@gnu.org>

On Fri, Jul 3, 2009 at 11:36 AM, Eli Zaretskii<eliz@gnu.org> wrote:
>> Date: Fri, 3 Jul 2009 03:13:12 +0200
>> From: Lennart Borgman <lennart.borgman@gmail.com>
>> Cc: "Eric M. Ludlam" <eric@siege-engine.com>,
>>       Emacs-Devel devel <emacs-devel@gnu.org>
>>
>> (defun semantic-gcc-get-include-paths (lang)
>>   (let* ((gcc-cmd (cond
>>                    ((string= lang "c") "gcc")
>>                    (t (error "Unknown lang: %s" lang))))
>>          (gcc-output (semantic-gcc-query gcc-cmd "-v" "-E" "-x" lang)))
>>     ))
>>
>> However calling (semantic-gcc-get-include-paths "c") does not catch
>> the output I want to gcc-output. I get
>>
>> Result: "gcc.exe: warning: `-x c' after last input file has no effect\n
>
> This is because your forgot to append null-device to the arguments you
> pass to semantic-gcc-get-include-paths.  So the command line ends with
> a "-x c", which, as GCC tells you, is quite pointless without a file
> name after it.

Thanks.


>> Yes, but what about the two different categories of include paths. How
>>  should they be handled? Just use both?
>
> Yes, both.
>
> Btw, as Miles's output shows, there could be more than 2 directories
> in this list, and all of them should be looked in.  AFAIR, the order
> of lookup should be the order in which GCC prints them, because that's
> what GCC does.

What about this version?

(defun semantic-gcc-query (gcc-cmd &rest gcc-option)
  "Return command output.
GCC-CMD is the command to execute and GCC-OPTIONS are the options
to give to the command."
  ;; $ gcc -v
  ;;
  (let ((buff (get-buffer-create " *gcc-query*")))
    (save-excursion
      (set-buffer buff)
      (erase-buffer)
      (condition-case nil
          (apply 'call-process gcc-cmd nil (cons buff t) nil gcc-option)
	(error ;; Some bogus directory for the first time perhaps?
	 (let ((default-directory (expand-file-name "~/")))
	   (condition-case nil
               (apply 'call-process gcc-cmd nil (cons buff t) nil gcc-option)
	     (error ;; gcc doesn't exist???
	      nil)))))
      (prog1
	  (buffer-string)
	(kill-buffer buff)
        ))))

;;(semantic-gcc-get-include-paths "c")
;;(semantic-gcc-get-include-paths "c++")
(defun semantic-gcc-get-include-paths (lang)
  (let* ((gcc-cmd (cond
                   ((string= lang "c") "gcc")
                   ((string= lang "c++") "c++")
                   (t (error "Unknown lang: %s" lang))))
         (gcc-output (semantic-gcc-query gcc-cmd "-v" "-E" "-x" lang
null-device))
         (lines (split-string gcc-output "\n"))
         (include-marks 0)
         (inc-mark "#include ")
         (inc-mark-len (length "#include "))
         inc-path)
    (message "gcc-output=%s" gcc-output)
    (dolist (line lines)
      (when (> (length line) 1)
        (if (= 0 include-marks)
            (when (and (> (length line) inc-mark-len)
                       (string= inc-mark (substring line 0 inc-mark-len)))
              (setq include-marks (1+ include-marks)))
          (let ((chars (append line nil)))
            (when (= 32 (nth 0 chars))
              (when (if (memq system-type '(windows-nt))
                        (/= ?/ (nth 1 chars))
                      (= ?/ (nth 1 chars)))
                (add-to-list 'inc-path
                             (expand-file-name (substring line 1))
                             t)))))))
    inc-path))




  reply	other threads:[~2009-07-03 11:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-01 19:06 CEDET calls cpp -E -dM -x c++ /dev/null Lennart Borgman
2009-07-01 19:20 ` Eli Zaretskii
2009-07-01 19:25   ` Lennart Borgman
2009-07-01 19:36     ` Eli Zaretskii
2009-07-01 20:01       ` Sean O'Rourke
2009-07-01 20:16         ` Lennart Borgman
2009-07-01 20:32           ` Sean O'Rourke
2009-07-01 20:25       ` Lennart Borgman
2009-07-02  3:24         ` Eli Zaretskii
2009-07-02  3:34           ` Eric M. Ludlam
2009-07-02 18:13             ` Lennart Borgman
2009-07-02 19:29               ` Eli Zaretskii
2009-07-03  0:31                 ` Lennart Borgman
2009-07-03  0:46                   ` Miles Bader
2009-07-03  1:13                     ` Lennart Borgman
2009-07-03  9:36                       ` Eli Zaretskii
2009-07-03 11:22                         ` Lennart Borgman [this message]
2009-07-01 19:58     ` Lennart Borgman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e01d8a50907030422h2a6f7ebaj9f88a5fbed6d17f6@mail.gmail.com \
    --to=lennart.borgman@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=eric@siege-engine.com \
    --cc=miles@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).