bioweb  0.09.92
C++/Python(django)/JavaScript(angularJS) framework
SConscript
Go to the documentation of this file.
1 # -*- mode: Python; -*-
2 
3 ## @file client/SConscript
4 # @brief scons build for client part (JavaScript, AngularJS)
5 
6 import os
7 import file_include
8 
9 Import('env')
10 
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')
15 
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' )
22  file.close()
23  return
24 
25 def build_lighttpd_conf(target, source, env):
26  configText = """
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
32 
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
37 
38 index-file.names = ( "index.html" )
39 
40 mimetype.assign = (
41  ".html" => "text/html",
42  ".txt" => "text/plain",
43  ".jpg" => "image/jpeg",
44  ".png" => "image/png",
45  ".css" => "text/css",
46  ".svg" => "image/svg+xml",
47  ".js" => "text/javascript"
48 )
49 
50 static-file.exclude-extensions = (".py")
51 server.modules += ( "mod_proxy" )
52 #server.modules += ( "mod_accesslog" )
53 
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"
57 
58 $HTTP["url"] =~ "^/{prefix}" {{
59  proxy.balance = "hash"
60  proxy.server = ( "" => (
61  "{prefix}" => ( "host" => "{server_host}", "port" => {server_port} )
62  ))
63 }}
64 """
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)
74  return
75 
76 
77 # #install client files
78 client_ver_name = 'js/version.js'
79 env.Command(client_ver_name, [], build_client_version )
80 
81 in_index = 'myapp.html'
82 out_index = os.path.normpath('index.html')
83 file_include.file_substitution(in_file=in_index,
84  out_file=out_index,
85  inc_dir=os.path.normpath('.'))
86 env.SideEffect(out_index, in_index )
87 env.SideEffect('file_include.pyc', in_index )
88 
89 in_test = 'unit_test.html'
90 out_test = 'unit_test_out.html'
91 file_include.file_substitution(in_file=in_test,
92  out_file=out_test,
93  inc_dir=os.path.normpath('.'))
94 env.SideEffect(out_test, in_test )
95 env.SideEffect('file_include.pyc', in_test )
96 
97 #build lighttpd config
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)
Definition: file_include.py:7