2010-03-07 33 views
2

我想用一個不支持boost的特定編譯器編譯一個文件。我做了一個規則:你如何在BJAM中創建規則?

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

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

現在這段代碼將文件建立到Jamroot目錄中(很明顯)。不過,我希望它能夠在常規目標路徑(bin/gcc-4.4/release/threading-multi/...)中生成。那麼如何在my_rule中獲取/生成標準路徑?

謝謝您提前。

回答

1

使用「make」目標(請參閱BBv2 Custom Commands)。當然,這並不能真正讓你覺得你在追求什麼。你想要的是創建一個相當複雜的新工具集。您需要閱讀文檔的extender chapter。特別是tools and generators部分。請加入我們的Boost Build郵件列表,瞭解詳細的問題和調試。

0

不完全是你在問什麼,但看起來足夠類似的幫助。在下面的示例中,我使用gdc編譯D語言源文件並最終將它們與C庫鏈接(編寫我自己的C函數需要定義接口d模塊,因爲d名稱與C不同,並且會引發鏈接問題)。我遵循tools and generators部分中的描述(請參閱@GrafikRobot的回答)來實現這一點,這很容易。

下面是示例果醬文件和代碼。

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"); 
} 
相關問題