emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnat-compiler 97d26c0f18 1/3: Fix bug in alire-get-env;


From: Stephen Leake
Subject: [elpa] externals/gnat-compiler 97d26c0f18 1/3: Fix bug in alire-get-env; create-alire-project now works for als
Date: Wed, 16 Nov 2022 10:23:01 -0500 (EST)

branch: externals/gnat-compiler
commit 97d26c0f18b0c8633e5f28badfc84bb6858c0f8e
Author: Stephen Leake <stephen_leake@stephe-leake.org>
Commit: Stephen Leake <stephen_leake@stephe-leake.org>

    Fix bug in alire-get-env; create-alire-project now works for als
    
    * gnat-alire.el (alire-get-env): Handle alire.toml setting
    ADA_PROJECT_PATH. Fix bugs with quotes.
    (create-alire-project): Add file-env arg, for completeness.
    
    * gnat-compiler.el (gnat-run): Improve verbosity.
---
 gnat-alire.el    | 35 ++++++++++++++++++++++++++++-------
 gnat-compiler.el | 18 ++++++++++--------
 2 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/gnat-alire.el b/gnat-alire.el
index 5768d97615..9ca951f041 100644
--- a/gnat-alire.el
+++ b/gnat-alire.el
@@ -31,9 +31,15 @@
   ;; https://github.com/alire-project/alire/issues/1147). So empty it
   ;; here.
   ;;
+  ;; gnat list does not respect ADA_PROJECT_PATH, so if the
+  ;; alire.toml specifies ADA_PROJECT_PATH (ada_language_server does
+  ;; this), append that to GPR_PROJECT_PATH here.
+  ;;
   ;; We need all of the alire settings for "gnat list" and "gpr_query"
   ;; to properly process complex projects (like Alire).
-  (let ((process-environment (copy-sequence process-environment)))
+  (let ((process-environment (copy-sequence process-environment))
+       ada-project-path
+       gpr-project-path)
     (setenv "GPR_PROJECT_PATH" "")
 
     (with-temp-buffer
@@ -42,19 +48,34 @@
         ((= 0 status)
          (goto-char (point-min))
          (while (not (eobp))
-           (looking-at "export \\(.*\\)$")
+           (looking-at "export \\(.*\\)=\"\\(.*\\)\"$")
            (setf (wisi-prj-file-env project)
-                 (append (wisi-prj-file-env project) (list 
(match-string-no-properties 1))))
+                 (append (wisi-prj-file-env project)
+                         (list (concat (match-string-no-properties 1) "=" 
(match-string-no-properties 2)))))
+
+           (let ((name  (match-string-no-properties 1))
+                 (value (match-string-no-properties 2)))
+             (when (string= name "ADA_PROJECT_PATH")
+               (setq ada-project-path value))
+             (when (string= name "GPR_PROJECT_PATH")
+               (setq gpr-project-path value)))
            (forward-line 1)
            ))
 
         (t
          (user-error "alr printenv failed; bad or missing alire.toml?"))
-        ))
-      )))
+        )))
+    (when ada-project-path
+      (setf (wisi-prj-file-env project)
+           (delete (concat "GPR_PROJECT_PATH=" gpr-project-path) 
(wisi-prj-file-env project)))
+      (setf (wisi-prj-file-env project)
+           (append (wisi-prj-file-env project)
+                   (list (concat "GPR_PROJECT_PATH="
+                                 (concat gpr-project-path ":" 
ada-project-path))))))
+    ))
 
 ;;;###autoload
-(cl-defun create-alire-project (&key name gpr-file compile-env xref-label)
+(cl-defun create-alire-project (&key name gpr-file compile-env file-env 
xref-label)
   ;; We could use "alr exec -P -- echo" to get the project file (also
   ;; see https://github.com/alire-project/alire/issues/1151), but that
   ;; doesn't work when there are multiple project files listed in
@@ -68,7 +89,7 @@
   "Return an initial wisi project for the current Alire workspace."
   (let* ((default-directory (locate-dominating-file default-directory 
"alire.toml"))
         (abs-gpr-file (expand-file-name gpr-file))
-        (project (make-wisi-prj :name name :compile-env compile-env))
+        (project (make-wisi-prj :name name :compile-env compile-env :file-env 
file-env))
         )
 
     (alire-get-env project)
diff --git a/gnat-compiler.el b/gnat-compiler.el
index 266b8475f1..81c00611b8 100644
--- a/gnat-compiler.el
+++ b/gnat-compiler.el
@@ -268,17 +268,19 @@ Assumes current buffer is (gnat-run-buffer)"
     (funcall process-list (wisi-prj-compile-env project))
     (funcall process-list (wisi-prj-file-env project))
 
-    (when (gnat-debug-enabled 0)
-      (insert (format "GPR_PROJECT_PATH=%s\n%s " (getenv "GPR_PROJECT_PATH") 
exec))
-      (mapc (lambda (str) (insert (concat str " "))) command)
-      (newline))
+    (let ((exec-path (split-string (getenv "PATH") path-separator)))
+      (when (gnat-debug-enabled 0)
+       (insert (format "GPR_PROJECT_PATH=%s\n%s " (getenv "GPR_PROJECT_PATH")
+                       (executable-find exec)))
+       (mapc (lambda (str) (insert (concat str " "))) command)
+       (newline))
 
-    (when (gnat-debug-enabled 1)
-      (dolist (item process-environment)
-       (insert item)(insert "\n")))
+      (when (gnat-debug-enabled 1)
+       (dolist (item process-environment)
+         (insert item)(insert "\n")))
 
-    (let ((exec-path (split-string (getenv "PATH") path-separator)))
       (setq status (apply 'call-process exec nil t nil command)))
+
     (cond
      ((memq status (or expected-status '(0))); success
       nil)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]