File: configio.py

package info (click to toggle)
yafray 0.0.9+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 1,856 kB
  • ctags: 4,334
  • sloc: cpp: 26,560; python: 418; makefile: 208; sh: 118
file content (71 lines) | stat: -rw-r--r-- 2,312 bytes parent folder | download | duplicates (3)
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
import os
import sys
from globalinfo import *

def write_conf(C):
	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")
		
		# !EXR!
		config.write("#define HAVE_EXR %d\n"%(C.exr.present));
		
		config.write("#define HAVE_JPEG %d\n"%(C.jpeg.present))
		config.write("#define HAVE_PTHREAD %d\n"%(C.pthread.present))
		config.write("#define HAVE_ZLIB %d\n"%(C.zlib.present))
		if sys.platform == 'darwin' :  # STUPID HARDCODED PATH FIXME
			config.write("#define LIBPATH \"/usr/local/lib\"\n")
		else:
			config.write("#define LIBPATH \"%s\"\n"%(C.libpath))
		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()