Merge of itasc branch. Project files, scons and cmake should be working. Makefile...
[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 makesrna_tool.Append(CPPDEFINES=defs)
78
79 makesrna_tool.Append (CPPPATH = Split(incs))
80
81 if env['OURPLATFORM'] == 'linuxcross':
82         USE_WINE = True # when cross compiling on linux 64bit this is useful
83 else:
84         USE_WINE = False
85
86 if not USE_WINE:
87         if env['OURPLATFORM'] == 'linuxcross':
88                 makesdna_tool.Replace(CC='gcc')
89                 makesdna_tool.Replace(AR='ar')
90                 makesdna_tool.Replace(LINK='gcc')
91
92 if sys.platform != 'cygwin':
93         makesrna_tool.Append (CCFLAGS = cflags)
94 makesrna_tool.Append (CPPDEFINES = defines)
95
96 libdir = root_build_dir+'/lib'
97 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
98         libdir = '#' + libdir
99
100 makesrna_tool.Append (LIBPATH = libdir)
101
102 makesrna_tool.Append( CFLAGS = env['CFLAGS'])
103 makesrna_tool.Append( CCFLAGS = env['CCFLAGS'])
104 makesrna_tool.Append( LINKFLAGS = env['PLATFORM_LINKFLAGS'])
105
106 if env['BF_PROFILE']:
107         makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
108
109 if env['BF_DEBUG']:
110         makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
111         makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
112         if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
113                 makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
114
115 targetpath = root_build_dir+'/makesrna'
116 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
117         targetpath = '#' + targetpath
118
119 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
120         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
121 else:
122         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
123
124 rna_dict = rna.Dictionary()
125 rna.Depends (generated_files, makesrna)
126
127 # this seems bad, how to retrieve it from scons?
128 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
129
130 if env['OURPLATFORM'] != 'linuxcross':
131         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
132                 rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
133         else:
134                 rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna "  + build_dir)
135 else:
136         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
137         
138         if USE_WINE:
139                 rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
140         else:
141                 rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
142
143
144 obj = ['intern/rna_access.c']
145 for generated_file in generated_files:
146         obj += ['intern/' + generated_file]
147
148 Return ('obj')
149