svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22704:22717
[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'
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 makesrna_tool.Append(CPPDEFINES=defs)
66
67 makesrna_tool.Append (CPPPATH = Split(incs))
68
69 if env['OURPLATFORM'] == 'linuxcross':
70         USE_WINE = True # when cross compiling on linux 64bit this is useful
71 else:
72         USE_WINE = False
73
74 if not USE_WINE:
75         if env['OURPLATFORM'] == 'linuxcross':
76                 makesdna_tool.Replace(CC='gcc')
77                 makesdna_tool.Replace(AR='ar')
78                 makesdna_tool.Replace(LINK='gcc')
79
80 if sys.platform != 'cygwin':
81         makesrna_tool.Append (CCFLAGS = cflags)
82 makesrna_tool.Append (CPPDEFINES = defines)
83
84 libdir = root_build_dir+'/lib'
85 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
86         libdir = '#' + libdir
87
88 makesrna_tool.Append (LIBPATH = libdir)
89
90 if env['BF_PROFILE']:
91         makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
92
93 if env['BF_DEBUG']:
94         makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
95         makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
96         if env['OURPLATFORM'] in ('win32-vc','win64-vc'):
97                 makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
98
99 targetpath = root_build_dir+'/makesrna'
100 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
101         targetpath = '#' + targetpath
102
103 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
104         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
105 else:
106         makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
107
108 rna_dict = rna.Dictionary()
109 rna.Depends (generated_files, makesrna)
110
111 # this seems bad, how to retrieve it from scons?
112 build_dir = root_build_dir + os.sep +'source' + os.sep + 'blender' + os.sep + 'makesrna' + os.sep + 'intern' + os.sep
113
114 if env['OURPLATFORM'] != 'linuxcross':
115         if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
116                 rna.Command (generated_files, '', "\"" + root_build_dir+os.sep+"makesrna.exe\" \""  + build_dir )
117         else:
118                 rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna "  + build_dir)
119 else:
120         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
121         
122         if USE_WINE:
123                 rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
124         else:
125                 rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
126
127
128 obj = ['intern/rna_access.c']
129 for generated_file in generated_files:
130         obj += ['intern/' + generated_file]
131
132 Return ('obj')
133