fe6950e62dd578b88c72c55d64ae802dfed527c8
[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_OIIO']:
86     defs.append('WITH_OPENIMAGEIO')
87
88 if env['WITH_BF_OPENEXR']:
89     defs.append('WITH_OPENEXR')
90
91 if env['WITH_BF_TIFF']:
92     defs.append('WITH_TIFF')
93
94 if env['WITH_BF_OPENJPEG']:
95     defs.append('WITH_OPENJPEG')
96
97 if env['WITH_BF_DDS']:
98     defs.append('WITH_DDS')
99
100 if env['WITH_BF_CINEON']:
101     defs.append('WITH_CINEON')
102
103 if env['WITH_BF_HDR']:
104     defs.append('WITH_HDR')
105
106 if env['WITH_BF_FRAMESERVER']:
107     defs.append('WITH_FRAMESERVER')
108
109 if env['WITH_BF_FFMPEG']:
110     defs.append('WITH_FFMPEG')
111     incs += ' ' + env['BF_FFMPEG_INC']
112
113 if env['WITH_BF_QUICKTIME']:
114     defs.append('WITH_QUICKTIME')
115     incs += ' ../../quicktime'
116
117 if env['WITH_BF_GAMEENGINE']:
118     defs.append('WITH_GAMEENGINE')
119     
120 if env['WITH_BF_FFTW3']:
121     defs.append('WITH_FFTW3')
122
123 if env['WITH_BF_SDL']:
124     defs.append('WITH_SDL')
125
126 if env['WITH_BF_OPENAL']:
127     defs.append('WITH_OPENAL')
128
129 if env['WITH_BF_JACK']:
130     defs.append('WITH_JACK')
131
132 if env['BF_UNIT_TEST']:
133     defs.append('UNIT_TEST')
134
135 if env['WITH_BF_PYTHON']:
136     defs.append('WITH_PYTHON')
137
138 if env['WITH_BF_COLLADA']:
139     defs.append('WITH_COLLADA')
140
141 if env['WITH_BF_CYCLES']:
142     defs.append('WITH_CYCLES')
143
144 if env['OURPLATFORM'] == 'linux':
145     cflags='-pthread'
146
147 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
148     incs += ' ' + env['BF_PTHREADS_INC']
149
150 if env['WITH_BF_INTERNATIONAL']:
151     defs.append('WITH_INTERNATIONAL')
152
153 if not env['BF_DEBUG']:
154     defs.append('NDEBUG')
155
156 makesrna_tool.Append(CPPDEFINES=defs)
157
158 makesrna_tool.Append (CPPPATH = Split(incs))
159
160 if env['OURPLATFORM'] == 'linuxcross':
161     USE_WINE = True # when cross compiling on linux 64bit this is useful
162 else:
163     USE_WINE = False
164
165 if not USE_WINE:
166     if env['OURPLATFORM'] == 'linuxcross':
167         makesdna_tool.Replace(CC='gcc')
168         makesdna_tool.Replace(AR='ar')
169         makesdna_tool.Replace(LINK='gcc')
170
171 if sys.platform != 'cygwin':
172     makesrna_tool.Append (CCFLAGS = cflags)
173 makesrna_tool.Append (CPPDEFINES = defines)
174
175 libdir = root_build_dir+'/lib'
176 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
177     libdir = '#' + libdir
178
179 makesrna_tool.Append (LIBPATH = libdir)
180
181 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
182 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
183 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
184
185 if env['BF_PROFILE']:
186     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
187
188 if env['BF_DEBUG']:
189     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
190     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
191     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
192         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
193
194 targetpath = root_build_dir+'/makesrna'
195 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
196     targetpath = '#' + targetpath
197
198 if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep:
199     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
200 else:
201     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
202
203 rna_dict = rna.Dictionary()
204 rna.Depends (generated_files, makesrna)
205
206 # this seems bad, how to retrieve it from scons?
207 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
208     
209 if env['OURPLATFORM'] != 'linuxcross':
210     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
211         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
212     else:
213         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
214 else:
215     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
216     
217     if USE_WINE:
218         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
219     else:
220         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
221
222
223 obj = ['intern/rna_access.c']
224 for generated_file in generated_files:
225     obj += ['intern/' + generated_file]
226
227 Return ('obj')
228