comp.lang.ada
 help / color / mirror / Atom feed
From: "Hibou57 (Yannick Duchêne)" <yannick_duchene@yahoo.fr>
Subject: Re: Adding a compiler to GPS or a GPR project
Date: Fri, 1 Jan 2010 06:58:16 -0800 (PST)
Date: 2010-01-01T06:58:16-08:00	[thread overview]
Message-ID: <d5869bdf-b989-4ac2-9812-4d743463b8b7@j4g2000yqe.googlegroups.com> (raw)
In-Reply-To: d29dcb1f-25f7-443f-8ca0-d5e3c862ca6a@e27g2000yqd.googlegroups.com

I've noticed a seaming trick with language files and compiler
definitions files.

With language files : when a kind of file does not make distinction
between specification and implementation, the documentation suggest to
use the element Extension instead of the two element Spec_Suffix and
Body_Suffix. However, as I've noticed with AdaControl file, which was
relying on the file zadactl.xml for its language definition, enabling
the AdaControl language support in a project, was not showing up
AdaControl files (*.aru) in the project view.

This can be solved using either the Spec_Suffix or the Body_Suffix,
instead of Extension, and unlike what the documentation suggest.

Exemple of modification to be applied in zadactl.xml :

  <Name>AdaControl</Name>
  <Body_Suffix>.aru</Body_Suffix>

Next, in the compiler configuration files now, the documentation point
that if a language is not associated to a compiler (like AdaControl
source files are), then the <executable> element in
<compiler_description> should contains an empty string. Unfortunately,
GPRConfig which is invoked prior to GPRBuild when building from GPS,
does not seems to handle this properly, and simply do as if a compiler
was to be found for AdaControl file and none was found, so finally,
GPRBuild gives warning messages complaining no compiler could be found
for AdaControl and all AdaControl source files were ignored. This is
an erroneous warning message.

There is luckily a work around : provid in <executable>, the name of
an application which GPRConfig will be able to find, then, use an
empty string in the “package Compiler” chunk for Driver.

Exemple :

   <compiler_description>
      <name>AdaCtl</name>               <!-- The name of the
application -->
                                        <!-- associated with the
AdaControl -->
                                        <!-- language -->
      <version>DummyVersion</version>
      <executable>adactl</executable>   <!-- Trick here. See below -->

....
....

         package Compiler is
            for Driver ("AdaControl") use "";
         end Compiler;
      </config>
   </configuration>

I've applied this trick to have access to AdaControl files from GPS
without getting any erroneous warnings at build time. The complete
source of the adacontrol.xml file I use for the AdaControl dummy
compiler definition I use, with a long comment at the end, is given
below.


<?xml version="1.0" ?>
<gprconfig>

   <!-- This file is required to avoid messages of the kind -->
   <!-- “ warning: no compiler specified for language "Adacontrol", --
>
   <!-- ignoring all of its sources ”. -->

   <!-- Tell about the AdaCtl application -->
   <compiler_description>
      <name>AdaCtl</name>               <!-- The name of the
application -->
                                        <!-- associated with the
AdaControl -->
                                        <!-- language -->
      <version>DummyVersion</version>
      <executable>adactl</executable>   <!-- Trick here. See below -->
      <languages>AdaControl</languages> <!-- The language name which
AdaCtl -->
                                        <!-- handles -->
      <target>i386-pc-mingw32</target>  <!-- You may have to add some
-->
                                        <!-- target-triplets here -->
      <target>i686-pc-mingw32</target>
      <target>pentium-mingw32msv</target>
      <target>i386-pc-linux</target>
      <target>i686-pc-linux</target>
      <target>pentium-linux</target>
   </compiler_description>

   <!-- This is needed to associate AdaControl files to a none-
existing -->
   <!-- compiler. -->
   <configuration>
      <compilers>
         <compiler name="AdaCtl" language="AdaControl" />
      </compilers>
      <config>
         package Naming is
            for Body_Suffix ("AdaControl") use ".aru";
         end Naming;
         package Compiler is
            for Driver ("AdaControl") use ""; -- Use an empty string
         end Compiler;        -- here, instead of in the Executable
tag
      </config>             <!-- See below to learn more -->
   </configuration>

   <!-- To understand this configuration file, have a look at -->
   <!-- http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/html/gprbuild_ug.html#The-GPRconfig-knowledge-base
-->

<!--
 A trick is used to avoid GPRBuild warnings of the kind
 “ warning: no compiler specified for language "Adacontrol", ignoring
all
 its sources ” when AdaControl is selected as one of the language in a
 project (which is a good choice if you want to have AdaControl files
 appearing in project view). Such a message can be confusing for a
first
 time user, who may believe something is going wrong with either
AdaCtl or
 GPS/GPRBuild. For a better user experience, this is nice to avoid
such
 erroneous warning messages.

 In the compiler definition file in the gprconfig directory, use
“adactl”
 instead of the blank string which is supposed to means “not a
compiler” but
 which is not well handled by GPRBuild. The use of AdaCtl here, is
just to be
 an application GPRConfig will be able to find. Then, in the “package
Compiler”
 in the “configuration” section, use an empty string (at this place,
not in the
 compiler definition).

 You may have to add some host-triplets where indicated if you want it
 to work. Keep in mind GPRConfig believes this is a compiler.

 More explanations : if you use an empty string in the compiler
definition,
 GPRConfig is supposed to handle this as an indication that the
corresponding
 language is on purpose not associated to any compiler. But it seems
to
 forget about it, and warns you it did not find a suitable compiler
for
 AdaControl files. So we must provide simething there, the name of an
 application GPRConfig will be able to find. This is AdaCtl dummy's
role here.

 But for GPRConfig, a compiler definition is nothing without an
associated
 project chunck. This takes place in the <configuration> node. There,
we
 will have to provide an application a second time. This should be
adactl
 as well, but it will then fail, as AdaCtl will be hungry with the
parameters
 it will recieve then. Fortunately, there is a tip : we may use there,
an
 application which is not the same as the one specified in the
compiler
 definition (but both are still needed). And it appears it works fine
to
 give an empty string here. GPRBuild, unlike GPRConfig which is
invoked
 prior to GPRBuild, does not complains it did not find a compiler, and
as
 there is no compiler, it simply does not attempt to apply a compiler
on
 AdaControl files. This only works if given, may it be an empty
string.
 Giving an empty string is not the same as giving nothing.

 In few words : when a language is not to be associated to a compiler,
 do not use an empty string in the compiler definition, but use a
dummy
 application there, and use an empty string, instead, in the “package
 Compiler” chunck in the configuration node.

 Questions and comments : yannick_duchene@yahoo.fr
-->
</gprconfig>



  reply	other threads:[~2010-01-01 14:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-30 14:05 Adding a compiler to GPS or a GPR project Hibou57 (Yannick Duchêne)
2009-12-30 14:31 ` Dmitry A. Kazakov
2009-12-30 17:46   ` Hibou57 (Yannick Duchêne)
2009-12-31  7:03   ` Stephen Leake
2009-12-31 12:39     ` Hibou57 (Yannick Duchêne)
2010-01-01 14:58       ` Hibou57 (Yannick Duchêne) [this message]
2010-01-01 15:51         ` Hibou57 (Yannick Duchêne)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox