From d8dbd13bd15d2dd5dfe388212ff54dcbf521a97e Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 23 Jun 2004 08:10:25 +0000 Subject: [PATCH] * tools/borland.jam (init): Rewrite. * tools/common.jam (get-absolute-tool-path): New rule. [SVN r23164] --- src/tools/borland.jam | 59 ++++++++++--------------------------------- src/tools/common.jam | 21 +++++++++++++-- 2 files changed, 32 insertions(+), 48 deletions(-) diff --git a/src/tools/borland.jam b/src/tools/borland.jam index f78a2aba3..a444c35dc 100644 --- a/src/tools/borland.jam +++ b/src/tools/borland.jam @@ -18,53 +18,20 @@ import common ; toolset.register borland ; -feature.subfeature toolset borland : version ; - -# Installation root to use for versionless toolset -.root = "" ; -STDHDRS = ; -STDLIBPATH = ; - - -rule init ( version ? : root ? ) +rule init ( version ? : command ? ) { - # If version is not provided, change the global variable - # It would probably be better to introduce 'unspecified' version - # and set flags on borland-unspecified, but, - # default values are not applied to subfeatures. - if ! $(version) - { - if ! $(root) - { - # versionless and rootless, we assume the user has bcc in the path - # so we try and find it, and set up the paths accordingly - import regex ; - import modules ; - local bcc = [ GLOB [ modules.peek : Path ] [ modules.peek : PATH ] : bcc32.exe ] ; - root = $(bcc[1]:D) ; root = $(root:P) ; - } - if $(root) - { - toolset.flags borland.compile STDHDRS borland : $(root)/include/ ; - toolset.flags borland.link STDLIBPATH borland : $(root)/lib ; - toolset.flags borland .root borland : $(root)/bin/ ; - } - } - else - { - feature.extend-subfeature toolset borland : version : $(version) ; - local condition = borland-$(version) ; - - toolset.flags borland.compile STDHDRS $(condition) : $(root)/include/ ; - toolset.flags borland.link STDLIBPATH $(condition) : $(root)/lib/ ; - - root = $(root)/bin/ ; - root ?= "" ; - toolset.flags borland .root $(condition) : $(root) ; - } - # strange that this return is needed, because if absent the - # unversioned/unrooted case doesn't work at all - return ; + local condition = [ common.check-init-parameters borland : + version $(version) ] ; + + local command = [ common.get-invocation-command borland : bcc32.exe + : $(command) ] ; + + local root = [ common.get-absolute-tool-path $(command) ] ; + root = $(root:D) ; + + toolset.flags borland.compile STDHDRS $(condition) : $(root)/include/ ; + toolset.flags borland.link STDLIBPATH $(condition) : $(root)/lib ; + toolset.flags borland .root $(condition) : $(root)/bin/ ; } diff --git a/src/tools/common.jam b/src/tools/common.jam index 0ba59b36a..440360c1c 100644 --- a/src/tools/common.jam +++ b/src/tools/common.jam @@ -129,6 +129,23 @@ rule get-invocation-command ( return $(command) ; } +# Given an invocation command returned by 'get-invocation-command', +# return the absolute path to the command. This works even if commnad +# has not path element and is present in PATH. +rule get-absolute-tool-path ( command ) +{ + if $(command:D) + { + return $(command:D) ; + } + else + { + local m = [ GLOB [ modules.peek : PATH Path path ] : $(command) $(command).exe ] ; + return $(m[1]:D) ; + } +} + + # Attempts to find tool (binary) named 'name' in PATH and in 'additiona-paths'. # If found in path, returns 'name'. @@ -137,14 +154,14 @@ rule get-invocation-command ( # Otherwise, returns empty string. rule find-tool ( name : additional-paths * ) { - local m = [ GLOB [ modules.peek : PATH Path path ] : $(name) ] ; + local m = [ GLOB [ modules.peek : PATH Path path ] : $(name) $(name).exe ] ; if $(m) { return $(name) ; } else { - return [ path.glob $(additional-paths) : $(name) ] ; + return [ path.glob $(additional-paths) : $(name) $(name).exe ] ; } }