File: SConstruct

package info (click to toggle)
yafray 0.0.7-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,036 kB
  • ctags: 3,461
  • sloc: cpp: 21,032; sh: 8,321; makefile: 205
file content (279 lines) | stat: -rw-r--r-- 8,520 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
import os
import shutil
import sys
import re

package='yafray'
version='0.0.7'
config_file='config.h'

def replaceInFile(remp, name, out):
	inf=open(name,'r')
	outf=open(out,'w')
	line=inf.readline();
	while line:
		for x in remp:
			line=re.sub(x[0],x[1],line)
		outf.write(line)
		line=inf.readline();
	outf.close();
	inf.close();

def removeFile(patt, dirname, names):
	for x in names:
		if re.compile(patt).search(x):
			if os.path.isdir(dirname+os.sep+x):
				shutil.rmtree(dirname+os.sep+x)
			else:
				os.unlink(dirname+os.sep+x)

def removeFiles(dir,patt):
	os.path.walk(dir,removeFile,patt)

comm='/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -build -p /tmp/yafray-888.pkg -f /Users/coala/jandro/package/Package_Root -r /Users/coala/jandro/package/Resources'

def makeosxpackage(target,source,env):
	print 'building OS X package ...'
	removeFiles('osxpaknocvs','CVS')
	removeFiles('osxpaknocvs','sconsign')
	pak=os.getcwd()+'/osxpaknocvs'
	pakroot=pak+'/Package_Root'
	pakresources=pak+'/Resources'
	pakinfo=pak+'/yafray.info'
	pakdes=pak+'/yafraydes.plist'
	pakmaker='/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker'
	pakresult=os.getcwd()+'/yafray-%s.pkg'%(version)
	pakresultstrip='yafray-%s.pkg'%(version)
	if os.path.isdir(pakresultstrip):
		shutil.rmtree(pakresultstrip)
	if os.path.isfile(pakresultstrip+'.zip'):
		os.unlink(pakresultstrip+'.zip')
	os.system(pakmaker+' -build -p '+pakresult+' -f '+pakroot+' -r '+pakresources+' -i '+pakinfo+' -d '+pakdes)
	os.system('zip -r '+pakresultstrip+'.zip '+pakresultstrip)
	#shutil.rmtree(pakresult)

def makewin32package(target,source,env):
	print 'building Win32 installer ...'
	pak=os.getcwd()+os.sep+'win32pak'
	template=pak+os.sep+'yafray_win_iss.tmpl'
	result=  pak+os.sep+'yafray_win.iss'
	if os.path.isfile(result):
		os.unlink(result)
	replaceInFile([ ['SRCROOT', pak] ], template, result)

def get_cflags(env):
	debug=ARGUMENTS.get('debug',0)
	debugdll=ARGUMENTS.get('debugdll',0)
	arch=ARGUMENTS.get('arch','')
	if sys.platform == 'win32':
		compiler = 'msvc'
#		env.Append(CPPDEFINES = ['MSVC'])
		flags='/DWIN32 /D_WIN32 /D_USE_MATH_DEFINES /EHsc /DHAVE_CONFIG_H'
		if debug:
			flags+=' /Zi /GS /RTC1 /Yd /MTd'
		else:
			flags+=' /Ox /MT'
		if arch!='':
			flags+=' /'+arch
	else:
		flags='-Wall -DHAVE_CONFIG_H -D_PTHREADS'
		if debug:
			flags+=' -O3 -ffast-math -ggdb'
		else:
			flags+=' -O3 -ffast-math -fomit-frame-pointer'
		if debugdll:
			flags+=' -DDEBUGDLL'
		if arch!='':
			flags+=' -march='+arch
	return flags

def write_conf():
	have_jpeg=1
	have_pthread=1
	have_zlib=1
	double_coords=0
	yafray_namespace='yafray'
	if double_coords :
		min_raydist="0.000000000005"
	else:
		min_raydist="0.00005"
	
	if sys.platform == 'win32':
		compiler='MSVC'
	else:
		compiler='GCC'

	if os.path.exists(config_file):
		print "Using config file: "+config_file
	else:
		print "Creating config file:"+config_file
		config=open(config_file,'w')
		config.write("//Config file header created by scons\n\n")
		config.write("#ifndef __CONFIG_H\n")
		config.write("#define __CONFIG_H\n")
		config.write("#define "+compiler+"\n")
		config.write("#define HAVE_JPEG %d\n"%(have_jpeg))
		if compiler != 'MSVC':
			config.write("#define HAVE_PTHREAD %d\n"%(have_pthread))
		config.write("#define HAVE_ZLIB %d\n"%(have_zlib))
		if sys.platform == 'darwin' :
			config.write("#define LIBPATH \"/usr/local/lib\"\n")
		else:
			config.write("#define LIBPATH \"%s\"\n"%(lib_path))
		config.write("#define MIN_RAYDIST %s\n"%(min_raydist))
		config.write("#define PACKAGE \"%s\"\n"%(package))
		config.write("#define VERSION \"%s\"\n"%(version))
		config.write("\n")
		config.write("#define __BEGIN_YAFRAY namespace "+yafray_namespace+" {\n");
		config.write("#define __END_YAFRAY }\n")
		config.write("\n")
		config.write("__BEGIN_YAFRAY\n");
		config.write("typedef float CFLOAT;\n");
		config.write("typedef float GFLOAT;\n");
		if double_coords:
			config.write("typedef double PFLOAT;\n");
		else:
			config.write("typedef float PFLOAT;\n");
		config.write("__END_YAFRAY\n");

		if sys.platform == 'win32' :
			config.write("#ifdef BUILDING_YAFRAYCORE\n")
			config.write("#define YAFRAYCORE_EXPORT __declspec(dllexport)\n")
			config.write("#else \n")
			config.write("#define YAFRAYCORE_EXPORT __declspec(dllimport)\n")
			config.write("#endif \n")

			config.write("#ifdef BUILDING_YAFRAYPLUGIN\n")
			config.write("#define YAFRAYPLUGIN_EXPORT __declspec(dllexport)\n")
			config.write("#else \n")
			config.write("#define YAFRAYPLUGIN_EXPORT __declspec(dllimport)\n")
			config.write("#endif \n")
		else :
			config.write("#define YAFRAYPLUGIN_EXPORT\n")
			config.write("#define YAFRAYCORE_EXPORT\n")

		config.write("#endif\n");
		config.close()

