Debian Codegraph @

Source/VSProps/qtmoc.targets

raw
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3 /****************************************************************************
4 **
5 ** Copyright (C) 2018 The Qt Company Ltd.
6 ** Contact: https://www.qt.io/licensing/
7 **
8 ** This file is part of the Qt VS Tools.
9 **
10 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
11 ** Commercial License Usage
12 ** Licensees holding valid commercial Qt licenses may use this file in
13 ** accordance with the commercial license agreement provided with the
14 ** Software or, alternatively, in accordance with the terms contained in
15 ** a written agreement between you and The Qt Company. For licensing terms
16 ** and conditions see https://www.qt.io/terms-conditions. For further
17 ** information use the contact form at https://www.qt.io/contact-us.
18 **
19 ** GNU General Public License Usage
20 ** Alternatively, this file may be used under the terms of the GNU
21 ** General Public License version 3 as published by the Free Software
22 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
23 ** included in the packaging of this file. Please review the following
24 ** information to ensure the GNU General Public License requirements will
25 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 **
27 ** $QT_END_LICENSE$
28 **
29 ****************************************************************************/
30 -->
31
32 <!--
33 ///////////////////////////////////////////////////////////////////////////////////////////////////
34 // Definitions specific to moc
35 ///////////////////////////////////////////////////////////////////////////////////////////////////
36 // -->
37 <Project>
38 <!--
39 /////////////////////////////////////////////////////////////////////////////////////////////////
40 // Import pre-requisites
41 // -->
42 <Import
43 Condition="'$(QtMsBuildTargets_BeforeMoc)' != ''"
44 Project="$(QtMsBuildTargets_BeforeMoc)"/>
45
46 <!--
47 /////////////////////////////////////////////////////////////////////////////////////////////////
48 // Qt/MSBuild global properties
49 // -->
50 <PropertyGroup>
51 <QtBuildTargets>QtMoc;$(QtBuildTargets)</QtBuildTargets>
52 </PropertyGroup>
53
54 <!--
55 /////////////////////////////////////////////////////////////////////////////////////////////////
56 // Setup item type and property page
57 // -->
58 <Choose>
59 <When Condition="'$(QtVsProjectSettings)' == 'true' AND '$(QtVsProjectClProperties)' == 'true'">
60 <ItemGroup>
61 <PropertyPageSchema
62 Include="$(MSBuildThisFileDirectory)qtmoc_v3.xml" />
63 </ItemGroup>
64 </When>
65 <Otherwise>
66 <ItemGroup Condition="'$(QtVsProjectSettings)' == 'false'">
67 <PropertyPageSchema
68 Include="$(MSBuildThisFileDirectory)qtmoc.xml" />
69 </ItemGroup>
70 </Otherwise>
71 </Choose>
72 <ItemGroup>
73 <AvailableItemName Include="QtMoc">
74 <Targets>Qt;_ClCompile</Targets>
75 </AvailableItemName>
76 </ItemGroup>
77 <PropertyGroup>
78 <QtMocRuleName>QtRule30_Moc</QtMocRuleName>
79 </PropertyGroup>
80
81 <!--
82 /////////////////////////////////////////////////////////////////////////////////////////////////
83 /// TARGET QtMocInit
84 /////////////////////////////////////////////////////////////////////////////////////////////////
85 // Initialize default metadata
86 // -->
87 <Target Name="QtMocInit">
88 <!--// Initialize %(OutputFile) -->
89 <ItemGroup Condition="'$(QtVsProjectSettings)' == 'true' AND '@(QtMoc)' != ''">
90 <QtMocAux Include="@(QtMoc)">
91 <OutputFile
92 >$([System.IO.Path]::Combine('%(QtMoc.QtMocDir)','%(QtMoc.QtMocFileName)'))</OutputFile>
93 </QtMocAux>
94 <QtMoc Remove="@(QtMoc)"/>
95 <QtMoc Include="@(QtMocAux)"/>
96 <QtMocAux Remove="@(QtMocAux)"/>
97 </ItemGroup>
98 <!--
99 ///////////////////////////////////////////////////////////////////////////////////////////////
100 // Add moc output dir to C++ include path
101 // -->
102 <ItemGroup Condition="'@(QtMoc)' != ''">
103 <QtIncludePath Include="$([System.IO.Path]::GetDirectoryName('%(QtMoc.OutputFile)'))"/>
104 </ItemGroup>
105 </Target>
106
107 <!--
108 /////////////////////////////////////////////////////////////////////////////////////////////////
109 /// TARGET QtMocPrepare
110 /////////////////////////////////////////////////////////////////////////////////////////////////
111 // Prepare to process sources
112 // -->
113 <Target Name="QtMocPrepare" DependsOnTargets="_SelectedFiles;QtMocInit"
114 Inputs="%(QtMoc.Identity)" Outputs="@(QtMoc->'####### Don't skip this target #######')">
115
116 <Message Importance="High" Condition="'$(QtDebug)' == 'true'"
117 Text="## QtMocPrepare @(QtMoc)"/>
118
119 <PropertyGroup>
120 <selected_files>[@(SelectedFiles->'%(Identity)','][')]</selected_files>
121 <file>[@(QtMoc->'%(Identity)')]</file>
122 <output_file>@(QtMoc->'%(OutputFile)')</output_file>
123 <is_selected Condition="$(selected_files.Contains('$(file)'))">true</is_selected>
124 <is_selected Condition="!$(selected_files.Contains('$(file)'))">false</is_selected>
125 </PropertyGroup>
126
127 <!--// Delete output file to force build of source if it was manually selected to build
128 // (e.g. by the 'Compile' option in the context menu for the file) -->
129 <Delete Files="$(output_file)"
130 Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' == 'true'" />
131
132 <!--// If a source was manually selected to build, remove all other sources -->
133 <ItemGroup Condition="'@(SelectedFiles)' != ''">
134 <QtMoc Remove="@(QtMoc)"
135 Condition="'$(SelectedFiles)' != '' AND '$(is_selected)' != 'true'" />
136 </ItemGroup>
137
138 <!--// Remove sources excluded from build -->
139 <ItemGroup>
140 <QtMoc Remove="@(QtMoc)"
141 Condition="'$(SelectedFiles)' == '' AND '%(QtMoc.ExcludedFromBuild)' == 'true'"/>
142 </ItemGroup>
143
144 <PropertyGroup>
145 <selected_files/>
146 <file/>
147 <output_file/>
148 <is_selected/>
149 </PropertyGroup>
150 </Target>
151
152 <!--
153 /////////////////////////////////////////////////////////////////////////////////////////////////
154 /// TARGET QtMocSetModified
155 /////////////////////////////////////////////////////////////////////////////////////////////////
156 // Set InputChanged flag if source file or dependencies have been modified
157 // -->
158 <Target Name="QtMocSetModified" DependsOnTargets="QtMocPrepare"
159 Condition="'@(QtMoc)' != ''"
160 Inputs="%(QtMoc.FullPath);%(QtMoc.AdditionalDependencies)" Outputs="@(QtMoc->'%(OutputFile)')">
161
162 <Message Importance="High" Condition="'$(QtDebug)' == 'true'"
163 Text="## QtMocSetModified @(QtMoc)" />
164
165 <CreateProperty Value="true">
166 <Output TaskParameter="ValueSetByTask" PropertyName="input_changed" />
167 </CreateProperty>
168 <ItemGroup>
169 <QtMoc>
170 <InputChanged>$(input_changed)</InputChanged>
171 </QtMoc>
172 </ItemGroup>
173 </Target>
174
175 <!--
176 /////////////////////////////////////////////////////////////////////////////////////////////////
177 /// TARGET QtMocOverrideCpp
178 /////////////////////////////////////////////////////////////////////////////////////////////////
179 //
180 // -->
181 <Import Project="qtmoc_cl.targets"/>
182
183 <!--
184 /////////////////////////////////////////////////////////////////////////////////////////////////
185 /// TARGET QtMoc
186 /////////////////////////////////////////////////////////////////////////////////////////////////
187 // Process each source file and produce the corresponding QtWork items
188 // -->
189 <PropertyGroup>
190 <QtMocDependsOn>
191 QtPrepare;
192 QtMocPrepare;
193 QtMocSetModified;
194 QtMocOverrideCpp;
195 $(QtMocDependsOn)
196 </QtMocDependsOn>
197 </PropertyGroup>
198 <Target Name="QtMoc"
199 DependsOnTargets="$(QtMocDependsOn)"
200 BeforeTargets="$(QtMocBeforeTargets)" AfterTargets="$(QtMocAfterTargets)"
201 Condition="'@(QtMoc)' != ''"
202 Inputs="%(QtMoc.FullPath);%(QtMoc.AdditionalDependencies);$(MSBuildProjectFile)"
203 Outputs="@(QtMoc->'%(OutputFile)')">
204
205 <Message Importance="High" Condition="'$(QtDebug)' == 'true'" Text="## QtMoc @(QtMoc)" />
206
207 <CreateProperty Value="true">
208 <Output TaskParameter="ValueSetByTask" PropertyName="dependencies_changed" />
209 </CreateProperty>
210
211 <!--
212 ///////////////////////////////////////////////////////////////////////////////////////////////
213 // Convert string lists in source item properties to lists of items
214 // -->
215 <Flatten Items="@(QtMoc)"
216 Metadata="InputFile;
217 OutputFile;
218 IncludePath;
219 MacFramework;
220 PreprocessOnly;
221 Define;
222 Undefine;
223 Metadata;
224 CompilerFlavor;
225 NoInclude;
226 PathPrefix;
227 ForceInclude;
228 PrependInclude;
229 Include;
230 NoNotesWarnings;
231 NoNotes;
232 NoWarnings;
233 IgnoreConflicts;
234 OptionsFile">
235 <Output
236 TaskParameter="Result" ItemName="options" />
237 </Flatten>
238
239 <!--
240 ///////////////////////////////////////////////////////////////////////////////////////////////
241 // Translate local paths to build host paths
242 // -->
243 <HostTranslatePaths
244 Items="@(options)"
245 Names="InputFile;
246 OutputFile;
247 IncludePath;
248 MacFramework;
249 PathPrefix;
250 ForceInclude;
251 PrependInclude;
252 Include;
253 OptionsFile">
254 <Output
255 TaskParameter="Result" ItemName="HostPath" />
256 </HostTranslatePaths>
257 <ItemGroup>
258 <options Condition="'%(Identity)' != ''">
259 <Value>@(HostPath->'%(Value)')</Value>
260 </options>
261 </ItemGroup>
262
263 <ItemGroup>
264 <!--
265 /////////////////////////////////////////////////////////////////////////////////////////////
266 // Escape double-quotes in macro definitions
267 // -->
268 <options>
269 <Value Condition="('%(Name)' == 'Define' OR '%(Name)' == 'Undefine')
270 AND ($([System.String]::Copy('%(Value)').Contains(' '))
271 OR $([System.String]::Copy('%(Value)').Contains('&quot;')))"
272 > &quot;$([System.String]::Copy('%(Value)').Replace('&quot;', '\&quot;'))&quot;</Value>
273 </options>
274
275 <!--
276 /////////////////////////////////////////////////////////////////////////////////////////////
277 // Remove quotes from all paths
278 // Escape trailing back-slash in paths
279 // Add quotes to paths containing spaces
280 // -->
281 <options>
282 <Value Condition="'%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
283 OR '%(Name)' == 'IncludePath' OR '%(Name)' == 'MacFramework' OR '%(Name)' == 'PathPrefix'
284 OR '%(Name)' == 'ForceInclude' OR '%(Name)' == 'PrependInclude' OR '%(Name)' == 'Include'
285 OR '%(Name)' == 'OptionsFile'"
286 >$([System.String]::Copy('%(Value)').Replace('&quot;', ''))</Value>
287 </options>
288
289 <options>
290 <Value Condition="('%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
291 OR '%(Name)' == 'IncludePath' OR '%(Name)' == 'MacFramework' OR '%(Name)' == 'PathPrefix'
292 OR '%(Name)' == 'ForceInclude' OR '%(Name)' == 'PrependInclude' OR '%(Name)' == 'Include'
293 OR '%(Name)' == 'OptionsFile')
294 AND $([System.String]::Copy('%(Value)').Contains(' '))
295 AND $([System.String]::Copy('%(Value)').EndsWith('\'))"
296 >%(Value)\</Value>
297 </options>
298
299 <options>
300 <Value Condition="('%(Name)' == 'InputFile' OR '%(Name)' == 'OutputFile'
301 OR '%(Name)' == 'IncludePath' OR '%(Name)' == 'MacFramework' OR '%(Name)' == 'PathPrefix'
302 OR '%(Name)' == 'ForceInclude' OR '%(Name)' == 'PrependInclude' OR '%(Name)' == 'Include'
303 OR '%(Name)' == 'OptionsFile')
304 AND $([System.String]::Copy('%(Value)').Contains(' '))"
305 >&quot;%(Value)&quot;</Value>
306 </options>
307
308 <!--
309 ///////////////////////////////////////////////////////////////////////////////////////////////
310 // Generate tool command line arguments
311 // -->
312 <!--// [header-file] Header file to read from -->
313 <options>
314 <Value Condition="'%(Name)' == 'InputFile'">%(Value)</Value>
315 </options>
316
317 <!--// -o <file> Write output to file -->
318 <options>
319 <Value Condition="'%(Name)' == 'OutputFile'">-o %(Value)</Value>
320 </options>
321
322 <!--// -I <dir> Add dir to the include path for header files -->
323 <options>
324 <Value Condition="'%(Name)' == 'IncludePath'">-I%(Value)</Value>
325 </options>
326
327 <!--// -F <framework> Add macOS framework to the include path for headers -->
328 <options>
329 <Value Condition="'%(Name)' == 'MacFramework'">-F %(Value)</Value>
330 </options>
331
332 <!--// -E Preprocess only; do not generate meta object code -->
333 <options>
334 <Value Condition="'%(Name)' == 'PreprocessOnly' AND '%(Value)' != 'true'"></Value>
335 </options>
336 <options>
337 <Value Condition="'%(Name)' == 'PreprocessOnly' AND '%(Value)' == 'true'">-E</Value>
338 </options>
339
340 <!--// -D <macro[=def]> Define macro, with optional definition -->
341 <options>
342 <Value Condition="'%(Name)' == 'Define'">-D%(Value)</Value>
343 </options>
344
345 <!--// -U <macro> Undefine macro-->
346 <options>
347 <Value Condition="'%(Name)' == 'Undefine'">-U%(Value)</Value>
348 </options>
349
350 <!--// -M <key=value> Add key/value pair to plugin meta data -->
351 <options>
352 <Value Condition="'%(Name)' == 'Metadata'">-M%(Value)</Value>
353 </options>
354
355 <!--// -compiler-flavor <flavor> Set the compiler flavor: either "msvc" or "unix" -->
356 <options>
357 <Value Condition="'%(Name)' == 'CompilerFlavor'">--compiler-flavor %(Value)</Value>
358 </options>
359
360 <!--// -i Do not generate an #include statement -->
361 <options>
362 <Value Condition="'%(Name)' == 'NoInclude' AND '%(Value)' != 'true'"></Value>
363 </options>
364 <options>
365 <Value Condition="'%(Name)' == 'NoInclude' AND '%(Value)' == 'true'">-i</Value>
366 </options>
367
368 <!--// -p <path> Path prefix for included file -->
369 <options>
370 <Value Condition="'%(Name)' == 'PathPrefix'">-p%(Value)</Value>
371 </options>
372
373 <!--// -f <file> Force #include <file> (overwrite default) -->
374 <options>
375 <Value Condition="'%(Name)' == 'ForceInclude'">-f %(Value)</Value>
376 </options>
377
378 <!--// -b <file> Prepend #include <file> (preserve default include) -->
379 <options>
380 <Value Condition="'%(Name)' == 'PrependInclude'">-b %(Value)</Value>
381 </options>
382
383 <!--// -include <file> Parse <file> as an #include before the main source(s) -->
384 <options>
385 <Value Condition="'%(Name)' == 'Include'">--include %(Value)</Value>
386 </options>
387
388 <!--// -n <which> Do not display notes (-nn) or warnings (-nw) -->
389 <options>
390 <Value Condition="'%(Name)' == 'NoNotesWarnings'">-n%(Value)</Value>
391 </options>
392
393 <!--// -no-notes Do not display notes -->
394 <options>
395 <Value Condition="'%(Name)' == 'NoNotes' AND '%(Value)' != 'true'"></Value>
396 </options>
397 <options>
398 <Value Condition="'%(Name)' == 'NoNotes' AND '%(Value)' == 'true'">--no-notes</Value>
399 </options>
400
401 <!--// -no-warnings Do not display warnings (implies -no-notes) -->
402 <options>
403 <Value Condition="'%(Name)' == 'NoWarnings' AND '%(Value)' != 'true'"></Value>
404 </options>
405 <options>
406 <Value Condition="'%(Name)' == 'NoWarnings' AND '%(Value)' == 'true'">--no-warnings</Value>
407 </options>
408
409 <!--// -ignore-option-clashes Ignore all options that conflict with compilers -->
410 <options>
411 <Value Condition="'%(Name)' == 'IgnoreConflicts' AND '%(Value)' != 'true'"></Value>
412 </options>
413 <options>
414 <Value Condition="'%(Name)' == 'IgnoreConflicts' AND '%(Value)' == 'true'"
415 >--ignore-option-clashes</Value>
416 </options>
417
418 <!--// [@option-file] Read additional options from option-file-->
419 <options>
420 <Value Condition="'%(Name)' == 'OptionsFile'">@%(Value)</Value>
421 </options>
422 </ItemGroup>
423 <PropertyGroup>
424 <options>@(options->'%(Value)', ' ')</options>
425 </PropertyGroup>
426
427 <!--
428 ///////////////////////////////////////////////////////////////////////////////////////////////
429 // Aux properties
430 // -->
431 <PropertyGroup>
432 <!--// Force modified flag if source was manually selected to build -->
433 <input_changed Condition="'$(SelectedFiles)' != ''"
434 >true</input_changed>
435 <input_changed Condition="'$(SelectedFiles)' == ''"
436 >%(QtMoc.InputChanged)</input_changed>
437
438 <!--// Run work in parallel processes -->
439 <run_parallel Condition="'@(QtMoc)' != ''
440 AND '%(QtMoc.ParallelProcess)' == 'true'
441 AND '$(SelectedFiles)' == ''"
442 >true</run_parallel>
443
444 <!--// Run work in single process -->
445 <run_single Condition="'@(QtMoc)' != ''
446 AND ('%(QtMoc.ParallelProcess)' != 'true'
447 OR '$(SelectedFiles)' != '')"
448 >true</run_single>
449
450 <!--// Get relative path to output -->
451 <output_relative
452 >$([MSBuild]::MakeRelative($(ProjectDir), %(QtMoc.OutputFile)).TrimStart('\'))</output_relative>
453
454 <!--// Get relative path to input -->
455 <input_relative
456 >$([MSBuild]::MakeRelative($(ProjectDir), %(QtMoc.InputFile)).TrimStart('\'))</input_relative>
457 </PropertyGroup>
458
459 <!--
460 ///////////////////////////////////////////////////////////////////////////////////////////////
461 // Create work item
462 // -->
463 <ItemGroup Condition="'$(run_parallel)' == 'true' OR '$(run_single)' == 'true'">
464 <QtWork Include="@(QtMoc)">
465 <WorkType>moc</WorkType>
466 <ToolPath Condition="'$(QtVsProjectSettings)' == 'true'"
467 >$(QtToolsPath)/moc</ToolPath>
468 <ToolPath Condition="'$(QtVsProjectSettings)' != 'true'"
469 >%(QtMoc.QTDIR)\bin\moc.exe</ToolPath>
470 <Options>$(options)</Options>
471 <Message>%(QtMoc.ExecutionDescription)</Message>
472 <DependenciesChanged>$(dependencies_changed)</DependenciesChanged>
473 <InputChanged>$(input_changed)</InputChanged>
474 <ParallelBuild Condition="'$(run_parallel)' == 'true'">true</ParallelBuild>
475 <ParallelBuild Condition="'$(run_single)' == 'true'">false</ParallelBuild>
476 <!--
477 ///////////////////////////////////////////////////////////////////////////////////////////
478 // C++ dynamic source -->
479 <ClCompile Condition="'%(QtMoc.DynamicSource)' == 'output'">$(output_relative)</ClCompile>
480 <ClCompile Condition="'%(QtMoc.DynamicSource)' == 'input'">$(input_relative)</ClCompile>
481 </QtWork>
482 </ItemGroup>
483
484 <!--
485 ///////////////////////////////////////////////////////////////////////////////////////////////
486 // Clean-up
487 // -->
488 <PropertyGroup>
489 <options/>
490 <dependencies_changed/>
491 <input_changed/>
492 <run_parallel/>
493 <run_single/>
494 <output_relative/>
495 <input_relative/>
496 </PropertyGroup>
497 <ItemGroup>
498 <options Remove="@(options)"/>
499 </ItemGroup>
500 </Target>
501
502 <!--
503 /////////////////////////////////////////////////////////////////////////////////////////////////
504 // Import dependants
505 // -->
506 <Import
507 Condition="'$(QtMsBuildTargets_AfterMoc)' != ''"
508 Project="$(QtMsBuildTargets_AfterMoc)"/>
509
510 </Project>