-
Notifications
You must be signed in to change notification settings - Fork 126
/
CopyResults.mak
287 lines (237 loc) · 7.19 KB
/
CopyResults.mak
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# Required parameters
#
# TargetDir Project subfolder with files to be copied (e.g. WinDebug). Define it as $(OutDir).
#
# TargetName Base name of the files to be copied. Define it as $(TargetName).
#
# Optional parameters
#
# ProjDir Project folder (default is ".", i.e. current folder)
#
# HierarchyLevel Depth of ProjDir relative to ROOT. Default is 1. Used to determine LibRelativePath.
#
# LibRelativePath Path to lib destination relative to $(ProjDir). Default depends on HierarchyLevel.
#
# DontCopyLib If defined, lib files are not copied.
#
# RelativeBRD Path to executables destination relative to $(RESULTS_ROOT). Default is $(TargetDir)
#
# CustomCopy Name of the *.mak file with additional rules.
# It wll be included by !include "$(CustomCopy)" directive.
# File can modify "targets" macro (add additional space-delimeted
# targets at the end) and use $(BRD), $(LBD), $(SRD), $(ProjDir),
# $(ROOT), $(TargetName) macros to define copy rules.
#
# Platform Platform name, e.g. x64. Used as suffix for library directory.
#
# Internal macros
#
# SRD Folder with files to be copied, $(ProjDir)\$(TargetDir)
#
# LBD Destination for LIBs, $(ProjDir)\$(LibRelativePath)
#
# BRD Destination for executables, PDBs, etc., $(RESULTS_ROOT)\$(RelativeBRD)
#
# Environment
#
# ROOT Build root, required
# RESULTS_ROOT Results root, default is $(ROOT)
# COPYPDB If set to 0, PDBs are not copied.
#
# main pseudorule
all: copyAllFiles
#all: debugPrint
!if !defined( TargetDir )
! error Undefined TargetDir
!endif
!if !defined( TargetName )
! error Undefined TargetName
!endif
# ROOT
!ifdef RESULTS_ROOT
ROOT=$(RESULTS_ROOT)
!endif
!if !defined( ROOT )
! error Undefined ROOT
!endif
# project directory
!ifndef ProjDir
ProjDir=.
!endif
# build result directory
!ifndef RelativeBRD
RelativeBRD=$(TargetDir)
!endif
!ifndef BRD
BRD=$(ROOT)\$(RelativeBRD)
!endif
# copy source directory
!ifndef SRD
SRD=$(ProjDir)\$(TargetDir)
!endif
!ifndef HierarchyLevel
HierarchyLevel=1
!endif
# library output directory path relative to the project
!ifndef LibRelativePath
! if "$(HierarchyLevel)" == "1"
LibRelativePath=lib
! else if "$(HierarchyLevel)" == "2"
LibRelativePath=..\lib
! else if "$(HierarchyLevel)" == "3"
LibRelativePath=..\..\lib
! else if "$(HierarchyLevel)" == "4"
LibRelativePath=..\..\..\lib
! else if "$(HierarchyLevel)" == "5"
LibRelativePath=..\..\..\..\lib
! else
! error Bad HierarchyLevel=$(HierarchyLevel)
! endif
!endif
!ifndef LBD
LBD=$(ProjDir)\$(LibRelativePath)
!endif
!ifndef COPYPDB
COPYPDB=1
!endif
targets=
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).lib"
doCopyLibrary=1
!endif
!if defined(Platform) && "$(Platform)" == "x64" && !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName)64.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName)64.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).Win32.Debug.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).Win32.Debug.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).Win32.Release.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).Win32.Release.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).Win32.Final.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).Win32.Final.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).x64.Debug.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).x64.Debug.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).x64.Release.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).x64.Release.lib"
doCopyLibrary=1
!endif
!if !defined( DontCopyLib ) && exist( "$(SRD)\$(TargetName).x64.Final.lib" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).x64.Final.lib"
doCopyLibrary=1
!endif
!if exist( "$(SRD)\$(TargetName).dll" )
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).dll"
doCopyExecutable=1
!endif
!if exist( "$(SRD)\$(TargetName).exe" )
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).exe"
doCopyExecutable=1
!endif
!if exist( "$(SRD)\$(TargetName).drv" )
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).drv"
doCopyExecutable=1
!endif
!if exist( "$(SRD)\$(TargetName).map" )
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).map"
!endif
!if exist( "$(SRD)\$(TargetName).pdb" )
! if exist( "$(BRD)\$(TargetName).pdb" )
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).pdb"
! endif
! if exist( "$(LBD)\$(TargetName).pdb" )
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).pdb"
! endif
! if ("$(COPYPDB)" != "") && ("$(COPYPDB)" != "0")
! ifdef doCopyExecutable
targets=$(targets) "$(BRD)" "$(BRD)\$(TargetName).pdb"
! elseifdef doCopyLibrary
targets=$(targets) "$(LBD)" "$(LBD)\$(TargetName).pdb"
! endif
! endif
!endif
!undef signCommand
!if defined( AUTHENTICODE_CERT ) && defined( AUTHENTICODE_PASS )
signCommand=@AbbyySignTool.exe sign /f "$(ROOT)\$(AUTHENTICODE_CERT)" /p "$(AUTHENTICODE_PASS)"
!elseif defined( AUTHENTICODE_CERT_HASH )
signCommand=@AbbyySignTool.exe sign /sm /a /sha1 "%AUTHENTICODE_CERT_HASH%"
!endif
!if defined( signCommand ) && defined( AUTHENTICODE_TIME_SERVER )
signCommand=$(signCommand) /t "$(AUTHENTICODE_TIME_SERVER)"
!endif
# create build results directory
"$(BRD)" :
-1 md "$(BRD)"
# create library directory
"$(LBD)" :
-1 md "$(LBD)"
#Copy dependencies
"$(LBD)\$(TargetName).lib" : "$(SRD)\$(TargetName).lib"
copy $? $@
"$(LBD)\$(TargetName)64.lib" : "$(SRD)\$(TargetName)64.lib"
copy $? $@
"$(LBD)\$(TargetName).Win32.Debug.lib" : "$(SRD)\$(TargetName).Win32.Debug.lib"
copy $? $@
"$(LBD)\$(TargetName).Win32.Release.lib" : "$(SRD)\$(TargetName).Win32.Release.lib"
copy $? $@
"$(LBD)\$(TargetName).Win32.Final.lib" : "$(SRD)\$(TargetName).Win32.Final.lib"
copy $? $@
"$(LBD)\$(TargetName).x64.Debug.lib" : "$(SRD)\$(TargetName).x64.Debug.lib"
copy $? $@
"$(LBD)\$(TargetName).x64.Release.lib" : "$(SRD)\$(TargetName).x64.Release.lib"
copy $? $@
"$(LBD)\$(TargetName).x64.Final.lib" : "$(SRD)\$(TargetName).x64.Final.lib"
copy $? $@
"$(BRD)\$(TargetName).dll" : "$(SRD)\$(TargetName).dll"
!if defined( signCommand )
@echo Digitally signing $?
$(signCommand) $?
!endif
copy $? $@
"$(BRD)\$(TargetName).exe" : "$(SRD)\$(TargetName).exe"
!if defined( signCommand )
@echo Digitally signing $?
$(signCommand) $?
!endif
copy $? $@
"$(BRD)\$(TargetName).drv" : "$(SRD)\$(TargetName).drv"
!if defined( signCommand )
@echo Digitally signing $?
$(signCommand) $?
!endif
copy $? $@
"$(BRD)\$(TargetName).map" : "$(SRD)\$(TargetName).map"
copy $? $@
"$(BRD)\$(TargetName).pdb" : "$(SRD)\$(TargetName).pdb"
copy $? $@
"$(LBD)\$(TargetName).pdb" : "$(SRD)\$(TargetName).pdb"
copy $? $@
# Additional dependencies
!ifdef CustomCopy
!include "$(CustomCopy)"
!endif
# next pseudotarget have to be placed after !include "$(CustomCopy)" command
copyAllFiles: $(targets)
@echo $(SRD) $(TargetName) >"$(SRD)\copyTimeStamp.txt"
debugPrint:
@echo Current directory:
@cd
@echo ROOT=$(ROOT)
@echo TargetDir=$(TargetDir)
@echo TargetName=$(TargetName)
@echo ProjDir=$(ProjDir)
@echo SRD=$(SRD)
@echo BRD=$(BRD)
@echo LBD=$(LBD)
!ifdef DontCopyLib
@echo DontCopyLib defined
!endif
@echo Targets:
@echo $(targets)