日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用 SCons 代替 Makefile 快速构建应用程序

發布時間:2025/3/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用 SCons 代替 Makefile 快速构建应用程序 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

使用 SCons 代替 Makefile 快速構建應用程序

2971人閱讀 評論(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 -Q gcc -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 快速构建应用程序的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。