mirror of
https://github.com/boostorg/build.git
synced 2026-02-18 01:52:17 +00:00
Moved comments in from of implementation.
[SVN r13523]
This commit is contained in:
@@ -20,36 +20,6 @@
|
||||
# Targets defined in Jamfile, as well as target representing the entire
|
||||
# Jamfile will be available using facilities in the 'targets' module.
|
||||
#
|
||||
# By the time jamfile is included, the jamfile module will have certain
|
||||
# local rules defined, intended to make writing jamfiles less cumbersome.
|
||||
# By default, only project.project rule is available; more rules can be
|
||||
# declared using project.add_jamfile_rule below.
|
||||
|
||||
#
|
||||
# Loads jamfile at the given location. Certain rule will be imported in the
|
||||
# jamfile module, to ease describing targets. After loading, project global
|
||||
# file and jamfile needed by the loaded one will be loaded recursively.
|
||||
#
|
||||
rule load ( jamfile-location ) { }
|
||||
|
||||
#
|
||||
# Appends the given rules to the list of rules that will be implicitly
|
||||
# imported in any jamfile module. Rules must be unqualified.#
|
||||
#
|
||||
rule add_jamfile_rules ( rules + ) { }
|
||||
|
||||
#
|
||||
# Projects can be referred using path@project-id notation. In it, 'path'
|
||||
# selects jamfile location and 'project-id' names project relatively to
|
||||
# the selected jamfile. Rooted 'project-id' is possible:
|
||||
# "@/boost" will refer to the top-level project called "boost".
|
||||
# If part after "@" is not rooted, then part before "@" must be present.
|
||||
# This rules returns the name of project module given its id.
|
||||
rule lookup ( id ) { }
|
||||
|
||||
|
||||
# Interface description end.
|
||||
###########################################################################
|
||||
|
||||
import modules : poke ;
|
||||
import numbers ;
|
||||
@@ -60,9 +30,10 @@ import errors : error ;
|
||||
import project-root ;
|
||||
|
||||
|
||||
jamfile-rules = project.project ;
|
||||
|
||||
|
||||
#
|
||||
# Loads jamfile at the given location. After loading, project global
|
||||
# file and jamfile needed by the loaded one will be loaded recursively.
|
||||
#
|
||||
rule load ( jamfile-location )
|
||||
{
|
||||
local loaded = ;
|
||||
@@ -78,6 +49,14 @@ rule load ( jamfile-location )
|
||||
return $(module-name) ;
|
||||
}
|
||||
|
||||
#
|
||||
# Returns the name of project module given its id.
|
||||
# Projects can be referred using path@project-id notation. In it, 'path'
|
||||
# selects jamfile location and 'project-id' names project relatively to
|
||||
# the selected jamfile. Rooted 'project-id' is possible:
|
||||
# "@/boost" will refer to the top-level project called "boost".
|
||||
# If part after "@" is not rooted, then part before "@" must be present.
|
||||
#
|
||||
rule lookup ( id )
|
||||
{
|
||||
local split = [ MATCH (.*)@(.*) : $(id) ] ;
|
||||
@@ -221,7 +200,7 @@ local rule find-jamfile (
|
||||
{
|
||||
jamfile-glob = [ GLOB $(dir) : $(JAMFILE) ] ;
|
||||
}
|
||||
|
||||
|
||||
# Normalize the paths of each file found.
|
||||
#
|
||||
local jamfile-found = ;
|
||||
@@ -235,7 +214,7 @@ local rule find-jamfile (
|
||||
normalized =
|
||||
[ os.path.native [ os.path.root_relative_path $(jamfile) $(root-path) ] ] ;
|
||||
}
|
||||
|
||||
|
||||
# Filter out if the found file is above the target parent root.
|
||||
if $(parent-root)
|
||||
{
|
||||
@@ -244,10 +223,10 @@ local rule find-jamfile (
|
||||
normalized = ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jamfile-found += $(normalized) ;
|
||||
}
|
||||
|
||||
|
||||
return $(jamfile-found) ;
|
||||
}
|
||||
|
||||
@@ -263,7 +242,7 @@ local rule load-jamfile (
|
||||
# See if the Jamfile is where it should be.
|
||||
#
|
||||
local jamfile-to-load = [ find-jamfile $(dir) ] ;
|
||||
|
||||
|
||||
# Could not find it, error.
|
||||
#
|
||||
if ! $(jamfile-to-load)
|
||||
@@ -274,11 +253,11 @@ local rule load-jamfile (
|
||||
"this pattern:" $(JAMFILE)"."
|
||||
"Please consult the documentation at 'http://www.boost.org'." ;
|
||||
}
|
||||
|
||||
|
||||
# The module of the jamfile.
|
||||
#
|
||||
local jamfile-module = Jamfile<$(jamfile-to-load[1]:D)> ;
|
||||
|
||||
|
||||
# Don't even bother with the rest if we know the file is already loaded.
|
||||
#
|
||||
if ! [ modules.binding $(jamfile-module) ]
|
||||
@@ -293,21 +272,21 @@ local rule load-jamfile (
|
||||
"Loading the first one: '"$(jamfile-to-load[1]:D=)"'." ;
|
||||
}
|
||||
jamfile-to-load = $(jamfile-to-load[1]) ;
|
||||
|
||||
|
||||
# Initialize the jamfile module before loading.
|
||||
#
|
||||
initialize $(jamfile-module) : $(jamfile-to-load) ;
|
||||
|
||||
|
||||
# Setup, by coordinating with project-root.
|
||||
#
|
||||
local project-root-module = [ $(jamfile-module).project-root-module ] ;
|
||||
$(project-root-module).register-project $(jamfile-module) ;
|
||||
|
||||
|
||||
# Now load the Jamfile in it's own context.
|
||||
#
|
||||
modules.load $(jamfile-module)
|
||||
: $(jamfile-to-load:D=) : $(jamfile-to-load:D) ;
|
||||
|
||||
|
||||
# Indicate we loaded the Jamfile.
|
||||
#
|
||||
if $(loaded-var)
|
||||
@@ -315,7 +294,7 @@ local rule load-jamfile (
|
||||
$(loaded-var) = true ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Return the Jamfile's filename/module.
|
||||
#
|
||||
return $(jamfile-module) ;
|
||||
@@ -424,7 +403,7 @@ module project-rules {
|
||||
{
|
||||
import sequence ;
|
||||
import print ;
|
||||
|
||||
|
||||
print.section "'"$(__id__)"'" ;
|
||||
print.list-start ;
|
||||
print.list-item "Project root:" [ project-root ] ;
|
||||
|
||||
@@ -12,120 +12,32 @@
|
||||
|
||||
# Each target is an instanse of some class derived from 'target' class.
|
||||
|
||||
# Note: classes will be actually declared in the implementation section.
|
||||
# Declaring them here will cause incomplete ctor declarations to be used.
|
||||
|
||||
# Base target class.
|
||||
rule target ( )
|
||||
{
|
||||
# Adds new depencies for this target
|
||||
rule depends ( d + ) { }
|
||||
# Retrives the list of dependencies
|
||||
rule dependencies ( ) { }
|
||||
# Generates build instruction for the target and the specified build
|
||||
# request. If 'build-request' is omitted, default build is performed,
|
||||
# if appropriate
|
||||
rule generate ( build-request * ) { }
|
||||
}
|
||||
|
||||
# Project target class (derived from 'target')
|
||||
rule project-target ( requirements * : default-build * )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
# Concrete target (derived from 'target')
|
||||
rule typed-target ( name : type : sources * : requirements * : default-build * )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Returns the target instance for the specified jamfile-location and target
|
||||
# pair. If 'jamfile-location' is not yet known, loads Jamfile there.
|
||||
#
|
||||
rule abstract-target-name ( jamfile-location : target-in-jamfile ? )
|
||||
|
||||
#
|
||||
# Creates project target at the specified location
|
||||
#
|
||||
rule create-abstract-project-target ( jamfile-location )
|
||||
|
||||
|
||||
|
||||
# Class which represents a virtual target
|
||||
rule virtual-target ( name : subvariant : project )
|
||||
{
|
||||
# Name of the target
|
||||
rule name ( ) { }
|
||||
# Property set that distinguishes different variants of a target.
|
||||
# May be a subset of the property set that is used for building.
|
||||
# Determines the location of target, in an unspecified way.
|
||||
rule subvariant ( ) { }
|
||||
# Project where this target was declared
|
||||
rule project ( ) { }
|
||||
|
||||
rule includes ( ) { }
|
||||
rule add_includes ( i + ) { }
|
||||
|
||||
rule dependencies ( ) { }
|
||||
rule depends ( d + ) { }
|
||||
|
||||
# If 'a' is supplied, sets action to 'a'.
|
||||
# Returns the action currently set.
|
||||
rule action ( a ? ) { }
|
||||
|
||||
# Generates all the actual targets and build instructions needed to build
|
||||
# this target. Returns the actual target name. Can be called several times.
|
||||
# Does no processing for other targets that 'action' will generate.
|
||||
# Rationale: we might need only one file from the set created by an
|
||||
# action, and there's no need to run the action if the file is up-to-date,
|
||||
# only because some other file in set is out-of-date.
|
||||
rule actualize ( ) { }
|
||||
}
|
||||
|
||||
# Class which represents an action.
|
||||
# Both 'targets' and 'sources' should list instances of 'virtual-target'.
|
||||
# Action name should name a rule with this prototype
|
||||
# rule action_name ( targets + : sources * : properties * )
|
||||
# Targets and sources are passed as actual jam targets. The rule may
|
||||
# not establish dependency relationship, but should do everything else.
|
||||
rule action ( targets + : sources * : action_name : properties * )
|
||||
{
|
||||
rule targets ( ) { }
|
||||
rule sources ( ) { }
|
||||
rule action_name ( ) { }
|
||||
rule properties ( ) { }
|
||||
# Generates actual build instructions.
|
||||
rule actualize ( ) { }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# Interface description end.
|
||||
###########################################################################
|
||||
|
||||
import sequence ;
|
||||
import class : class ;
|
||||
import regex ;
|
||||
import property ;
|
||||
|
||||
# Base target class.
|
||||
rule target ( )
|
||||
{
|
||||
__dependencies__ = ;
|
||||
|
||||
# Adds new depencies for this target
|
||||
rule depends ( d + )
|
||||
{
|
||||
d = [ sequence.insertion-sort $(d) ] ;
|
||||
__dependencies__ = [ sequence.merge $(__dependencies__) $(d) ] ;
|
||||
}
|
||||
|
||||
# Retrives the list of dependencies
|
||||
rule dependencies ( )
|
||||
{
|
||||
return $(__dependencies__) ;
|
||||
}
|
||||
|
||||
# Generates build instruction for the target and the specified build
|
||||
# request. If 'build-request' is omitted, default build is performed,
|
||||
# if appropriate
|
||||
rule generate ( build-request * )
|
||||
{
|
||||
for local d in [ dependencies ] {
|
||||
@@ -136,6 +48,7 @@ rule target ( )
|
||||
|
||||
class.class target ;
|
||||
|
||||
# Project target class (derived from 'target')
|
||||
rule project-target ( requirements * : default-build * )
|
||||
{
|
||||
__requirements__ = $(requirements) ;
|
||||
@@ -146,6 +59,7 @@ rule project-target ( requirements * : default-build * )
|
||||
|
||||
class.class project-target : target ;
|
||||
|
||||
# Concrete target (derived from 'target')
|
||||
rule typed-target ( name : type : sources * : requirements * : default-build * )
|
||||
{
|
||||
__name__ = $(name) ;
|
||||
@@ -168,6 +82,10 @@ class.class typed-target : target ;
|
||||
|
||||
__targets__ = ;
|
||||
|
||||
#
|
||||
# Returns the target instance for the specified jamfile-location and target
|
||||
# pair. If 'jamfile-location' is not yet known, loads Jamfile there.
|
||||
#
|
||||
rule abstract-target-name ( jamfile-location : target-in-jamfile ? )
|
||||
{
|
||||
if $(target-in-jamfile) {
|
||||
@@ -177,12 +95,16 @@ rule abstract-target-name ( jamfile-location : target-in-jamfile ? )
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Creates project target at the specified location
|
||||
#
|
||||
rule create-abstract-project-target ( jamfile-location )
|
||||
{
|
||||
local target = [ abstract-target-name $(jamfile-location) ] ;
|
||||
class.instance $(target) : project-target ;
|
||||
}
|
||||
|
||||
|
||||
# Class which represents a virtual target
|
||||
rule virtual-target ( name : subvariant : project )
|
||||
{
|
||||
@@ -220,6 +142,8 @@ rule virtual-target ( name : subvariant : project )
|
||||
[ sequence.insertion-sort $(d) ] ] ;
|
||||
}
|
||||
|
||||
# If 'a' is supplied, sets action to 'a'.
|
||||
# Returns the action currently set.
|
||||
rule action ( a ? )
|
||||
{
|
||||
if $(a) {
|
||||
@@ -228,6 +152,12 @@ rule virtual-target ( name : subvariant : project )
|
||||
return $(__action__) ;
|
||||
}
|
||||
|
||||
# Generates all the actual targets and build instructions needed to build
|
||||
# this target. Returns the actual target name. Can be called several times.
|
||||
# Does no processing for other targets that 'action' will generate.
|
||||
# Rationale: we might need only one file from the set created by an
|
||||
# action, and there's no need to run the action if the file is up-to-date,
|
||||
# only because some other file in set is out-of-date.
|
||||
rule actualize ( )
|
||||
{
|
||||
ECHO "Actualizing target $(__name__)" ;
|
||||
@@ -273,6 +203,12 @@ rule virtual-target ( name : subvariant : project )
|
||||
|
||||
class virtual-target ;
|
||||
|
||||
# Class which represents an action.
|
||||
# Both 'targets' and 'sources' should list instances of 'virtual-target'.
|
||||
# Action name should name a rule with this prototype
|
||||
# rule action_name ( targets + : sources * : properties * )
|
||||
# Targets and sources are passed as actual jam targets. The rule may
|
||||
# not establish dependency relationship, but should do everything else.
|
||||
rule action ( targets + : sources * : action_name : properties )
|
||||
{
|
||||
__targets__ = $(targets) ;
|
||||
@@ -297,6 +233,7 @@ rule action ( targets + : sources * : action_name : properties )
|
||||
return $(__properties__) ;
|
||||
}
|
||||
|
||||
# Generates actual build instructions.
|
||||
rule actualize ( )
|
||||
{
|
||||
local actual_targets ;
|
||||
|
||||
Reference in New Issue
Block a user