1# Digital Mars C++ 2 3# (C) Copyright Christof Meerwald 2003. 4# (C) Copyright Aleksey Gurtovoy 2004. 5# (C) Copyright Arjan Knepper 2006. 6# 7# Distributed under the Boost Software License, Version 1.0. (See 8# accompanying file LICENSE_1_0.txt or copy at 9# http://www.boost.org/LICENSE_1_0.txt) 10 11#| tag::doc[] 12 13[[bbv2.reference.tools.compiler.dmc]] 14= Digital Mars C/C++ Compiler 15 16The `dmc` module supports the http://www.digitalmars.com/[Digital Mars 17C++ compiler.] 18 19The module is initialized using the following syntax: 20 21---- 22using dmc : [version] : [c++-compile-command] : [compiler options] ; 23---- 24 25This statement may be repeated several times, if you want to configure 26several versions of the compiler. 27 28If the command is not specified, B2 will search for a binary 29named `dmc` in PATH. 30 31The following options can be provided, using 32_`<option-name>option-value syntax`_: 33 34`cflags`:: 35Specifies additional compiler flags that will be used when compiling C 36sources. 37 38`cxxflags`:: 39Specifies additional compiler flags that will be used when compiling C++ 40sources. 41 42`compileflags`:: 43Specifies additional compiler flags that will be used when compiling both C 44and C++ sources. 45 46`linkflags`:: 47Specifies additional command line options that will be passed to the linker. 48 49|# # end::doc[] 50 51# The following #// line will be used by the regression test table generation 52# program as the column heading for HTML tables. Must not include version number. 53#//<a href="http://www.digitalmars.com/">Digital<br>Mars C++</a> 54 55import feature generators common ; 56import toolset : flags ; 57import sequence regex ; 58 59feature.extend toolset : dmc ; 60 61rule init ( version ? : command * : options * ) 62{ 63 local condition = [ common.check-init-parameters dmc : version $(version) ] ; 64 65 local command = [ common.get-invocation-command dmc : dmc : $(command) ] ; 66 command ?= dmc ; 67 68 common.handle-options dmc : $(condition) : $(command) : $(options) ; 69 70 if $(command) 71 { 72 command = [ common.get-absolute-tool-path $(command[-1]) ] ; 73 } 74 root = $(command:D) ; 75 76 if $(root) 77 { 78 # DMC linker is sensitive the the direction of slashes, and 79 # won't link if forward slashes are used in command. 80 root = [ sequence.join [ regex.split $(root) "/" ] : "\\" ] ; 81 flags dmc .root $(condition) : $(root)\\bin\\ ; 82 } 83 else 84 { 85 flags dmc .root $(condition) : "" ; 86 } 87} 88 89 90# Declare generators 91generators.register-linker dmc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>dmc ; 92generators.register-linker dmc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>dmc ; 93 94generators.register-archiver dmc.archive : OBJ : STATIC_LIB : <toolset>dmc ; 95generators.register-c-compiler dmc.compile.c++ : CPP : OBJ : <toolset>dmc ; 96generators.register-c-compiler dmc.compile.c : C : OBJ : <toolset>dmc ; 97 98 99# Declare flags 100# dmc optlink has some limitation on the amount of debug-info included. Therefore only linenumbers are enabled in debug builds. 101# flags dmc.compile OPTIONS <debug-symbols>on : -g ; 102flags dmc.compile OPTIONS <debug-symbols>on : -gl ; 103flags dmc.link OPTIONS <debug-symbols>on : /CO /NOPACKF /DEBUGLI ; 104flags dmc.link OPTIONS <debug-symbols>off : /PACKF ; 105 106flags dmc.compile OPTIONS <optimization>off : -S -o+none ; 107flags dmc.compile OPTIONS <optimization>speed : -o+time ; 108flags dmc.compile OPTIONS <optimization>space : -o+space ; 109flags dmc.compile OPTIONS <exception-handling>on : -Ae ; 110flags dmc.compile OPTIONS <rtti>on : -Ar ; 111# FIXME: 112# Compiling sources to be linked into a shared lib (dll) the -WD cflag should be used 113# Compiling sources to be linked into a static lib (lib) or executable the -WA cflag should be used 114# But for some reason the -WD cflag is always in use. 115# flags dmc.compile OPTIONS <link>shared : -WD ; 116# flags dmc.compile OPTIONS <link>static : -WA ; 117 118# Note that these two options actually imply multithreading support on DMC 119# because there is no single-threaded dynamic runtime library. Specifying 120# <threading>multi would be a bad idea, though, because no option would be 121# matched when the build uses the default settings of <runtime-link>dynamic 122# and <threading>single. 123flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>shared : -ND ; 124flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>shared : -ND ; 125 126flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>single : ; 127flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>single : ; 128flags dmc.compile OPTIONS <runtime-debugging>off/<runtime-link>static/<threading>multi : -D_MT ; 129flags dmc.compile OPTIONS <runtime-debugging>on/<runtime-link>static/<threading>multi : -D_MT ; 130 131flags dmc.compile OPTIONS : <cflags> ; 132flags dmc.compile.c++ OPTIONS : <cxxflags> ; 133 134flags dmc.compile DEFINES : <define> ; 135flags dmc.compile INCLUDES : <include> ; 136 137flags dmc.link <linkflags> ; 138flags dmc.archive OPTIONS <arflags> ; 139 140flags dmc LIBPATH <library-path> ; 141flags dmc LIBRARIES <library-file> ; 142flags dmc FINDLIBS <find-library-sa> ; 143flags dmc FINDLIBS <find-library-st> ; 144 145actions together link bind LIBRARIES 146{ 147 "$(.root)link" $(OPTIONS) /NOI /DE /XN "$(>)" , "$(<[1])" ,, $(LIBRARIES) user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def" 148} 149 150actions together link.dll bind LIBRARIES 151{ 152 echo LIBRARY "$(<[1])" > $(<[2]:B).def 153 echo DESCRIPTION 'A Library' >> $(<[2]:B).def 154 echo EXETYPE NT >> $(<[2]:B).def 155 echo SUBSYSTEM WINDOWS >> $(<[2]:B).def 156 echo CODE EXECUTE READ >> $(<[2]:B).def 157 echo DATA READ WRITE >> $(<[2]:B).def 158 "$(.root)link" $(OPTIONS) /NOI /DE /XN /ENTRY:_DllMainCRTStartup /IMPLIB:"$(<[2])" "$(>)" $(LIBRARIES) , "$(<[1])" ,, user32.lib kernel32.lib "$(FINDLIBS:S=.lib)" , "$(<[2]:B).def" 159} 160 161actions compile.c 162{ 163 "$(.root)dmc" -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" 164} 165 166actions compile.c++ 167{ 168 "$(.root)dmc" -cpp -c -Ab $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o"$(<)" "$(>)" 169} 170 171actions together piecemeal archive 172{ 173 "$(.root)lib" $(OPTIONS) -c -n -p256 "$(<)" "$(>)" 174} 175