afa4ab3a67d14e4bf7d2d337414082ac29ac356c
[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 = env['BF_GL_DEFINITIONS']
57
58 incs = [
59     '#/intern/guardedalloc',
60     env['BF_GLEW_INC'],
61     '#/intern/glew-mx',
62     '#/intern/audaspace/intern',
63     '#/intern/cycles/blender',
64     '#/intern/smoke/extern',
65     '../../blenfont',
66     '../../blenkernel',
67     '../../blenlib',
68     '../../bmesh',
69     '../../depsgraph',
70     '../../editors/include',
71     '../../gpu',
72     '../../ikplugin',
73     '../../imbuf',
74     '../../makesdna',
75     '../../makesrna',
76     '../../physics',
77     '../../render/extern/include',
78     '../../windowmanager',
79     ]
80 incs = ' '.join(incs)
81
82 if env['WITH_BF_SMOKE']:
83     defs.append('WITH_SMOKE')
84
85 if env['WITH_BF_BULLET']:
86     defs.append('WITH_BULLET')
87     incs += ' #/intern/rigidbody'
88
89 if env['WITH_BF_OIIO']:
90     defs.append('WITH_OPENIMAGEIO')
91
92 if env['WITH_BF_OPENEXR']:
93     defs.append('WITH_OPENEXR')
94
95 if env['WITH_BF_TIFF']:
96     defs.append('WITH_TIFF')
97
98 if env['WITH_BF_OPENJPEG']:
99     defs.append('WITH_OPENJPEG')
100
101 if env['WITH_BF_DDS']:
102     defs.append('WITH_DDS')
103
104 if env['WITH_BF_CINEON']:
105     defs.append('WITH_CINEON')
106
107 if env['WITH_BF_HDR']:
108     defs.append('WITH_HDR')
109
110 if env['WITH_BF_FRAMESERVER']:
111     defs.append('WITH_FRAMESERVER')
112
113 if env['WITH_BF_FFMPEG']:
114     defs.append('WITH_FFMPEG')
115     incs += ' ' + env['BF_FFMPEG_INC'] + ' #/intern/ffmpeg'
116
117 if env['WITH_BF_QUICKTIME']:
118     defs.append('WITH_QUICKTIME')
119     incs += ' ../../quicktime'
120
121 if env['WITH_BF_GAMEENGINE']:
122     defs.append('WITH_GAMEENGINE')
123     
124 if env['WITH_BF_FFTW3']:
125     defs.append('WITH_FFTW3')
126
127 if env['WITH_BF_SDL']:
128     if env['WITH_BF_SDL_DYNLOAD']:
129         defs.append('WITH_SDL_DYNLOAD')
130         incs += ' #extern/sdlew/include'
131     defs.append('WITH_SDL')
132
133 if env['WITH_BF_OPENAL']:
134     defs.append('WITH_OPENAL')
135
136 if env['WITH_BF_JACK']:
137     defs.append('WITH_JACK')
138
139 if env['BF_UNIT_TEST']:
140     defs.append('UNIT_TEST')
141
142 if env['WITH_BF_PYTHON']:
143     defs.append('WITH_PYTHON')
144
145 if env['WITH_BF_COLLADA']:
146     defs.append('WITH_COLLADA')
147
148 if env['WITH_BF_CYCLES']:
149     defs.append('WITH_CYCLES')
150     if env['WITH_BF_CYCLES_DEBUG']:
151         defs.append('WITH_CYCLES_DEBUG')
152
153 if env['WITH_BF_FREESTYLE']:
154     defs.append('WITH_FREESTYLE')
155     incs += ' ../../freestyle'
156
157 if env['OURPLATFORM'] == 'linux':
158     cflags='-pthread'
159
160 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
161     incs += ' ' + env['BF_PTHREADS_INC']
162
163 if env['WITH_BF_INTERNATIONAL']:
164     defs.append('WITH_INTERNATIONAL')
165
166 if not env['BF_DEBUG']:
167     defs.append('NDEBUG')
168
169 makesrna_tool.Append(CPPDEFINES=defs)
170
171 makesrna_tool.Append (CPPPATH = Split(incs))
172
173 if env['OURPLATFORM'] == 'linuxcross':
174     USE_WINE = True # when cross compiling on linux 64bit this is useful
175 else:
176     USE_WINE = False
177
178 if not USE_WINE:
179     if env['OURPLATFORM'] == 'linuxcross':
180         makesdna_tool.Replace(CC='gcc')
181         makesdna_tool.Replace(AR='ar')
182         makesdna_tool.Replace(LINK='gcc')
183
184 if sys.platform != 'cygwin':
185     makesrna_tool.Append (CCFLAGS = cflags)
186 makesrna_tool.Append (CPPDEFINES = defines)
187
188 libdir = root_build_dir+'/lib'
189 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
190     libdir = '#' + libdir
191
192 makesrna_tool.Append (LIBPATH = libdir)
193
194 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
195 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
196 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
197
198 if env['BF_PROFILE']:
199     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
200
201 if env['BF_DEBUG']:
202     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
203     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
204     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
205         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
206
207 targetpath = root_build_dir+'/makesrna'
208 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
209     targetpath = '#' + targetpath
210
211 if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep:
212     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
213 else:
214     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
215
216 rna_dict = rna.Dictionary()
217 rna.Depends (generated_files, makesrna)
218
219 build_dir = Dir(".").abspath + os.sep
220     
221 if env['OURPLATFORM'] != 'linuxcross':
222     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw', 'win64-mingw'):
223         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
224     else:
225         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
226 else:
227     rna.Command (generated_files, '', ('', 'wine ')[USE_WINE] + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
228
229
230 obj = ['intern/rna_access.c']
231 for generated_file in generated_files:
232     obj += ['intern/' + generated_file]
233
234 Return ('obj')
235