]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/embarcadero.jam
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / tools / build / src / tools / embarcadero.jam
1 # Copyright (c) 2020 Edward Diener
2 #
3 # Use, modification and distribution is subject to the Boost Software
4 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
5 # http://www.boost.org/LICENSE_1_0.txt)
6
7 #| tag::doc[]
8
9 [[bbv2.reference.tools.compiler.borland]]
10 = Embarcadero C++ Compiler
11
12 The `embarcadero` module supports the 32-bit command line C++ compiler
13 bcc32x and the 64-bit command line C++ compiler bcc64, both clang-based,
14 running on Microsoft Windows. These are the clang-based Windows compilers
15 for all versions of Embarcadero C++.
16
17 The module is initialized using the following syntax:
18
19 ----
20 using embarcadero : [version] : [c++-compile-command] : [compiler options] ;
21 ----
22
23 This statement may be repeated several times, if you want to configure
24 several versions of the compiler.
25
26 `version`:
27
28 The version should be the compiler version if specified. if the
29 version is not specified Boost Build will find the latest installed
30 version of Embarcadero C++ and use that for the version. If the version
31 is specified Boost Build does not check if this matches any particular
32 version of Embarcadero C++, so you may use the version as a mnemonic to
33 configure separate 'versions'.
34
35 `c++-compile-command`:
36
37 If the c++-compile-command is not specified, Boost.Build will default to the
38 bcc64 compiler. If you specify a compiler option of <address-model>32 the
39 default compiler will be bcc32x. In either case when the command is not given
40 Boost Build will assume the compiler is in the PATH. So it is not necessary
41 to specify a command if you accept the default compiler and the Embarcadero
42 C++ binary directory is in the PATH.
43
44 If the command is specified it will be used as is to invoke the compiler.
45 If the command has either 'bcc32x(.exe)' or 'bcc64(.exe)' in it Boost Build
46 will use the appropriate compiler to configure the toolset. If the command
47 does not have either 'bcc32x(.exe)' or 'bcc64(.exe)' in it, Boost Build
48 will use the default compiler to configure the toolset. If you have your
49 own command, which does not have 'bcc32x(.exe)' in it but invokes the
50 'bcc32x(.exe)' compiler, specify the <address-model>32 compiler option.
51
52 `compiler options`:
53
54 The following options can be provided, using
55 _`<option-name>option-value syntax`_:
56
57 `cflags`::
58 Specifies additional compiler flags that will be used when compiling C
59 and C++ sources.
60
61 `cxxflags`::
62 Specifies additional compiler flags that will be used when compiling C++
63 sources.
64
65 `linkflags`::
66 Specifies additional command line options that will be passed to the linker.
67
68 `asmflags`::
69 Specifies additional command line options that will be passed to the assembler.
70
71 `archiveflags`::
72 Specifies additional command line options that will be passed to the archiver,
73 which creates a static library.
74
75 `address-model`::
76 This option can be used to specify the default compiler as specified in the
77 dicsussion above of the c++-compile-command. Otherwise the address model
78 is not used to initialize the toolset.
79
80 `user-interface`::
81 Specifies the user interface for applications. Valid choices are `console`
82 for a console applicatiuon and `gui` for a Windows application.
83
84 `root`::
85 Normallly Boost Build will automatically be able to determine the root of
86 the Embarcadero C++ installation. It does this in various ways, but primarily
87 by checking a registry entry. If you specify the root it will use that
88 path, and the root you specify should be the full path to the Embarcadero
89 C++ installation on your machine ( without a trailing \ or / ). You should
90 not need to specify this option unless Boost Build can not find the
91 Embarcadero C++ root directory.
92
93 Examples::
94
95 using embarcadero ;
96
97 Configures the toolset to use the latest version, with bcc64 as the compiler.
98 The bcc64 compiler must be in the PATH.
99
100 using embarcadero : 7.40 ;
101
102 Configures the toolset to use the 7.40 version, with bcc64 as the compiler.
103 The bcc64 compiler must be in the PATH.
104
105 using embarcadero : 7.40 : bcc32x ;
106 using embarcadero : 7.40 : : <address-model>32 ;
107
108 Configures the toolset to use the 7.40 version, with bcc32x as the compiler.
109 The bcc32x compiler must be in the PATH.
110
111 using embarcadero : : c:/some_path/bcc64 ;
112
113 Configures the toolset to use the latest version, with full command specified.
114
115 using embarcadero : : full_command : <address-model>32 ;
116
117 Configures the toolset to use the latest version, with full command specified
118 and bcc32x as the compiler.
119
120 using embarcadero : : : <root>c:/root_path ;
121
122 Configures the toolset to use the latest version, with bcc64 as the compiler
123 and the root directory of the installation specified. The bcc64 compiler must
124 be in the PATH.
125
126 |# # end::doc[]
127
128 import clang-linux ;
129 import path ;
130 import os ;
131 import type ;
132 import common ;
133 import toolset ;
134 import feature ;
135 import toolset : flags ;
136 import clang ;
137 import gcc ;
138 import generators ;
139 import errors ;
140
141 feature.extend toolset : embarcadero ;
142
143 toolset.inherit-generators embarcadero : clang-linux ;
144 generators.override embarcadero.prebuilt : builtin.lib-generator ;
145 generators.override embarcadero.prebuilt : builtin.prebuilt ;
146 generators.override embarcadero.searched-lib-generator : searched-lib-generator ;
147
148 toolset.inherit-rules embarcadero : clang-linux ;
149 toolset.inherit-flags embarcadero
150 : clang-linux
151 : <runtime-link>shared
152 <link>shared
153 <threading>multi
154 <threading>multi/<target-os>windows
155 <stdlib>gnu
156 <stdlib>gnu11
157 <stdlib>libc++
158 <target-os>windows/<runtime-link>static
159 <target-os>windows/<runtime-link>shared
160 <rtti>off
161 <cxxstd>98
162 <cxxstd>03
163 <cxxstd>0x
164 <cxxstd>11
165 <cxxstd>1y
166 <cxxstd>14
167 <cxxstd>1z
168 <cxxstd>17
169 <cxxstd>2a
170 <cxxstd>20
171 <cxxstd>latest
172 <cxxstd>98/<cxxstd-dialect>iso
173 <cxxstd>03/<cxxstd-dialect>iso
174 <cxxstd>0x/<cxxstd-dialect>iso
175 <cxxstd>11/<cxxstd-dialect>iso
176 <cxxstd>1y/<cxxstd-dialect>iso
177 <cxxstd>14/<cxxstd-dialect>iso
178 <cxxstd>1z/<cxxstd-dialect>iso
179 <cxxstd>17/<cxxstd-dialect>iso
180 <cxxstd>2a/<cxxstd-dialect>iso
181 <cxxstd>20/<cxxstd-dialect>iso
182 <cxxstd>latest/<cxxstd-dialect>iso
183 ;
184
185 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
186 .debug-configuration = true ;
187 }
188
189 rule init ( version ? : command * : options * )
190 {
191
192 local compiler = bcc64 ;
193 local preprocessor = cpp64 ;
194 local amodel = 64 ;
195
196 local optam = [ feature.get-values <address-model> : $(options) ] ;
197
198 if $(optam)
199 {
200 if $(optam) = 32
201 {
202 compiler = bcc32x ;
203 preprocessor = cpp32x ;
204 amodel = 32 ;
205 }
206 else if ! ( $(optam) = 64 )
207 {
208 $(optam) = "" ;
209 }
210 }
211
212 command = [ common.get-invocation-command embarcadero : $(compiler) : $(command) ] ;
213
214 switch $(command[1]:BL)
215 {
216 case bcc32x :
217 compiler = bcc32x ;
218 preprocessor = cpp32x ;
219 amodel = 32 ;
220 case bcc64 :
221 compiler = bcc64 ;
222 preprocessor = cpp64 ;
223 amodel = 64 ;
224 case "bcc32x.exe" :
225 compiler = bcc32x ;
226 preprocessor = cpp32x ;
227 amodel = 32 ;
228 case "bcc64.exe" :
229 compiler = bcc64 ;
230 preprocessor = cpp64 ;
231 amodel = 64 ;
232 }
233
234 if $(optam) && $(optam) != $(amodel)
235 {
236 errors.user-error "embarcadero initialization: compiler and address model" :
237 "the compiler '$(compiler)' does not match the address-model of '$(optam)'" ;
238 }
239 else
240 {
241 # Determine the version
242 if $(command) {
243 local command-string = "$(command)" ;
244 command-string = $(command-string:J=" ") ;
245 local soutput = [ SHELL "$(command-string) --version" ] ;
246 version ?= [ MATCH "Embarcadero C[+][+] ([0-9.]+)" : $(soutput) ] ;
247 cl_version = [ MATCH ".+version[ ]+([0-9.]+)" : $(soutput) ] ;
248 if ! $(cl_version)
249 {
250 cl_version = 5.0 ;
251 }
252 }
253
254 local condition = [ common.check-init-parameters embarcadero : version $(version) ] ;
255 handle-options $(condition) : $(command) : $(options) ;
256
257 # Support for the Embarcadero root directory. If the Embarcadero binary
258 # directory is not in the PATH we need to tell the underlying clang
259 # implementation where to find the Embarcadero header/library files
260 # and set the correct runtime path so that we can execute Embarcadero
261 # programs and find Embarcadero DLLs.
262
263 local root = [ feature.get-values <root> : $(options) ] ;
264
265 # 1) Look in registry
266
267 if ! $(root)
268 {
269
270 local sdkdir = [ get_sdk_dir ] ;
271
272 if $(sdkdir)
273 {
274
275 local bdsv = [ get_bds_version $(sdkdir) ] ;
276
277 if $(bdsv)
278 {
279
280 local has_dec = [ MATCH "(.+[.])" : $(bdsv) ] ;
281 local bdsv_full ;
282
283 if ! $(has_dec)
284 {
285 bdsv_full = $(bdsv).0 ;
286 }
287
288 local troot = [ W32_GETREG "HKEY_LOCAL_MACHINE\\SOFTWARE\\Embarcadero\\BDS\\$(bdsv)" : RootDir ] ;
289
290 if $(troot)
291 {
292 troot = $(troot:T) ;
293 troot = [ concatenate $(troot) : name ] ;
294 root = $(troot:D) ;
295 }
296 else
297 {
298 troot = [ W32_GETREG "HKEY_CURRENT_USER\\SOFTWARE\\Embarcadero\\BDS\\$(bdsv)" : RootDir ] ;
299 if $(troot)
300 {
301 troot = $(troot:T) ;
302 troot = [ concatenate $(troot) : name ] ;
303 root = $(troot:D) ;
304 }
305 else if $(bdsv_full)
306 {
307 troot = [ W32_GETREG "HKEY_LOCAL_MACHINE\\SOFTWARE\\Embarcadero\\BDS\\$(bdsv_full)" : RootDir ] ;
308 if $(troot)
309 {
310 troot = $(troot:T) ;
311 troot = [ concatenate $(troot) : name ] ;
312 root = $(troot:D) ;
313 }
314 else
315 {
316 troot = [ W32_GETREG "HKEY_CURRENT_USER\\SOFTWARE\\Embarcadero\\BDS\\$(bdsv_full)" : RootDir ] ;
317 if $(troot)
318 {
319 troot = $(troot:T) ;
320 troot = [ concatenate $(troot) : name ] ;
321 root = $(troot:D) ;
322 }
323 }
324 }
325 }
326 }
327 }
328 }
329
330
331 # 2) Look for path in the command
332
333 if ! $(root)
334 {
335
336 local cpath = $(command[1]:D) ;
337
338 if $(cpath)
339 {
340 root = $(cpath:P) ;
341 }
342 }
343
344 # 3) Search for the directory of the command
345
346 if ! $(root)
347 {
348
349 local pdirs = [ path.programs-path ] ;
350
351 for local dir in $(pdirs)
352 {
353
354 local match = [ MATCH "/(.:.+)" : $(dir) ] ;
355
356 if $(match)
357 {
358 dir = "$(match)" ;
359 }
360
361 if [ CHECK_IF_FILE $(dir)/$(command) ]
362 {
363 root = $(dir:P) ;
364 break ;
365 }
366 if [ CHECK_IF_FILE $(dir)/$(command).exe ]
367 {
368 root = $(dir:P) ;
369 break ;
370 }
371 }
372 }
373
374 if ! $(root)
375 {
376 errors.user-error "Embarcadero toolset initialization: the root directory for the Embarcadero installation can not be found" ;
377 }
378 else
379 {
380
381 local lib_path = $(root)/bin $(root)/bin64 $(root)/Bpl C:/Users/Public/Documents/Embarcadero ;
382 if $(.debug-configuration)
383 {
384 ECHO "notice:" using Embarcadero libraries with clang compilation"::" $(condition) "::" $(lib_path) ;
385 }
386 flags embarcadero.link RUN_PATH $(condition) : $(lib_path) ;
387
388 local system_include_option = "-isystem " ;
389 local system_include_directories = $(root)/include/windows/crtl $(root)/include/windows/sdk $(root)/include/windows/rtl $(root)/include/dinkumware64 ;
390
391 local lib_dir_release ;
392 local lib_dir_debug ;
393 local archiver ;
394 local arflags ;
395 local implib ;
396 local assembler ;
397 local asmflags ;
398 local asmoutput ;
399
400 if $(compiler) = bcc32x
401 {
402 lib_dir_release = $(root)/lib/win32c/release $(root)/lib/win32c/release/psdk ;
403 lib_dir_debug = $(root)/lib/win32c/debug ;
404 archiver = tlib ;
405 arflags = /P512 ;
406 implib = implib ;
407 assembler = $(root)/bin/tasm32 ;
408
409 # /ml makes all symbol names case-sensitive
410
411 asmflags = /ml ;
412 asmoutput = "," ;
413 }
414 else if $(compiler) = bcc64
415 {
416
417 lib_dir_release = $(root)/lib/win64/release $(root)/lib/win64/release/psdk ;
418 lib_dir_debug = $(root)/lib/win64/debug ;
419 archiver = tlib64 ;
420 arflags = /P2048 ;
421 implib = mkexp ;
422 }
423
424 flags embarcadero.compile .EMB_SYSINC $(condition) : $(system_include_option)$(system_include_directories) ;
425 flags embarcadero.link LINKPATH $(condition)/<variant>release : $(lib_dir_release) ;
426 flags embarcadero.link LINKPATH $(condition)/<variant>debug : $(lib_dir_debug) $(lib_dir_release) ;
427 flags embarcadero.archive .AR $(condition) : $(root)/bin/$(archiver) ;
428 flags embarcadero.archive .ARFLAGS $(condition) : $(arflags) ;
429 flags embarcadero.asm .ASM $(condition) : $(assembler) ;
430 flags embarcadero.asm .ASMFLAGS $(condition) : $(asmflags) ;
431 flags embarcadero.asm .ASMOUTPUT $(condition) : $(asmoutput) ;
432 flags embarcadero.asm USER_OPTIONS $(condition) : [ feature.get-values <asmflags> : $(options) ] ;
433 flags embarcadero.archive AROPTIONS $(condition) : [ feature.get-values <archiveflags> : $(options) ] ;
434 flags embarcadero.link.dll .IMPLIB_COMMAND $(condition) : $(root)/bin/$(implib) ;
435
436 local mte = [ feature.get-values <user-interface> : $(options) ] ;
437
438 if $(mte)
439 {
440 flags embarcadero OPTIONS <main-target-type>EXE/$(condition) : <user-interface>$(mte) ;
441 }
442 else
443 {
444 flags embarcadero OPTIONS <main-target-type>EXE/$(condition) : <user-interface>console ;
445 }
446 }
447 }
448 }
449
450 local rule concatenate ( path : name )
451 {
452
453 local result ;
454 local has_ending_slash = [ MATCH ".*([/\\])$" : $(path) ] ;
455 local has_backward_slash = [ MATCH ".*([\\])" : $(path) ] ;
456
457 if $(has_ending_slash)
458 {
459 result = $(path)$(name) ;
460 }
461 else if $(has_backward_slash)
462 {
463 result = $(path)"\\"$(name) ;
464 }
465 else
466 {
467 result = $(path)"/"$(name) ;
468 }
469 return $(result) ;
470 }
471
472 local rule get_sdk_dir ( )
473 {
474
475 local ret ;
476 local appdata = [ os.environ APPDATA ] ;
477
478 if $(appdata)
479 {
480 ret = $(appdata:T)/Embarcadero/BDS ;
481 }
482 return $(ret) ;
483 }
484
485 local rule get_bds_version ( sdir )
486 {
487
488 local ret ;
489 local flist = [ GLOB $(sdir) : * ] ;
490
491 if $(flist)
492 {
493
494 local dirs ;
495
496 for local file in $(flist)
497 {
498 if ! [ CHECK_IF_FILE $(file) ]
499 {
500 dirs += $(file) ;
501 }
502 }
503 if $(dirs)
504 {
505
506 local ldir = $(dirs[-1]) ;
507
508 ret = $(ldir:B) ;
509 }
510 }
511 return $(ret) ;
512 }
513
514 local rule handle-options ( condition * : command * : options * )
515 {
516 if $(.debug-configuration)
517 {
518 ECHO "notice:" will use '$(command)' for embarcadero, condition
519 $(condition:E=(empty)) ;
520 }
521
522 flags embarcadero CONFIG_COMMAND $(condition) : $(command) ;
523
524 flags embarcadero.compile OPTIONS $(condition) :
525 [ feature.get-values <cflags> : $(options) ] ;
526
527 flags embarcadero.compile.c++ OPTIONS $(condition) :
528 [ feature.get-values <cxxflags> : $(options) ] ;
529
530 flags embarcadero.link OPTIONS $(condition) :
531 [ feature.get-values <linkflags> : $(options) ] ;
532 }
533
534 ###############################################################################
535 # Declare generators
536
537 type.set-generated-target-suffix OBJ : <toolset>embarcadero <target-os>windows <address-model>64 : o ;
538 type.set-generated-target-suffix OBJ : <toolset>embarcadero <target-os>windows <address-model>32 : obj ;
539 type.set-generated-target-suffix STATIC_LIB : <toolset>embarcadero <target-os>windows <address-model>64 : a ;
540 type.set-generated-target-suffix STATIC_LIB : <toolset>embarcadero <target-os>windows <address-model>32 : lib ;
541 type.set-generated-target-suffix IMPORT_LIB : <toolset>embarcadero <target-os>windows <address-model>64 : a ;
542 type.set-generated-target-suffix IMPORT_LIB : <toolset>embarcadero <target-os>windows <address-model>32 : lib ;
543
544 generators.register-linker embarcadero.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>embarcadero ;
545 generators.register-linker embarcadero.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>embarcadero ;
546
547 generators.register-archiver embarcadero.archive : OBJ : STATIC_LIB : <toolset>embarcadero ;
548 generators.register-c-compiler embarcadero.compile.c++ : CPP : OBJ : <toolset>embarcadero ;
549 generators.register-c-compiler embarcadero.compile.c : C : OBJ : <toolset>embarcadero ;
550 generators.register-c-compiler embarcadero.compile.asm : ASM : OBJ : <toolset>embarcadero <address-model>64 ;
551 generators.register-standard embarcadero.asm : ASM : OBJ : <toolset>embarcadero <address-model>32 ;
552
553 # Flags
554
555 local opt_console = -tC ;
556 local opt_shared = -tD ;
557 local opt_mt = -tM ;
558 local opt_drtl = -tR ;
559 local opt_dapp = -tW ;
560 local opt_compile_flags = -DNDEBUG ;
561 local opt_lflags = "-lS:1048576 -lSc:4098 -lH:1048576 -lHc:8192" ;
562
563 flags embarcadero OPTIONS <user-interface>console : $(opt_console) ;
564 flags embarcadero OPTIONS <user-interface>gui : $(opt_dapp) ;
565 flags embarcadero OPTIONS <runtime-link>shared : $(opt_drtl) ;
566 flags embarcadero OPTIONS <main-target-type>LIB/<link>shared : $(opt_shared) ;
567 flags embarcadero OPTIONS <threading>multi : $(opt_mt) ;
568 flags embarcadero.compile OPTIONS <variant>release : $(opt_compile_flags) ;
569 flags embarcadero.link OPTIONS : $(opt_lflags) ;
570 flags embarcadero.archive AROPTIONS <archiveflags> ;
571 flags embarcadero.asm USER_OPTIONS <asmflags> ;
572 flags embarcadero.compile OPTIONS <address-model>32 : -m32 ;
573 flags embarcadero.compile OPTIONS <address-model>64 : -m64 ;
574 flags embarcadero.link OPTIONS <address-model>32 : -m32 ;
575 flags embarcadero.link OPTIONS <address-model>64 : -m64 ;
576 flags embarcadero.link .EMBLRSP <variant>release : _emb_lpr ;
577 flags embarcadero.link .EMBLRSP <variant>debug : _emb_lpd ;
578 flags embarcadero.compile .EMBCRSP <variant>release : _emb_sir ;
579 flags embarcadero.compile .EMBCRSP <variant>debug : _emb_sid ;
580
581 nl = "
582 " ;
583
584 rule compile.c++ ( targets * : sources * : properties * ) {
585 }
586
587 actions compile.c++ {
588 "$(CONFIG_COMMAND)" -c -x c++ @"@($(<[1]:DBW)$(.EMBCRSP)$(<[1]:S).rsp:E=$(nl)"$(.EMB_SYSINC)")" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
589 }
590
591 rule compile.c ( targets * : sources * : properties * )
592 {
593 }
594
595 actions compile.c
596 {
597 "$(CONFIG_COMMAND)" -c -x c @"@($(<[1]:DBW)$(.EMBCRSP)$(<[1]:S).rsp:E=$(nl)"$(.EMB_SYSINC)")" $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)"
598 }
599
600 rule archive ( targets * : sources * : properties * )
601 {
602 }
603
604 actions updated together piecemeal archive
605 {
606 "$(.AR)" $(AROPTIONS) $(.ARFLAGS) /u /a /C "$(<)" +-"$(>)"
607 }
608
609 rule link ( targets * : sources * : properties * ) {
610 JAM_SEMAPHORE on $(targets) = <s>embarcadero-link-semaphore ;
611 }
612
613 rule link.dll ( targets * : sources * : properties * ) {
614 JAM_SEMAPHORE on $(targets) = <s>embarcadero-link-semaphore ;
615 }
616
617 actions link bind LIBRARIES {
618 "$(CONFIG_COMMAND)" @"@($(<[1]:DBW)$(.EMBLRSP)$(<[1]:S).rsp:E=$(nl)-L"$(LINKPATH)")" -o "$(<)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)")" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS)
619 }
620
621 actions link.dll bind LIBRARIES {
622 "$(CONFIG_COMMAND)" @"@($(<[1]:DBW)$(.EMBLRSP)$(<[1]:S).rsp:E=$(nl)-L"$(LINKPATH)")" -o "$(<[1])" @"@($(<[1]:W).rsp:E=$(nl)"$(>)")" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) $(USER_OPTIONS) && "$(.IMPLIB_COMMAND)" "$(<[2])" "$(<[1])"
623 }
624
625 rule asm ( targets * : sources * : properties * )
626 {
627 }
628
629 actions asm
630 {
631 $(.ASM) $(.ASMFLAGS) $(USER_OPTIONS) "$(>)" $(.ASMOUTPUT) "$(<)"
632 }
633
634 rule compile.asm ( targets * : sources * : properties * )
635 {
636 LANG on $(<) = "-x assembler-with-cpp" ;
637 }
638
639 actions compile.asm
640 {
641 "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
642 }