svn merge ^/trunk/blender -r43482:43524
[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 defs.append('WITH_FRAMESERVER')  # TODO, make optional
58
59 if env['WITH_BF_FFMPEG']:
60     defs.append('WITH_FFMPEG')
61     incs += ' ' + env['BF_FFMPEG_INC']
62
63 if env['WITH_BF_QUICKTIME']:
64     defs.append('WITH_QUICKTIME')
65     incs += ' ../../quicktime'
66
67 if env['WITH_BF_GAMEENGINE']:
68     defs.append('WITH_GAMEENGINE')
69     
70 if env['WITH_BF_FFTW3']:
71     defs.append('WITH_FFTW3')
72
73 if env['WITH_BF_SDL']:
74     defs.append('WITH_SDL')
75
76 if env['WITH_BF_OPENAL']:
77     defs.append('WITH_OPENAL')
78
79 if env['WITH_BF_JACK']:
80     defs.append('WITH_JACK')
81
82 if env['BF_UNIT_TEST']:
83     defs.append('UNIT_TEST')
84
85 if env['WITH_BF_PYTHON']:
86     defs.append('WITH_PYTHON')
87
88 if env['WITH_BF_COLLADA']:
89     defs.append('WITH_COLLADA')
90
91 if env['WITH_BF_CYCLES']:
92     defs.append('WITH_CYCLES')
93
94 if env['OURPLATFORM'] == 'linux':
95     cflags='-pthread'
96     incs += ' ../../../extern/binreloc/include'
97
98 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
99     incs += ' ' + env['BF_PTHREADS_INC']
100
101 if env['WITH_BF_INTERNATIONAL']:
102     defs.append('WITH_INTERNATIONAL')
103
104 if not env['BF_DEBUG']:
105     defs.append('NDEBUG')
106
107
108 makesrna_tool.Append(CPPDEFINES=defs)
109
110 makesrna_tool.Append (CPPPATH = Split(incs))
111
112 if env['OURPLATFORM'] == 'linuxcross':
113     USE_WINE = True # when cross compiling on linux 64bit this is useful
114 else:
115     USE_WINE = False
116
117 if not USE_WINE:
118     if env['OURPLATFORM'] == 'linuxcross':
119         makesdna_tool.Replace(CC='gcc')
120         makesdna_tool.Replace(AR='ar')
121         makesdna_tool.Replace(LINK='gcc')
122
123 if sys.platform != 'cygwin':
124     makesrna_tool.Append (CCFLAGS = cflags)
125 makesrna_tool.Append (CPPDEFINES = defines)
126
127 libdir = root_build_dir+'/lib'
128 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
129     libdir = '#' + libdir
130
131 makesrna_tool.Append (LIBPATH = libdir)
132
133 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
134 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
135 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
136
137 if env['BF_PROFILE']:
138     makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
139
140 if env['BF_DEBUG']:
141     makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
142     makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
143     if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
144         makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
145
146 targetpath = root_build_dir+'/makesrna'
147 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
148     targetpath = '#' + targetpath
149
150 if env['OURPLATFORM'] == 'linux' and root_build_dir[0]==os.sep:
151     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
152 else:
153     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
154
155 rna_dict = rna.Dictionary()
156 rna.Depends (generated_files, makesrna)
157
158 # this seems bad, how to retrieve it from scons?
159 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
160     
161 if env['OURPLATFORM'] != 'linuxcross':
162     if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
163         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
164     else:
165         rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
166 else:
167     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
168     
169     if USE_WINE:
170         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
171     else:
172         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
173
174
175 obj = ['intern/rna_access.c']
176 for generated_file in generated_files:
177     obj += ['intern/' + generated_file]
178
179 Return ('obj')
180