forked from rehlds/ReGameDLL_CS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shared_msvc.gradle
135 lines (123 loc) · 4.53 KB
/
shared_msvc.gradle
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
import org.doomedsociety.gradlecpp.cfg.BinaryKind
import org.doomedsociety.gradlecpp.msvc.CallingConvention
import org.doomedsociety.gradlecpp.msvc.CodeGenerationKind
import org.doomedsociety.gradlecpp.msvc.CppExceptions
import org.doomedsociety.gradlecpp.msvc.DebugInfoFormat
import org.doomedsociety.gradlecpp.msvc.EnhancedInstructionsSet
import org.doomedsociety.gradlecpp.msvc.ErrorReporting
import org.doomedsociety.gradlecpp.msvc.FloatingPointModel
import org.doomedsociety.gradlecpp.msvc.LinkTimeCodeGenKind
import org.doomedsociety.gradlecpp.msvc.MsvcToolchainConfig
import org.doomedsociety.gradlecpp.msvc.OptimizationLevel
import org.doomedsociety.gradlecpp.msvc.RuntimeChecks
import org.doomedsociety.gradlecpp.msvc.WarningLevel
rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
MsvcToolchainConfig cfg
if (release) {
cfg = new MsvcToolchainConfig(
compilerOptions: new MsvcToolchainConfig.CompilerOptions(
codeGeneration: CodeGenerationKind.MULTITHREADED,
optimizationLevel: OptimizationLevel.FULL_OPTIMIZATION,
debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
runtimeChecks: RuntimeChecks.DEFAULT,
cppExceptions: CppExceptions.ENABLED_WITH_SEH,
warningLevel: WarningLevel.LEVEL_3,
callingConvention: CallingConvention.CDECL,
enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
floatingPointModel: FloatingPointModel.FAST,
enableMinimalRebuild: false,
omitFramePointers: false,
wholeProgramOptimization: true,
enabledFunctionLevelLinking: true,
enableSecurityCheck: true,
analyzeCode: false,
sdlChecks: false,
treatWarningsAsErrors: false,
treatWchartAsBuiltin: true,
forceConformanceInForLoopScope: true,
extraDefines: [
'WIN32': null,
'_MBCS': null,
'NDEBUG': null,
]
),
linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
enableIncrementalLinking: false,
eliminateUnusedRefs: true,
enableCOMDATFolding: true,
generateDebugInfo: true,
dataExecutionPrevention: true,
randomizedBaseAddress: true,
),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
),
generatePdb: true
)
} else {
// debug
cfg = new MsvcToolchainConfig(
compilerOptions: new MsvcToolchainConfig.CompilerOptions(
codeGeneration: CodeGenerationKind.MULTITHREADED_DEBUG,
optimizationLevel: OptimizationLevel.DISABLED,
debugInfoFormat: DebugInfoFormat.PROGRAM_DATABASE,
runtimeChecks: RuntimeChecks.DEFAULT,
cppExceptions: CppExceptions.ENABLED_WITH_SEH,
warningLevel: WarningLevel.LEVEL_3,
callingConvention: CallingConvention.CDECL,
enhancedInstructionsSet: EnhancedInstructionsSet.SSE2,
floatingPointModel: FloatingPointModel.FAST,
enableMinimalRebuild: true,
omitFramePointers: false,
wholeProgramOptimization: false,
enabledFunctionLevelLinking: true,
enableSecurityCheck: true,
analyzeCode: false,
sdlChecks: false,
treatWarningsAsErrors: false,
treatWchartAsBuiltin: true,
forceConformanceInForLoopScope: true,
extraDefines: [
'WIN32': null,
'_MBCS': null,
'_DEBUG': null,
]
),
linkerOptions: new MsvcToolchainConfig.LinkerOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.DEFAULT,
errorReportingMode: ErrorReporting.NO_ERROR_REPORT,
enableIncrementalLinking: true,
eliminateUnusedRefs: false,
enableCOMDATFolding: false,
generateDebugInfo: true,
dataExecutionPrevention: true,
randomizedBaseAddress: true
),
librarianOptions: new MsvcToolchainConfig.LibrarianOptions(
linkTimeCodeGenKind: LinkTimeCodeGenKind.USE_LTCG
),
generatePdb: true
)
if (binKind == BinaryKind.STATIC_LIBRARY) {
cfg.compilerConfig.extraDefines['_LIB'] = null
}
}
// Detect and setup UCRT paths
def ucrtInfo = "getucrtinfo.bat".execute().text
def m = ucrtInfo =~ /^(.*)\r\n(.*)?$/
if (!m.find()) {
return cfg
}
def kitPath = m.group(1)
def ucrtVersion = m.group(2)
def ucrtCheckFile = new File("${kitPath}Include/${ucrtVersion}/ucrt/stdio.h");
if (!ucrtCheckFile.exists()) {
return cfg
}
cfg.compilerOptions.args "/FS", "/I${kitPath}Include/${ucrtVersion}/ucrt";
cfg.linkerOptions.args("/LIBPATH:${kitPath}Lib/${ucrtVersion}/ucrt/x86");
cfg.singleDefines('REGAMEDLL_SSE')
return cfg
}