User Tools

Site Tools


scons

윈도에서 scons 설치하기

  • 파이썬 2.6.x설치
  • 윈도용 scons 다운로드 → 설치
  • 제어판→시스템→고급→환경변수→PATH에서 편집 ;C:\Python26\Scripts 추가

basic

정적라이브러리

StaticLibrary(’foo’, [’f1.c, ’f2.c, ’f3.c])

동적라이브러리

SharedLibrary(’foo’, [’f1.c, ’f2.c, ’f3.c])

라이브러리와 링크

Library('foo', ['f1.c', 'f2.c', 'f3.c'])
Program('prog.c', LIBS=['foo', 'bar'], LIBPATH='.')
Program('prog.c', LIBS = 'm', LIBPATH = ['/usr/lib', '/usr/local/lib'])

env

env = Environment(FOO = 'foo', BAR = 'bar')
dict = env.Dictionary()
for key in ['OBJSUFFIX', 'LIBSUFFIX', 'PROGSUFFIX']:
        print "key = %s, value = %s" % (key, dict[key])
opt = Environment(CCFLAGS = '-O2')
dbg = Environment(CCFLAGS = '-g')
o = opt.Object('foo-opt', 'foo.c')
opt.Program(o)
d = dbg.Object('foo-dbg', 'foo.c')
dbg.Program(d)

환경 추가

env.Append(CCFLAGS = "-g" )
env.Append(LINKFLAGS = "-Xlinker -Map=output.map")

install

install 이라는 alias를 생성

env = Environment()
hello = env.Program('hello.c')
env.Install('/usr/bin', hello)
env.Alias('install', ’/usr/bin’)

실행하면 요래

% scons -Q
cc -o hello.o -c hello.c
cc -o hello hello.o
% scons -Q install
Install file: "hello" as "/usr/bin/hello"

custom builder

외부 명령어 foobuild를 쓸 때

bld = Builder(action = 'foobuild < $SOURCE > $TARGET', suffix = '.foo', src_suffix = '.input')
env = Environment(BUILDERS = {'Foo' : bld})
env.Foo('file1')
env.Foo('file2')

파이썬 코드를 쓸 때

def build_function(target, source, env):
  # Code to build "target" from "source"
  return None
bld = Builder(action = build_function, suffix = '.foo', src_suffix = '.input')
env = Environment(BUILDERS = {'Foo' : bld})
env.Foo('file')

references

scons.txt · Last modified: 2013/08/03 05:04 (external edit)