-
Notifications
You must be signed in to change notification settings - Fork 37
/
config.cake
132 lines (113 loc) · 4.49 KB
/
config.cake
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
###############################################################################
# DisruptorPlus - C++ Library implementing a Disruptor data-structure
# Copyright (c) 2013 Lewis Baker
###############################################################################
import sys
import cake.path
import cake.system
from cake.engine import Variant
from cake.script import Script
configuration = Script.getCurrent().configuration
engine = configuration.engine
hostPlatform = cake.system.platform().lower()
hostArchitecture = cake.system.architecture().lower()
from cake.library.script import ScriptTool
from cake.library.variant import VariantTool
from cake.library.env import EnvironmentTool
from cake.library.project import ProjectTool
from cake.library.compilers import CompilerNotFoundError
from cake.library.compilers.msvc import findMsvcCompiler
# Setup all of the parameters common to all variants
baseVariant = Variant()
baseVariant.tools["script"] = script = ScriptTool(configuration=configuration)
baseVariant.tools["variant"] = variant = VariantTool(configuration=configuration)
baseVariant.tools["env"] = env = EnvironmentTool(configuration=configuration)
env["DISRUPTOR"] = "."
env["VARIANT"] = "${PLATFORM}_${ARCHITECTURE}_${COMPILER}${COMPILER_VERSION}_${RELEASE}"
env["BUILD"] = "build/${VARIANT}"
env["DISRUPTOR_BUILD"] = "${BUILD}"
env["DISRUPTOR_PROJECT"] = "build/project"
env["DISRUPTOR_BIN"] = "${DISRUPTOR_BUILD}/bin"
env["DISRUPTOR_LIB"] = "${DISRUPTOR_BUILD}/lib"
baseVariant.tools["project"] = project = ProjectTool(configuration=configuration)
project.product = project.VS2010
project.enabled = engine.options.createProjects
if project.enabled:
engine.addBuildSuccessCallback(project.build)
def createVariants(baseVariant):
for release in ["debug", "optimised"]:
variant = baseVariant.clone(release=release)
platform = variant.keywords["platform"]
compilerName = variant.keywords["compiler"]
architecture = variant.keywords["architecture"]
env = variant.tools["env"]
env["RELEASE"] = release
env["BUILD"] = env.expand("${BUILD}")
compiler = variant.tools["compiler"]
compiler.enableRtti = True
compiler.enableExceptions = True
compiler.outputMapFile = True
compiler.messageStyle = compiler.MSVS_CLICKABLE
if release == "debug":
compiler.addDefine("_DEBUG")
compiler.debugSymbols = True
compiler.useIncrementalLinking = True
compiler.optimisation = compiler.NO_OPTIMISATION
compiler.runtimeLibraries = 'debug-dll'
elif release == "optimised":
compiler.addDefine("NDEBUG")
compiler.debugSymbols = True
compiler.useIncrementalLinking = False
compiler.useFunctionLevelLinking = True
compiler.optimisation = compiler.FULL_OPTIMISATION
compiler.runtimeLibraries = 'release-dll'
compiler.addCppFlag('/Oxs')
# Disable the compiler during project generation
if engine.options.createProjects:
compiler.enabled = False
projectTool = variant.tools["project"]
projectTool.projectConfigName = "%s (%s) %s (%s)" % (
platform.capitalize(),
architecture,
release.capitalize(),
compilerName,
)
projectTool.projectPlatformName = "Win32"
projectTool.solutionConfigName = release.capitalize()
projectTool.solutionPlatformName = "%s %s (%s)" % (
platform.capitalize(),
compilerName.capitalize(),
architecture,
)
configuration.addVariant(variant)
if cake.system.isWindows() or cake.system.isCygwin():
for msvcVer in ("11.0", "12.0"):
for arch in ("x86", "x64"):
try:
msvcVariant = baseVariant.clone(
platform="windows",
compiler="msvc" + msvcVer,
compilerFamily="msvc",
architecture=arch,
)
msvcVariant.tools["compiler"] = compiler = findMsvcCompiler(
configuration=configuration,
architecture=arch,
version=msvcVer,
)
compiler.addCppFlag("/Zc:forScope")
compiler.addDefine("WIN32")
compiler.addDefine("_WIN32_WINNT", "0x0500") # WinXP
compiler.addDefine("NOMINMAX")
if arch in ("x64", "ia64"):
compiler.addDefine("WIN64")
env = msvcVariant.tools["env"]
env["COMPILER"] = "msvc"
env["COMPILER_VERSION"] = msvcVer
env["PLATFORM"] = "windows"
env["ARCHITECTURE"] = arch
createVariants(msvcVariant)
except CompilerNotFoundError:
pass
else:
configuration.engine.raiseError("Unsupported platform: %s\n" % cake.system.platform())