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