rename most scons build targets to match cmake
[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'
33 incs += ' ../../imbuf ../../makesdna ../../makesrna ../../ikplugin'
34 incs += ' ../../windowmanager ../../editors/include'
35 incs += ' ../../render/extern/include'
36 incs += ' #/intern/audaspace/intern '
37
38 if env['WITH_BF_OPENEXR']:
39         defs.append('WITH_OPENEXR')
40
41 if env['WITH_BF_TIFF']:
42     defs.append('WITH_TIFF')
43
44 if env['WITH_BF_OPENJPEG']:
45         defs.append('WITH_OPENJPEG')
46
47 if env['WITH_BF_DDS']:
48         defs.append('WITH_DDS')
49
50 if env['WITH_BF_CINEON']:
51         defs.append('WITH_CINEON')
52
53 if env['WITH_BF_HDR']:
54         defs.append('WITH_HDR')
55
56 if env['WITH_BF_FFMPEG']:
57         defs.append('WITH_FFMPEG')
58         incs += ' ' + env['BF_FFMPEG_INC']
59
60 if env['WITH_BF_OGG']:
61         defs.append('WITH_OGG')
62
63 if env['WITH_BF_QUICKTIME']:
64         defs.append('WITH_QUICKTIME')
65         incs += ' ../../quicktime'
66
67 if env['WITH_BF_LCMS']:
68         defs.append('WITH_LCMS')
69
70 if env['WITH_BF_GAMEENGINE']:
71         defs.append('GAMEBLENDER=1')
72         
73 if env['WITH_BF_FFTW3']:
74     defs.append('FFTW3=1')
75
76 if env['WITH_BF_SDL']:
77     defs.append('WITH_SDL')
78
79 if env['WITH_BF_OPENAL']:
80     defs.append('WITH_OPENAL')
81
82 if env['WITH_BF_JACK']:
83     defs.append('WITH_JACK')
84
85 if env['BF_UNIT_TEST']:
86         defs.append('UNIT_TEST')
87
88 if not env['WITH_BF_PYTHON']:
89         defs.append('DISABLE_PYTHON')
90
91 if env['OURPLATFORM'] == 'linux2':
92         cflags='-pthread'
93         incs += ' ../../../extern/binreloc/include'
94
95 if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'):
96         incs += ' ' + env['BF_PTHREADS_INC']
97
98 makesrna_tool.Append(CPPDEFINES=defs)
99
100 makesrna_tool.Append (CPPPATH = Split(incs))
101
102 if env['OURPLATFORM'] == 'linuxcross':
103         USE_WINE = True # when cross compiling on linux 64bit this is useful
104 else:
105         USE_WINE = False
106
107 if not USE_WINE:
108         if env['OURPLATFORM'] == 'linuxcross':
109                 makesdna_tool.Replace(CC='gcc')
110                 makesdna_tool.Replace(AR='ar')
111                 makesdna_tool.Replace(LINK='gcc')
112
113 if sys.platform != 'cygwin':
114         makesrna_tool.Append (CCFLAGS = cflags)
115 makesrna_tool.Append (CPPDEFINES = defines)
116
117 libdir = root_build_dir+'/lib'
118 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
119         libdir = '#' + libdir
120
121 makesrna_tool.Append (LIBPATH = libdir)
122
123 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
124 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
125 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
126
127 if env['BF_PROFILE']:
128         makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
129
130 if env['BF_DEBUG']:
131         makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
132         makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
133         if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
134                 makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
135
136 targetpath = root_build_dir+'/makesrna'
137 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
138         targetpath = '#' + targetpath
139
140 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
141         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
142 else:
143         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_intern_guardedalloc', 'bf_dna', 'bf_blenlib'])
144
145 rna_dict = rna.Dictionary()
146 rna.Depends (generated_files, makesrna)
147
148 # this seems bad, how to retrieve it from scons?
149 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
150         
151 if env['OURPLATFORM'] != 'linuxcross':
152         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
153                 rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
154         else:
155                 rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna\" \""  + build_dir + '"' )
156 else:
157         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
158         
159         if USE_WINE:
160                 rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
161         else:
162                 rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
163
164
165 obj = ['intern/rna_access.c']
166 for generated_file in generated_files:
167         obj += ['intern/' + generated_file]
168
169 Return ('obj')
170