@@ -70,7 +70,7 @@ def make_static(env, target, source):
7070
7171 out_files = []
7272 for file in listdir (dist_dir ):
73- if isfile (join (dist_dir , file )):
73+ if isfile (join (dist_dir , file )) and ( file . endswith ( ".gz" ) or file . endswith ( ".png" ) or file . endswith ( ".jpg" )) :
7474 out_files .append (file )
7575
7676 # Sort files to make sure the order is constant
@@ -84,24 +84,27 @@ def make_static(env, target, source):
8484 output += "StaticFile staticFiles[] = {\n "
8585
8686 for out_file in out_files :
87- filetype = "TEXT"
88- if out_file .endswith (".css" ):
87+ filetype = None
88+ compress = True
89+ if out_file .endswith (".css.gz" ):
8990 filetype = "CSS"
90- elif out_file .endswith (".js" ):
91+ elif out_file .endswith (".js.gz " ):
9192 filetype = "JS"
92- elif out_file .endswith (".htm" ) or out_file .endswith (".html" ):
93+ elif out_file .endswith (".htm.gz " ) or out_file .endswith (".html.gz " ):
9394 filetype = "HTML"
9495 elif out_file .endswith (".jpg" ):
9596 filetype = "JPEG"
97+ compress = False
9698 elif out_file .endswith (".png" ):
9799 filetype = "PNG"
98- elif out_file .endswith (".svg" ):
100+ compress = False
101+ elif out_file .endswith (".svg.gz" ):
99102 filetype = "SVG"
100- elif out_file .endswith (".json" ):
103+ elif out_file .endswith (".json.gz " ):
101104 filetype = "JSON"
102105
103106 c_name = get_c_name (out_file )
104- output += " { \" /" + out_file + "\" , CONTENT_" + c_name + ", sizeof(CONTENT_" + c_name + ") - 1, _CONTENT_TYPE_" + filetype + ", CONTENT_" + c_name + "_ETAG },\n "
107+ output += " { \" /" + out_file . replace ( ".gz" , "" ) + "\" , CONTENT_" + c_name + ", sizeof(CONTENT_" + c_name + ") - 1, _CONTENT_TYPE_" + filetype + ", CONTENT_" + c_name + "_ETAG, " + ( "true" if compress else "false" ) + " },\n "
105108
106109 output += "};\n "
107110
@@ -115,7 +118,7 @@ def process_html_app(source, dest, env):
115118 web_server_static = join ("$BUILDSRC_DIR" , "web_server_static.cpp.o" )
116119
117120 for file in sorted (listdir (source )):
118- if isfile (join (source , file )):
121+ if isfile (join (source , file )) and ( file . endswith ( ".gz" ) or file . endswith ( ".png" ) or file . endswith ( ".jpg" )) :
119122 data_file = join (source , file )
120123 header_file = join (dest , "web_server." + file + ".h" )
121124 env .Command (header_file , data_file , data_to_header )
0 commit comments