Lock-free memory allocator
[blender.git] / source / blender / makesrna / intern / SConscript
1 #!/usr/bin/env python
2 #
3 # ***** BEGIN GPL LICENSE BLOCK *****
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19 # The Original Code is Copyright (C) 2006, Blender Foundation
20 # All rights reserved.
21 #
22 # The Original Code is: all of this file.
23 #
24 # Contributor(s): Nathan Letwory.
25 #
26 # ***** END GPL LICENSE BLOCK *****
27
28 import sys
29 import os
30
31 def normpath(path):
32     return os.path.abspath(os.path.normpath(path))
33
34 Import ('env')
35 cflags = [] #['-Wall']
36 defines = []
37 root_build_dir=normpath(env['BF_BUILDDIR'])
38
39 source_files = env.Glob('*.c')
40 source_files.remove('rna_access.c')
41
42 generated_files = source_files[:]
43 generated_files.remove('rna_define.c')
44 generated_files.remove('makesrna.c')
45
46 api_files = env.Glob('*_api.c')
47 for api_file in api_files:
48     generated_files.remove(api_file)
49
50 generated_files = [filename[:-2] + '_gen.c' for filename in generated_files]
51
52 makesrna_tool = env.Clone()
53 rna = env.Clone()
54 makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
55
56 defs = []
57
58 incs = [
59     '#/intern/guardedalloc',
60     '#/extern/glew/include',
61     '#/intern/audaspace/intern',
62     '#/intern/cycles/blender',
63     '#/intern/smoke/extern',
64     '../../blenfont',
65     '../../blenkernel',
66     '../../blenlib',
67     '../../bmesh',
68     '../../editors/include',
69     '../../ikplugin',
70     '../../imbuf',
71     '../../makesdna',
72     '../../makesrna',
73     '../../render/extern/include',
74     '../../windowmanager',
75     ]
76 incs = ' '.join(incs)
77
78 if env['WITH_BF_SMOKE']:
79     defs.append('WITH_SMOKE')
80
81 if env['WITH_BF_BULLET']:
82     defs.append('WITH_BULLET')
83     incs += ' #/intern/rigidbody'
84
85 if env['WITH_BF_OPENEXR']:
86     defs.append('WITH_OPENEXR')
87
88 if env['WITH_BF_TIFF']:
89     defs.append('WITH_TIFF')
90
91 if env['WITH_BF_OPENJPEG']:
92     defs.append('WITH_OPENJPEG')
93
94 if env['WITH_BF_DDS']:
95     defs.append('WITH_DDS')
96
97 if env['WITH_BF_CINEON']:
98     defs.append('WITH_CINEON')
99
100 if env['WITH_BF_HDR']:
101     defs.append('WITH_HDR')
102
103 if env['WITH_BF_FRAMESERVER']:
104     defs.append('WITH_FRAMESERVER')
105
106 if env['WITH_BF_FFMPEG']:
107     defs.append('WITH_FFMPEG')
108     incs += ' ' + env['BF_FFMPEG_INC']
109
110 if env['WITH_BF_QUICKTIME']:
111     defs.append('WITH_QUICKTIME')
112     incs += ' ../../quicktime'
113
114 if env['WITH_BF_GAMEENGINE']:
115     defs.append('WITH_GAMEENGINE')
116     
117 if env['WITH_BF_FFTW3']:
118     defs.append('WITH_FFTW3')
119
120 if env['WITH_BF_SDL']:
121     defs.append('WITH_SDL')
122
123 if env['WITH_BF_OPENAL']:
124     defs.append('WITH_OPENAL')
125
126 if env['WITH_BF_JACK']:
127     defs.append('WITH_JACK')
128
129 if env['BF_UNIT_TEST']:
130     defs.append('UNIT_TEST')
131
132 if env['WITH_BF_PYTHON']:
133     defs.append('WITH_PYTHON')
134
135 if env['WITH_BF_COLLADA']:
136     defs.append('WITH_COLLADA')
137
138 if env['WITH_BF_CYCLES']:
139     defs.append('WITH_CYCLES')
140
141 if env['OURPLATFORM'] == 'linux':
142     cflags='-pthread'
143
144 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
145     incs += ' ' + env['BF_PTHREADS_INC']
146
147 if env['WITH_BF_INTERNATIONAL']:
148     defs.append('WITH_INTERNATIONAL')
149
150 if not env['BF_DEBUG']:
151     defs.append('NDEBUG')
152
153 makesrna_tool.Append(CPPDEFINES=defs)
154
155 makesrna_tool.Append (CPPPATH = Split(incs))
156
157 if env['OURPLATFORM'] == 'linuxcross':
158     USE_WINE = True # when cross compiling on linux 64bit this is useful
159 else:
160     USE_WINE = False
161
162 if not USE_WINE:
163     if env['OURPLATFORM'] == 'linuxcross':
164         makesdna_tool.Replace(CC='gcc')
165         makesdna_tool.Replace(AR='ar')
166         makesdna_tool.Replace(LINK='gcc')
167
168 if sys.platform != 'cygwin':
169     makesrna_tool.Append (CCFLAGS = cflags)
170 makesrna_tool.Append (CPPDEFINES = defines)
171
172 libdir = root_build_dir+'/lib'
173 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
174     libdir = '#' + libdir
175
176 makesrna_tool.Append (LIBPATH = libdir)
177
178 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
179 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
180 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
181
182 if env['BF_PROFILE']:
183     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
184
185 if env['BF_DEBUG']:
186     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
187     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
188     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
189         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
190
191 targetpath = root_build_dir+'/makesrna'
192 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
193     targetpath = '#' + targetpath
194
195 if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep:
196     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
197 else:
198     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
199
200 rna_dict = rna.Dictionary()
201 rna.Depends (generated_files, makesrna)
202
203 # this seems bad, how to retrieve it from scons?
204 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
205     
206 if env['OURPLATFORM'] != 'linuxcross':
207     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
208         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
209     else:
210         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
211 else:
212     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
213     
214     if USE_WINE:
215         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
216     else:
217         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
218
219
220 obj = ['intern/rna_access.c']
221 for generated_file in generated_files:
222     obj += ['intern/' + generated_file]
223
224 Return ('obj')
225