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