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