prefix=ARGUMENTS.get('prefix','/usr/local')

if sys.platform == 'darwin' :
	if os.path.isdir('osxpak'):
		os.rename('osxpak','osxpaknocvs')
	lib_path=os.getcwd()+'/osxpaknocvs/Package_Root/usr/local/lib'
	plugin_path=os.getcwd()+'/osxpaknocvs/Package_Root/usr/local/lib/yafray'
	bin_path=os.getcwd()+'/osxpaknocvs/Package_Root/usr/local/bin'
	conf_path=os.getcwd()+'/osxpaknocvs/Package_Root/private/etc'
elif sys.platform != 'win32' :
	lib_path=prefix+"/lib"
	plugin_path=prefix+"/lib/yafray"
	bin_path=prefix+"/bin"
	conf_path=prefix+"/etc"
else:
	cwd = os.getcwd()
	prefix=ARGUMENTS.get('prefix',cwd + os.sep + 'win32pak' )
	lib_path=prefix
	plugin_path=prefix+ os.sep+"plugins"
	bin_path=prefix
	conf_path=prefix

print "Stuff will be installed under:"
print prefix
print bin_path
print lib_path
print plugin_path
print conf_path

write_conf();

common_env=Environment(ENV=os.environ);
cxxflags=get_cflags(common_env);

if sys.platform == 'darwin':
	jpeglib_include=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'osx'+os.sep+'jpeg'+os.sep+'include'
	jpeglib_lib=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'osx'+os.sep+'jpeg'+os.sep+'lib'
	sharedlib_env=common_env.Copy(SHLINKFLAGS='-dynamic -dynamiclib',SHLIBSUFFIX='.dylib')
	plugin_env=common_env.Copy(SHLINKFLAGS='-Wall -bundle',CPPPATH=jpeglib_include,LIBPATH=jpeglib_lib)
	program_env=common_env.Copy()
elif sys.platform == 'win32':
	zlib_include=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'msvc'+os.sep+'zlib'+os.sep+'include'
	zlib_lib=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'msvc'+os.sep+'zlib'+os.sep+'lib'
	jpeglib_include=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'msvc'+os.sep+'jpeg'+os.sep+'include'
	jpeglib_lib=os.getcwd()+os.sep+os.pardir+os.sep+'libs'+os.sep+'msvc'+os.sep+'jpeg'+os.sep+'lib'

	sharedlib_env=common_env.Copy(CPPPATH=zlib_include,LIBPATH=zlib_lib)
	plugin_env=common_env.Copy(CPPPATH=jpeglib_include,LIBPATH=jpeglib_lib)
	program_env=common_env.Copy(CPPPATH=zlib_include,LIBPATH=zlib_lib)
elif sys.platform == 'cygwin':
	sharedlib_env=common_env.Copy(SHLINKFLAGS='-shared -Wl,--enable-auto-import')
	plugin_env=common_env.Copy(SHLINKFLAGS='-shared -Wl,--export-all -Wl,--enable-auto-import')
	program_env=common_env.Copy()
elif sys.platform == 'sunos5':
	sharedlib_env=common_env.Copy(CXX='g++')
	plugin_env=common_env.Copy(CXX='g++')
	program_env=common_env.Copy(CXX='g++')
else:
	sharedlib_env=common_env.Copy()
	plugin_env=common_env.Copy()
	program_env=common_env.Copy()

if sys.platform == 'cygwin':
	dynload_lib=''
elif sys.platform == 'win32':
	dynload_lib=''
else:
	dynload_lib='dl'


if sys.platform == 'sunos5':
	threads_lib= [ 'pthread' , 'rt' ]
	z_lib=['z']
	jpeg_lib=['jpeg']
elif sys.platform == 'win32':
	threads_lib= [ ]
	z_lib=['zlib']
	jpeg_lib=['libjpeg']
else:
	threads_lib= [ 'pthread' ]
	z_lib=['z']
	jpeg_lib=['jpeg']


#sharedlib_env.SourceSignatures('timestamp')
#plugin_env.SourceSignatures('timestamp')
#program_env.SourceSignatures('timestamp')


Export('cxxflags')
Export('prefix')
Export('bin_path')
Export('lib_path')
Export('plugin_path')
Export('conf_path')
Export('sharedlib_env')
Export('plugin_env')
Export('program_env')
Export('dynload_lib')
Export('threads_lib')
Export('z_lib')
Export('jpeg_lib')

SConscript(['src/SConscript'])

Alias('install',['install_core',
								 'install_lights',
								 'install_shaders',
								 'install_backgs',
								 'install_interface',
								 'install_loader'])

if sys.platform == 'darwin':
	Default('install')
	Depends('osxpackage','install')
	Command('osxpackage','install',makeosxpackage)
elif sys.platform == 'win32':
	Default('install')
	Depends('win32installer','install')
	Command('win32installer','install',makewin32package)