Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Sharing tips fo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 5559 of 5931
Post > Topic >>

Sharing tips for GNAT project files

by "Alex R. Mosteo" <amosteo@[EMAIL PROTECTED] > Feb 20, 2008 at 02:33 PM

Hello,

I'm posting here my default project file, so interested people can look
at it and suggest improvements.

With this project file I can build a set of files as a library (static
or dynamic), which will compile all source files, or pulling in only the
 "withed" files. It also includes several optimization settings.

--8<--

project Template is

   type Yes_No           is ("Yes",     "No");

   for Languages use ("Ada");
   -- , "C", "C++");

   for Source_Dirs use ("src");
   for Object_Dir  use "obj";
   for Exec_Dir    use "obj";

   Lib_Name    := "template";
   Lib_Version := "20070102";

   type Build_Type   is ("Debug", "Release", "No_Options", "Profile");
   type Linking_Type is ("Dependencies", "Static_Library",
"Dynamic_Library");

   Build : Build_Type   := external ("Template_Build", "Debug");
   Link  : Linking_Type := External ("Template_Link",  "Dependencies");

   case Link is
      when "Dependencies" =>
         null;
      when "Static_Library" =>
         for Library_Dir     use "libstatic";
         for Library_Name    use Lib_Name;
         for Library_Kind    use "Static";
         for Library_Version use Lib_Name & ".a." & Lib_Version;
      when "Dynamic_Library" =>
         for Library_Dir     use "libdynamic";
         for Library_Name    use Lib_Name;
         for Library_Kind    use "Dynamic";
         for Library_Version use Lib_Name & ".so." & Lib_Version;
   end case;

   Include_Test : Yes_No := external ("Template_Include_Test", "Yes");

   case Include_Test is
      when "Yes" => for Source_Dirs use project'Source_Dirs & "test";
      when "No"  => null;
   end case;

   package Ide is
      for Vcs_Kind use "Subversion";
   end Ide;

   package Compiler is
      for Default_Switches ("C")   use ("-g", "-Wall", "-O2");
      for Default_Switches ("C++") use ("-g", "-Wall", "-O2");
      for Default_Switches ("Ada") use
        ("-g", "-gnatf", "-gnat05",
         "-gnatwcfjklmopruvz", "-gnatyacehikn", "-gnatqQ");

      case Build is
         when "Profile" =>
            for Default_Switches ("Ada") use
              Compiler'Default_Switches ("Ada") &
              ("-O2", "-gnato", "-fstack-check", "-gnata", "-gnatpg");
         when "Debug" =>
            for Default_Switches ("Ada") use
              Compiler'Default_Switches ("Ada") &
              ("-O2", "-gnato", "-fstack-check", "-gnata");
         when "Release" =>
            for Default_Switches ("Ada") use
              Compiler'Default_Switches ("Ada") &
              ("-O3", "-gnatn", "-gnatN");
            for Default_Switches ("C")   use
              Compiler'Default_Switches ("C")   & ("-O3");
            for Default_Switches ("C++") use
              Compiler'Default_Switches ("C")   & ("-O3");
         when "No_Options" =>
            for Default_Switches ("Ada") use ("-gnat05");
            --  Deliberately override default switches not to have any!
      end case;
   end Compiler;

   package Binder is
      for Default_Switches ("Ada") use ("-E", "-g"); -- , "-r");
      -- "Show restrictions
   end Binder;

   package Linker is
      for Default_Switches ("Ada") use ("-g", "-Wl,--gc-sections");
      for Default_Switches ("C")   use ("-g");
      for Default_Switches ("C++") use ("-g");
   end Linker;

   package Builder is
      for Default_Switches ("Ada") use ("-g");
      -- , "-j2"); -- Two files at a time
   end Builder;

   package Pretty_Printer is
      for Default_Switches ("Ada") use ("-A1", "-A2", "-A3", "-A4");
   end Pretty_Printer;

   package Naming is
      for Specification_Suffix  ("C") use ".h";
      for Implementation_Suffix ("C") use ".c";
      for Specification_Suffix  ("C++") use ".hh";
      for Implementation_Suffix ("C++") use ".cc";
      for Specification_Suffix  ("Changelog") use "changelog";
      for Specification_Suffix  ("Project file") use ".gpr";
      for Specification_Suffix  ("Python") use ".py";
   end Naming;

end Template;
 




 1 Posts in Topic:
Sharing tips for GNAT project files
"Alex R. Mosteo"  2008-02-20 14:33:58 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 19:43:35 CDT 2008.