From c2e5d0ddf43dc0df429152dfff74a2ed15f4fabf Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 12 Jul 2004 15:13:14 +0000 Subject: [PATCH] Added Metrowerks toolset, from Reece Dunn. [SVN r23467] --- v2/tools/common.jam | 16 +++- v2/tools/cw.jam | 229 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 v2/tools/cw.jam diff --git a/v2/tools/common.jam b/v2/tools/common.jam index fee981939..4709dcd8a 100644 --- a/v2/tools/common.jam +++ b/v2/tools/common.jam @@ -219,7 +219,21 @@ rule check-tool ( xcommand + ) } } - +# returns the location of the "program files" directory on a windows +# platform +rule get-program-files-dir ( ) +{ + local ProgramFiles = [ modules.peek : ProgramFiles ] ; + if $(ProgramFiles) + { + ProgramFiles = "$(ProgramFiles:J= )" ; + } + else + { + ProgramFiles = "c:\\Program Files" ; + } + return $(ProgramFiles) ; +} if [ os.name ] = NT { diff --git a/v2/tools/cw.jam b/v2/tools/cw.jam new file mode 100644 index 000000000..50c0132ad --- /dev/null +++ b/v2/tools/cw.jam @@ -0,0 +1,229 @@ +# Copyright (C) Reece H Dunn 2004 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# based on the msvc.jam toolset + +import property ; +import generators ; +import os ; +import type ; +import toolset : flags ; +import errors : error ; +import feature : feature ; +import path ; +import sequence : unique ; +import common ; + +if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] +{ + .debug-configuration = true ; +} + +feature.extend toolset : cw ; + +rule init ( version ? : command * : setup ? compiler ? linker ? ) +{ + # TODO: fix the $(command[1]) = $(compiler) issue + + setup ?= cwenv.bat ; + compiler ?= mwcc ; + linker ?= mwld ; + + local condition = [ common.check-init-parameters cw : + version $(version) ] ; + + command = [ common.get-invocation-command cw : mwcc.exe : $(command) : + [ default-paths $(version) ] ] ; + + if $(command) + { + command = [ common.get-absolute-tool-path $(command[-1]) ] ; + } + local root = $(command) ; + + setup = $(root)\\$(setup) ; + + # map the batch file in setup so it can be executed + + setup = "call \""$(setup)"\" > nul " ; + + if [ os.name ] = NT + { + setup = $(setup)" +" ; + } + else + { + setup = "cmd /S /C "$(setup)" \"&&\" " ; + } + + # bind the setup command to the tool so it can be executed before the + # command + + local prefix = $(setup) ; + + flags cw.compile .CC $(condition) : $(prefix)$(compiler) ; + flags cw.link .LD $(condition) : $(prefix)$(linker) ; + flags cw.archive .LD $(condition) : $(prefix)$(linker) ; +} + +rule default-paths ( version ? ) # FIXME +{ + local possible-paths ; + local ProgramFiles = [ common.get-program-files-dir ] ; + + # TODO: add support for cw8 and cw9 detection + + local version-6-path = $(ProgramFiles)"\\Metrowerks\\CodeWarrior" ; + possible-paths += $(version-6-path) ; + + # perform post-processing + + possible-paths + = $(possible-paths)"\\Other Metrowerks Tools\\Command Line Tools" ; + + possible-paths += [ modules.peek : PATH Path path ] ; + + return $(possible-paths) ; +} + +## declare generators + +generators.register-c-compiler cw.compile.c++ : CPP : OBJ : cw ; +generators.register-c-compiler cw.compile.c : C : OBJ : cw ; + +generators.register-linker cw.link + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : EXE RSP + : cw + ; +generators.register-linker cw.link.dll + : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB + : SHARED_LIB IMPORT_LIB RSP + : cw + ; + +generators.register-composing cw.archive + : OBJ + : STATIC_LIB RSP + : cw + ; + +## compilation phase + +flags cw WHATEVER ; + +flags cw.compile CFLAGS on : -g ; +flags cw.compile CFLAGS off : -O0 ; +flags cw.compile CFLAGS speed : -O4,p ; +flags cw.compile CFLAGS space : -O4,s ; +flags cw.compile CFLAGS off : -inline off ; +flags cw.compile CFLAGS on : -inline on ; +flags cw.compile CFLAGS full : -inline all ; +flags cw.compile CFLAGS off : -Cpp_exceptions off ; +flags cw.compile CFLAGS off : -RTTI off ; + +flags cw.compile USER_CFLAGS : ; +flags cw.compile.c++ USER_CFLAGS : ; + +flags cw.compile DEFINES ; +flags cw.compile UNDEFS ; +flags cw.compile INCLUDES ; + +actions compile.c +{ + $(.CC) -c -cwd include -lang c -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(USER_CFLAGS) -I- -I"$(INCLUDES)" -o "$(<)" "$(>)" +} +actions compile.c++ +{ + $(.CC) -c -cwd include -lang c++ -U$(UNDEFS) -D$(DEFINES) $(CFLAGS) $(USER_CFLAGS) -I- -I"$(INCLUDES)" -o "$(<)" "$(>)" +} + +## linking phase + +flags cw.link DEF_FILE ; + +flags cw LINKFLAGS on : -g ; +flags cw LINKFLAGS console : -subsystem console ; +flags cw LINKFLAGS gui : -subsystem windows ; +flags cw LINKFLAGS wince : -subsystem wince ; +flags cw LINKFLAGS native : -subsystem native ; +flags cw LINKFLAGS auto : -subsystem auto ; + +flags cw LINKFLAGS LIB/static : -library ; +flags cw LINKFLAGS LIB/shared : -shared ; + +toolset.flags cw.link USER_LINKFLAGS ; +toolset.flags cw.link LINKPATH ; + +if [ os.name ] in NT +{ + rule link ( targets + : sources * : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[2]) + : $(properties) ; + } + + rule link.dll ( targets + : sources * : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[3]) + : $(properties) ; + DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; + } + + rule archive ( targets + : sources * : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[2]) + : $(properties) ; + } + + actions archive + { + if exist "$(<[1])" DEL "$(<[1])" + $(.LD) -library -o "$(<[1])" @"$(<[2])" + } +} +else # cygwin +{ + rule link ( targets + : sources * : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[2]) + : $(properties) ; + } + + rule link.dll ( targets + : sources + : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[3]) + : $(properties) ; + .cygpath = "cygpath -d " ; + DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ; + } + + rule archive ( targets + : sources * : properties * ) + { + common.response-file $(targets) : $(sources) : $(targets[2]) + : $(properties) ; + } + + actions archive + { + _bbv2_out_="$(<)" + if test -f "$_bbv2_out_" ; then + _bbv2_existing_="$(<:W)" + fi + $(.LD) -library -o "$(<:W)" $_bbv2_existing_ @"$(>:W)" + } +} + +actions link bind DEF_FILE +{ + $(.LD) -o "$(<[1]:W)" -L"$(LINKPATH)" $(LINKFLAGS) $(USER_LINKFLAGS) @"$(<[2]:W)" +} + +actions link.dll bind DEF_FILE +{ + $(.LD) -o "$(<[1]:W)" -implib "$(<[2]:W)" -L"$(LINKPATH)" $(LINKFLAGS) -f "$(DEF_FILE)" $(USER_LINKFLAGS) @"$(<[3]:W)" +} +