+ ;;
+ ;; WORKAROUND: GNAT 7.2.1 gnatls does not support C++ fully; it
+ ;; does not return src_dirs from C++ projects (see AdaCore ticket
+ ;; M724-045). The workaround is to include the src_dirs in an
+ ;; Emacs Ada mode project.
+ (gnat-run-gnat "list" (list "-v") '(0 4))
+
+ (goto-char (point-min))
+
+ (condition-case nil
+ (progn
+ ;; Source path
+ (search-forward "Source Search Path:")
+ (forward-line 1)
+ (while (not (looking-at "^$")) ; terminate on blank line
+ (back-to-indentation) ; skip whitespace forward
+ (if (looking-at "<Current_Directory>")
+ (add-to-list 'src-dirs (directory-file-name default-directory))
+ (add-to-list 'src-dirs
+ (expand-file-name ; canonicalize path part
+ (directory-file-name
+ (buffer-substring-no-properties (point) (point-at-eol))))))
+ (forward-line 1))
+
+ ;; Project path
+ ;;
+ ;; These are also added to src_dir, so compilation errors
+ ;; reported in project files are found.
+ (search-forward "Project Search Path:")
+ (forward-line 1)
+ (while (not (looking-at "^$"))
+ (back-to-indentation)
+ (if (looking-at "<Current_Directory>")
+ (add-to-list 'prj-dirs ".")
+ (add-to-list 'prj-dirs
+ (expand-file-name
+ (buffer-substring-no-properties (point) (point-at-eol))))
+ (add-to-list 'src-dirs
+ (expand-file-name
+ (buffer-substring-no-properties (point) (point-at-eol)))))
+ (forward-line 1))
+
+ )
+ ('error
+ (pop-to-buffer (current-buffer))
+ ;; search-forward failed
+ (error "parse gpr failed")
+ ))
+ (list src-dirs prj-dirs)))