From: Hibou57 (Yannick Duchêne) on
Hi all of you,

Withins GPS, it is easy to add support for a language syntax, as easy
as it is on most today's editors or IDEs. But I was not able to find
how to associate a compilation command to a file of a given language,
either in GPS or in a GPR project file.

This is not formally required, as this could probably be done manually
most of times, but just that this would be cleaner.

GPS can compile C files in a project (sometimes a few ones may be
required) invoking gcc to produce the corresponding object file in the
object output directory. Is it possible to do the same with let say,
*.rc files (Windows resource files) ?

I had a look at the GPS documentation, and found about the <Language>
root tag for XML configuration files. This allow to define most of
syntactic concerns of a language, but I was not able to find a way to
define a command line to compile a file of a given language with this
kind of configuration files.
From: Dmitry A. Kazakov on
On Wed, 30 Dec 2009 06:05:45 -0800 (PST), Hibou57 (Yannick Duch�ne) wrote:

> Withins GPS, it is easy to add support for a language syntax, as easy
> as it is on most today's editors or IDEs. But I was not able to find
> how to associate a compilation command to a file of a given language,
> either in GPS or in a GPR project file.
>
> This is not formally required, as this could probably be done manually
> most of times, but just that this would be cleaner.
>
> GPS can compile C files in a project (sometimes a few ones may be
> required) invoking gcc to produce the corresponding object file in the
> object output directory. Is it possible to do the same with let say,
> *.rc files (Windows resource files) ?
>
> I had a look at the GPS documentation, and found about the <Language>
> root tag for XML configuration files. This allow to define most of
> syntactic concerns of a language, but I was not able to find a way to
> define a command line to compile a file of a given language with this
> kind of configuration files.

What about:

http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/html/gprbuild_ug.html#Package-Compiler

which defines the compiler for the given language. (The compilation command
line is determined by a combination of various project setting, obviously.)

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: Hibou57 (Yannick Duchêne) on
On 30 déc, 15:31, "Dmitry A. Kazakov" <mail...(a)dmitry-kazakov.de>
wrote:
> What about:
>
> http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/htm...
>
> which defines the compiler for the given language. (The compilation command
> line is determined by a combination of various project setting, obviously..)
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

This is a nice link, worth to read.

I've tried to do with this.

I've noticed two rather stange things :
+ The suffix provided in the language definition (the xml file) does
not seems to be reused by the GPR builder.
+ The substition given in the latter doc (%f, %u, and so on) does not
seems to work at all.

Note: things must be done with manual edition of the *.gpr file, as
some properties are not accessible with GUI project manager (notably
the Driver attribute).

Tips: the “ tool ” is launched with the object directory as the
current working directory. This must be properly handled if the file
to compile use relative paths to link to various stuff.

For people who wants to know more, here is how I could set up the GPR
project so that is automatically (re)compiles any Windows resource
files included in the project.


First of all, the language definition for the RC language, which must
be a valid XML moved to one of the GPS plug-ins directory :

<?xml version="1.0"?>
<!-- Adds syntax highlighting for RC resource files. -->
<GPS>
<Language>
<Name>Windows Resources</Name>
<Extension>.rc</Extension>
<Context>
<New_Line_Comment_Start>//</New_Line_Comment_Start>
<Comment_Start>/*</Comment_Start>
<Comment_End>*/</Comment_End>
<String_Delimiter>&quot;</String_Delimiter>
<Can_Indent>True</Can_Indent>
<Syntax_Highlighting>True</Syntax_Highlighting>
<Case_Sensitive>True</Case_Sensitive>
</Context>
</Language>
</GPS>

Then, the line added in the Compiler nested package of the GPR project
file :

for Driver ("windows resources") use "windres.bat";

(assuming Windows). This must be manually edited, as the GUI project
manager does not provide access to this.

The other option, can be edited from GPS. Open the project properties
sheet and select the tab named “ Naming convention ” and set the
implementation suffix of Windows Resource to .rc. Alternatively, you
may manually edit the GPR file, to add this line in a Naming nested
package :

package Naming is

for Implementation_Suffix ("windows resources") use ".rc";

end Naming;

The last step, is the windres.bat which is as follow :

@echo off

rem Compiles a Windows resource file (*.rc). It do so running windres
from
rem the directory where the resource file belong, just for windres to
be
rem able to resolve relative path the resource file may contains.
rem The object file is produced in this same directory. Later, the
object
rem file is moved to the object directory, which is the one from where
rem gnatmake will invok this batch.
rem
rem This batch script is to be invoked with the file name to compile
as
rem its first and unique argument.
rem
rem The argument is retrieved in %1
rem
rem %1 is the full file name
rem %~n1 is the base file name
rem %~dp1 is the parent directory name of the file
rem pushd <dir> goes to <dir> and remember of the actual directory
rem popd comes back to the actual directory

pushd %~dp1
windres.exe -i %1 -o %~n1.o
popd
if exist %~n1.o del %~n1.o
if exist %~dp1\%~n1.o move %~dp1\%~n1.o .


These tips may be reused for any other similar needs.
From: Stephen Leake on
"Dmitry A. Kazakov" <mailbox(a)dmitry-kazakov.de> writes:

> On Wed, 30 Dec 2009 06:05:45 -0800 (PST), Hibou57 (Yannick Duchêne) wrote:
>
>> Withins GPS, it is easy to add support for a language syntax, as easy
>> as it is on most today's editors or IDEs. But I was not able to find
>> how to associate a compilation command to a file of a given language,
>> either in GPS or in a GPR project file.
>>
>> ...
>
> What about:
>
> http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/html/gprbuild_ug.html#Package-Compiler
>
> which defines the compiler for the given language. (The compilation command
> line is determined by a combination of various project setting, obviously.)

Another approach is to teach gprbuild about the language at a deeper
level; see

http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/html/gprbuild_ug.html#The-GPRconfig-knowledge-base

Once gpr knows about the RC language, you can just put

for Languages use ("Ada", "RC");

in your main *.gpr file.

--
-- Stephe
From: Hibou57 (Yannick Duchêne) on
I will be back later to tell more, I was just to tell I've found a
configuration attribute in some files in ${PREFIX}/share/gprconfig/
*.xml, which is not documentated in
http://www.adacore.com/wp-content/files/auto_update/gprbuild-docs/html/gprbuild_ug.html

This attribute is Leading_Required_Switches. I've just found it used
to be named Final_Required_Switches in the past, but did not find any
documentation about Final_Required_Switches neither.
 |  Next  |  Last
Pages: 1 2
Prev: software engineer required
Next: Safe Pointers