试用Bakefile(1)

来源:互联网 发布:悦诗风吟洗面奶知乎 编辑:程序博客网 时间:2024/06/05 19:10
杨东:yangdong101@gmail.com

1. 什么是Bakefile?
引用http://www.bakefile.org的一段介绍:
Bakefile is cross-platform, cross-compiler native makefiles generator. It takes compiler-independent description of build tasks as input and generates native makefile (autoconf's Makefile.in, Visual C++ project, bcc makefile etc.).
许多项目都在使用这个跨平台跨编译器的本地makefile生成器,例如wxWidgets。

2. 安装
下载最新版本bakefile-0.2.5-setup.exe,安装目录追加到PATH环境变量中,检查如下:



3. 用法示例
hello.c程序:

  1. #include <stdio.h>
  2. int main()
  3. {
  4.     printf("Hello, world!/n");
  5.     return 0;
  6. }
hello.bkl脚本文件:
  1. <?xml version="1.0"?>
  2. <makefile>
  3.     <exe id="hello">
  4.         <sources>hello.c</sources>
  5.     </exe>
  6. </makefile>
我的编译环境是VC++2005Express,所以我将用上面这个bkl文件生成nmake的makefile,如下:


生成了makefile.vc,然后:


这样就成功生成hello.exe:


4. 一个小问题
在做clean时,无法删除对应的hello.exe.manifest,可能是Bakefile项目没有及时跟进VC编译器的发展。不过稍微改一下bkl文件就可以解决这个小问题:
  1. <?xml version="1.0"?>
  2. <makefile>
  3.     <exe id="hello">
  4.         <sources>hello.c</sources>
  5.         <clean-files>*.manifest</clean-files>
  6.     </exe>
  7. </makefile>
再重新生成makefile.vc就可以了。

原创粉丝点击