forked from ubisoft/Sharpmake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.Configuration.cs
More file actions
3732 lines (3221 loc) · 179 KB
/
Copy pathProject.Configuration.cs
File metadata and controls
3732 lines (3221 loc) · 179 KB
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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) Ubisoft. All Rights Reserved.
// Licensed under the Apache 2.0 License. See LICENSE.md in the project root for license information.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
namespace Sharpmake
{
/// <summary>
/// Options to specify the properties of the dependencies between projects. This is used with
/// <see cref="Project.Configuration.AddPublicDependency"/> and
/// <see cref="Project.Configuration.AddPrivateDependency"/>.
/// </summary>
[Flags]
public enum DependencySetting
{
/// <summary>
/// The dependent project must be built after the dependency.
/// Otherwise the two files have no dependencies.
/// </summary>
OnlyBuildOrder = 0,
/// <summary>
/// The dependent project inherits the library files of the dependency.
/// Valid only when the project is a C or a C++ project.
/// </summary>
LibraryFiles = 1 << 1,
/// <summary>
/// The dependent project inherits the library paths of the dependency.
/// Valid only when the project is a C or a C++ project.
/// </summary>
LibraryPaths = 1 << 2,
/// <summary>
/// The dependent project inherits the include paths of the dependency.
/// Valid only when the project is a C or a C++ project.
/// </summary>
IncludePaths = 1 << 3,
/// <summary>
/// The dependent project inherits the defined symbols of the dependency.
/// Valid only when the project is a C or a C++ project.
/// </summary>
Defines = 1 << 4,
/// <summary>
/// The dependent project inherits the `using` paths of the dependency.
/// Valid only if the project is a C# project and uses Microsoft C++/CX extensions .
/// </summary>
AdditionalUsingDirectories = 1 << 5,
ForceUsingAssembly = 1 << 6,
/// <summary>
/// Specifies that the dependent project inherits the dependency's library files, library
/// paths, include paths and defined symbols.
/// </summary>
Default = LibraryFiles |
LibraryPaths |
IncludePaths |
Defines,
/// <summary>
/// Specifies that the dependent project inherits the dependency's include paths and
/// defined symbols, but not it's library files or library paths. Use this for header-only
/// C++ libraries.
/// </summary>
DefaultWithoutLinking = IncludePaths |
Defines,
DefaultForceUsing = ForceUsingAssembly
| IncludePaths
| Defines,
}
/// <summary>
/// Visibility types for inter-project dependency relationships. This setting is
/// usually only meaningful in cases where a library depends on another library because
/// one of its executables has an end-point in the other's dependency graph.
/// </summary>
public enum DependencyType
{
/// <summary>
/// Specifies that the dependency relationship is private. The dependent project will not
/// expose the dependency's exported properties, such as it's include paths.
/// </summary>
/// <remarks>
/// A library that has a private dependency relationship with another library will use that
/// library internally when compiled but will not expose the private dependency's
/// exported properties (library paths, include paths, etc.) when other projects link to
/// it. For example, if library B has a private dependency on C and A wants to link to B,
/// A will not inherit any of C's include paths, library paths, etc.
/// </remarks>
Private,
/// <summary>
/// Specifies that the dependency relationship is public. The dependent project will expose
/// the dependency's exported properties as it's own.
/// </summary>
/// <remarks>
/// A library that has a public dependency relationship with another library will expose
/// that dependency's include paths, library paths, etc. to any project that has a public
/// dependency on it. For example, if library B has a public dependency on C and A wants to
/// link to B, A will inherit all of C's include paths, library paths, etc.
/// </remarks>
Public
}
public partial class Project
{
/// <summary>
/// Holds the properties of an individual project's configuration. This holds all the
/// properties and settings needed to generate the configuration.
/// </summary>
/// <remarks>
/// This class is at the core of Sharpmake's generation engine. Methods marked with
/// <see cref="Generate"/> are passed an instance of this class and set its properties
/// accordingly in order to generate the configuration. Please refer to the (Sharpmake
/// documentation and tutorials)[https://github.com/ubisoftinc/Sharpmake/wiki] for a
/// full explanation.
/// <para>
/// Unless specified otherwise, all string properties can contain tokens that are resolved
/// after the configuration phase, during the generation. Those tokens are inserted
/// using square brackets. For example, you can write the following to refer to the
/// project's */src/code.cpp* file in it's root.
/// <c>
/// conf.Property = "[project.SourceRootPath]/src/code.cpp";
/// </c>
/// This is very useful for paths because they often need to combine path elements, and
/// this is much less verbose than <c>Path.Combine</c>. This is also useful because Sharpmake
/// currently doesn't support string interpolation (it uses Roslyn to compile the scripts).
/// Note, however, these tokens don't understand the scope in which they're used and
/// only support the following source objects:
/// * `project`
/// * `solution`
/// * `conf`
/// </para>
/// <note>
/// There is one important caveat for C++ projects in relation to exceptions. Because
/// Sharpmake was originally designed as an internal tool to build engines for interactive
/// games at Ubisoft, **C++ exceptions are disabled by default**. If your project uses
/// exceptions, they currently must be manually re-enabled by adding the correct exception
/// setting. For Visual Studio projects, add the correct value of
/// <see cref="Options.Vc.Compiler.Exceptions"/> to the
/// <see cref="Sharpmake.Configuration.Options"/> property, as in the example below.
/// <code language=cs>
/// conf.Options.Add(Sharpmake.Options.Vc.Compiler.Exceptions.Enable);
/// </code>
/// </note>
/// <note>
/// In addition, you can selectively enable and disable exceptions on source files on a
/// file-by-file basis using <see cref="SourceFilesExceptionsEnabled"/>,
/// <see cref="SourceFilesExceptionsEnabledWithExternC"/> or
/// <see cref="SourceFilesExceptionsEnabledWithSEH"/>.
/// </note>
/// <note>
/// Finally, source files compiled in a context that requires C++ exceptions
/// (such as source files compiled with the WinRT extensions)
/// are implicitly added to <see cref="SourceFilesExceptionsEnabled"/>.
/// </note>
/// </remarks>
[Resolver.Resolvable]
public class Configuration : Sharpmake.Configuration
{
/// <summary>
/// Interface for classes that implement platform-specific tasks for generating
/// configurations. An implementation of this interface is required when generating
/// for a platform.
/// </summary>
/// <remarks>
/// Implementations can assume that they will only be called by Sharpmake, and that the
/// arguments are sane (ex: <see cref="SetupStaticLibraryPaths"/> is passed valid (non-null)
/// configurations).
/// </remarks>
public interface IConfigurationTasks
{
/// <summary>
/// Sets up the library paths when adding a dependency on a dynamic library.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/> instance on which
/// to set the paths.</param>
/// <param name="dependencySetting">The <see cref="DependencySetting"/> bitflags
/// that specify the properties of the dependency relationship.</param>
/// <param name="dependency">The <see cref="Configuration"/> instance of the dependency.</param>
void SetupDynamicLibraryPaths(Configuration configuration, DependencySetting dependencySetting, Configuration dependency);
/// <summary>
/// Sets up the library paths when adding a dependency on a static library.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/> instance on which to
/// set the paths.</param>
/// <param name="dependencySetting">The <see cref="DependencySetting"/> bitflags
/// that specify the properties of the dependency relationship.</param>
/// <param name="dependency">The <see cref="Configuration"/> instance of the dependency.</param>
void SetupStaticLibraryPaths(Configuration configuration, DependencySetting dependencySetting, Configuration dependency);
// The below method was replaced by GetDefaultOutputFullExtension
// string GetDefaultOutputExtension(OutputType outputType);
/// <summary>
/// Gets the default file extension for a given output type.
/// </summary>
/// <param name="outputType">The <see cref="OutputType"/> whose default file extension we are seeking.</param>
/// <returns>A string, containing the file extension (could be empty on some platforms, like exe on linux).</returns>
string GetDefaultOutputFullExtension(OutputType outputType);
/// <summary>
/// Gets the default file prefix for a given output type.
/// </summary>
/// <param name="outputType">The <see cref="OutputType"/> whose default file prefix we are seeking.</param>
/// <returns>A string, containing the file prefix (for instance lib on linux).</returns>
string GetOutputFileNamePrefix(Project.Configuration.OutputType outputType);
/// <summary>
/// Gets the library paths native to the specified configuration's platform.
/// </summary>
/// <param name="configuration">The <see cref="Configuration"/> to get the paths for.</param>
/// <returns>A list of library paths for the specified configuration and platform.</returns>
IEnumerable<string> GetPlatformLibraryPaths(Configuration configuration);
}
private static int s_count = 0;
/// <summary>
/// Gets the number of generated <see cref="Configuration"/> instances.
/// </summary>
public static int Count => s_count;
private const string RemoveLineTag = "REMOVE_LINE_TAG";
private enum LinkState
{
NotLinked,
Linking,
Linked
}
private LinkState _linkState = LinkState.NotLinked;
public Configuration()
{
PrecompSourceExcludeExtension.Add(".asm");
}
/// <summary>
/// Maps the .NET <see cref="OutputType"/> into its native counterpart.
/// </summary>
/// <param name="type">Specifies the <see cref="OutputType"/> to map.</param>
/// <returns> Returns the mapped <see cref="OutputType"/> value.</returns>
/// <remarks>
/// This method maps values of <see cref="OutputType"/> in the following way:
/// * <see cref="OutputType.DotNetConsoleApp"/> and <see cref="OutputType.DotNetWindowsApp"/> are mapped to <see cref="OutputType.Exe"/>.
/// * <see cref="OutputType.DotNetClassLibrary"/> is mapped to <see cref="OutputType.Dll"/>.
/// * Other values are mapped to themselves.
/// </remarks>
public static OutputType SimpleOutputType(OutputType type)
{
switch (type)
{
case OutputType.DotNetConsoleApp:
case OutputType.DotNetWindowsApp:
return OutputType.Exe;
case OutputType.DotNetClassLibrary:
return OutputType.Dll;
default:
return type;
}
}
/// <summary>
/// Output types for the <see cref="Configuration"/>.
/// </summary>
public enum OutputType
{
/// <summary>
/// Output is an executable/>.
/// </summary>
Exe,
/// <summary>
/// Output is a static library/>.
/// </summary>
Lib,
/// <summary>
/// Output is a DLL(Dynamic Link library)/>.
/// </summary>
Dll,
/// <summary>
/// The project does not produce any code. It is either a header-only library, or a
/// utility project that is used as part of the build system but does not produce
/// any code.
/// </summary>
Utility,
/// <summary>
/// The output is an executable .NET program that opens a console window on
/// startup. The extension is always <c>.exe</c>.
/// </summary>
DotNetConsoleApp,
/// <summary>
/// The output is a .NET class library that can be added as a reference. The
/// extension is always <c>.dll</c>.
/// </summary>
DotNetClassLibrary,
/// <summary>
/// The output is an executable .NET program that does not display a console window
/// on startup. The extension is always <c>.exe</c>.
/// </summary>
DotNetWindowsApp,
/// <summary>
/// The output is an Apple (macOS|iOS|tvOS|watchOS) app.
/// </summary>
AppleApp,
/// <summary>
/// The output is an Apple (macOS|iOS|tvOS|watchOS) framework (i.e. a Bundle of DLL (dylib) and Headers).
/// </summary>
AppleFramework,
/// <summary>
/// The output is an Apple (macOS|iOS|tvOS|watchOS) Bundle (i.e. kind of equivalent to DLL (dylib)).
/// </summary>
AppleBundle,
/// <summary>
/// The output is an iOS test bundle.
/// </summary>
IosTestBundle,
/// <summary>
/// Specifies no output. Do not use this.
/// </summary>
None,
}
/// <summary>
/// Methods to list source files.
/// </summary>
/// <remarks>
/// This is only used for FASTBuild generation.
/// </remarks>
public enum InputFileStrategy
{
/// <summary>
/// Explicitly refer to files in FASTBuild configuration files using file lists.
/// </summary>
Include = 0x01,
/// <summary>
/// Implicitly refer to files in FASTBuild configuration files using paths and
/// exclusion file lists.
/// </summary>
Exclude = 0x02
}
/// <summary>
/// FASTBuild deoptimization strategies for writable files.
/// </summary>
public enum DeoptimizationWritableFiles
{
/// <summary>
/// No deoptimization. This is the default.
/// </summary>
NoDeoptimization = 0x01, // default
/// <summary>
/// Deoptimize all files with a writable flag on the file system.
/// </summary>
/// <remarks>
/// This is useful when using Perforce, since files that have not been modified are
/// typically read-only. That is, this option enables automatic deoptimization of modified files.
/// </remarks>
DeoptimizeWritableFiles = 0x02,
/// <summary>
/// When the <c>FASTBUILD_DEOPTIMIZE_OBJECT</c> token is specified,
/// deoptimize files with writable status.
/// </summary>
/// <remarks>
/// This is useful when using Perforce, since files that have not been modified are
/// typically read-only. That is, this enables automatic deoptimization of modified files.
/// </remarks>
DeoptimizeWritableFilesWithToken = 0x04
//
// Probably want to support deoptimiztion for other SSCs, ie: files that are changed or staged on Git.
//
}
/// <summary>
/// When the output is an executable program, this lists the levels of privileges that
/// it can require upon execution, using Windows' User Account Control (UAC.)
/// </summary>
public enum UACExecutionLevel
{
/// <summary>
/// UAC Execution Level: as invoker.
/// </summary>
/// <remarks>
/// Use the same privileges as the process that created the program.
/// </remarks>
asInvoker,
/// <summary>
/// UAC Execution Level: highest available.
/// </summary>
/// <remarks>
/// Use the highest privileges available to the current user.
/// </remarks>
highestAvailable,
/// <summary>
/// UAC Execution Level: require administrator.
/// </summary>
/// <remarks>
/// Always run with administrator privileges. This will usually open a UAC dialog
/// box for the user.
/// </remarks>
requireAdministrator
}
public Strings PathExcludeBuild = new Strings();
private OutputType _output = OutputType.Exe; // None is default if Export
/// <summary>
/// Gets or sets the output type of the current configuration, exe, lib or dll.
/// </summary>
public OutputType Output
{
get { return _output; }
set
{
if (!Project.IsValidConfigurationOutputType(value))
throw new Error("The specified configuration output type \"{0}\" is not valid for the project \"{1}\".", value, Project.GetType().ToNiceTypeName());
_output = value;
}
}
/// <summary>
/// Gets or sets the project's output extension (ie: .dll, .self, .exe, .dlu).
/// </summary>
[Obsolete("Use " + nameof(TargetFileFullExtension) + " instead", error: true)]
public string OutputExtension = null;
/// <summary>
/// Gets or sets whether to copy output files to the output directory.
/// </summary>
/// <remarks>
/// This setting is provided for libraries, because they are usually intermediate
/// artifacts during the compilation process and do not need to be in the final output
/// directory unless it's necessary.
/// <para>
/// The default is <c>false</c>. Setting this to <c>true</c> will force the generators
/// to copy the library artifacts.
/// </para>
/// <para>
/// If <see cref="Output"/> is set to a value that corresponds to an executable program
/// (ie: <see cref="OutputType.Exe"/>), the generators disregard this property and
/// always copy the results.
/// </para>
/// </remarks>
public bool ExecuteTargetCopy = false;
/// <summary>
/// Gets or sets whether the configuration output dll file will be copied in the target path of the projects depending on it.
/// </summary>
/// <remarks>
/// This setting only apply with <see cref="OutputType.Dll"/>
/// This setting is usefull for dlls that are dynamically loaded:
/// The dll do not need to be put along the executable.
/// <para>
/// The default is <c>true</c>. Setting this to <c>false</c> will prevent the generators
/// to copy the library artifact in the exe directory.
/// </para>
/// </remarks>
public bool AllowOutputDllCopy = true;
/// <summary>
/// Controls whether the .pdb files of [Export] projects will be copied to dependents.
/// The default value is <c>false</c>.
/// </summary>
public bool AllowExportProjectsToCopyPdbToDependentTargets = false;
/// <summary>
/// Gets or sets whether dependent projects will copy their dll debugging database to the
/// target path of their dependency projects. The default value is <c>true</c>.
/// </summary>
public bool CopyLinkerPdbToDependentTargets = true;
/// <summary>
/// Gets or sets whether dependent projects will copy their debugging database to the
/// target path of their dependency projects. The default value is <c>false</c>.
/// </summary>
public bool CopyCompilerPdbToDependentTargets = false;
// Xcopy parameters
// /d Copy file only if the source time is newer than the destination time.
// /F Displays full source and destination file names while copying.
// /R Overwrites read-only files.
// /H Copies hidden and system files.
// /V Verifies the size of each new file.
// /Y Suppresses prompting to confirm whether you want to overwrite an existing destination file or not.
/// <summary>
/// Command to execute <see cref="TargetCopyFiles"/>.
/// </summary>
/// <param name="relativeSourcePath">The relative path to the files.</param>
/// <param name="relativeTargetPath">The relative path to the target directory.</param>
/// <param name="workingPath">The path to the working directory.</param>
/// <returns>The mapped <see cref="OutputType"/> value as a string.</returns>
public delegate string TargetCopyCommandCreator(string relativeSourcePath, string relativeTargetPath, string workingPath);
public TargetCopyCommandCreator CreateTargetCopyCommand =
(source, target, workingPath) => string.Format(@"xcopy /d /F /R /H /V /Y ""{0}"" ""{1}"" >nul", source, target);
/// <summary>
/// Setting this boolean to true forces Sharpmake to fill in the AD fields in the current static
/// library project.
/// </summary>
/// <remarks>
/// Since Sharpmake handles all dependencies, using an <c>AdditionalDependencies</c> field in
/// your project is typically useless for static libraries. However, when dependents aren't
/// generated by Sharpmake, (that is, when a .sln contains Sharpmake generated projects as static
/// libraries as well as manually maintained dependent projects) this feature can be useful.
/// <para>
/// The default is <c>false</c>. Set this boolean to <c>true</c> to make Sharpmake fill in the fields
/// for the current static library project.
/// </para>
/// </remarks>
public bool ExportAdditionalLibrariesEvenForStaticLib = false;
/// <summary>
/// Setting this boolean to true forces Sharpmake to bypass the additional dependencies prefix added normally
/// on libraries (-l{...}, or lib{...}.a).
/// </summary>
/// <remarks>
/// Since Sharpmake handles all dependencies, using an <c>AdditionalDependencies</c> field in
/// your project as librairies, it is impossible to add other dependencies like externally built objects
/// (i.e. *.asm files build externally as *.o). When this is the case, bypassing the prefixing can allow us
/// more flexibility on our build pipeline.
/// <para>
/// The default is <c>false</c>. Set this boolean to <c>true</c> to make Sharpmake skip the name mangling of
/// the additional dependencies.
/// </para>
/// </remarks>
public bool BypassAdditionalDependenciesPrefix = false;
/// <summary>
/// Gets or sets the name of the project, as viewed by the configuration.
/// </summary>
/// <remarks>
/// Under normal circumstances, you should not need to edit this property. The name of
/// the project is set in <see cref="Name"/> and this is the default value.
/// </remarks>
public string ProjectName = "[project.Name]";
/// <summary>
/// Gets or sets the file name for the generated project, without any file extension.
/// (ex: `"MyProject"`)
/// </summary>
public string ProjectFileName = "[project.Name]";
/// <summary>
/// Gets or sets the directory in which the project will be generated.
/// </summary>
/// <remarks>
/// By default, this is set to the same directory that this Sharpmake script is running in.
/// </remarks>
public string ProjectPath = "[project.SharpmakeCsPath]";
/// <summary>
/// Gets or sets the name of the generated .NET assembly.
/// </summary>
/// <remarks>
/// Ignored in projects that are not built on the .NET framework.
/// </remarks>
public string AssemblyName = "[project.AssemblyName]";
/// <summary>
/// Gets the full path of the project file, including the directory and the
/// file name. This doesn't include the file extension which depends on
/// the generator.
/// </summary>
public string ProjectFullFileName { get { return Path.Combine(ProjectPath, ProjectFileName); } }
/// <summary>
/// Gets or sets the solution folder that will hold the Visual Studio solution for this project.
/// </summary>
/// <remarks>
/// Ignored unless building a Visual Studio project.
/// <para>
/// To place the project in a sub-directory, use a `/` as a directory separator.
/// </para>
/// </remarks>
public string SolutionFolder = "";
/// <summary>
/// Set the solution folder associated with a solution name
/// </summary>
/// <remarks>
/// Ignored unless generating for Visual Studio
/// This property allows to get the same project being in different folder dependeng on the solution name. Ex. In Engine.sln the project Physic is at root, while in Tools.sln it is in a Engine/ directory
/// Use the property SolutionFolder if not found inside the dictionary.
/// <para>
/// To place the project in a sub-directory, use a `/` as a directory separator.
/// </para>
/// </remarks>
public void AddSolutionFolder(string solutionName, string solutionFolder)
{
_solutionFolders[solutionName] = solutionFolder;
}
/// <summary>
/// Gets the solution folder associated with a solution name.
/// </summary>
public string GetSolutionFolder(string solutionName)
{
string specificSolutionFolder = null;
if (_solutionFolders.TryGetValue(solutionName, out specificSolutionFolder) == false)
return SolutionFolder;
return specificSolutionFolder;
}
private Dictionary<string, string> _solutionFolders = new Dictionary<string, string>();
/// <summary>
/// Gets or sets the suffix to use in <see cref="LinkerPdbSuffix"/>.
/// If unset, the pdb file names will be the target name with a suffix and the .pdb extension.
/// </summary>
/// <remarks>
/// Always put a separate pdb for the compiler in the intermediate path to avoid
/// conflicts with the one from the linker.
/// This helps the following things:
/// 1. Makes the linker go faster
/// 2. Avoid pdbs for dlls and .exe(s) growing and growing at each link
/// 3. Makes incremental linking work better.
/// </remarks>
public string LinkerPdbSuffix = string.Empty;
/// <summary>
/// Gets or sets the directory and file name of the Visual Studio *linker* PDB file,
/// including the file extension.
/// </summary>
/// <remarks>
/// Used only when generating a Visual Studio project.
/// <para>
/// The default value is:
/// <c>[conf.TargetPath]/[conf.TargetFileFullName][conf.LinkerPdbSuffix].pdb</c>.
/// </para>
/// <para>
/// Always put a separate PDB for the compiler in the intermediate path to avoid
/// conflicts with the one from the linker.
/// </para>
/// </remarks>
public string LinkerPdbFilePath = "[conf.TargetPath]" + Path.DirectorySeparatorChar + "[conf.TargetFileFullName][conf.LinkerPdbSuffix].pdb";
/// <summary>
/// Gets or sets the suffix to use in <see cref="CompilerPdbFilePath"/>.
/// </summary>
/// <remarks>
/// Provided only as a convenience as it is only used in the default
/// value of <see cref="CompilerPdbFilePath"/> to assign a suffix to the PDB. If you
/// change <see cref="CompilerPdbFilePath"/> so that it doesn't use this property,
/// then it isn't used.
/// </remarks>
public string CompilerPdbSuffix = "_compiler";
/// <summary>
/// Gets or sets the directory and file name of the Visual Studio <i>compiler</i> PDB file,
/// including the file extension.
/// </summary>
/// <remarks>
/// Used only when generating a Visual Studio project.
/// <para>
/// The default value is
/// <c>[conf.IntermediatePath]/[conf.TargetFileFullName][conf.CompilerPdbSuffix].pdb</c>.
/// </para>
/// <para>
/// The default file name in <see cref="CompilerPdbFilePath"/> in Sharpmake does not
/// match its default file name in Visual Studio for compiler PDB, which is <c>VCx0.pdb</c>.
/// See <externalLink>
/// <linkText> /Fd (Program Database File Name)</linkText>
/// <linkUri>https://msdn.microsoft.com/en-us/library/9wst99a9.aspx</linkUri>
/// </externalLink>.
/// If you mean to use Visual Studio's default value, you must set this property to <c>null</c>.
/// </para>
/// <para>
/// Always put a separate PDB for the compiler in the intermediate path to avoid
/// conflicts with the one from the linker.
/// </para>
/// </remarks>
public string CompilerPdbFilePath = "[conf.IntermediatePath]" + Path.DirectorySeparatorChar + "[conf.TargetFileFullName][conf.CompilerPdbSuffix].pdb";
/// <summary>
/// Gets or sets whether <see cref="CompilerPdbFilePath"/> and
/// <see cref="LinkerPdbFilePath"/> are relative.
/// </summary>
public bool UseRelativePdbPath = true;
/// <summary>
/// Gets or sets the suffix of the manifests when building a project that uses
/// Microsoft's C++/CX with the build option *Embed Manifest*.
/// </summary>
public string ManifestFileSuffix = ".intermediate.manifest";
/// <summary>
/// Prefix for compiled embedded resource files
/// </summary>
public string EmbeddedResourceOutputPrefix = string.Empty;
/// <summary>
/// Gets or sets the directory where the compiler will place the intermediate files.
/// </summary>
/// <remarks>
/// This corresponds to the <i>Intermediate</i> directory in the Visual Studio project
/// configuration.
/// <para>
/// The default value is <c>[conf.ProjectPath]/obj/[target.Platform]</c>.
/// </para>
/// </remarks>
public string IntermediatePath = "[conf.ProjectPath]" + Path.DirectorySeparatorChar + "obj" + Path.DirectorySeparatorChar + "[target.Platform]" + Path.DirectorySeparatorChar + "[target.Name]";
/// <summary>
/// Base Intermediate devEnv directory. Only used in csproj
/// </summary>
public string BaseIntermediateOutputPath = string.Empty;
/// <summary>
/// Gets the list of defined symbols to use when compiling the project.
/// </summary>
/// <remarks>
/// Generators are allowed to add new symbols to this list when needed. For example,
/// you don't need to explicitly add <c>_WIN32</c> to the list when building for Windows.
/// <para>
/// These symbols are defined during the compilation, not when the project is used as a library.
/// The symbols that need to be defined when this project is being consumed as a
/// library, must be added to <seealso cref="ExportDefines"/> instead.
/// </para>
/// </remarks>
public Strings Defines = new Strings();
/// <summary>
/// Gets the list of symbols that are exported when the project is being used as a
/// library.
/// </summary>
/// <remarks>
/// Not used if the project is not a library.
/// <para>
/// The symbols defined in this list are not defined when building the library. You
/// must define them in <seealso cref="Defines"/>.
/// </para>
/// </remarks>
public Strings ExportDefines = new Strings();
/// <summary>
/// Excludes the specified files from the build. Removes the files in this list from
/// project.SourceFiles and matches project.SourceFilesRegex.
/// </summary>
public Strings SourceFilesBuildExclude = new Strings();
/// <summary>
/// Gets a list of regular expressions that are used to filter matching source files
/// out of the build.
/// </summary>
public Strings SourceFilesBuildExcludeRegex = new Strings();
/// <summary>
/// Gets a list of regular expressions that are used to filter matching source files
/// into the build.
/// </summary>
public Strings SourceFilesFiltersRegex = new Strings();
/// <summary>
/// Source files that match this regex will be compiled as C Files.
/// </summary>
public Strings SourceFilesCompileAsCRegex = new Strings();
/// <summary>
/// Source files that match this regex will be compiled as CPP Files.
/// </summary>
public Strings SourceFilesCompileAsCPPRegex = new Strings();
/// <summary>
/// Source files that match this regex will be compiled as ObjC Files.
/// </summary>
public Strings SourceFilesCompileAsObjCRegex = new Strings();
/// <summary>
/// Source files that match this regex will be compiled as ObjCPP Files.
/// </summary>
public Strings SourceFilesCompileAsObjCPPRegex = new Strings();
/// <summary>
/// Source files that match this regex will be compiled as CLR Files.
/// </summary>
public Strings SourceFilesCompileAsCLRRegex = new Strings();
/// <summary>
/// Source files that match this regex will be excluded from the CLR Files list.
/// Used on C++ projects rather than C++/CLI projects.
/// </summary>
public Strings SourceFilesCompileAsCLRExcludeRegex = new Strings();
/// <summary>
/// Source files that match this regex will be explicitly not compiled as CLR files.
/// Used on C++/CLI projects to force certain files to be compiled without the <c>/clr</c> switch.
/// </summary>
public Strings SourceFilesCompileAsNonCLRRegex = new Strings();
/// <summary>
/// Gets a list of include paths for compiling C and C++ projects.
/// </summary>
/// <remarks>
/// If the project is a library, the include paths are imported in dependent
/// projects. Use <see cref="IncludePrivatePaths"/> if you need to use include paths
/// that are only used to compile the library.
/// </remarks>
public OrderableStrings IncludePaths = new OrderableStrings();
public OrderableStrings DependenciesIncludePaths = new OrderableStrings();
/// <summary>
/// Gets a list of include paths for compiling C and C++ libraries that are not
/// shared with dependent projects.
/// </summary>
public OrderableStrings IncludePrivatePaths = new OrderableStrings();
/// <summary>
/// Gets a list of system include paths for compiling C and C++ projects. When possible, these paths are searched first when #include <> is used.
/// </summary>
public OrderableStrings IncludeSystemPaths = new OrderableStrings();
public OrderableStrings DependenciesIncludeSystemPaths { get; private set; } = new OrderableStrings();
#region Resource Includes
/// <summary>
/// Include paths for resource compilation.
/// These paths will propagate via the IncludePaths DependencySetting, use ResourceIncludePrivatePaths if you want to avoid this
/// </summary>
public OrderableStrings ResourceIncludePaths = new OrderableStrings();
/// <summary>
/// Include paths for resource compilation.
/// These paths are received from dependencies via the IncludePaths DependencySetting.
/// </summary>
public IEnumerable<string> DependenciesResourceIncludePaths => _dependenciesResourceIncludePaths;
protected OrderableStrings _dependenciesResourceIncludePaths = new OrderableStrings();
/// <summary>
/// Include paths for resource compilation.
/// These paths will never propagate.
/// </summary>
public OrderableStrings ResourceIncludePrivatePaths = new OrderableStrings();
#endregion
/// <summary>
/// Include paths for Microsoft Macro Assembler compilation.
/// </summary>
/// <remarks>
/// The maximum number of these paths is 10.
/// </remarks>
public OrderableStrings AssemblyIncludePaths = new OrderableStrings();
/// <summary>
/// Gets a list of compiler options to send when calling the compiler.
/// </summary>
/// <remarks>
/// Generators are allowed to transform the textual representation of the options added
/// here so that they work with the shell of the operating system or with the makefile
/// format.
/// <list type="bullet">
/// <item>The values in this list are simply concatenated, separated with spaces, sanitized
/// for the shell, and then appended directly to the command that calls the compiler.
/// </item>
/// <item>
/// They are not translated from one compiler to the other. When you
/// use this property, you need to know which C++ compiler you're using.
/// </item>
/// </list>
/// <para>
/// This property is for the compiler. Its counterpart for the linker is
/// <see cref="AdditionalLinkerOptions"/>.
/// </para>
/// </remarks>
public OrderableStrings AdditionalCompilerOptions = new OrderableStrings();
/// <summary>
/// Get a list of compiler optimization options to send when calling the compiler. It is necessary to properly implement the
/// fastbuild .CompilerOptionsDeoptimized
/// </summary>
/// <remarks>
/// <para>
/// This property is for the compiler. It is similar to
/// <see cref="AdditionalCompilerOptions"/> but only for optimizations options not exposed by Sharpmake.
/// </para>
/// </remarks>
public OrderableStrings AdditionalCompilerOptimizeOptions = new OrderableStrings();
/// <summary>
/// Compiler-specific options to pass when invoking the compiler to create PCHs.
/// </summary>
/// <remarks>
/// Currently only respected by the BFF generator.
/// </remarks>
public OrderableStrings AdditionalCompilerOptionsOnPCHCreate = new OrderableStrings();
/// <summary>
/// Compiler-specific options to pass when invoking the compiler telling it to use PCHs.
/// </summary>
/// <remarks>
/// Currently only respected by the BFF generator.
/// </remarks>
public OrderableStrings AdditionalCompilerOptionsOnPCHUse = new OrderableStrings();
/// <summary>
/// Gets a list of file extensions that are added to a Visual Studio project with the
/// <b>None</b> build action.
/// </summary>
/// <remarks>
/// Used only by the Visual Studio generators.
/// </remarks>
public Strings AdditionalNone = new Strings();
/// <summary>
/// Adds commands for VS debugger
/// </summary>
/// <remarks>
/// Used only by the Visual Studio generators.
/// </remarks>
public string AdditionalDebuggerCommands = RemoveLineTag;
/// <summary>
/// Gets or sets the name of the source file for the precompiled header in C and C++
/// projects, ie: <c>stdafx.cpp</c>. This property must be <c>null</c> for projects that don't
/// have a precompiled header.
/// </summary>
/// <remarks>
/// Both <see cref="PrecompHeader"/> and <see cref="PrecompSource"/> must be <c>null</c> if
/// the project doesn't have precompiled headers.
/// <para>
/// Sharpmake assumes that a relative path here is relative to <see cref="SourceRootPath"/>.
/// If that isn't correct, you must use an absolute path.
/// </para>
/// </remarks>
public string PrecompSource = null;
/// <summary>
/// Gets or sets the name of the precompiled header in C and C++ projects,
/// ie: <c>stdafx.h</c>. This property must be <c>null</c> for projects that do not have a
/// precompiled header.
/// </summary>
/// <remarks>
/// Both <see cref="PrecompHeader"/> and <see cref="PrecompSource"/> must be <c>null</c> if
/// the project doesn't have precompiled headers.
/// <para>
/// Sharpmake assumes that any relative path entered here is relative to
/// <see cref="SourceRootPath"/>. If that isn't correct, you must use an absolute path.
/// </para>
/// <note>
/// The source files must manually include this header or you will have
/// compiler errors. Sharpmake merely tells the compiler to expect a precompiled
/// header. The compiler doesn't implicitly include the header.
/// </note>
/// </remarks>
public string PrecompHeader = null;
/// <summary>
/// Gets or sets the output directory for the precompiled header's binary file in C and C++
/// projects.
/// </summary>
/// <remarks>
/// If this property is set to <c>null</c>, Sharpmake will simply write the binary file to
/// <see cref="IntermediatePath"/>, the same as the object file.
/// <para>
/// If defined, precompiled headers are written to this directory instead of the intermediate directory.
/// </para>
/// </remarks>
public string PrecompHeaderOutputFolder = null;
/// <summary>
/// Gets or sets the name for the precompiled header's binary file in C and C++ projects,
/// e.g. <c>pch.pch</c>.
/// </summary>
/// <remarks>
/// If this property is set to <c>null</c>, Sharpmake will simply use the project's name.
/// To modify the output directory of this file, use <see cref="PrecompHeaderOutputFolder"/>.
/// </remarks>
public string PrecompHeaderOutputFile = null;
/// <summary>
/// Gets a list of files that don't use the precompiled headers.