关键词搜索

源码搜索 ×
×

SCons — 程序构建工具

发布2021-11-11浏览1847次

详情内容

目录

SCons - a software construction tool

SCons 类似于 Make Tool,同样是一款自动化程序构建(Construction)工具,通过 Python 实现,可用来替代 Make 编写复杂的 makefile。并且 Scons 是跨平台的,只要 Scons 脚本写的好,就可以在 Linux 或 Windows 下随意编译。

  • github:https://github.com/SCons/scons

与传统的 Make Tool 比较,SCons 具有以下优点:

  1. 使用 Python 脚本做为配置文件。
  2. Build-in(内建)支持 C、C++、D、Java、Fortran,、Yacc、Lex、Qt、SWIG 以及 Tex/Latex 语言程序。用户还可以根据自己的需要进行扩展以获得对需要编程语言的支持。
  3. 对于 C、C++ 和 Fortran,Build-in 支持可靠的自动依赖分析功能。不用像 Make 那样需要执行 make depends 和 make clean 就可以获得所有的依赖关系。
  4. 支持 make -j 风格的并行建造。相比 make -j,SCons 可以同时运行 N 个工作,而不用担心代码的层次结构。
  5. 使用 Autoconf 风格查找头文件、函数库、函数和类型定义。
  6. 良好的跨平台,SCons 可以运行在 Linux、AIX、BSD、HP/UX、IRIX、Solaris、Windows、Mac OS X 和 OShttps://cdn.jxasp.com:9143/image/2 上。

SCons 支持的编译类型有:

  • Program: 编译成可执行程序(在 Windows 平台上即是 exe 文件),这是最常用的一种编译类型。
  • Object: 只编译成目标文件。使用这种类型,编译结束后,只会产生目标文件。在 POSIX 系统中,目标文件以 .o 结尾,在 Windows 平台上以 .OBJ 结尾。
  • Library: 编译成库文件。SCons 默认编译的库是指静态链接库。
  • StaticLibrary: 显示的编译成静态链接库,与上面的 Library 效果一样。
  • SharedLibrary: 在 POSIX 系统上编译动态链接库,在 Windows 平台上编译 DLL。

使用示例

  • 源码 hello.c
#include <stdio.h>

int main(void)
{
	printf("hello, world!\n");

	return 0;
}
    • SConstruct,相当于 Makefile,以 Python 语言编写
    Program("hello.c")
    
    • 1
    • Building
    $ scons
    scons: Reading SConscript files ...
    scons: done reading SConscript files.
    scons: Building targets ...
    gcc -o hello.o -c hello.c
    gcc -o hello hello.o
    scons: done building targets.
    
    $ ls
    hello  hello.c  hello.o  SConstruct
    
    $ ./hello 
    hello, world!
    
      9
    • 10
    • 11
    • 12
    • 13

    相关技术文章

    点击QQ咨询
    开通会员
    返回顶部
    ×
    微信扫码支付
    微信扫码支付
    确定支付下载
    请使用微信描二维码支付
    ×

    提示信息

    ×

    选择支付方式

    • 微信支付
    • 支付宝付款
    确定支付下载