2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 13:22:11 +00:00
Files
build/new/type.jam
Vladimir Prus 4950f269d3 Some cleanups. At the same time, allowed several suffixes to target types
(e.g. "cpp" and "cxx").


[SVN r15262]
2002-09-11 14:18:52 +00:00

73 lines
2.3 KiB
Plaintext

# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears in
# all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
# Deals with target type declaration and defines target class which supports
# typed targets.
import feature ;
import generators : * ;
import class : class new ;
feature.feature target-type : : composite optional ;
feature.feature base-target-type : : composite optional ;
feature.feature main-target-type : : optional incidental ;
# Registers a target type, possible derived from a 'base-type'.
# If 'suffixes' are provided, they given all the suffixes that mean a file is of 'type'.
# Also, the first element gives the suffix to be used when constructing and object of
# 'type'.
# If 'main' is given, a rule with the same name as the target type
# and signature
# rule target-type ( name : sources * : requirements * : default-build )
# will be added to the global scope.
rule register ( type : suffixes * : base-type ? : main ? )
{
if $(type) in $(.types)
{
error "Type $(type) is already registered." ;
}
else
{
.types += $(type) ;
.suffix.$(type) = $(suffixes[1]) ;
.type.$(suffixes) = $(type) ;
feature.extend target-type : $(type) ;
feature.compose <target-type>$(type) : $(base-type:G=<base-target-type>) ;
feature.compose <base-target-type>$(type) : $(base-type:G=<base-target-type>) ;
if $(main)
{
IMPORT $(__name__) : main-target-rule : : $(type:L) ;
}
}
}
# Returns suffix that should be used when generating target of 'type'.
rule generated-target-suffix ( type )
{
return $(.suffix.$(type)) ;
}
# Returns file type given its suffix.
rule type ( suffix )
{
return $(.type$(suffix)) ;
}
rule main-target-rule ( name : sources * : requirements * : default-build ? )
{
# First find requuired target type, which is equal to the name used to
# invoke us.
local bt = [ BACKTRACE 1 ] ;
local type = $(bt[4]) ;
targets.main-target-alternative $(name) [ CALLER_MODULE ] typed-target : 3 : 4
: $(type:U) : $(sources) : $(requirements) : $(default-build)
;
}