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 * ======== Win64 ========
38 * Microsoft Windows 64-bit target using the Visual C/C++ compiler
39 *
40 * This target can be configured to be used with different versions of
41 * Microsoft Visual C/C++ and different installations of Platform SDK (or a
42 * newer equivalent Windows SDK). The optional Platform SDK is needed only
43 * for building applications that use Windows API.
44 * The target `Win64` contains default configuration for Visual C/C++
45 * version 14.0, but in order to support future versions of Visual C/C++ and
46 * different Windows SDK installations, there is a parameter {@link #sdkPath},
47 * which users can set in their `config.bld` files to enable usage of this
48 * target with their installations.
49 */
50 metaonly module Win64 inherits microsoft.targets.ITarget {
51
52 override readonly config string name = "Win64";
53 override readonly config string os = "Windows";
54 override readonly config string suffix = "64W";
55 override readonly config string isa = "x64";
56 override readonly config xdc.bld.ITarget.Model model = {
57 endian: "little"
58 };
59
60 override readonly config string rts = "microsoft.targets.rts";
61
62 override config string platform = "host.platforms.PC";
63 override config string execExt = ".exe";
64
65 /*!
66 * ======== path ========
67 * Path components added during execution of commands
68 */
69 readonly config string path =
70 "$(rootDir)/VC/bin/amd64;$(rootDir)/Common7/IDE";
71
72 /*!
73 * ======== SDKPath ========
74 *
75 * A structure type that defines Windows SDK paths to be used for building
76 * Windows applications with this target.
77 *
78 * A Windows SDK installation is needed for building programs that use
79 * Windows API. However, Windows SDK installations can be anywhere on the
80 * disk and also include SDK version numbers (10.0.10586.0 for example).
81 * Therefore, these paths can't be derived from the target's rootDir.
82 *
83 * @field(includePath) Absolute path to the Include directory of a Windows
84 * SDK installation. Windows SDK is required if the target is used to build
85 * executables that use Windows API.
86 *
87 * @field(libraryPath) Absolute path to the Lib directory of a Windows
88 * SDK installation.
89 *
90 * @field(libs) List of Windows SDK libraries to be added to the linker
91 * command line.
92 */
93 struct SDKPath {
94 string includePath[];
95 string libraryPath[];
96 string libs;
97 };
98
99 /*!
100 * ======== sdkPath ========
101 * Location of the header and library files in a Windows SDK installation
102 *
103 * This parameter contains paths to the optional Windows SDK.
104 *
105 * @a(Examples)
106 * If the content of `sdkPath`, set in `config.bld` is
107 * @p(code)
108 * Win64.sdkPath = {
109 * includePath: "C:/PROGRA~2/WI3CF2~1/10/Include/10.0.10586.0/ucrt",
110 * libraryPath: "C:/PROGRA~2/WI3CF2~1/10/Lib/10.0.10586.0/um/x64";
111 * libs: " libucrt.lib setargv.obj oldnames.lib ole32.lib
112 * oleaut32.lib olepro32.lib uuid.lib kernel32.lib user32.lib gdi32.lib
113 * advapi32.lib shell32.lib comctl32.lib mfc70.lib ucrt.lib"
114 * };
115 * the contents of `includePath`, `libraryPath` and `libs` are added to
116 * appropriate command lines.
117 *
118 * If Windows SDK is not installed or needed, sdkPath's `includePath` and
119 * `libraryPath` should be empty.
120 * @p
121 *
122 */
123 config SDKPath sdkPath = {
124 includePath: [],
125 libraryPath: [],
126 libs: "ole32.lib oleaut32.lib uuid.lib kernel32.lib user32.lib gdi32.lib advapi32.lib shell32.lib comctl32.lib"
127 };
128
129 /*!
130 * ======== profiles ========
131 * Standard options profiles are overwritten because we can't use 'MTs'
132 * and -D_DEBUG=1. Both of them added the debug version of the C runtime
133 * library to the manifest.
134 */
135 override config xdc.bld.ITarget.OptionSet profiles[string] = [
136 ["debug", {
137 compileOpts: {
138 copts: "-Z7 -Odi -MTd",
139 defs: "",
140 },
141 linkOpts: "-debug msvcrtd.lib vcruntimed.lib ucrtd.lib oldnames.lib",
142 }],
143
144 ["release", {
145 compileOpts: {
146 copts: "-O2 -MT",
147 defs: "",
148 },
149 linkOpts: "msvcrt.lib vcruntime.lib ucrt.lib oldnames.lib",
150 }],
151 ];
152
153 /*!
154 * ======== ar ========
155 * The archiver command and all required options
156 * @p(dlist)
157 * -`-nologo`
158 * don't display archiver copyright
159 */
160 override readonly config xdc.bld.ITarget2.Command ar = {
161 cmd: "$(rootDir)/VC/bin/amd64/lib.exe -nologo",
162 opts: ""
163 };
164
165 /*!
166 * ======== cc ========
167 * The compile command and all required options
168 * @p(dlist)
169 * -`-W3`
170 * enable all warnings recommended for production purposes.
171 * -`-c`
172 * don't link
173 * -`-nologo`
174 * don't display compiler copyright
175 * -`-Zp1`
176 * Packs structure members on 1-byte boundry
177 */
178 override readonly config xdc.bld.ITarget2.Command cc = {
179 cmd: "$(rootDir)/VC/bin/amd64/cl.exe -nologo -c",
180 opts: '-Zp1 -W3 -D_DLL -DWINVER=_WIN32_WINNT_WIN7 -D_WIN32_WINNT=_WIN32_WINNT_WIN7 -DWIN64 -DEXPORT=""'
181 };
182
183 /*!
184 * ======== asm ========
185 * The assemble command and all required options
186 * @p(dlist)
187 * -`-c`
188 * don't link
189 * -`-nologo`
190 * don't display macro assembler copyright
191 */
192 override readonly config xdc.bld.ITarget2.Command asm = {
193 cmd: "$(rootDir)/VC/bin/amd64/ml64 -c",
194 opts: "-nologo"
195 };
196
197 /*!
198 * ======== lnk ========
199 * The linker command and all required options
200 * @p(dlist)
201 * -`-nologo`
202 * Don't display linker copyright
203 */
204 override readonly config xdc.bld.ITarget2.Command lnk = {
205 cmd: "$(rootDir)/VC/bin/amd64/link",
206 opts: "-nologo"
207 };
208
209 /*!
210 * ======== ccOpts ========
211 * User modifiable default options.
212 * @p(dlist)
213 * -`-Ob1`
214 * Expand only functions marked as inline or, in a C++
215 * member function, defined within a class declaration
216 * -`-Gs`
217 * Probe stack to automatically grow stack as necessary
218 */
219 override config xdc.bld.ITarget2.Options ccOpts = {
220 prefix: "-Ob1 -Gs",
221 suffix: "-Dfar= "
222 };
223
224 /*!
225 * ======== lnkOpts ========
226 * User modifiable linker options
227 * @p(dlist)
228 * -`-libpath`
229 * directories to search for toolchain specific libraries
230 * -`-nodefaultlib`
231 * don't search for default libraries when linking; all
232 * libraries used must be explicitly named
233 * -`-incremental:no`
234 * link for execution (no subsequent link will occur)
235 * -`-machine:ix64`
236 * link for the 64-bit architecture
237 * -`-map:$(XDCCFGDIR)/$@.map`
238 * output any link map information to the specified file
239 * ($(XDCCFGDIR) is usually package/cfg)
240 * -`-pdb:$(XDCCFGDIR)/$@.pdb`
241 * output any program debug information to the specified file
242 * ($(XDCCFGDIR) is usually package/cfg)
243 */
244 override config xdc.bld.ITarget2.Options lnkOpts = {
245 prefix: "-libpath:$(rootDir)/VC/lib/amd64 -libpath:$(rootDir)/VC/atlmfc/lib/amd64",
246 suffix: "-map:$(XDCCFGDIR)/$@.map -pdb:$(XDCCFGDIR)/$@.pdb -machine:x64 -nodefaultlib -incremental:no"
247 };
248
249 /*!
250 * ======== includeOpts ========
251 * User modifiable include paths
252 * @p(dlist)
253 * -`-I$(rootDir)/$(compilerDir)/include`
254 * include compiler specific headers
255 */
256 override config string includeOpts = "-I$(rootDir)/VC/include -I$(rootDir)/VC/atlmfc/include";
257
258 /*!
259 * ======== stdTypes ========
260 */
261 override readonly config xdc.bld.ITarget.StdTypes stdTypes = {
262 t_IArg : { size: 8, align: 1 },
263 t_Char : { size: 1, align: 1 },
264 t_Double : { size: 8, align: 1 },
265 t_Float : { size: 4, align: 1 },
266 t_Fxn : { size: 8, align: 1 },
267 t_Int : { size: 4, align: 1 },
268 t_Int8 : { size: 1, align: 1 },
269 t_Int16 : { size: 2, align: 1 },
270 t_Int32 : { size: 4, align: 1 },
271 t_Int64 : { size: 8, align: 1 },
272 t_Long : { size: 4, align: 1 },
273 t_LLong : { size: 8, align: 1 },
274 t_LDouble : { size: 8, align: 1 },
275 t_Ptr : { size: 8, align: 1 },
276 t_Short : { size: 2, align: 1 },
277 t_Size : { size: 8, align: 1 },
278 };
279 }