Scons ToDo:
[blender.git] / source / blender / makesrna / intern / SConscript
1 #!/usr/bin/python
2 import sys
3 import os
4
5 def normpath(path):
6     return os.path.abspath(os.path.normpath(path))
7
8 Import ('env')
9 cflags = [] #['-Wall']
10 defines = []
11 root_build_dir=normpath(env['BF_BUILDDIR'])
12
13 source_files = env.Glob('*.c')
14 source_files.remove('rna_access.c')
15
16 generated_files = source_files[:]
17 generated_files.remove('rna_define.c')
18 generated_files.remove('makesrna.c')
19
20 api_files = env.Glob('*_api.c')
21 for api_file in api_files:
22     generated_files.remove(api_file)
23
24 generated_files = [filename[:-2] + '_gen.c' for filename in generated_files]
25
26 makesrna_tool = env.Clone()
27 rna = env.Clone()
28 makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
29
30 defs = []
31
32 incs = '#/intern/guardedalloc ../../blenlib ../../blenkernel ../../blenloader'
33 incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
34 incs += ' ../../windowmanager ../../editors/include ../../blenfont'
35 incs += ' ../../render/extern/include ../../bmesh'
36 incs += ' #/intern/audaspace/intern #/intern/cycles/blender'
37 incs += ' #/extern/glew/include '
38
39 if env['WITH_BF_OPENEXR']:
40     defs.append('WITH_OPENEXR')
41
42 if env['WITH_BF_TIFF']:
43     defs.append('WITH_TIFF')
44
45 if env['WITH_BF_OPENJPEG']:
46     defs.append('WITH_OPENJPEG')
47
48 if env['WITH_BF_DDS']:
49     defs.append('WITH_DDS')
50
51 if env['WITH_BF_CINEON']:
52     defs.append('WITH_CINEON')
53
54 if env['WITH_BF_HDR']:
55     defs.append('WITH_HDR')
56
57 if env['WITH_BF_FRAMESERVER']:
58     defs.append('WITH_FRAMESERVER')
59
60 if env['WITH_BF_FFMPEG']:
61     defs.append('WITH_FFMPEG')
62     incs += ' ' + env['BF_FFMPEG_INC']
63
64 if env['WITH_BF_QUICKTIME']:
65     defs.append('WITH_QUICKTIME')
66     incs += ' ../../quicktime'
67
68 if env['WITH_BF_GAMEENGINE']:
69     defs.append('WITH_GAMEENGINE')
70     
71 if env['WITH_BF_FFTW3']:
72     defs.append('WITH_FFTW3')
73
74 if env['WITH_BF_SDL']:
75     defs.append('WITH_SDL')
76
77 if env['WITH_BF_OPENAL']:
78     defs.append('WITH_OPENAL')
79
80 if env['WITH_BF_JACK']:
81     defs.append('WITH_JACK')
82
83 if env['BF_UNIT_TEST']:
84     defs.append('UNIT_TEST')
85
86 if env['WITH_BF_PYTHON']:
87     defs.append('WITH_PYTHON')
88
89 if env['WITH_BF_COLLADA']:
90     defs.append('WITH_COLLADA')
91
92 if env['WITH_BF_CYCLES']:
93     defs.append('WITH_CYCLES')
94
95 if env['OURPLATFORM'] == 'linux':
96     cflags='-pthread'
97     incs += ' ../../../extern/binreloc/include'
98
99 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
100     incs += ' ' + env['BF_PTHREADS_INC']
101
102 if env['WITH_BF_INTERNATIONAL']:
103     defs.append('WITH_INTERNATIONAL')
104
105 if not env['BF_DEBUG']:
106     defs.append('NDEBUG')
107
108
109 makesrna_tool.Append(CPPDEFINES=defs)
110
111 makesrna_tool.Append (CPPPATH = Split(incs))
112
113 if env['OURPLATFORM'] == 'linuxcross':
114     USE_WINE = True # when cross compiling on linux 64bit this is useful
115 else:
116     USE_WINE = False
117
118 if not USE_WINE:
119     if env['OURPLATFORM'] == 'linuxcross':
120         makesdna_tool.Replace(CC='gcc')
121         makesdna_tool.Replace(AR='ar')
122         makesdna_tool.Replace(LINK='gcc')
123
124 if sys.platform != 'cygwin':
125     makesrna_tool.Append (CCFLAGS = cflags)
126 makesrna_tool.Append (CPPDEFINES = defines)
127
128 libdir = root_build_dir+'/lib'
129 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
130     libdir = '#' + libdir
131
132 makesrna_tool.Append (LIBPATH = libdir)
133
134 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
135 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
136 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
137
138 if env['BF_PROFILE']:
139     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
140
141 if env['BF_DEBUG']:
142     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
143     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
144     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
145         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
146
147 targetpath = root_build_dir+'/makesrna'
148 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
149     targetpath = '#' + targetpath
150
151 if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep:
152     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
153 else:
154     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
155
156 rna_dict = rna.Dictionary()
157 rna.Depends (generated_files, makesrna)
158
159 # this seems bad, how to retrieve it from scons?
160 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
161     
162 if env['OURPLATFORM'] != 'linuxcross':
163     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
164         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
165     else:
166         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
167 else:
168     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
169     
170     if USE_WINE:
171         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
172     else:
173         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
174
175
176 obj = ['intern/rna_access.c']
177 for generated_file in generated_files:
178     obj += ['intern/' + generated_file]
179
180 Return ('obj')
181