使用windows和Linux的NativeCall发布C库的Perl6绑定的最佳策略是什么?
开发人员是否需要编译.dll和.so文件,并将它们与perl6代码一起上传到github?或者像perl5这样的perl6上有一个选项,可以将C源文件与Perl6代码捆绑在一起,C编译器将作为make和make install的一部分运行?
发布于 2016-03-04 10:44:29
这些库不需要首先编译(尽管它们可以编译)。要完成此操作,首先需要在发行版的根目录中添加一个Build.pm文件:
class Builder {
method build($dist-path) {
# do build stuff to your module
# which is located at $dist-path
}
# Only needed for panda compatability
method isa($what) {
return True if $what.^name eq 'Panda::Builder';
callsame;
}
}然后,您将希望使用像LibraryMake这样的模块。下面我们在build方法中使用它的make例程:
use LibraryMake;
class Builder {
method build($dist-path) {
make($dist-path, "$dist-path/resources");
# or you could do the appropriate `shell` calls
# yourself and have no extra dependencies
}
...包管理器zef和panda支持此方法,并允许通过perl6 -I. -MBuild -e 'Builder.new.build($*CWD)'手动运行此方法
Here就是一个有效的例子
https://stackoverflow.com/questions/35782800
复制相似问题