2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00

The "explicit" targets are now specified by "explicit" rule in Jamfile,

not by project attribute. The problem with the previous interface was
that it was not possible to mark target as explicit anywhere else,
such as in helper module which declares target in project module, or
in toolset module.

* new/targets.jam
  (project-target.mark-target-as-explicit): New rule
  (project-target.targets-to-build): Use self.explicit-targets.

* new/project.jam
  (project-attributes.set): Don't allow 'explicit-targets'.


[SVN r18900]
This commit is contained in:
Vladimir Prus
2003-07-01 06:46:15 +00:00
parent e855587387
commit 1d55c1e7bd
8 changed files with 124 additions and 66 deletions

View File

@@ -22,12 +22,12 @@
div.alert { color: red }
table { align: center; border: thin; }
</style>
</style>
</head>
<!-- Things yet to document:
- build request, build request expansion and directly requested targets
- conditional properties
-->
- build request, build request expansion and directly requested targets
- conditional properties
-->
<body>
<p><a href="../../index.htm"><img class="banner" height="86" width="277"
@@ -138,12 +138,12 @@
<tt>bjam</tt> there. A simple application will be built. You can also
play with other projects in <tt>examples-v2</tt>.
<!-- This part should not go into intoduction docs, but we need to place
it somewhere.
<p>It is slighly better way is to copy <tt>new/user-config.jam</tt>
into one of the locations where it can be found (given in <a href=
"#config_files_location">this table</a>). This prevent you from
accidentally overwriting your config when updating.</p> -->
it somewhere.
<p>It is slighly better way is to copy <tt>new/user-config.jam</tt>
into one of the locations where it can be found (given in <a href=
"#config_files_location">this table</a>). This prevent you from
accidentally overwriting your config when updating.</p> -->
</li>
</ol>
@@ -1211,6 +1211,13 @@ borland/runtime-link=static,dynamic
<td>Build another project when this one is built.</td>
</tr>
<tr>
<td><a href="#explicit_rule">explicit</a></td>
<td>States that the target should be built only by explicit
request.</td>
</tr>
</table>
<p>Each project is also associated with <em>project root</em>. That's a
@@ -1461,17 +1468,17 @@ borland/runtime-link=static,dynamic
<li>It allows to have main target names with slashes.
<!-- The motivation for which is:
So, to summarize:
1. The project which extract tarfile may extract all possible kinds of
targets, and it's reasonable to use them directly from other project.
2. The rule for unpacking tar is inplemented in terms of "patch-file", for
maintainability, and therefore, must use main target name which contains
slashes?
3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is not an
option, because you should not change existing tree
So, to summarize:
1. The project which extract tarfile may extract all possible kinds of
targets, and it's reasonable to use them directly from other project.
2. The rule for unpacking tar is inplemented in terms of "patch-file", for
maintainability, and therefore, must use main target name which contains
slashes?
3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is not an
option, because you should not change existing tree
That makes good rationale for why main target must contain names.
-->
That makes good rationale for why main target must contain names.
-->
</li>
</ul>
@@ -1554,10 +1561,21 @@ borland/runtime-link=static,dynamic
follows:</p>
<ul>
<li>For project targets, all of main targets are generated with the
same properties. Then all projects referred via "build-project" are
generated as well. If it's not possible to refine requested properties
with project requirements, the project is skipped.</li>
<li>
<p>For project targets, all of main targets are generated with the
same properties. Then all projects referred via "build-project" are
generated as well. If it's not possible to refine requested
properties with project requirements, the project is skipped.</p>
<p id="explicit_rule">It is possible to disable building of certain
target using the <tt>explicit</tt> rule, available in all project
modules. The syntax is</p>
<pre>
rule explicit ( target-name )
</pre>
If this rule is invoked on a target, it will be built only when it's
explicitly requested on the command line.
</li>
<li>
For main target, steps are:

View File

@@ -467,7 +467,7 @@ rule project-attributes ( location )
self.build-dir = [ path.root $(specification) $(self.location) ] ;
}
else if ! $(attribute) in "id" "default-build" "location" "source-location"
"parent" "projects-to-build" "explicit-targets"
"parent" "projects-to-build"
{
errors.error "Invalid project attribute '$(attribute)' specified "
"for project at '$(self.location)'" ;
@@ -605,6 +605,13 @@ module project-rules
local now = [ $(attributes).get projects-to-build ] ;
$(attributes).set projects-to-build : $(now) $(dir) ;
}
rule explicit ( target-name )
{
import project ;
local t = [ project.target $(__name__) ] ;
$(t).mark-target-as-explicit $(target-name) ;
}
}

View File

