forked from msorvig/qt-webassembly-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakedist.py
53 lines (43 loc) · 1.65 KB
/
makedist.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
48
49
50
51
52
import sys
import os
import shutil
if len(sys.argv) < 2:
print("Usage: makedist source dest")
sys.exit(1)
source = sys.argv[1]
dest = sys.argv[2]
print("Creating Qt WebAassembly examples distribution.")
print("Source: {0}".format(source))
print("Destination: {0}".format(dest))
# process each source dir
dirs = sorted(list([f for f in os.listdir(source) if os.path.isdir(os.path.join(source, f))]))
for dir in dirs:
sourcepath = os.path.join(source, dir)
destpath = os.path.join(dest, dir)
# find all files
files = [os.path.join(dp, f) for dp, dn, fn in os.walk(sourcepath) for f in fn]
# skip some intermediate build artifacts
def skipFile(path):
return path.endswith(".cpp") or path.endswith(".h") or path.endswith(".o") or path.endswith("Makefile") \
or path.endswith(".moc") or path.endswith(".stash") or path.endswith(".cache") or path.endswith(".qrc")
prunedFiles = list(filter(lambda x: not skipFile(x), files))
# copy all files
print("")
print("mkdir {0}".format(destpath))
os.makedirs(destpath, exist_ok=True)
for file in prunedFiles:
filePath = os.path.join(sourcepath, file)
print(" copy {0}".format(file))
shutil.copy(filePath, destpath)
# create index.html
html = "<html>\n<head><title>Qt For WebAssembly Examples</title></head>\n<body>\n"
html += "Qt For WebAssembly Examples<br><br>\n"
for dir in dirs:
html += "<a href={0}>{1}</a> <br>\n".format(dir + "/" + dir + ".html", dir)
html += "</body>\n</html>\n"
htmlfile = os.path.join(dest, "index.html")
print("")
print("Create {0}".format(htmlfile))
f = open(htmlfile, 'w')
f.write(html)
print("")