开发者

How do you create rules in BJAM?

I would like to compile a file with a specific compiler not supported on boost. I made a rule:

rule my_rule ( source : target )
{
    compile_specially source target ;
}

actions compile_specially
{
    my_compile_command $(my_parameters) $(1) -o $(2)
}

now this code builds the file into the Jamroot directory (obviously). I, however want it to be build in the regular target path (bin/gcc-4.4/release/threading-multi/...). So how do I get/generate th开发者_如何学JAVAe standard path in my_rule?

Thank You in advance.


Use the "make" target (see BBv2 Custom Commands). Of course this doesn't really get you what I think you are after. What you want is to create a new toolset which is considerably more complicated. You'll want to read through the extender chapter of the documentation. In particular the tools and generators section. And join us in the Boost Build mail list for detailed questions and debugging.


Not exactly what you are asking, but looks similar enough to help. In the example below I compile D language source files using gdc and eventually link them with C libraries (writing my own C functions would need to define interface d modules as d name mangling differs from C ones and would raise linking issues). I followed what is described in tools and generators section (see answer by @GrafikRobot) to achieve this and it was quite easy.

Here is sample jam files and code.

gdc.jam

import type ;
type.register D : d ;

import generators ;
generators.register-standard gdc.compile : D : OBJ ;

actions compile
{
#    "echo" $(>) $(<)
    "gdc" -c -o $(<) $(>)
}

Jamroot

import gdc ;

project hello
    : requirements
    <cflags>-O3
    : default-build release

;

lib gphobos2 : : <file>/usr/lib/gcc/x86_64-linux-gnu/4.6/libgphobos2.a <name>gphobos2 ;
lib m : : <name>m ;
lib z : : <name>z ;
lib rt : : <name>rt ;
lib pthread : : <name>pthread <link>shared ;

exe hello
    :
        hello.d
        bye.d

        gphobos2 m z rt pthread
    :
        <link>static
    ;

Hello.d

import std.stdio;

void main()
{
  writeln("Hello World!");

    static import bye ;

    bye.bye();
}

Bye.d module bye;

import std.stdio;

void bye()
{
  writeln("Good bye");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