11 Import(
'MYAPP_VER_MAJOR')
12 Import(
'MYAPP_VER_MINOR')
13 Import(
'MYAPP_VER_COMPILATION')
14 Import(
'WEB_SRV_PREFIX WEB_SRV_HOST WEB_SRV_PORT WEB_CLIENT_HOST WEB_CLIENT_PORT')
16 def build_client_version( target, source, env):
17 file=open(str(target[0]),
'w')
18 file.write(
'client_ver_major = ' + MYAPP_VER_MAJOR +
'\n')
19 file.write(
'client_ver_minor = "' + MYAPP_VER_MINOR +
'"\n')
20 file.write(
'client_ver_compilation = ' + MYAPP_VER_COMPILATION +
'\n')
21 file.write(
'client_server_prefix = "' + WEB_SRV_PREFIX +
'"\n' )
25 def build_lighttpd_conf(target, source, env):
27 var.server_root = "{root_path}"
28 var.log_root = server_root
29 var.state_dir = server_root
30 var.home_dir = server_root
31 var.conf_dir = server_root
33 server.port = {client_port}
34 server.pid-file = state_dir + "/lighttpd.pid"
35 server.errorlog = log_root + "/lighttpd.log"
36 server.document-root = server_root
38 index-file.names = ( "index.html" )
41 ".html" => "text/html",
42 ".txt" => "text/plain",
43 ".jpg" => "image/jpeg",
44 ".png" => "image/png",
46 ".svg" => "image/svg+xml",
47 ".js" => "text/javascript"
50 static-file.exclude-extensions = (".py")
51 server.modules += ( "mod_proxy" )
52 #server.modules += ( "mod_accesslog" )
54 #### accesslog format (enable for using a proxy, like Pound, in front of Lighttpd)
55 #accesslog.format = "%h %t %r %>s %b time: %T [s]"
56 #accesslog.filename = log_root + "/access.log"
58 $HTTP["url"] =~ "^/{prefix}" {{
59 proxy.balance = "hash"
60 proxy.server = ( "" => (
61 "{prefix}" => ( "host" => "{server_host}", "port" => {server_port} )
65 with open(str(target[0]),
'w')
as file:
66 server_root_path = os.path.abspath(
'client')
67 clientConfig = configText.format(prefix=WEB_SRV_PREFIX,
68 server_host=WEB_SRV_HOST,
69 server_port=WEB_SRV_PORT,
70 client_host=WEB_CLIENT_HOST,
71 client_port=WEB_CLIENT_PORT,
72 root_path=server_root_path)
73 file.write(clientConfig)
78 client_ver_name =
'js/version.js'
79 env.Command(client_ver_name, [], build_client_version )
81 in_index =
'myapp.html'
82 out_index = os.path.normpath(
'index.html')
85 inc_dir=os.path.normpath(
'.'))
86 env.SideEffect(out_index, in_index )
87 env.SideEffect(
'file_include.pyc', in_index )
89 in_test =
'unit_test.html'
90 out_test =
'unit_test_out.html'
93 inc_dir=os.path.normpath(
'.'))
94 env.SideEffect(out_test, in_test )
95 env.SideEffect(
'file_include.pyc', in_test )
98 lighttd_conf =
'lighttpd.develop'
99 env.Command(lighttd_conf, [], build_lighttpd_conf )
100 env.SideEffect(
'lighttpd.log', lighttd_conf)
101 env.SideEffect(
'lighttpd.pid', lighttd_conf)
def file_substitution(in_file, out_file, inc_dir)