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