Pages

Thursday, September 30, 2010

SCONS and Python

1) fnmatch python
src = []

#Collects all *.cpp and *.c files under source directory

for file in os.listdir('source'):
if (fnmatch.fnmatch(file, '*.cpp') | fnmatch.fnmatch(file, '*.c')):
#prefix "build" to the file
src.append(file)


The above python script looks for source files under source directory and adds to a list src[]

2) Path Join python
import os
pj = os.path.join

glutHeader = pj('include','GL','glut.h')

3) To put your obj files in another directory (Scons)

env.VariantDir('build', 'source', 0)

env.Program(target = 'main', source = src)

build - The directory where u need to put your obj files
source - The directory to look for your source files
0 - No duplicates (source dir does not create obj file in itself)

src should contain path respective to the 'build directory'
eg - src = 'build/main.cpp'

No comments: