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