跳轉到內容

Ada 程式設計/平臺/可移植構建

來自華夏公益教科書

Ada. Time-tested, safe and secure.
Ada. 經時間考驗,安全可靠。

GPRbuild 可用於構建可移植的構建。

平臺無關程式碼

[編輯 | 編輯原始碼]

為所有支援平臺通用的平臺無關程式碼建立專案。

portable.gpr

project Portable is

   for Main use ("portable.adb");

   -- GPS uses this to start the executable
   for Exec_Dir use "bin";

   for Source_Dirs use ("src");

end Portable;

平臺相關程式碼

[編輯 | 編輯原始碼]

例如,使用 GPS 或 GPRbuild 開啟 portable-windows.gpr 以構建 Windows 專案。

portable-windows.gpr

project Portable.Windows extends "portable.gpr" is

   -- Object for Windows Resources
   for Languages use ("Ada", "WinRes");
   for Source_Dirs use ("windows", "resources");
   for Object_Dir use "windows-obj";

   -- This should be the same as the parent project
   -- or the executable will be placed on the object directory
   for Exec_Dir use "bin";

   package Linker is
      for Default_Switches ("Ada") use
        ("-lgdi32", "windows-obj/resources.o", "-mwindows");
   end Linker;

   package Compiler is
      for Driver ("WinRes") use "windres";
      for Default_Switches ("WinRes") use ("--target=pe-x86-64");
      for Leading_Required_Switches ("WinRes") use ("-i");
      for Object_File_Suffix ("WinRes") use ".o";
   end Compiler;

   package Naming is
      for Body_Suffix ("WinRes") use ".rc";
   end Naming;

end Portable.Windows;
華夏公益教科書