diff --git a/doc/src/reference.xml b/doc/src/reference.xml index 51720a998..45c7c9d60 100644 --- a/doc/src/reference.xml +++ b/doc/src/reference.xml @@ -181,6 +181,26 @@ ECHO [ glob-tree *.cpp : .svn ] ; their containing project is built. + + always + always building a metatarget + + The always funciton takes a single + parameter—a list of metatarget names. The top-level targets produced + by the named metatargets will be always considered out of date. Consider this example: + + +exe hello : hello.cpp ; +exe bye : bye.cpp ; +always hello ; + + If a build of hello is requested, then the binary will + always be relinked. The object files will not be recompiled, though. Note that if + a build of hello is not requested, for example you specify just + bye on the command line, hello will not + be relinked. + + constant diff --git a/src/build/project.jam b/src/build/project.jam index e55521901..8b6a75c05 100644 --- a/src/build/project.jam +++ b/src/build/project.jam @@ -1035,6 +1035,16 @@ module project-rules } } + rule always ( target-names * ) + { + import project ; + local t = [ project.current ] ; + for local n in $(target-names) + { + $(t).mark-target-as-always $(n) ; + } + } + rule glob ( wildcards + : excludes * ) { import project ; diff --git a/src/build/targets.jam b/src/build/targets.jam index 38736769a..3d38002d3 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -303,6 +303,13 @@ class project-target : abstract-target # before main target instances are created. self.explicit-targets += $(target-name) ; } + + rule mark-target-as-always ( target-name ) + { + # Record the name of the target, not instance, since this rule is called + # before main target instances are created. + self.always-targets += $(target-name) ; + } # Add new target alternative # @@ -466,6 +473,11 @@ class project-target : abstract-target self.main-targets += $(t) ; target = $(self.main-target.$(name)) ; } + + if $(name) in $(self.always-targets) + { + $(a).always ; + } $(target).add-alternative $(a) ; } @@ -1100,7 +1112,12 @@ class basic-target : abstract-target [ full-name ] ; } } - + + rule always ( ) + { + self.always = 1 ; + } + # Returns the list of abstract-targets which are used as sources. The extra # properties specified for sources are not represented. The only user for # this rule at the moment is the "--dump-tests" feature of the test system. @@ -1267,7 +1284,15 @@ class basic-target : abstract-target { local gur = $(result[1]) ; result = $(result[2-]) ; - + + if $(self.always) + { + for local t in $(result) + { + $(t).always ; + } + } + local s = [ create-subvariant $(result) : [ virtual-target.recent-targets ] : $(property-set) : $(source-targets)