使用 SCons 代替 Makefile 快速构建应用程序
2014-11-05 17:01
351 查看
使用 SCons 代替 Makefile 快速构建应用程序
2012-03-22 01:372971人阅读 评论(5)
收藏
举报
makefilefilegccpython工具build
目录(?)[+]
使用 SCons 代替 Makefile 快速构建应用程序
作者:柳大·Poechant博客:blog.CSDN.net/Poechant
邮箱:zhongchao.ustc@gmail.com
Copyright © 柳大·Poechant
0 Introduction
为 make 工具编写建造规则不是一件容易的事。它复杂的配置规则,即使是有经验的开发者也望而生畏。make 工具的许多替代品便因此而诞生,SCons 就是是其中之一。SCons 是一个用 Python 语言编写的类似于 make 工具的程序。与 make 工具相比较,SCons 的配置文件更加简单清晰明了,除此之外,它还有许多的优点。SCons 支持多种操作系统平台,实现程序的构建可移植性。
1 Install
$ tar -xvf scons-2.0.1.tar $ cd scons-2.0.1 $ sudo python setup.py install
2 Hello World
2.1 Source File
#include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { printf("Hello, SCons!\n"); return 0; }
2.2 Config File
Program('helloscons.c')
2.3 Build
$ ls helloscons helloscons.c SConstruct $ cd helloscons/ $ scons scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... gcc -o helloscons.o -c helloscons.c gcc -o helloscons helloscons.o scons: done building targets. $ ls helloscons helloscons.c helloscons.o SConstruct $ ./helloscons Hello, SCons!
2.4 Run
$ ./helloscons Hello, SCons!
2.5 Clean
$ scons -c scons: Reading SConscript files ... scons: done reading SConscript files. scons: Cleaning targets ... Removed helloscons.o Removed helloscons scons: done cleaning targets. $ ls -a helloscons.c SConstruct .sconsign.dblite
3 Improve your skills!
3.1 Specify your executable file name
Program('myscons, 'helloscons.c')
3.2 Be quiet when building!
$ scons -Q
3.3 A little more complicated program
Program('helloscons2', ['helloscons2.c', 'file1.c', 'file2.c'],
LIBS = 'm',
LIBPATH = ['/usr/lib', '/usr/local/lib'],
CCFLAGS = '-DHELLOSCONS')
$ scons -Qgcc -o file1.o -c -DHELLOSCONS file1.c
gcc -o file2.o -c -DHELLOSCONS file2.c
gcc -o helloscons2.o -c -DHELLOSCONS helloscons2.c
gcc -o helloscons2 helloscons2.o file1.o file2.o -L/usr/lib -L/usr/local/lib -lm
3.4 Regular expression
Program('helloscons2', Glob('*.c')
4 Reference
http://www.ibm.com/developerworks/cn/linux/l-cn-scons/index.html?ca=drs--
转载请注明来自“柳大的CSDN博客”:blog.CSDN.net/Poechant
-
相关文章推荐
- 使用 SCons 代替 Makefile 快速构建应用程序
- 使用ASP.NET 构建 Web 应用程序快速入门-8小时的免费培训视频 - Scott Hanselman的中文博客【转载】
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用ASP.NET 构建 Web 应用程序快速入门-8小时的免费培训视频
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用SpringBoot快速构建应用程序
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用eclipse和JavaFX Scene Builder进行快速构建JavaFX应用程序
- 使用Microsoft SQL Server 2000全文搜索功能构建Web搜索应用程序 --作者:Andrew B. Cencini
- (转摘)_《数据库设计入门经典》:构建快速执行的数据库模型_8.6 应用程序缓存
- 使用可重用资产构建 SOA 应用程序,第 3 部分:WS 响应模板模式
- 使用 Google Web Toolkit、Apache Derby 和 Eclipse 构建 Ajax 应用程序,第 2 部分: 可靠后端
- 使用 Google Web Toolkit、Apache Derby 和 Eclipse 构建 Ajax 应用程序 第 1 部分: 梦幻前端
- 使用 JSF 构建数据库驱动的应用程序
- 在 .NET 中使用 BDP 和 DB2 UDB 构建分布式数据库应用程序3
- 使用 Ruby on Rails 快速开发 Web 应用程序
- NetBeans Visual Web Pack 5.5以可视方式快速构建基于标准的 Web 应用程序。
- 使用 Google Web Toolkit、Apache Derby 和 Eclipse 构建 Ajax 应用程序,第 4 部分: 部署