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