-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre_compile_script.py
47 lines (38 loc) · 1.38 KB
/
pre_compile_script.py
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
"""Generate the CSS and JS files to be included in binary."""
char_limit = 16300
n_script_strings = 4 # Split JS into 4 strings for MSVC compiler
print("Making style.h ...")
css_in = open("./src/library_explorer/src/style.css")
css_string = css_in.read()
css_in.close()
print("CSS input is {} characters long".format(len(css_string)))
css_out = open("./src/library_explorer/strings/style.txt", "w")
css_out.write("R\"=====(<style>{}</style>)=====\"".format(css_string))
css_out.close()
print("style.txt success")
print("Making script(s).txt ...")
js_in = open("./src/library_explorer/src/script.js")
js_string = js_in.read()
js_in.close()
js_string_len = len(js_string)
print("JS input is {} characters long".format(js_string_len))
n = 1 # start at script_1.h
i = 0 # start at index 0 of the string
while n <= n_script_strings:
c = 0 # init character counter
js_out = open("./src/library_explorer/strings/script_{}.txt".format(n), "w")
js_out.write("R\"=====(")
if n == 1: # open script tag on first file
js_out.write("<script>")
while c < char_limit:
if i >= js_string_len:
break
js_out.write(js_string[i])
c += 1 # count characters written
i += 1
if n == n_script_strings:
js_out.write("</script>")
js_out.write(")=====\"")
print("script_{}.txt success".format(n))
n += 1
print("Pre-compile success")