1# Copyright 2005 Dave Abrahams 2# Copyright 2003 Rene Rivera 3# Copyright 2003, 2004, 2005 Vladimir Prus 4# Copyright (c) 2020 Edward Diener 5# Distributed under the Boost Software License, Version 1.0. 6# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 7 8#| tag::doc[] 9 10[[bbv2.reference.tools.compiler.borland]] 11= Borland C++ Compiler 12 13The `borland` module supports the 32-bit command line C++ compilers 14running on Microsoft Windows. This is the bcc32 executable for all 15versions of Borland C++ and C++ Builder, as well as the command line 16compatible compiler bcc32c on later versions of C++ Builder. 17 18The module is initialized using the following syntax: 19 20---- 21using borland : [version] : [c++-compile-command] : [compiler options] ; 22---- 23 24This statement may be repeated several times, if you want to configure 25several versions of the compiler. 26 27If the command is not specified, Boost.Build will search for a binary 28named `bcc32` in PATH. 29 30The following options can be provided, using 31_`<option-name>option-value syntax`_: 32 33`cflags`:: 34Specifies additional compiler flags that will be used when compiling C 35sources. 36 37`cxxflags`:: 38Specifies additional compiler flags that will be used when compiling C++ 39sources. 40 41`compileflags`:: 42Specifies additional compiler flags that will be used when compiling both C 43and C++ sources. 44 45`linkflags`:: 46Specifies additional command line options that will be passed to the linker. 47 48`user-interface`:: 49Specifies the user interface for applications. Valid choices are `console` 50for a console applicatiuon and `gui` for a Windows application. 51 52|# # end::doc[] 53 54# Support for the Borland's command line compiler 55 56import property ; 57import generators ; 58import os ; 59import toolset : flags ; 60import feature : get-values ; 61import type ; 62import common ; 63import version ; 64 65feature.extend toolset : borland ; 66 67rule init ( version ? : command * : options * ) 68{ 69 70 local condition = [ common.check-init-parameters borland : 71 version $(version) ] ; 72 73 local command = [ common.get-invocation-command borland : bcc32.exe 74 : $(command) ] ; 75 76 common.handle-options borland : $(condition) : $(command) : $(options) ; 77 78 local just_bcc32 = [ MATCH ".*(bcc32)([^a-z0-9]|$)" : $(command:L) ] ; 79 80 if $(command) 81 { 82 command = [ common.get-absolute-tool-path $(command[-1]) ] ; 83 } 84 root = $(command:D) ; 85 86 flags borland.compile STDHDRS $(condition) : $(root)/include/ ; 87 flags borland.link STDLIBPATH $(condition) : $(root)/lib ; 88 flags borland.link RUN_PATH $(condition) : $(root)/bin ; 89 flags borland .root $(condition) : $(root)/bin/ ; 90 91 local jv ; 92 93 if $(version) 94 { 95 jv = [ MATCH "^([0-9.]+)" : $(version) ] ; 96 } 97 if ! $(jv) || [ version.version-less [ version-split $(jv) ] : 6 30 ] 98 { 99 init-earlier-releases $(condition) ; 100 } 101 else 102 { 103 init-later-releases $(condition) ; 104 } 105 106 if $(just_bcc32) && ( $(just_bcc32[1]) = bcc32 ) 107 { 108 flags borland.compile OPTIONS $(condition) : -g255 -Vx- -Ve- -b- ; 109 } 110} 111 112# Splits a version in its form of n[.n][.n] into n n n etc. 113# 114local rule version-split ( v ) 115{ 116return [ SPLIT_BY_CHARACTERS $(v) : . ] ; 117} 118 119local rule init-earlier-releases ( condition ) 120{ 121 122# Deal with various runtime configs... 123 124# This should be not for DLL 125flags borland OPTIONS $(condition)/<user-interface>console : -tWC ; 126 127# -tWR sets -tW as well, so we turn it off here and then turn it 128# on again later if we need it: 129flags borland OPTIONS $(condition)/<runtime-link>shared : -tWR -tWC ; 130 131flags borland OPTIONS $(condition)/<main-target-type>LIB/<link>shared : -tWD ; 132# Hmm.. not sure what's going on here. 133flags borland OPTIONS $(condition) : -WM- ; 134flags borland OPTIONS $(condition)/<threading>multi : -tWM ; 135 136flags borland.link OPTIONS $(condition)/<link>shared : -tWD ; 137 138} 139 140local rule init-later-releases ( condition ) 141{ 142 143# Deal with various runtime configs... 144 145# This should be not for DLL 146flags borland OPTIONS $(condition)/<user-interface>console : -tC ; 147 148flags borland OPTIONS $(condition)/<runtime-link>shared : -tR ; 149 150flags borland OPTIONS $(condition)/<main-target-type>LIB/<link>shared : -tD ; 151flags borland OPTIONS $(condition)/<main-target-type>EXE : -tC ; 152flags borland OPTIONS $(condition)/<threading>multi : -tM ; 153 154flags borland.link.dll OPTIONS $(condition)/<link>shared : -tD ; 155 156} 157 158# A borland-specific target type 159type.register BORLAND.TDS : tds ; 160 161# Declare generators 162 163generators.register-linker borland.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>borland ; 164generators.register-linker borland.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>borland ; 165 166generators.register-archiver borland.archive : OBJ : STATIC_LIB : <toolset>borland ; 167generators.register-c-compiler borland.compile.c++ : CPP : OBJ : <toolset>borland ; 168generators.register-c-compiler borland.compile.c : C : OBJ : <toolset>borland ; 169generators.register-standard borland.asm : ASM : OBJ : <toolset>borland ; 170 171# Declare flags 172 173flags borland.compile OPTIONS <debug-symbols>on : -v ; 174flags borland.link OPTIONS <debug-symbols>on : -v ; 175 176flags borland.compile OPTIONS <optimization>off : -Od ; 177flags borland.compile OPTIONS <optimization>speed : -O2 ; 178flags borland.compile OPTIONS <optimization>space : -O1 ; 179 180if $(.BORLAND_HAS_FIXED_INLINING_BUGS) 181{ 182 flags borland CFLAGS <inlining>off : -vi- ; 183 flags borland CFLAGS <inlining>on : -vi -w-inl ; 184 flags borland CFLAGS <inlining>full : -vi -w-inl ; 185} 186else 187{ 188 flags borland CFLAGS : -vi- ; 189} 190 191flags borland.compile OPTIONS <warnings>off : -w- ; 192flags borland.compile OPTIONS <warnings>all : -w ; 193flags borland.compile OPTIONS <warnings>extra : -w ; 194flags borland.compile OPTIONS <warnings>pedantic : -w ; 195flags borland.compile OPTIONS <warnings-as-errors>on : -w! ; 196 197flags borland OPTIONS <user-interface>gui : -tW ; 198 199flags borland.compile OPTIONS <cflags> ; 200flags borland.compile.c++ OPTIONS <cxxflags> ; 201flags borland.compile DEFINES <define> ; 202flags borland.compile INCLUDES <include> ; 203 204flags borland NEED_IMPLIB <main-target-type>LIB/<link>shared : "" ; 205 206# 207# for C++ compiles the following options are turned on by default: 208# 209# -j5 stops after 5 errors 210# -g255 allow an unlimited number of warnings 211# -q no banner 212# -c compile to object 213# -P C++ code regardless of file extension 214# -a8 8 byte alignment, this option is on in the IDE by default 215# and effects binary compatibility. 216# 217 218# -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(C++FLAGS) -I"$(HDRS)" -I"$(STDHDRS)" -o"$(<)" "$(>)" 219 220 221actions compile.c++ 222{ 223 "$(CONFIG_COMMAND)" -j5 -q -c -P -a8 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)" 224} 225 226# For C, we don't pass -P flag 227actions compile.c 228{ 229 "$(CONFIG_COMMAND)" -j5 -q -c -a8 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -I"$(STDHDRS)" -o"$(<)" "$(>)" 230} 231 232 233# Declare flags and action for linking 234flags borland.link OPTIONS <debug-symbols>on : -v ; 235flags borland.link LIBRARY_PATH <library-path> ; 236flags borland.link FINDLIBS_ST <find-static-library> ; 237flags borland.link FINDLIBS_SA <find-shared-library> ; 238flags borland.link LIBRARIES <library-file> ; 239 240flags borland.link OPTIONS <linkflags> ; 241 242flags borland.link LIBRARY_PATH_OPTION <toolset>borland : -L : unchecked ; 243flags borland.link LIBRARY_OPTION <toolset>borland : "" : unchecked ; 244 245 246 247# bcc32 needs to have ilink32 in the path in order to invoke it, so explicitly 248# specifying $(BCC_TOOL_PATH)bcc32 doesn't help. You need to add 249# $(BCC_TOOL_PATH) to the path 250# The NEED_IMPLIB variable controls whether we need to invoke implib. 251 252flags borland.archive AROPTIONS <archiveflags> ; 253 254# Declare action for archives. We don't use response file 255# since it's hard to get "+-" there. 256# The /P256 increases 'page' size -- with too low 257# values tlib fails when building large applications. 258# CONSIDER: don't know what 'together' is for... 259actions updated together piecemeal archive 260{ 261 $(.set-path)$(.root:W)$(.old-path) 262 tlib $(AROPTIONS) /P256 /u /a /C "$(<:W)" +-"$(>:W)" 263} 264 265 266if [ os.name ] = CYGWIN 267{ 268 .set-path = "cmd /S /C set \"PATH=" ; 269 .old-path = ";%PATH%\" \"&&\"" ; 270 271 272 # Couldn't get TLIB to stop being confused about pathnames 273 # containing dashes (it seemed to treat them as option separators 274 # when passed through from bash), so we explicitly write the 275 # command into a .bat file and execute that. TLIB is also finicky 276 # about pathname style! Forward slashes, too, are treated as 277 # options. 278 actions updated together piecemeal archive 279 { 280 chdir $(<:D) 281 echo +-$(>:BS) > $(<:BS).rsp 282 $(.set-path)$(.root)$(.old-path) "tlib.exe" $(AROPTIONS) /P256 /C $(<:BS) @$(<:BS).rsp && $(RM) $(<:BS).rsp 283 } 284} 285else if [ os.name ] = NT 286{ 287 .set-path = "set \"PATH=" ; 288 .old-path = ";%PATH%\" 289 " ; 290} 291else 292{ 293 .set-path = "PATH=\"" ; 294 .old-path = "\":$PATH 295 export PATH 296 " ; 297} 298 299RM = [ common.rm-command ] ; 300 301nl = " 302" ; 303 304actions link 305{ 306 $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" 307} 308 309 310actions link.dll bind LIBRARIES RSP 311{ 312 $(.set-path)$(.root:W)$(.old-path) "$(CONFIG_COMMAND)" -v -q $(OPTIONS) -L"$(LIBRARY_PATH:W)" -L"$(STDLIBPATH:W)" -e"$(<[1]:W)" @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" && "$(.root)implib" "$(<[2]:W)" "$(<[1]:W)" 313} 314 315# It seems impossible to specify output file with directory when compiling 316# asm files using bcc32, so use tasm32 directly. 317# /ml makes all symbol names case-sensitive 318actions asm 319{ 320 $(.set-path)$(.root:W)$(.old-path) tasm32.exe /ml "$(>)" "$(<)" 321} 322 323