@@ -195,18 +195,17 @@ rule project-target ( name : project : requirements * : default-build * )
}
return $(usage-requirements) $(targets) ;
}
# Computes and returns a list of abstract-target instances which
# must be built when this project is built.
rule targets-to-build ( )
{
local result ;
# Collect all main targets here, except for "explicit" ones.
local explicit-targets = [ project.attribute $(self.project) explicit-targets ] ;
for local name in $(self.main-targets)
{
if ! $(name) in $(explicit-targets)
if ! $(name) in $(self.explicit-targets)
{
result += [ main-target $(name) ] ;
}
@@ -223,7 +222,13 @@ rule project-target ( name : project : requirements * : default-build * )
return $(result) ;
}
# Add 'target' to the list of targets in this project that should be build
# only by explicit request
rule mark-target-as-explicit ( target-name )
{
self.explicit-targets += $(target-name) ;
}
# Returns a 'main-target' class instance corresponding to the 'name'.
# Creates the instance if needed.
rule main-target ( name )

View File

@@ -14,12 +14,11 @@ t = Tester()
t.write("project-root.jam", "")
t.write("Jamfile", """
project
: explicit-targets hello2
;
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
explicit hello2 ;
""")
t.write("hello.cpp", """
int main()

View File

@@ -22,12 +22,12 @@
div.alert { color: red }
table { align: center; border: thin; }
</style>
</style>
</head>
<!-- Things yet to document:
- build request, build request expansion and directly requested targets
- conditional properties
-->
- build request, build request expansion and directly requested targets
- conditional properties
-->
<body>
<p><a href="../../index.htm"><img class="banner" height="86" width="277"
@@ -138,12 +138,12 @@
<tt>bjam</tt> there. A simple application will be built. You can also
play with other projects in <tt>examples-v2</tt>.
<!-- This part should not go into intoduction docs, but we need to place
it somewhere.
<p>It is slighly better way is to copy <tt>new/user-config.jam</tt>
into one of the locations where it can be found (given in <a href=
"#config_files_location">this table</a>). This prevent you from
accidentally overwriting your config when updating.</p> -->
it somewhere.
<p>It is slighly better way is to copy <tt>new/user-config.jam</tt>
into one of the locations where it can be found (given in <a href=
"#config_files_location">this table</a>). This prevent you from
accidentally overwriting your config when updating.</p> -->
</li>
</ol>
@@ -1211,6 +1211,13 @@ borland/runtime-link=static,dynamic
<td>Build another project when this one is built.</td>
</tr>
<tr>
<td><a href="#explicit_rule">explicit</a></td>
<td>States that the target should be built only by explicit
request.</td>
</tr>
</table>
<p>Each project is also associated with <em>project root</em>. That's a
@@ -1461,17 +1468,17 @@ borland/runtime-link=static,dynamic
<li>It allows to have main target names with slashes.
<!-- The motivation for which is:
So, to summarize:
1. The project which extract tarfile may extract all possible kinds of
targets, and it's reasonable to use them directly from other project.
2. The rule for unpacking tar is inplemented in terms of "patch-file", for
maintainability, and therefore, must use main target name which contains
slashes?
3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is not an
option, because you should not change existing tree
So, to summarize:
1. The project which extract tarfile may extract all possible kinds of
targets, and it's reasonable to use them directly from other project.
2. The rule for unpacking tar is inplemented in terms of "patch-file", for
maintainability, and therefore, must use main target name which contains
slashes?
3. Using sub-Jamfile in "foo" to declare extracted file "foo/b" is not an
option, because you should not change existing tree
That makes good rationale for why main target must contain names.
-->
That makes good rationale for why main target must contain names.
-->
</li>
</ul>
@@ -1554,10 +1561,21 @@ borland/runtime-link=static,dynamic
follows:</p>
<ul>
<li>For project targets, all of main targets are generated with the
same properties. Then all projects referred via "build-project" are
generated as well. If it's not possible to refine requested properties
with project requirements, the project is skipped.</li>
<li>
<p>For project targets, all of main targets are generated with the
same properties. Then all projects referred via "build-project" are
generated as well. If it's not possible to refine requested
properties with project requirements, the project is skipped.</p>
<p id="explicit_rule">It is possible to disable building of certain
target using the <tt>explicit</tt> rule, available in all project
modules. The syntax is</p>
<pre>
rule explicit ( target-name )
</pre>
If this rule is invoked on a target, it will be built only when it's
explicitly requested on the command line.
</li>
<li>
For main target, steps are:

View File

@@ -467,7 +467,7 @@ rule project-attributes ( location )
self.build-dir = [ path.root $(specification) $(self.location) ] ;
}
else if ! $(attribute) in "id" "default-build" "location" "source-location"
"parent" "projects-to-build" "explicit-targets"
"parent" "projects-to-build"
{
errors.error "Invalid project attribute '$(attribute)' specified "
"for project at '$(self.location)'" ;
@@ -605,6 +605,13 @@ module project-rules
local now = [ $(attributes).get projects-to-build ] ;
$(attributes).set projects-to-build : $(now) $(dir) ;
}
rule explicit ( target-name )
{
import project ;
local t = [ project.target $(__name__) ] ;
$(t).mark-target-as-explicit $(target-name) ;
}
}

View File

@@ -195,18 +195,17 @@ rule project-target ( name : project : requirements * : default-build * )
}
return $(usage-requirements) $(targets) ;
}
# Computes and returns a list of abstract-target instances which
# must be built when this project is built.
rule targets-to-build ( )
{
local result ;
# Collect all main targets here, except for "explicit" ones.
local explicit-targets = [ project.attribute $(self.project) explicit-targets ] ;
for local name in $(self.main-targets)
{
if ! $(name) in $(explicit-targets)
if ! $(name) in $(self.explicit-targets)
{
result += [ main-target $(name) ] ;
}
@@ -223,7 +222,13 @@ rule project-target ( name : project : requirements * : default-build * )
return $(result) ;
}
# Add 'target' to the list of targets in this project that should be build
# only by explicit request
rule mark-target-as-explicit ( target-name )
{
self.explicit-targets += $(target-name) ;
}
# Returns a 'main-target' class instance corresponding to the 'name'.
# Creates the instance if needed.
rule main-target ( name )

View File

@@ -14,12 +14,11 @@ t = Tester()
t.write("project-root.jam", "")
t.write("Jamfile", """
project
: explicit-targets hello2
;
exe hello : hello.cpp ;
exe hello2 : hello.cpp ;
explicit hello2 ;
""")
t.write("hello.cpp", """
int main()