-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
61 lines (50 loc) · 1.79 KB
/
SConscript
File metadata and controls
61 lines (50 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Import('env', 'config', 'platform')
import os
import sys
###############################################################################
# recursive search
def recursive_glob(pathname, extensions):
# Recursively look for files ending with extensions.
# Return a list of matching files.
matches = []
for dirpath, dirnames, filenames in os.walk(pathname, topdown=True):
dirnames[:] = [d for d in dirnames if d not in excludedirs]
for filename in filenames:
if filename.endswith(extensions):
matches.append(os.path.join(dirpath, filename))
return matches
# find files
def find_files(cwd, extensions):
filenames = []
filenames = recursive_glob(cwd, extensions)
return filenames
###############################################################################
platform = sys.platform
srcextensions = ('.c', '.cc', '.cpp', '.m', '.mm')
objextensions = ('.o', '.obj')
excludedirs = set()
# HARDCODING BEGINS
excludedirs |= set(['DevIL', 'glsw'])
# HARDCODING ENDS
# platform specific
if platform == 'win32':
excludedirs |= set(['MacOS', 'Linux'])
elif platform == 'darwin':
excludedirs |= set(['Windows', 'Linux'])
elif platform == 'linux':
excludedirs |= set(['Windows', 'MacOS'])
###############################################################################
# find root directory
root = os.getcwd()
# find src files
srcfilenames = find_files(root, srcextensions)
# for return purposes
objects = []
# generate obj files
for srcfilename in srcfilenames:
objfilepath = srcfilename.replace(root, '').rsplit('.', 1)[0] + env['OBJSUFFIX']
objfilename = '#obj/%s/%s' % (config, objfilepath)
object = env.Object(source=srcfilename, target=objfilename)
objects.append(object)
# return all compiled objects
Return('objects')