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