changeset:   1613:693192899644
branch:      org.emacs.ada-mode
tag:         tip
user:        Simon Wright <simonjwright@users.sourceforge.net>
date:        Mon Apr 25 11:18:55 2016 +0100
files:       ada-gnat-xref.el gnat-core.el
description:
Support cross-compilation.

For the moment, the necessary settings can't be extracted using
gpr_query; instead, set them in an ada-mode project file, for example

gpr_file=io_expander.gpr
target=arm-eabi-
runtime=ravenscar-sfp-stm32f4

  * ada-gnat-xref.el (ada-gnat-xref-all): use "${target}gnat find".

  * gnat-core.el (gnat-run-gnat): use ${target}gnat.
      If COMMAND is "list", add --RTS=${runtime}.


diff --git a/ada-gnat-xref.el b/ada-gnat-xref.el
--- a/ada-gnat-xref.el
+++ b/ada-gnat-xref.el
@@ -145,7 +145,9 @@
   ;; is asynchronous, and automatically runs the compilation error
   ;; filter.
 
-  (let* ((cmd (format "gnat find -a -r %s:%s:%d:%d" identifier file line col)))
+  (let* ((cmd (format "%sgnat find -a -r %s:%s:%d:%d"
+                      (or (ada-prj-get 'target) "")
+                      identifier file line col)))
 
     (with-current-buffer (gnat-run-buffer); for default-directory
       (let ((compilation-environment (ada-prj-get 'proc_env))
diff --git a/gnat-core.el b/gnat-core.el
--- a/gnat-core.el
+++ b/gnat-core.el
@@ -287,9 +287,16 @@
   (let* ((project-file-switch
 	  (when (ada-prj-get 'gpr_file)
 	    (concat "-P" (file-name-nondirectory (ada-prj-get 'gpr_file)))))
-	 (cmd (append (list command) (list project-file-switch) switches-args)))
+         (target-gnat (concat (ada-prj-get 'target) "gnat"))
+         ;; gnat list understands --RTS without a fully qualified
+         ;; path, gnat find (in particular) doesn't (but it doesn't
+         ;; need to, it uses the ALI files found via the GPR)
+         (runtime
+          (when (and (ada-prj-get 'runtime) (string= command "list"))
+            (list (concat "--RTS=" (ada-prj-get 'runtime)))))
+	 (cmd (append (list command) (list project-file-switch) runtime switches-args)))
 
-    (gnat-run "gnat" cmd nil expected-status)
+    (gnat-run target-gnat cmd nil expected-status)
     ))
 
 (defun gnat-run-no-prj (command &optional dir)

