bjam でターゲットを指定して呼び出す方法を理解するのに問題があります。これは、単に全体を実行するのではなく、ビルド プロセスのさまざまな側面に対応する (実際には Makefile から) ビルドするためのコマンド ライン ターゲットを bjam に提供したいということです。
たとえば、現在「bjam」と入力すると、停止して Python 拡張機能がビルドされ、単体テスト ファイルが実行され、別の「main」実行可能ファイルも作成されます。各ステップを実行するカスタム ルールがあり、Jamfile にはそれらを順番にリストするだけです。
project-name = example ;
sources =
$(project-name).cpp
$(project-name)_ext.cpp
;
build-ext $(project-name) : $(sources) ;
build-main $(project-name) ;
私の Jamroot (1 つ上のディレクトリ) には、これらのルールが定義されています。不完全なファイルは次のとおりです。
# A rule to simplify declaration of extension tests:
rule run-test ( test-name : sources + )
{
import testing ;
testing.make-test run-pyd : $(sources) : : $(test-name) ;
}
# A rule to further simply declaration of extension tests:
rule run-ext-test ( project-name )
{
run-test $(project-name) : $(project-name)_ext test_$(project-name)_ext.py ;
}
# A rule to simplify copying of the extension and Boost.Python libraries to the current directory
rule convenient-copy ( project-name )
{
install convenient_copy
: $(project-name)_ext
: <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
<location>.
;
}
rule build-ext ( project-name : sources + )
{
python-extension $(project-name)_ext : $(sources) : ;
# copy the extension and Boost.Python libraries to the current directory
convenient-copy $(project-name) ;
# run extension tests
run-ext-test $(project-name) ;
}
rule build-main ( project-name : other-sources * )
{
obj $(project-name).o : $(project-name).cpp ;
exe main_$(project-name) : main_$(project-name).cpp $(project-name).o $(other-sources) ;
install main : main_$(project-name) : <location>. ;
}
ただし、次の bjam の呼び出しでは、実行してもらいたいことが実行されないことに気付きました。
$ bjam build-main
notice: could not find main target build-main
notice: assuming it is a name of file to create.
don't know how to make <e>build-main
...found 1 target...
...can't find 1 target...
$ bjam main_example
...patience...
...patience...
...found 1597 targets...
...updating 3 targets...
gcc.compile.c++ bin/gcc-4.6/debug/main_example.o
gcc.compile.c++ bin/gcc-4.6/debug/example.o
gcc.link bin/gcc-4.6/debug/main_example
...updated 3 targets...
^^^ しかし、インストール ルールが実行されていないため、バイナリは Jamfile ディレクトリにコピーされません。
奇妙なことに、何かを行うターゲットがいくつかありますが、常に私が期待するものとは限りません:
$ bjam main
...patience...
...patience...
...found 1598 targets...
...updating 3 targets...
gcc.compile.c++ bin/gcc-4.6/debug/main_example.o
gcc.compile.c++ bin/gcc-4.6/debug/example.o
gcc.link main_example
...updated 3 targets...
Jamfile ディレクトリにバイナリが作成されました。
main
ターゲットはどこから来たのですか?定義してなかった…
別の奇妙なもの:
$ bjam example_ext
...patience...
...patience...
...found 2834 targets...
...updating 3 targets...
gcc.compile.c++ bin/gcc-4.6/debug/example.o
gcc.compile.c++ bin/gcc-4.6/debug/example_ext.o
gcc.link.dll bin/gcc-4.6/debug/example_ext.so
...updated 3 targets...
^^^ example_ext.so を作成しましたが、Jamfile の場所にコピーしませんでした。
$ bjam example_ext.so
notice: could not find main target example_ext.so
notice: assuming it is a name of file to create.
...patience...
...patience...
...found 2836 targets...
...updating 4 targets...
gcc.compile.c++ bin/gcc-4.6/debug/example.o
gcc.compile.c++ bin/gcc-4.6/debug/example_ext.o
gcc.link.dll bin/gcc-4.6/debug/example_ext.so
common.copy example_ext.so
...updated 4 targets...
^^^ .so ファイルを作成してコピーしましたが、便利なコピーを呼び出して libboost_python.so ファイルを取り込みませんでした。
ここで何が起こっているのか本当にわかりません。bjam のドキュメントは、本当に深刻な問題を引き起こしています。ターゲットを詳細に説明しますが、コマンド ラインから bjam を呼び出すコンテキストではなく、ルールのコンテキストで説明します。疑似ターゲットと「生成」についての言及に出くわしましたが、単純なユースケースである必要があると私が感じるには、あまりにも複雑に思えました。「バインド」メカニズムについての言及もありましたが、ドキュメントには=$(BINDRULE[1])=
意味がありません。
NOTFILE
エイリアスにも出くわしexplicit
ましたが、正しい軌道に乗っているかどうか確信が持てず、決定的なことは何もできませんでした.
bjam でカスタム ターゲットを作成する方法の良い例はありますか? それとも、意図しない方法で bjam を使用しようとしているだけですか?