Debian Codegraph @

Source/VSProps/qtrcc.targets

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 /***************************************************************************************************
4 Copyright (C) 2023 The Qt Company Ltd.
5 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
6 ***************************************************************************************************/
7 -->
8
9 <!--
10 ///////////////////////////////////////////////////////////////////////////////////////////////////
11 /// Definitions specific to rcc
12 ///////////////////////////////////////////////////////////////////////////////////////////////////
13 // -->
14 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
15 <!--
16 /////////////////////////////////////////////////////////////////////////////////////////////////
17 // Import pre-requisites
18 // -->
19 <Import
20 Condition="'$(QtMsBuildTargets_BeforeRcc)' != ''"
21 Project="$(QtMsBuildTargets_BeforeRcc)"/>
22
23 <!--
24 /////////////////////////////////////////////////////////////////////////////////////////////////
25 // Qt/MSBuild global properties
26 // -->
27 <PropertyGroup>
28 <QtBuildTargets>QtRcc;$(QtBuildTargets)</QtBuildTargets>
29 </PropertyGroup>
30
31 <!--
32 /////////////////////////////////////////////////////////////////////////////////////////////////
33 // Setup item type and property page
34 // -->
35 <Choose>
36 <When Condition="'$(QtVsProjectSettings)' == 'true' AND '$(QtVsProjectClProperties)' == 'true'">
37 <ItemGroup>
38 <PropertyPageSchema
39 Include="$(MSBuildThisFileDirectory)qtrcc_v3.xml" />
40 </ItemGroup>
41 </When>
42 <Otherwise>
43 <ItemGroup>
44 <PropertyPageSchema
45 Include="$(MSBuildThisFileDirectory)qtrcc.xml" />
46 </ItemGroup>
47 </Otherwise>
48 </Choose>
49 <ItemGroup>
50 <AvailableItemName Include="QtRcc">
51 <Targets>Qt;_ClCompile</Targets>
52 </AvailableItemName>
53 </ItemGroup>
54 <PropertyGroup>
55 <QtRccRuleName>QtRule40_Rcc</QtRccRuleName>
56 </PropertyGroup>
57
58 <!--
59 /////////////////////////////////////////////////////////////////////////////////////////////////
60 /// TARGET QtRccInit
61 /////////////////////////////////////////////////////////////////////////////////////////////////
62 // Initialize default metadata
63 // -->
64 <Target Name="QtRccInit">
65 <!--// Initialize %(OutputFile) -->
66 <ItemGroup Condition="'$(QtVsProjectSettings)' == 'true' AND '@(QtRcc)' != ''">
67 <QtRccAux Include="@(QtRcc)">
68 <OutputFile
69 >$([System.IO.Path]::Combine('%(QtRcc.QtRccDir)','%(QtRcc.QtRccFileName)'))</OutputFile>
70 </QtRccAux>
71 <QtRcc Remove="@(QtRcc)"/>
72 <QtRcc Include="@(QtRccAux)"/>
73 <QtRccAux Remove="@(QtRccAux)"/>
74 </ItemGroup>
75 </Target>
76
77 <!--
78 /////////////////////////////////////////////////////////////////////////////////////////////////
79 /// TARGET QtRccSetDependencies
80 /////////////////////////////////////////////////////////////////////////////////////////////////
81 // Add resource files as dependencies of the QRC file
82 // -->
83 <Target Name="QtRccSetDependencies" DependsOnTargets="QtRccInit"
84 Inputs="%(QtRcc.Identity)" Outputs="@(QtRcc->'####### Don't skip this target #######')">
85 <ItemGroup>
86 <selected_files Include="$(SelectedFiles)"/>
87 </ItemGroup>
88
89 <!--// Parse QRC -->
90 <ListQrc QrcFilePath="%(QtRcc.FullPath)">
91 <Output TaskParameter="Result" ItemName="res_file"/>
92 </ListQrc>
93
94 <!--// Add dependencies -->
95 <ItemGroup Condition="'@(QtRcc)' != '' AND '@(res_file)' != ''">
96 <QtRcc>
97 <ResourceFiles>@(res_file)</ResourceFiles>
98 <AdditionalDependencies
99 >%(QtRcc.AdditionalDependencies);@(res_file->'%(FullPath)')</AdditionalDependencies>
100 </QtRcc>
101 </ItemGroup>
102
103 <!--// Clean-up -->
104 <PropertyGroup>
105 <QtRccExeQuoted/>
106 <QtRccQuoted/>
107 <RccListQuoted/>
108 </PropertyGroup>
109 <ItemGroup>
110 <res_file Remove="@(res_file)"/>
111 </ItemGroup>
112 </Target>
113
114 <!--
115 /////////////////////////////////////////////////////////////////////////////////////////////////
116 /// TARGET QtRccPrepare
117 /////////////////////////////////////////////////////////////////////////////////////////////////
118 // Prepare items for processing
119 // -->
120 <Target Name="QtRccPrepare" DependsOnTargets="QtRccSetDependencies"
121 Inputs="%(QtRcc.Identity)" Outputs="@(QtRcc->'####### Don't skip this target #######')">
122
123 <Message Importance="High" Condition="'$(QtDebug)' == 'true'"
124 Text="## QtRccPrepare @(QtRcc)"/>
125
126 <PropertyGroup>
127 <selected_files>[@(selected_files->'%(Identity)','][')]</selected_files>
128 <file>[@(QtRcc->'%(Identity)')]</file>
129 <output_file>@(QtRcc->'%(OutputFile)')</output_file>
130 <is_selected Condition="$(selected_files.Contains('$(file)'))">true</is_selected>
131 <is_selected Condition="!$(selected_files.Contains('$(file)'))">false</is_selected>
132 </PropertyGroup>
133
134 <!--// Delete output file to force build of source if it was manually selected to build
135 // (e.g. by the 'Compile' option in the context menu for the file) -->
136 <Delete Files="$(output_file)"
137 Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' == 'true'" />
138
139 <!--// If a source was manually selected to build, remove all other sources -->
140 <ItemGroup Condition="'@(selected_files)' != ''">
141 <QtRcc Remove="@(QtRcc)"
142 Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' != 'true'" />
143 </ItemGroup>
144
145 <!--// Remove sources excluded from build -->
146 <ItemGroup>
147 <QtRcc Remove="@(QtRcc)"
148 Condition="'$(SelectedFiles)' == '' AND '%(QtRcc.ExcludedFromBuild)' == 'true'"/>
149 </ItemGroup>
150
151 <!--// Clean-up -->
152 <PropertyGroup>
153 <selected_files/>
154 <file/>
155 <output_file/>
156 <is_selected/>
157 </PropertyGroup>
158 </Target>
159
160 <!--
161 /////////////////////////////////////////////////////////////////////////////////////////////////
162 /// TARGET QtRccSetModified
163 /////////////////////////////////////////////////////////////////////////////////////////////////
164 // Set InputModified flag for modified files (i.e. Inputs newer than Outputs)
165 // -->
166 <Target Name="QtRccSetModified" DependsOnTargets="QtRccPrepare"
167 Condition="'@(QtRcc)' != ''"
168 Inputs="%(QtRcc.FullPath);%(QtRcc.AdditionalDependencies)" Outputs="@(QtRcc->'%(OutputFile)')">
169
170 <Message Importance="High" Condition="'$(QtDebug)' == 'true'"
171 Text="## QtRccSetModified @(QtRcc)" />
172
173 <CreateProperty Value="true">
174 <!-- // Using ValueSetByTask ensures $(input_changed) is only set to 'true' when the target
175 // is actually executed and not when MSBuild is figuring out which targets to run -->
176 <Output TaskParameter="ValueSetByTask" PropertyName="input_changed" />
177 </CreateProperty>
178 <ItemGroup>
179 <QtRcc>
180 <InputChanged>$(input_changed)</InputChanged>
181 </QtRcc>
182 </ItemGroup>
183 </Target>
184
185 <!--
186 /////////////////////////////////////////////////////////////////////////////////////////////////
187 /// TARGET QtRccOverrideCpp
188 /////////////////////////////////////////////////////////////////////////////////////////////////
189 //
190 // -->
191 <!--<Import Project="qtrcc_cl.targets"/>-->
192
193 <!--
194 /////////////////////////////////////////////////////////////////////////////////////////////////
195 /// TARGET QtRcc
196 /////////////////////////////////////////////////////////////////////////////////////////////////
197 // Process each QRC file and produce the corresponding QtWork items
198 // -->
199 <PropertyGroup>
200 <QtRccDependsOn>
201 QtPrepare;
202 QtRccPrepare;
203 QtRccSetModified;
204 $(QtRccDependsOn)
205 </QtRccDependsOn>
206 </PropertyGroup>
207 <Target Name="QtRcc"
208 DependsOnTargets="$(QtRccDependsOn)"
209 BeforeTargets="$(QtRccBeforeTargets)" AfterTargets="$(QtRccAfterTargets)"
210 Condition="'@(QtRcc)' != ''"
211 Inputs="%(QtRcc.FullPath);%(QtRcc.AdditionalDependencies);$(MSBuildProjectFile)"
212 Outputs="@(QtRcc->'%(OutputFile)')">
213
214 <Message Importance="High" Condition="'$(QtDebug)' == 'true'" Text="## QtRcc @(QtRcc)" />
215
216 <CreateProperty Value="true">
217 <Output TaskParameter="ValueSetByTask" PropertyName="dependencies_changed" />
218 </CreateProperty>
219
220 <PropertyGroup>
221 <two_pass Condition="'%(QtRcc.TwoPass)' == 'true'">true</two_pass>
222 </PropertyGroup>
223
224 <!--
225 ///////////////////////////////////////////////////////////////////////////////////////////////
226 // Convert string lists in source item properties to lists of items
227 // -->
228 <Flatten Items="@(QtRcc)"
229 Metadata="InputFile;
230 OutputFile;
231 TempFile;
232 InitFuncName;
233 Root;
234 Compression;
235 NoCompression;
236 CompressThreshold;
237 BinaryOutput;
238 NoZstd;
239 PassNumber;
240 NoNamespace;
241 Verbose;
242 List;
243 Project;
244 FormatVersion">
245 <Output
246 TaskParameter="Result" ItemName="LocalOptions" />
247 </Flatten>
248
249 <!--
250 ///////////////////////////////////////////////////////////////////////////////////////////////
251 // Translate local paths to build host paths
252 // -->
253 <HostTranslatePaths
254 Items="@(LocalOptions)"
255 Names="InputFile;
256 OutputFile;
257 TempFile;
258 Root">
259 <Output
260 TaskParameter="Result" ItemName="options" />
261 </HostTranslatePaths>
262
263 <ItemGroup>
264 <!--
265 /////////////////////////////////////////////////////////////////////////////////////////////
266 // Remove quotes from all paths
267 // Escape trailing back-slash in paths
268 // Add quotes to paths containing spaces
269 // -->
270 <options>
271 <Value Condition="'%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
272 OR '%(Name)' == 'TempFile' OR '%(Name)' == 'Root'"
273 >$([System.String]::Copy('%(Value)').Replace('&quot;', ''))</Value>
274 </options>
275 <options>
276 <Value Condition="('%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
277 OR '%(Name)' == 'TempFile' OR '%(Name)' == 'Root')
278 AND $([System.String]::Copy('%(Value)').Contains(' '))
279 AND $([System.String]::Copy('%(Value)').EndsWith('\'))"
280 >%(Value)\</Value>
281 </options>
282 <options>
283 <Value Condition="('%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
284 OR '%(Name)' == 'TempFile' OR '%(Name)' == 'Root')
285 AND $([System.String]::Copy('%(Value)').Contains(' '))"
286 >&quot;%(Value)&quot;</Value>
287 </options>
288
289 <!--
290 ///////////////////////////////////////////////////////////////////////////////////////////////
291 // Generate tool command line arguments
292 // -->
293 <!--// inputs Input files (*.qrc) -->
294 <options>
295 <Value Condition="'%(Name)' == 'InputFile'">%(Value)</Value>
296 </options>
297
298 <!--// -o, -output <file> Write output to <file> -->
299 <options>
300 <Value Condition="'%(Name)' == 'OutputFile' AND '$(two_pass)' != 'true'">-o %(Value)</Value>
301 </options>
302 <options>
303 <Value Condition="'%(Name)' == 'OutputFile' AND '$(two_pass)' == 'true'"></Value>
304 </options>
305
306 <!--// -t, -temp <file> Use temporary <file> for big resources -->
307 <options>
308 <Value Condition="'%(Name)' == 'TempFile'">--temp %(Value)</Value>
309 </options>
310
311 <!--// -name <name> Create an external initialization function with <name> -->
312 <options>
313 <Value Condition="'%(Name)' == 'InitFuncName'">--name %(Value)</Value>
314 </options>
315
316 <!--// -root <path> Prefix resource access path with root path -->
317 <options>
318 <Value Condition="'%(Name)' == 'Root'">--root %(Value)</Value>
319 </options>
320
321 <!--// -compress <level> Compress input files by <level> -->
322 <options>
323 <Value
324 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level1'">--compress 1</Value>
325 </options>
326 <options>
327 <Value
328 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level2'">--compress 2</Value>
329 </options>
330 <options>
331 <Value
332 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level3'">--compress 3</Value>
333 </options>
334 <options>
335 <Value
336 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level4'">--compress 4</Value>
337 </options>
338 <options>
339 <Value
340 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level5'">--compress 5</Value>
341 </options>
342 <options>
343 <Value
344 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level6'">--compress 6</Value>
345 </options>
346 <options>
347 <Value
348 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level7'">--compress 7</Value>
349 </options>
350 <options>
351 <Value
352 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level8'">--compress 8</Value>
353 </options>
354 <options>
355 <Value
356 Condition="'%(Name)' == 'Compression' AND '%(Value)' == 'level9'">--compress 9</Value>
357 </options>
358 <options>
359 <Value
360 Condition="'%(Name)' == 'Compression'
361 AND !$([System.String]::Copy('%(Value)').StartsWith('--compress'))"></Value>
362 </options>
363
364 <!--// -no-compress Disable all compression -->
365 <options>
366 <Value
367 Condition="'%(Name)' == 'NoCompression' AND '%(Value)' != 'true'"></Value>
368 </options>
369 <options>
370 <Value
371 Condition="'%(Name)' == 'NoCompression' AND '%(Value)' == 'true'">--no-compress</Value>
372 </options>
373
374 <!--// -threshold <level> Threshold to consider compressing files -->
375 <options>
376 <Value Condition="'%(Name)' == 'CompressThreshold'">--threshold %(Value)</Value>
377 </options>
378
379 <!--// -binary Output a binary file for use as a dynamic source -->
380 <options>
381 <Value Condition="'%(Name)' == 'BinaryOutput' AND '%(Value)' != 'true'"></Value>
382 </options>
383 <options>
384 <Value Condition="'%(Name)' == 'BinaryOutput' AND '%(Value)' == 'true'">--binary</Value>
385 </options>
386
387 <!--// -no-zstd Disable usage of zstd compression -->
388 <options>
389 <Value Condition="'%(Name)' == 'NoZstd' AND '%(Value)' != 'true'"></Value>
390 </options>
391 <options>
392 <Value Condition="'%(Name)' == 'NoZstd' AND '%(Value)' == 'true'">--no-zstd</Value>
393 </options>
394
395 <!--// -pass <number> Pass number for big resources -->
396 <options>
397 <Value Condition="'%(Name)' == 'PassNumber'">--pass %(Value)</Value>
398 </options>
399
400 <!--// -namespace Turn off namespace macros -->
401 <options>
402 <Value Condition="'%(Name)' == 'NoNamespace' AND '%(Value)' != 'true'"></Value>
403 </options>
404 <options>
405 <Value Condition="'%(Name)' == 'NoNamespace' AND '%(Value)' == 'true'">--namespace</Value>
406 </options>
407
408 <!--// -verbose Enable verbose mode -->
409 <options>
410 <Value Condition="'%(Name)' == 'Verbose' AND '%(Value)' != 'true'"></Value>
411 </options>
412 <options>
413 <Value Condition="'%(Name)' == 'Verbose' AND '%(Value)' == 'true'">--verbose</Value>
414 </options>
415
416 <!--// -list Only list .qrc file entries, do not generate code -->
417 <options>
418 <Value Condition="'%(Name)' == 'List' AND '%(Value)' != 'true'"></Value>
419 </options>
420 <options>
421 <Value Condition="'%(Name)' == 'List' AND '%(Value)' == 'true'">--list</Value>
422 </options>
423
424 <!--// -project Output a resource file containing all files from the
425 // current directory -->
426 <options>
427 <Value Condition="'%(Name)' == 'Project' AND '%(Value)' != 'true'"></Value>
428 </options>
429 <options>
430 <Value Condition="'%(Name)' == 'Project' AND '%(Value)' == 'true'">--project</Value>
431 </options>
432
433 <!--// -format-version <number> The RCC format version to write -->
434 <options>
435 <Value Condition="'%(Name)' == 'FormatVersion'">--format-version %(Value)</Value>
436 </options>
437 </ItemGroup>
438 <PropertyGroup>
439 <options>@(options->'%(Value)', ' ')</options>
440 </PropertyGroup>
441
442 <!--
443 ///////////////////////////////////////////////////////////////////////////////////////////////
444 // Aux properties
445 // -->
446 <PropertyGroup>
447 <!--// Force modified flag if source was manually selected to build -->
448 <input_changed Condition="'$(SelectedFiles)' == ''"
449 >%(QtRcc.InputChanged)</input_changed>
450 <input_changed Condition="'$(SelectedFiles)' != ''"
451 >true</input_changed>
452
453 <!--// Run work in parallel processes -->
454 <run_parallel Condition="'@(QtRcc)' != ''
455 AND '%(QtRcc.ParallelProcess)' == 'true'
456 AND '$(SelectedFiles)' == ''"
457 >true</run_parallel>
458
459 <!--// Run work in single process -->
460 <run_single Condition="'@(QtRcc)' != ''
461 AND ('%(QtRcc.ParallelProcess)' != 'true'
462 OR '$(SelectedFiles)' != '')"
463 >true</run_single>
464
465 <!--// Get relative path to output -->
466 <output_relative
467 >$([MSBuild]::MakeRelative($(ProjectDir), %(QtRcc.OutputFile)).TrimStart('\'))</output_relative>
468 </PropertyGroup>
469
470 <!--
471 ///////////////////////////////////////////////////////////////////////////////////////////////
472 // Create work item
473 // -->
474 <ItemGroup Condition="'$(run_parallel)' == 'true' OR '$(run_single)' == 'true'">
475 <QtWork Include="@(QtRcc)">
476 <WorkType>rcc</WorkType>
477 <ToolPath Condition="'$(QtVsProjectSettings)' == 'true'">$(QtToolsPath)/rcc</ToolPath>
478 <ToolPath Condition="'$(QtVsProjectSettings)' != 'true'">%(QtRcc.QTDIR)\bin\rcc.exe</ToolPath>
479 <Options>$(options)</Options>
480 <Message>%(QtRcc.ExecutionDescription)</Message>
481 <DependenciesChanged>$(dependencies_changed)</DependenciesChanged>
482 <InputChanged>$(input_changed)</InputChanged>
483 <ParallelBuild Condition="'$(run_parallel)' == 'true'">true</ParallelBuild>
484 <ParallelBuild Condition="'$(run_single)' == 'true'">false</ParallelBuild>
485 <!--
486 ///////////////////////////////////////////////////////////////////////////////////////////
487 // Two-pass ("resources_big"): pass 1 -->
488 <Message Condition="'%(QtRcc.TwoPass)' == 'true'">%(QtRcc.ExecutionDescription) [pass 1]</Message>
489 <RccPass Condition="'%(QtRcc.TwoPass)' == 'true'">1</RccPass>
490 <RccOptions Condition="'%(QtRcc.TwoPass)' == 'true'">$(options)</RccOptions>
491 <Options Condition="'%(QtRcc.TwoPass)' == 'true'"
492 >$(options) -pass 1 -o &quot;%(OutputFile)&quot;</Options>
493 <Optimization Condition="'%(QtRcc.TwoPass)' == 'true'">Disabled</Optimization>
494 <!--
495 ///////////////////////////////////////////////////////////////////////////////////////////
496 // C++ dynamic source -->
497 <ClCompile Condition="'%(QtRcc.DynamicSource)' == 'output'">$(output_relative)</ClCompile>
498 </QtWork>
499 </ItemGroup>
500
501 <!--
502 ///////////////////////////////////////////////////////////////////////////////////////////////
503 // Clean-up
504 // -->
505 <PropertyGroup>
506 <options/>
507 <dependencies_changed/>
508 <input_changed/>
509 <run_parallel/>
510 <run_single/>
511 <output_relative/>
512 <two_pass/>
513 </PropertyGroup>
514 <ItemGroup>
515 <LocalOptions Remove="@(LocalOptions)"/>
516 <options Remove="@(options)"/>
517 <selected_files Remove="@(selected_files)"/>
518 </ItemGroup>
519 </Target>
520
521 <!--
522 /////////////////////////////////////////////////////////////////////////////////////////////////
523 /// TARGET QtRccPass2
524 /////////////////////////////////////////////////////////////////////////////////////////////////
525 // Two-pass ("resources_big"): pass 2
526 // -->
527 <Target Name="QtRccPass2"
528 DependsOnTargets="QtRccPass2_GetObjs;QtRccPass2_Exec"/>
529
530 <Target Name="QtRccPass2_GetObjs"
531 DependsOnTargets="ComputeCLOutputs">
532 <ItemGroup>
533 <QtRccObj Include="@(Obj->WithMetadataValue('RccPass', '1'))">
534 <RccPass>2</RccPass>
535 </QtRccObj>
536 </ItemGroup>
537 </Target>
538
539 <Target Name="QtRccPass2_Exec"
540 DependsOnTargets="QtRccPass2_GetObjs"
541 Condition="'@(QtRccObj)' != ''">
542 <Move
543 SourceFiles="%(QtRccObj.Identity)"
544 DestinationFiles="%(QtRccObj.Identity)_TMP"/>
545 <Exec
546 Command="@(QtRccObj->'ECHO %(ExecutionDescription) [pass 2] &amp; %(ToolPath) %(RccOptions) -pass 2 -temp &quot;%(Identity)_TMP&quot; -o &quot;%(Identity)&quot;')"
547 IgnoreExitCode="true"/>
548 <ItemGroup>
549 <Obj Remove="@(QtRccObj->'%(Identity)')"/>
550 <Obj Include="@(QtRccObj)"/>
551 <QtRccObj Remove="@(QtRccObj)"/>
552 </ItemGroup>
553 </Target>
554
555 <Target Name="QtRccPass2_Link"
556 DependsOnTargets="QtRccPass2"/>
557
558 <Target Name="QtRccPass2_Lib"
559 DependsOnTargets="QtRccPass2"/>
560
561 <PropertyGroup>
562 <ComputeLinkInputsTargets>
563 $(ComputeLinkInputsTargets);
564 ;QtRccPass2_Link;
565 </ComputeLinkInputsTargets>
566 <ComputeLibInputsTargets>
567 $(ComputeLibInputsTargets);
568 ;QtRccPass2_Lib;
569 </ComputeLibInputsTargets>
570 </PropertyGroup>
571
572 <!--
573 /////////////////////////////////////////////////////////////////////////////////////////////////
574 // Import dependants
575 // -->
576 <Import
577 Condition="'$(QtMsBuildTargets_AfterRcc)' != ''"
578 Project="$(QtMsBuildTargets_AfterRcc)"/>
579
580 </Project>