跳转到内容

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;
华夏公益教科书