-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathQssEditor-common.pri
186 lines (147 loc) · 4.86 KB
/
QssEditor-common.pri
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
isEmpty(TARGET) {
error("TARGET is not defined")
}
!win32:!unix {
error("QSS Editor must be compiled on Windows or Linux/Mac")
}
greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets
INCLUDEPATH += .
DEPENDPATH += .
#QMAKE_CXXFLAGS += -flto
#QMAKE_LFLAGS += -flto
# for testing
#QMAKE_CXXFLAGS += -pedantic -std=c++11
win32 {
LANGUAGES=$$system(dir /B \"$${_PRO_FILE_PWD_}\\ts\\*.ts\")
} else {
LANGUAGES=$$system(find \"$${_PRO_FILE_PWD_}/ts/\" -name \"*.ts\" -printf \"%f \")
}
LANGUAGES=$$replace(LANGUAGES, .ts, )
CONFIG += warn_on
QMAKE_CXXFLAGS_WARN_ON *= -Wextra
VERSION=$$sprintf("%1.%2.%3", $$NVER1, $$NVER2, $$NVER3)
DEFINES += NVER1=$$NVER1
DEFINES += NVER2=$$NVER2
DEFINES += NVER3=$$NVER3
DEFINES += NVER_STRING=$$sprintf("\"\\\"%1\\\"\"", $$VERSION)
DEFINES += TARGET=$$TARGET
DEFINES += TARGET_STRING=$$sprintf("\"\\\"%1\\\"\"", $$TARGET)
# require at least Windows XP
win32:DEFINES += _WIN32_WINNT=0x0501 WINVER=0x0501
# use fast string concat
DEFINES *= QT_USE_QSTRINGBUILDER
contains(QMAKE_HOST.arch, x86_64) {
HOST64="-x86_64"
}
win32 {
SEP="\\"
} unix {
SEP="/"
}
# search an executable in PATH
defineReplace(findexeWin32) {
return ( $$system(for %i in ($${1}.exe) do @echo. %~$PATH:i) )
}
defineReplace(findexeUnix) {
return ( $$system(which $$1) )
}
# escape command to allow multiple lines in Makefile
defineReplace(mle) {
return ( $$1$$escape_expand(\\n\\t) )
}
# check for svn
win32 {
SVN=$$findexeWin32("svn")
} unix {
SVN=$$findexeUnix("svn")
}
# check for gcc
win32 {
GCC=$$findexeWin32("gcc")
} unix {
GCC=$$findexeUnix("gcc")
}
GCCDIR=$$dirname(GCC)
win32:isEmpty(GCC) {
error("MinGW is not found in PATH")
}
for(ts, LANGUAGES) {
win32 {
LRELEASE="$$[QT_INSTALL_BINS]\\lrelease.exe"
LUPDATE="$$[QT_INSTALL_BINS]\\lupdate.exe"
MTRANSLATIONS += $${_PRO_FILE_PWD_}\\ts\\$${ts}.ts
} else {
LRELEASE=$$system(which lrelease)
LUPDATE=$$system(which lupdate)
MTRANSLATIONS += $${_PRO_FILE_PWD_}/ts/$${ts}.ts
}
}
message(Translations: $$MTRANSLATIONS)
# copy translations
!isEmpty(LUPDATE) {
message("lupdate is found, will update the translations")
QMAKE_POST_LINK += $$mle($$LUPDATE -no-obsolete $$_PRO_FILE_ -ts $$MTRANSLATIONS)
}
# lrelease for each ts
!isEmpty(LRELEASE) {
win32 {
TRANSLATIONS_DIR="$${OUT_PWD}/$(DESTDIR_TARGET)/../translations"
QMAKE_POST_LINK += $$mle(if not exist \"$$TRANSLATIONS_DIR\" mkdir \"$$TRANSLATIONS_DIR\")
for(ts, LANGUAGES) {
QMAKE_POST_LINK += $$mle($$LRELEASE \"$${_PRO_FILE_PWD_}\\ts\\$${ts}.ts\" -qm \"$$TRANSLATIONS_DIR\\$${ts}.qm\")
QMAKE_POST_LINK += $$mle(copy /Y \"$${_PRO_FILE_PWD_}\\ts\\$${ts}.png\" \"$$TRANSLATIONS_DIR\\$${ts}.png\")
}
QMAKE_POST_LINK += $$mle(copy /Y \"$${_PRO_FILE_PWD_}\\ts\\translations.conf\" \"$$TRANSLATIONS_DIR\\\")
} else {
TRANSLATIONS_DIR="$${OUT_PWD}/translations"
QMAKE_POST_LINK += $$mle(mkdir -p \"$$TRANSLATIONS_DIR\")
for(ts, LANGUAGES) {
QMAKE_POST_LINK += $$mle($$LRELEASE \"$${_PRO_FILE_PWD_}/ts/$${ts}.ts\" -qm \"$$TRANSLATIONS_DIR/$${ts}.qm\")
QMAKE_POST_LINK += $$mle(cp -f \"$${_PRO_FILE_PWD_}/ts/$${ts}.png\" \"$$TRANSLATIONS_DIR/$${ts}.png\")
}
QMAKE_POST_LINK += $$mle(cp -f \"$${_PRO_FILE_PWD_}/ts/translations.conf\" \"$$TRANSLATIONS_DIR/\")
}
}
# check for upx
win32 {
UPX=$$findexeWin32("upx")
} unix {
UPX=$$findexeUnix("upx")
}
!isEmpty(USEUPX) {
isEmpty(HOST64):!isEmpty(UPX) {
message("UPX is found, will pack $$TARGET after linking")
QMAKE_POST_LINK += $$mle($$UPX -9 \"$${OUT_PWD}/$(DESTDIR_TARGET)\")
export(QMAKE_POST_LINK)
} else {
warning("UPX is not found, will not pack $$TARGET")
}
}
# check for signtool
win32 {
SIGNTOOL=$$findexeWin32("signtool")
CERT=$$dirname(_PRO_FILE_)-certs\\cert.pfx
RFC3161_SERVER="http://timestamp.comodoca.com/rfc3161"
!isEmpty(SIGNTOOL):exists($$CERT) {
message("Signtool and the certificate are found, will sign the $$TARGET executable")
} else {
warning("Signtool or the certificate is not found, will not sign the $$TARGET executable")
}
# sign
!isEmpty(SIGNTOOL):exists($$CERT) {
QMAKE_POST_LINK += $$mle($$SIGNTOOL sign /d \"QSS Editor\" /du \"$$HTTPROOT\" /f \"$$CERT\" /tr \"$$RFC3161_SERVER\" /v \"$${OUT_PWD}/$(DESTDIR_TARGET)\")
}
}
# check for 7z
win32 {
ZIP=$$findexeWin32("7z")
} unix {
ZIP=$$findexeUnix("7z")
}
# INNO setup
win32 {
INNO=$$system(echo %ProgramFiles(x86)%)\\Inno Setup 5\\iscc.exe
!exists($$INNO) {
INNO=$$system(echo %ProgramFiles%)\\Inno Setup 5\\iscc.exe
}
}