-
Notifications
You must be signed in to change notification settings - Fork 109
/
build-windows.py
69 lines (65 loc) · 2.86 KB
/
build-windows.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -----------------------------------------------------------------------------
# Name: CAJ2PDF Qt
# Description: CAJ 转 PDF 转换器
# Author: Sainnhe Park <[email protected]>
# Website: https://caj2pdf-qt.sainnhe.dev
# License: GPL3
# -----------------------------------------------------------------------------
import os
import sys
from os.path import join
from shutil import copyfile, move
import subprocess
# update submodules
workdir = os.getcwd()
os.chdir(workdir)
subprocess.run(["git", "submodule", "update",
"--init", "--recursive", "caj2pdf"])
subprocess.run(["git", "clean", "-dfx", "--", "."])
# build cli
workdir_cli = join(workdir, "caj2pdf")
os.chdir(workdir_cli)
subprocess.run(["git", "clean", "-dfx", "--", "."])
subprocess.run(["git", "checkout", "--", "."])
subprocess.run(["git", "apply", "../patches/caj2pdf.diff"])
subprocess.run([sys.executable, "-m", "venv", "venv"])
subprocess.run([".\\venv\\Scripts\\python.exe", "-m", "pip", "install",
"-r", "requirements.txt", "-i", "https://mirrors.aliyun.com/pypi/simple"])
subprocess.run([".\\venv\\Scripts\\python.exe", "-m", "pip", "install",
"pyinstaller", "-i", "https://mirrors.aliyun.com/pypi/simple"])
subprocess.run([".\\venv\\Scripts\\pyinstaller.exe", "-F", "caj2pdf"])
subprocess.run(["git", "checkout", "--", "."])
# build project
os.chdir(workdir)
subprocess.run(["git", "clean", "-dfx", "--", "."])
qt_path = sys.argv[1]
cmake_path = qt_path + "\\Tools\\CMake_64\\bin"
ninja_path = qt_path + "\\Tools\\Ninja"
os.environ["PATH"] = cmake_path + ";" + ninja_path + ";" + os.environ["PATH"]
dist_dir = join(workdir, "dist")
os.mkdir(dist_dir)
dist_external_dir = join(dist_dir, "external")
os.mkdir(dist_external_dir)
build_dir = join(workdir, "build")
os.mkdir(build_dir)
os.chdir(workdir)
subprocess.run(["windres", "app.rc", "-o", "build\\app.o"])
os.chdir(build_dir)
subprocess.run(["cmake", "-G", "Ninja", "-DCMAKE_BUILD_TYPE=Release", ".."])
subprocess.run(["cmake", "--build", ".", "--parallel", str(os.cpu_count())])
os.chdir(dist_dir)
move(join(build_dir, "caj2pdf.exe"),
dist_dir)
move(join(join(workdir_cli, "dist"), "caj2pdf.exe"),
join(dist_external_dir, "caj2pdf.exe"))
if sys.argv[2] == "64bit":
copyfile(join(join(join(workdir_cli, "lib"), "bin"), "libjbigdec-w64.dll"),
join(join(dist_dir, "external"), "libjbigdec.dll"))
copyfile(join(join(join(workdir_cli, "lib"), "bin"), "libjbig2codec-w64.dll"),
join(join(dist_dir, "external"), "libjbig2codec.dll"))
else:
copyfile(join(join(join(workdir_cli, "lib"), "bin"), "libjbigdec-w32.dll"),
join(join(dist_dir, "external"), "libjbigdec.dll"))
copyfile(join(join(join(workdir_cli, "lib"), "bin"), "libjbig2codec-w32.dll"),
join(join(dist_dir, "external"), "libjbig2codec.dll"))
subprocess.run(["windeployqt", "caj2pdf.exe"])