Understanding bjam goals and defining new ones?

I'm having trouble understanding how to specify and run targets using bjam. By this, I mean that I want to provide bjam with command line build goals (actually from the Makefile) that correspond to various aspects of the build process, rather than just doing it all.

For example, right now when I type 'bjam', it shuts down and builds the python extension, runs the unit-test file, and also creates a separate “main” executable. I have custom rules that follow each step, and my Jamfile just lists them in order:

project-name = example ;

sources =
  $(project-name).cpp
  $(project-name)_ext.cpp
  ;

build-ext $(project-name) : $(sources) ;

build-main $(project-name) ;

In my Jamroot (up one directory) I defined these rules, here is an incomplete file:

# 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>. ;
}

However, I noticed that the following bjam calls do not do what I would like to do:

$ 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 , ?

+5
1

A bjam , , explicit, , .

bjam build-main , build-main ; (), , .

bjam main_example , :

exe main_$(project-name) : main_$(project-name).cpp $(project-name).o $(other-sources) ;

, , install , .

bjam main main_example , main - install, : install main : main_$(project-name) : <location>. ;

, build-main jam , bjam error: No best alternative for ./main, - install_main_$(project-name), . bjam install_main_example main_example.

bjam example_ext , :

python-extension $(project-name)_ext : $(sources) : ;

, bjam main_example.

bjam example_ext.so example_ext.so - , ( , ), , example_ext.so, . , convenient-copy , bjam example_ext.so. - : " " - . convenient-copy - , , , , bjam. , , convenient_copy ( ), () ( ), . example_ext.so, libboost_python.so , <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION. convenient-copy , , . , , , bjam.

bjam convenient_copy example_ext.so , , main install target: , convenient-copy . convenient_copy install_$(project-name)_ext , bjam install_example_ext.

, , , bjam , , .

explicit install_main_$(project-name) ;

main_example, . main_example, explicit main_$(project-name) $(project-name).o:

explicit main_$(project-name) ;
explicit $(project-name).o ;

:

explicit install_main_$(project-name) main_$(project-name) $(project-name).o ;

, main_$(project-name) explicit, install_main_$(project-name), $(project-name).o explicit, main_$(project-name), , , , explicit.

+4

All Articles