RNA:
[blender.git] / source / blender / makesrna / intern / SConscript
1 #!/usr/bin/python
2 import sys
3 import os
4
5 Import ('env')
6 cflags = '-Wall'
7 defines = []
8 root_build_dir=env['BF_BUILDDIR']
9
10 source_files = env.Glob('*.c')
11
12 # making rna_access.c part of both makesrna and blender seems to
13 # give conflict, how to solve?
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 generated_files = [filename[:-2] + '_gen.c' for filename in generated_files]
21
22 makesrna_tool = env.Clone()
23 rna = env.Clone()
24 makesrna_tool.Append(CCFLAGS = '-DBASE_HEADER="\\"source/blender/makesrna/\\"" ')
25
26 makesrna_tool.Append (CPPPATH = ['#/intern/guardedalloc',
27                                  '../../blenlib',
28                                  '../../blenkernel',
29                                  '../../makesdna',
30                                  '../../makesrna',
31                                                                  '../../windowmanager'])
32
33 if env['OURPLATFORM'] == 'linuxcross':
34         USE_WINE = True # when cross compiling on linux 64bit this is useful
35 else:
36         USE_WINE = False
37
38 if not USE_WINE:
39         if env['OURPLATFORM'] == 'linuxcross':
40                 makesdna_tool.Replace(CC='gcc')
41                 makesdna_tool.Replace(AR='ar')
42                 makesdna_tool.Replace(LINK='gcc')
43
44 if sys.platform != 'cygwin':
45     makesrna_tool.Append (CCFLAGS = cflags)
46 makesrna_tool.Append (CPPDEFINES = defines)
47
48 libdir = root_build_dir+'/lib'
49 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
50         libdir = '#' + libdir
51
52 makesrna_tool.Append (LIBPATH = libdir)
53
54 if env['BF_PROFILE']:
55         makesrna_tool.Append (LINKFLAGS = env['BF_PROFILE_FLAGS'])
56
57 if env['BF_DEBUG']:
58         makesrna_tool.Append(CFLAGS = env['BF_DEBUG_CFLAGS'])
59         makesrna_tool.Append(CCFLAGS = env['BF_DEBUG_CCFLAGS'])
60         if env['OURPLATFORM'] == 'win32-vc':
61                 makesrna_tool.Append(LINKFLAGS = ['/DEBUG','/PDB:makesrna.pdb'])
62
63 targetpath = root_build_dir+'/makesrna'
64 if not (root_build_dir[0]==os.sep or root_build_dir[1]==':'):
65         targetpath = '#' + targetpath
66
67 if env['OURPLATFORM'] == 'linux2' and root_build_dir[0]==os.sep:
68     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
69 else:
70     makesrna = makesrna_tool.Program (target = targetpath, source = source_files, LIBS=['bf_guardedalloc', 'bf_dna'])
71
72 rna_dict = rna.Dictionary()
73 rna.Depends (generated_files, makesrna)
74
75 # this seems bad, how to retrieve it from scons?
76 build_dir = root_build_dir + '/source/blender/makesrna/intern/'
77
78 if env['OURPLATFORM'] != 'linuxcross':
79     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna " + build_dir)
80 else:
81     rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
82         
83     if USE_WINE:
84         rna.Command (generated_files, '', 'wine ' + root_build_dir+os.sep+"makesrna.exe "  + build_dir)
85     else:
86         rna.Command (generated_files, '', root_build_dir+os.sep+"makesrna.exe "  + build_dir)
87
88
89 obj = ['intern/rna_access.c']
90 for generated_file in generated_files:
91         obj += ['intern/' + generated_file]
92
93 Return ('obj')
94