我使用以下wscript_build片段来构建带有其gir文件的vala库:

lib = bld.shlib (
  features = 'c cshlib',
  target = 'sample',
  name = 'libsample',
  vnum = '0.0.0',
  vapi_dirs = '../vapi',
  uselib = 'GTK',
  cflags = ['-include', 'config.h'],
  gir = 'Sample-1.0',
  packages = 'gtk+-3.0',
  packages_private = 'config',
  source = bld.path.ant_glob (incl='**/*.vala'))


但是现在我想知道如何用waf从这个gir文件构建一个typelib?

最佳答案

debian软件包gobject-introspection中提供的g-ir-compiler工具将gir文件转换为typelib(另请参见this question

可以在wscript_build中使用以下任务定义来使用此工具在waf中构建一个typelib,并将其安装到它所属的/usr/lib/girepository-1.0中。

lib_typelib = bld.new_task_gen(
  name = 'libsample_typelib',
  after = 'libsample',
  source = 'Sample-1.0.gir',
  target = 'Sample-1.0.typelib',
  install_path = '${LIBDIR}/girepository-1.0',
  rule='g-ir-compiler ${SRC} -o ${TGT}')


有关完整示例,请参见here

10-08 14:26