2009年1月7日水曜日

bjam on ubuntu

いろいろはまってしまったが、 apt-get一発で入るようだ。bjamは独立したパッケージになっているが、それだけ入れてもだめなのがポイント。
sudo apt-get boost-build
設定としては、ホームディレクトリにuser-config.jamファイルを作り下のように書く。ポイントはgcc と ; の間を開けておくこと。どうもパーザが貧弱なので、トークン切り出しがうまくできていないようだ。
using gcc ;

プログラムを用意

test.hpp をtest.cppとmain.cppが共有。

test.hpp

void test();
test.cpp:
#include "test.hpp"
void test() {}
main.cpp
#include "test.hpp"
int main(){
    test();
}

Jamroot ファイルを書く

: は引数間の区切り. つまりrule exe は2引数で、第一引数がターゲットバイナリ名、第二引数に、ソースファイルのリストをとっている。
exe main : main.cpp test.cpp ;

実行

$ bjam
...found 13 targets...
...updating 6 targets...
MkDir1 bin
MkDir1 bin/gcc
MkDir1 bin/gcc/debug
gcc.compile.c++ bin/gcc/debug/main.o
gcc.compile.c++ bin/gcc/debug/test.o
gcc.link bin/gcc/debug/main
...updated 6 targets...
できた。test.hppにタッチするとちゃんと依存関係を認識していて再度コンパイルする。
$ touch test.hpp
$ bjam
...found 13 targets...
...updating 3 targets...
gcc.compile.c++ bin/gcc/debug/main.o
gcc.compile.c++ bin/gcc/debug/test.o
gcc.link bin/gcc/debug/main
...updated 3 targets...
すばらしい。。。

0 件のコメント: