scilab基本的builder
现在src和sci_gateway包含了所有为primitives fun和sumab创建builder所需要的文件(fun1.c,fun2.c, sci_fun.c, vectsum.c, sci_sumab.c) 。
我们需要撰写两个builder:
一是在src目录中,builder(叫做buildersrc)需要创建一系列跟C语言函数对应的共享库(请参考ilib_for_link函数帮助)。
另一个是在interface目录中, builder(叫做buildsci_gateway)创建新的共享库来连接已经编译好的C或者Fortran语言的接口,并生成loader(参考ilib_build函数帮助)。这个
loader文件调用addinter函数,加载动态连接库到Scilab(参考addinter函数帮助)。
buildsrc.sce
ilib_for_link('mytoolboxsrc',['fun1.o' 'fun2.o','vectsum.o'],[],"c")
buildsci_gateway.sce
// must be run from this directory
ilib_name = 'libmytoolbox' // interface library name
files = ['sci_fun.o', 'sci_sumab.o']; // objects files
libs = ["../src/libmytoolboxsrc"] // other libs needed for linking
table = [ 'fun', 'sci_fun';
'sumab','sci_sumab']; // table of (scilab_name,interface-name)
// do not modify below
ilib_build(ilib_name,table,files,libs)
The ilib_name value is the interface library name, the vector files contains all the object interface files,
the vector libs contains the libraries needed for linking (here the library included in the src directory),
the variable table contains the primitives names (first column) and the corresponding interfaces programs names (second column)
scilab的loader宏
这个loader宏将macros目录中的所有lib都装载到scilab。跟builder宏一样,它是一个通用的脚本。它第一步确定loadmacros.sce 文件的位置,第二步装载lib到Scilab(详细内容查看load函数的帮助)
loadmacros.sce
mode(-1) //在这种模式下,下面执行的代码不会显示在屏幕上
pathL=get_absolute_file_path('loadmacros.sce') //获取本文件的绝对路径
disp('Loading macros in ' +pathL) //打印提示到屏幕
load(pathL+'/lib') //装载lib到scilab
clear pathL //清除刚才定义的变量
scilab的builder宏
下面的builder宏从macros目录中的.sci文件中创建一个变量,(这儿的名字是mytoolboxlib= toolbox_name +'lib')并保存到库文件中。下面的builder宏代码是通用的,它做两步操作,第一步是找到buildmacros.sce所在的位置(详细内容查看get_absolute_file_path函数的帮助),第二步是生成库文件(详细内容查看genlib函数的帮助)。
buildmacros.sce
mode(-1) //在这种模式下,下面执行的代码不会显示在屏幕上
toolboxname='mytoolbox' //定义工具箱的名字
pathB=get_absolute_file_path('buildmacros.sce') //获取本文件的绝对路径
disp('Building macros in ' +pathB) //打印提示到屏幕
genlib(toolboxname+'lib',pathB,%t) //生成宏库
clear pathB genlib toolboxname //清除刚才定义的变量
请将字符串'mytoolbox'题换成你的工具箱的名字。
闲暇、偶然,杂乱、零碎、等等
『特注:此博客以转贴为主,大部分文章来自网络搜索,如果涉及版权,请及时告知,博主会及时撤下内容。』
2007年9月12日星期三
SciLab基本的builder、loader宏和builder宏
订阅:
博文评论 (Atom)

没有评论:
发表评论
愿与大家多交流分享。芸芸众生,相识即缘。。。 ^_^