• [SCons 有点翻译的scons学习] 1. 简单编译


    安装scons

    =====

    这个就不详细说了,嫌麻烦可以直接sudo apt-get install scons。不嫌麻烦去下载源码安装。


    简单编译

    =====

    来看一个最简单的hello, world程序
    int
    main()
    {
        printf("Hello, world!\n");
    }
    然后创建一个SConstruct文件,编写
    Program('hello.c')

    这个最简单的自动化编译文件有两条信息。第一指出了需要编译的结果是一个可执行文件,第二指出了输入文件是
    hello.c。
    这时在命令行终端运行scons,就能自动编译了。
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          cc -o hello hello.o
          scons: done building targets.
    scons只需要知道输入文件的名字,就能自动推导出依赖文件,并且自动找到编译器,这里是gcc。

    Building Object Files

    =====

    除了可以指定输出是可执行文件,还可以指定输出是.o 文件。
          Object('hello.c')
    输出
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          scons: done building targets.   

    清理工作

    =====

    当编译完输出可执行文件之后,剩下的.o 文件就多余了,这时可以加个 option -c,来执行清理工作。
          % scons
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Building targets ...
          cc -o hello.o -c hello.c
          cc -o hello hello.o
          scons: done building targets.
          % scons -c
          scons: Reading SConscript files ...
          scons: done reading SConscript files.
          scons: Cleaning targets ...
          Removed hello.o
          Removed hello
          scons: done cleaning targets.      

    SConstruct文件

    =====

    和make 工具类似,Scons 是根据SConstruct 文件来组织编译的,但有一点不同,SConstruct使用的是python的语法,这点比起makefile来就爽多了。

    如果觉得scons在编译的时候输出了太多信息,眼花缭乱,那么加个 -Q,这样scons: 开头的条目就被隐藏不予显示了。
          C:\>scons -Q
          cl /Fohello.obj /c hello.c /nologo
          link /nologo /OUT:hello.exe hello.obj
          embedManifestExeCheck(target, source, env)

    ilding Object Files


  • 相关阅读:
    uip UDPclient模式通信移植,p本地ort可以是无规
    正则表达式摘要
    Regular expression
    正则-合乎规则
    通配符-通配
    正则表达式总结
    判断大盘筑顶的方法
    筑顶和下跌规律
    股票的筑顶危险信号
    股票筑顶的基本特征
  • 原文地址:https://www.cnblogs.com/lyyyuna/p/4123922.html
Copyright © 2020-2023  润新知