コマンドラインでGNATプロジェクト機能を使用しますgnatmake
。
私はほんの少しの例を設定しました(それで私が言うことがうまくいくと確信することができます!)。私は3つのディレクトリを持っています。teacher/
教師が提供したソースが含まれています。これは、変更したくないと思いますが、とにかく書き込みアクセス権がない可能性があります。ポイントをjacks_lib/
含み(独自のライブラリコードをそこに置くこともできます) 、コードとを含みます。teacher.gpr
teacher/
jack/
main.adb
main.gpr
jacks_lib/teacher.gpr
:
project Teacher is
-- This project calls up the teacher-supplied source.
-- This is a list of paths, which can be absolute but
-- if relative are relative to the directory where this .gpr
-- is found.
for Source_Dirs use ("../teacher");
-- Keep the built objects (.ali, .o) out of the way. Use the -p
-- gnatmake flag to have directories like this built
-- automatically.
for Object_Dir use ".build";
end Teacher;
jack/main.gpr
:
-- teacher.gpr tells where to find library source and how to build it.
with "../jacks_lib/teacher";
project Main is
-- for Source_Dirs use ("."); (commented out because it's the default)
-- Keep built objects out of the way
for Object_Dir use ".build";
-- Build executables here rather than in Object_Dir
for Exec_Dir use ".";
-- What's the main program? (there can be more than one)
for Main use ("main.adb");
end Main;
jack/main.adb
:
with Foo;
procedure Main is
begin
null;
end Main;
次に、でjack/
、
$ gnatmake -p -P main.gpr
object directory "/Users/simon/tmp/jacks_lib/.build" created for project teacher
object directory "/Users/simon/tmp/jack/.build" created for project main
gcc -c -I- -gnatA /Users/simon/tmp/jack/main.adb
gcc -c -I- -gnatA /Users/simon/tmp/teacher/foo.ads
gnatbind -I- -x /Users/simon/tmp/jack/.build/main.ali
gnatlink /Users/simon/tmp/jack/.build/main.ali -o /Users/simon/tmp/jack/main
Mac OSXでGCC4.7.0を使用していることを追加する必要がありますが、これは最近のGNATで正常に機能するはずです。