This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfunctions.pri
165 lines (131 loc) · 4.44 KB
/
functions.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
Q_HOST_OS = $${QMAKE_HOST.os}
Q_LOWER_HOST_OS = $$lower( $${Q_HOST_OS} )
win32 {
!isEqual( Q_LOWER_HOST_OS, "windows" ) {
CONFIG *= cb_win32
}
}
mac {
!isEqual( Q_LOWER_HOST_OS, "darwin" ) {
CONFIG *= cb_mac
}
}
Q_TARGET = $${Q_HOST_OS}
Q_ARCH = $${QT_ARCH}
cb_win32 {
Q_TARGET = Windows
}
cb_mac {
Q_TARGET = Darwin
}
Q_TARGET_ARCH = "$${Q_TARGET}-$${Q_ARCH}"
Q_BACK_SLASH = "\\"
Q_SLASH = "/"
Q_QUOTE = "\""
Q_DOLLAR = "\\$"
Q_OPENING_BRACE = "\\{"
Q_CLOSING_BRACE = "\\}"
# lupdate/lrelease too buggy ( not full qmake interpreter ), so avoid functions def in this case
isEmpty( translations_pass ) {
# return the list of directories recursively from a given path ($$1)
# Forbidden filters can be given ($$2)
defineReplace( getFolders ) {
q_paths = $$1
q_filters = $$2 .svn
q_folders =
for( q_path, q_paths ) {
command = "ls -RQ1 \"$$q_path\" | grep \":\" | sed \"s/://g\" | sed \"s/'/\\\\\\'/g\""
mac|win32:command = ls -R1 \"$$q_path\" | grep \":\" | sed \"s/://g\" | sed \"s/\'/\\\\\\\'/g\" | sed \"s/\\(.*\\)/\\\"\\1\\\"/g\"
win32:!cb_win32:command = "for /D /R \"$$q_path\" %i in (*) do @echo \"%i\""
_q_folders = $$system( $$command )
_q_folders *= $$1
_q_folders = $$replace( _q_folders, $$Q_BACK_SLASH, $$Q_SLASH )
# loop paths
for( q_folder, _q_folders ) {
# check filters
filtered = false
for( q_filter, q_filters ) {
result = $$find( q_folder, $$q_filter )
!isEmpty( result ):filtered = true
}
greaterThan(QT_MAJOR_VERSION, 4) {
q_folder = $$replace(q_folder,\",)
}
isEqual( filtered, false ):exists( $$q_folder ) {
greaterThan(QT_MAJOR_VERSION, 4) {
q_folders *= "$$q_folder"
} else {
q_folders *= $$q_folder
}
}
}
}
#message( Getting folders for $$q_paths: $$q_folders )
return( $$q_folders )
}
# return relative paths for the given paths ($$1)
# according to root path ($$2)
# new root path can be given ($$3)
# Forbidden filters can be given ($$4)
defineReplace( getRelativeFolders ) {
q_paths = $$1
q_root_path = $$2
q_new_root_path = $$3
q_filters = $$4
q_folders = $$getFolders( $$q_paths, $$q_filters )
q_folders = $$replace( q_folders, $$q_root_path, $$q_new_root_path )
#message( Getting relative folders for $$q_paths: $$q_folders )
return( $$q_folders )
}
# return the project build mode
defineReplace( buildMode ) {
CONFIG( debug, debug|release ) {
return( debug )
} else {
return( release )
}
}
# return the target name ($$1) according to build mode($$2)
defineReplace( targetForMode ) {
q_target = $$1
q_mode = $$2
isEmpty( q_mode ):q_mode = $$buildMode()
isEqual( q_mode, release ) {
q_target = $$quote( $$q_target )
} else {
unix:q_target = $$quote( $$join( q_target, , , _debug ) )
else:q_target = $$quote( $$join( q_target, , , d ) )
}
return( $$q_target )
}
# this function set the target name ($$1) according to the build mode ($$2)
defineTest( setTarget ) {
TARGET = $$targetForMode( $$1, $$2 )
export( TARGET )
}
defineTest( setTemporaryDirectories ) {
q_build_path = $$1
q_mode = $$buildMode()
OBJECTS_DIR = $${q_build_path}/$${Q_TARGET_ARCH}/$${q_mode}/obj
UI_DIR = $${q_build_path}/$${Q_TARGET_ARCH}/$${q_mode}/ui
MOC_DIR = $${q_build_path}/$${Q_TARGET_ARCH}/$${q_mode}/moc
RCC_DIR = $${q_build_path}/$${Q_TARGET_ARCH}/$${q_mode}/rcc
export( OBJECTS_DIR )
export( UI_DIR )
export( MOC_DIR )
export( RCC_DIR )
}
} else {
defineReplace( getFolders ) {
}
defineReplace( getRelativeFolders ) {
}
defineReplace( buildMode ) {
}
defineReplace( targetForMode ) {
}
defineTest( setTarget ) {
}
defineTest( setTemporaryDirectories ) {
}
}