Chinaunix首页 | 论坛 | 博客
  • 博客访问: 756935
  • 博文数量: 231
  • 博客积分: 3217
  • 博客等级: 中校
  • 技术积分: 2053
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-04 12:01
文章分类

全部博文(231)

文章存档

2015年(1)

2013年(10)

2012年(92)

2011年(128)

分类: LINUX

2012-07-02 16:28:15

Finding Libraries: the $LIBPATH Construction Variable
Program('program.c',LIBS='m',LIBPATH=['/usr/lib','/usr/local/lib'])
% scons -Q
cc -o prog.o -c prog.c
cc -o prog prog.o -L/usr/lib -L/usr/local/lib -lm
 
Explicitly Creating File and Directory Nodes
scons支持Fil和Dir两个函数功能,返回的是文件或者目录节点
hello_c = File(’hello.c’)
Program(hello_c)
classes = Dir(’classes’)
Java(classes, ’src’)
scons支持Entry函数功能返回一个文件或者目录节点
xyzzy = Entry(’xyzzy’)
 
Printing Node File Names
 
hello_c = File('hello.c')
Program(hello_c)
object_list = Object('hello.c')
program_list = Program(object_list)
print "The object file is:", object_list[0]
print "The program file is:", program_list[0]
# gedit SConstruct
# scons
scons: Reading SConscript files ...
The object file is: hello.o
The program file is: hello
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
# ls
hello  hello.c  hello.o  SConstruct
# gedit SConstruct
 
Using a Node’s File Name as a String使用文件名字的节点当做字符:
if you want to use the Python os.path.exists to figure out whether a file exists while the SConstruct file is being read and
executed, you can fetch the string as follows:
import os.path
program_list = Program(’hello.c’)
program_name = str(program_list[0])
if not os.path.exists(program_name):
print program_name, "does not exist!"
 
import os.path
hello_c = File('hello.c')
Program(hello_c)
object_list = Object('hello.c')
program_list = Program(object_list)
p=str(program_list[0])
if not os.path.exists(p):
    print p ,"not exit"
print "The object file is:", object_list[0]
print "The program file is:", program_list[0]
# scons
scons: Reading SConscript files ...
hello not exit
The object file is: hello.o
The program file is: hello
scons: done reading SConscript files.
scons: Building targets ...
gcc -o hello.o -c hello.c
gcc -o hello hello.o
scons: done building targets.
 
 
阅读(929) | 评论(0) | 转发(0) |
0

上一篇:scons

下一篇:scons(四)

给主人留下些什么吧!~~