|
对于大的工程来说,使用IDE来管理总是有诸多限制,例如大多少数IDE不能够支持在工程中存在相同文件名的文件(即使是路径不相同)。而且用IDE来做 build,其速度确实要慢了好几拍。
RT-Thread 0.2.x以前都是采用的GNU Make + GNU GCC的方式来编译,但Makefile的组织太过复杂,特别是要做编译选项,会非常非常麻烦(编译选项不能够在多个Makefile之间自由传递)。 GNU还有一种方式,名为automake, autoconfig,不过当自动产生的Makefile比自己的代码还多的多的时,有时就不得不思考,程序员是在写代码,还是 automake&autoconfig在写程序员。
RT-Thread到0.3.x,主要的编译器切换到RealView ARM Compiler,所以默认没有发布出带Makefile的版本。当然最大的原因还是,Makefile太难以忍受了!为了达到更好编译的目的,尝试创建了一个小型的分支,这个分支完全采用的是新的scons构建系统(http://www.scons.org):先有尝试,然后考察其实用性,最后实施。
现在到了实施的阶段:因为scons构建系统优点值得称赞,值得应用。scons的优点,英文的,这里就不翻译了:
What makes SCons better?
* Configuration files are Python scripts--use the power of a real programming language to solve build problems.
* Reliable, automatic dependency analysis built-in for C, C++ and Fortran--no more "make depend" or "make clean" to get all of the dependencies. Dependency analysis is easily extensible through user-defined dependency Scanners for other languages or file types.
* Built-in support for C, C++, D, Java, Fortran, Yacc, Lex, Qt and SWIG, and building TeX and LaTeX documents. Easily extensible through user-defined Builders for other languages or file types.
* Building from central repositories of source code and/or pre-built targets.
* Built-in support for fetching source files from SCCS, RCS, CVS, BitKeeper and Perforce.
* Built-in support for Microsoft Visual Studio .NET and past Visual Studio versions, including generation of .dsp, .dsw, .sln and .vcproj files.
* Reliable detection of build changes using MD5 signatures; optional, configurable support for traditional timestamps.
* Improved support for parallel builds--like make -j but keeps N jobs running simultaneously regardless of directory hierarchy.
* Integrated Autoconf-like support for finding #include files, libraries, functions and typedefs.
* Global view of all dependencies--no more multiple build passes or reordering targets to build everything.
* Ability to share built files in a cache to speed up multiple builds--like ccache but for any type of target file, not just C/C++ compilation.
* Designed from the ground up for cross-platform builds, and known to work on Linux, other POSIX systems (including AIX, *BSD systems, HP/UX, IRIX and Solaris), Windows NT, Mac OS X, and OS/2.
如上所说的,scons是构建在python脚本的基础上的,功能繁多。依赖于python,可以说在scons的脚本中能够做非常多的事,控制灵活。试用下来,感觉最大的是,其-j选项。因为现在的机器多大是多核的,而-j后,将大大的加快编译的速度,真正有那种在指尖飞的感觉。
进入正题,说说RT-Thread里的命令行编译如何使用
首先,需要安装python,http://www.python.org,2.5或2.6版本
其次,安装 scons,http://www.scons.org,可以先装个安装版本,以后自己会了只装zip,源代码版本即可。
再次,从 google svn中获取RT-Thread的最新代码,因为最近才实施scons构建系统。
因为每个人机器上的编译器不同,安装的目录也不相同,需要根据你的环境设定编译选项
打开RT-Thread代码中bsp\stm3210\rtconfig.py文件,修改如下选项:
PLATFORM = 'gcc'
EXEC_PATH = 'd:/SourceryGCC/bin'
即把PLATFORM设置为你使用的编译器,可设置为gcc或armcc (iar过一段时间支持)
EXEC_PATH设置为相应编译器的目录(armcc的请设置到Keil的目录)
修改完成后,请打开命令行窗口,先设置上scons的命令出处:(假设python安装于C:根目录下)
set PATH=c:\Python25\Scripts;%PATH%
进入RT-Thread/STM3210的目录(假设RT- Thread目录放在h:根目录下)
cd h:\bsp\stm3210
然后执行
scons |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|