This repository has been archived by the owner on Dec 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom.sharpmake.cs
188 lines (153 loc) · 6.04 KB
/
custom.sharpmake.cs
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
using Sharpmake;
using System;
using System.IO;
// https://vector-of-bool.github.io/2018/09/16/layout-survey.html
// https://docs.microsoft.com/bs-cyrl-ba/cpp/build/profile-guided-optimizations?view=vs-2017
namespace Mockup
{
////////////////////////////////////////////////////////////////////////////////
[Fragment, Flags]
public enum CustomOptimization
{
Debug = 0x01,
Profile = 0x02,
Release = 0x04,
Final = 0x80
}
class CustomTarget : Sharpmake.ITarget
{
public Platform Platform = Platform.win64;
public BuildSystem BuildSystem = BuildSystem.MSBuild;
public DevEnv DevEnv = DevEnv.vs2019;
public OutputType OutputType = OutputType.Lib;
public DotNetFramework Framework = DotNetFramework.v4_7_2;
public Blob Blob = Blob.NoBlob;
public CustomOptimization Optimization;
public CustomTarget()
{
}
public CustomTarget(CustomOptimization optimization)
{
Optimization = optimization;
}
public override string Name
{
get { return Optimization.ToString(); }
}
}
////////////////////////////////////////////////////////////////////////////////
class CustomProject : Sharpmake.Project
{
public CustomProject() : base(typeof(CustomTarget))
{
RootPath = @"[project.SharpmakeCsPath]\.build\[project.Name]";
SourceFilesExcludeRegex.Add(@"\\___+");
CustomTarget target = new CustomTarget(CustomOptimization.Debug | CustomOptimization.Final | CustomOptimization.Profile | CustomOptimization.Release);
AddTargets(target);
}
// [Configure]
// void Configure(Configuration conf, Target target)
// {
// ConfigureOptimization(conf, target);
// ConfigureDefines(conf, target);
// }
// public virtual void ConfigureOptimization(Configuration conf, Target target)
// {
// }
// public virtual void ConfigureDefines(Configuration conf, Target target)
// {
// }
[Configure()]
public virtual void Configure(Configuration conf, CustomTarget target)
{
conf.ProjectFileName = "[project.Name]_[target.DevEnv]_[target.Platform]";
conf.ProjectPath = @"[project.RootPath]";
conf.PrecompHeader = @"_[project.Name].hpp";
conf.PrecompSource = @"_[project.Name].cpp";
conf.PrecompSourceExcludeFolders.Add(@"[project.SharpmakeCsPath]\external");
conf.PrecompSourceExcludeFolders.Add(@"[project.SharpmakeCsPath]\tools");
conf.Options.Add(Options.Vc.General.WarningLevel.Level3);
conf.Options.Add(Options.Vc.General.WindowsTargetPlatformVersion.v10_0_19041_0);
conf.Options.Add(Options.Vc.General.WindowsTargetPlatformVersion.Latest);
conf.Options.Add(Options.Vc.General.PlatformToolset.v142);
conf.Options.Add(Options.Vc.General.DebugInformation.ProgramDatabase);
conf.Options.Add(Options.Vc.Compiler.CppLanguageStandard.Latest);
conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable);
conf.Options.Add(Options.Vc.Compiler.RTTI.Enable);
conf.Options.Add(Options.Vc.Compiler.FunctionLevelLinking.Disable);
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDLL);
conf.Options.Add(Options.Vc.Compiler.Optimization.Disable);
conf.Options.Add(Options.Vc.Compiler.Inline.Disable);
conf.Options.Add(Options.Vc.Compiler.EnhancedInstructionSet.AdvancedVectorExtensions2);
conf.Options.Add(Options.Vc.Compiler.SupportJustMyCode.Yes);
conf.Options.Add(Options.Vc.Linker.SubSystem.Windows);
conf.AdditionalCompilerOptions.Add(@"/bigobj");
switch (target.Optimization)
{
case CustomOptimization.Debug:
{
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreadedDebug);
conf.Options.Add(Options.Vc.Compiler.FavorSizeOrSpeed.Neither);
conf.Options.Add(Options.Vc.Compiler.Optimization.Disable);
//conf.Defines.Add("DEBUG");
break;
}
case CustomOptimization.Profile:
case CustomOptimization.Release:
case CustomOptimization.Final:
{
conf.Options.Add(Options.Vc.Compiler.RuntimeLibrary.MultiThreaded);
conf.Options.Add(Options.Vc.Compiler.FavorSizeOrSpeed.FastCode);
conf.Options.Add(Options.Vc.Compiler.Optimization.FullOptimization);
conf.Options.Add(Options.Vc.Compiler.Inline.AnySuitable);
// conf.Options.Add(Options.Vc.General.WholeProgramOptimization.LinkTime);
break;
}
}
conf.IncludePrivatePaths.Add(@"[project.SourceRootPath]");
conf.IncludePrivatePaths.Add(@"[project.SharpmakeCsPath]\external");
conf.IncludePrivatePaths.Add(@"[project.SharpmakeCsPath]\source");
// conf.PrivateIncludePaths.Add();
// conf.LibraryPaths.Add();
// conf.LibraryFiles.Add();
conf.VcxprojUserFile = new Project.Configuration.VcxprojUserFileSettings();
}
}
////////////////////////////////////////////////////////////////////////////////
class CustomLibrary : CustomProject
{
public CustomLibrary()
{
RootPath = @"[project.SharpmakeCsPath]\.build\[project.Name]";
}
public override void Configure(Configuration conf, CustomTarget target)
{
base.Configure(conf, target);
conf.Output = Configuration.OutputType.Lib;
}
}
////////////////////////////////////////////////////////////////////////////////
class CustomProgram : CustomProject
{
public CustomProgram()
{
RootPath = @"[project.SharpmakeCsPath]\.build\[project.Name]";
}
}
////////////////////////////////////////////////////////////////////////////////
class CustomSolution : Sharpmake.Solution
{
public CustomSolution() : base(typeof(CustomTarget))
{
CustomTarget target = new CustomTarget(CustomOptimization.Debug | CustomOptimization.Final | CustomOptimization.Profile | CustomOptimization.Release);
AddTargets(target);
}
[Configure()]
public virtual void Configure(Configuration conf, CustomTarget target)
{
conf.SolutionFileName = "[solution.Name]_[target.DevEnv]_[target.Platform]";
conf.SolutionPath = @"[solution.SharpmakeCsPath]\.build\";
}
}
////////////////////////////////////////////////////////////////////////////////
}