forked from davidc604/qt_moc_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qt_rcc.py
54 lines (42 loc) · 1.13 KB
/
qt_rcc.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
#!/usr/bin/env python
#
# qt_rcc.py
#
# This script takes the qrc files and uses the Qt RCC to generate the source file for resources.
# The output files will be named: {filename}.qrc.cc
#
# Copyright (c) Taehee Kim, 2017
import os
import sys
file_dir = os.path.dirname(__file__)
sys.path.append(file_dir)
import argparse
import subprocess
import sys
import qt_shared
def main(argv):
parser = argparse.ArgumentParser()
parser.add_argument("--input",
help="The .qrc file.")
parser.add_argument("--output",
help="The fullpath of the output file.")
options = parser.parse_args()
qt_shared.setupQTDIR()
# MOC exists in the PATH
fullpath = qt_shared.which('rcc')
assert fullpath
input = options.input
output = options.output
ret = subprocess.call([
fullpath,
input,
"-o", output
])
if ret != 0:
raise RuntimeError("Rcc has returned non-zero status: "
"{0} .".format(ret))
if __name__ == "__main__":
try:
main(sys.argv)
except RuntimeError as e:
sys.exit(1)