00001 import os
00002 import sys
00003
00004 package='YafaRay'
00005 version='0.1.1'
00006 config_file='yafray_config.h'
00007 user_config_file='yafray_user_config.h'
00008
00009
00010 def write_conf(env):
00011 double_coords=0
00012 yafray_namespace='yafray'
00013 if double_coords :
00014 min_raydist="0.000000000005"
00015 else:
00016 min_raydist="0.00005"
00017
00018 print "Creating config file:"+config_file
00019 config=open(config_file,'w')
00020 config.write("//Config file header created by scons\n\n")
00021 config.write("#ifndef Y_CONFIG_H\n")
00022 config.write("#define Y_CONFIG_H\n")
00023 config.write("#include \"yafray_constants.h\"\n\n")
00024 config.write("#define MIN_RAYDIST %s\n"%(min_raydist))
00025 config.write("#define YAF_SHADOW_BIAS 0.0005\n")
00026 config.write("\n")
00027 config.write("#define Y_DEBUG(DebugLevel) if (DebugLevel <= env->Debug) std::cout << \"DEBUG[\"<< DebugLevel << \"]: \"\n")
00028 config.write("#define Y_INFO std::cout << \"INFO: \"\n")
00029 config.write("#define Y_WARNING std::cout << \"WARNING: \"\n")
00030 config.write("#define Y_ERROR std::cout << \"ERROR: \"\n")
00031 config.write("\n")
00032
00033 config.write("__BEGIN_YAFRAY\n");
00034 config.write("typedef float CFLOAT;\n");
00035 config.write("typedef float GFLOAT;\n");
00036 if double_coords:
00037 config.write("typedef double PFLOAT;\n");
00038 else:
00039 config.write("typedef float PFLOAT;\n");
00040 config.write("__END_YAFRAY\n");
00041 if os.path.exists(user_config_file):
00042 print "Using user config file: " + user_config_file
00043 else:
00044 print "Creating user config file: " + user_config_file
00045 config_user=open(user_config_file,'w')
00046 config_user.write("// Add extra information to the version string of this build\n")
00047 config_user.write("#define YAF_EXTRA_VERSION \n\n")
00048 config_user.write("// put code/defines outside of the yafray namespace here\n\n")
00049 config_user.write("__BEGIN_YAFRAY\n")
00050 config_user.write("// put code/defines inside the yafray namespace here\n\n")
00051 config_user.write("__END_YAFRAY\n\n")
00052
00053 config.write("#include \"" + user_config_file + "\"\n");
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 config.write("#endif\n");
00072 config.close()
00073
00074 def get_extra_version():
00075 extra_version = ""
00076 if os.path.exists(user_config_file):
00077 data = open(user_config_file).readlines()
00078 for line in data:
00079 strings = line.split()
00080 if "YAF_EXTRA_VERSION" in strings:
00081 if len(strings) > 2:
00082 for i in range(2,len(strings)):
00083 extra_version += " " + strings[i]
00084 return extra_version
00085 return ""
00086
00087 def write_rev(env):
00088 rev = os.popen('svnversion').readline().strip()
00089 if rev == 'exported' or rev == '': rev = "N/A"
00090 rev_string = rev
00091
00092
00093
00094
00095
00096 rev_string += get_extra_version()
00097
00098 rev_file=open('yaf_revision.h','w')
00099 rev_file.write("#ifndef Y_REV_H\n")
00100 rev_file.write("#define Y_REV_H\n")
00101 rev_file.write("#define YAF_SVN_REV \"" + rev_string +"\"\n")
00102
00103 rev_file.write("#define LIBPATH \"%s\"\n"%( env.subst('$YF_LIBOUT') ) )
00104 rev_file.write("#define Y_PLUGINPATH \"%s\"\n#endif\n"%( env.subst('$YF_PLUGINPATH') ) )
00105 rev_file.close()
00106