不完全是你在問什麼,但看起來足夠類似的幫助。在下面的示例中,我使用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");
}