mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 13:02:11 +00:00
Make build-dir project attribute and command-line option work.
[SVN r64357]
This commit is contained in:
@@ -56,7 +56,7 @@ class ProjectRegistry:
|
||||
|
||||
def __init__(self, manager, global_build_dir):
|
||||
self.manager = manager
|
||||
self.global_build_dir = None
|
||||
self.global_build_dir = global_build_dir
|
||||
self.project_rules_ = ProjectRules(self)
|
||||
|
||||
# The target corresponding to the project being loaded now
|
||||
@@ -339,7 +339,7 @@ expected value %s
|
||||
actual value %s""" % (jamfile_module, saved_project, self.current_project))
|
||||
|
||||
if self.global_build_dir:
|
||||
id = self.attribute(jamfile_module, "id")
|
||||
id = self.attributeDefault(jamfile_module, "id", None)
|
||||
project_root = self.attribute(jamfile_module, "project-root")
|
||||
location = self.attribute(jamfile_module, "location")
|
||||
|
||||
@@ -393,8 +393,6 @@ actual value %s""" % (jamfile_module, saved_project, self.current_project))
|
||||
# source paths are correct.
|
||||
if not location:
|
||||
location = ""
|
||||
else:
|
||||
location = b2.util.path.relpath(os.getcwd(), location)
|
||||
|
||||
attributes = ProjectAttributes(self.manager, location, module_name)
|
||||
self.module2attributes[module_name] = attributes
|
||||
@@ -523,8 +521,7 @@ actual value %s""" % (jamfile_module, saved_project, self.current_project))
|
||||
try:
|
||||
return self.module2attributes[project].get(attribute)
|
||||
except:
|
||||
print "Sucks", project, attribute
|
||||
raise "Sucks"
|
||||
raise BaseException("No attribute '%s' for project" % (attribute, project))
|
||||
|
||||
def attributeDefault(self, project, attribute, default):
|
||||
"""Returns the value of the specified attribute in the
|
||||
@@ -708,7 +705,7 @@ class ProjectAttributes:
|
||||
self.attributes = {}
|
||||
self.usage_requirements = None
|
||||
|
||||
def set(self, attribute, specification, exact):
|
||||
def set(self, attribute, specification, exact=False):
|
||||
"""Set the named attribute from the specification given by the user.
|
||||
The value actually set may be different."""
|
||||
|
||||
@@ -893,6 +890,8 @@ class ProjectRules:
|
||||
id = '/' + id
|
||||
self.registry.register_id (id, jamfile_module)
|
||||
|
||||
attributes.set('id', id)
|
||||
|
||||
explicit_build_dir = None
|
||||
for a in args:
|
||||
if a:
|
||||
@@ -912,16 +911,17 @@ class ProjectRules:
|
||||
# This is Jamroot.
|
||||
if id:
|
||||
if explicit_build_dir and os.path.isabs(explicit_build_dir):
|
||||
self.register.manager.errors()(
|
||||
self.registry.manager.errors()(
|
||||
"""Absolute directory specified via 'build-dir' project attribute
|
||||
Don't know how to combine that with the --build-dir option.""")
|
||||
|
||||
rid = id
|
||||
if rid[0] == '/':
|
||||
rid = rid[1:]
|
||||
|
||||
p = os.path.join(self.registry.global_build_dir,
|
||||
rid, explicit_build_dir)
|
||||
|
||||
p = os.path.join(self.registry.global_build_dir, rid)
|
||||
if explicit_build_dir:
|
||||
p = os.path.join(p, explicit_build_dir)
|
||||
attributes.set("build-dir", p, exact=1)
|
||||
elif explicit_build_dir:
|
||||
self.registry.manager.errors()(
|
||||
|
||||
@@ -380,8 +380,7 @@ class ProjectTarget (AbstractTarget):
|
||||
if not self.build_dir_:
|
||||
self.build_dir_ = self.get ('build-dir')
|
||||
if not self.build_dir_:
|
||||
self.build_dir_ = os.path.join (os.path.dirname(
|
||||
self.project_.get ('location')), 'bin')
|
||||
self.build_dir_ = os.path.join(self.project_.get ('location'), 'bin')
|
||||
|
||||
return self.build_dir_
|
||||
|
||||
|
||||
@@ -453,7 +453,6 @@ def main_real():
|
||||
engine = Engine()
|
||||
|
||||
global_build_dir = option.get("build-dir")
|
||||
|
||||
manager = Manager(engine, global_build_dir)
|
||||
|
||||
if "--version" in sys.argv:
|
||||
|
||||
@@ -99,7 +99,7 @@ exe a : a.cpp ;
|
||||
build-project sub ;
|
||||
""" % string.replace(os.getcwd(), '\\', '\\\\'))
|
||||
|
||||
t.run_build_system("--build-dir=build", status=1)
|
||||
t.run_build_system("--build-dir=build")
|
||||
t.fail_test(string.find(t.stdout(),
|
||||
"Absolute directory specified via 'build-dir' project attribute") == -1)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import sys
|
||||
import re
|
||||
import b2.util.regex
|
||||
|
||||
options = {}
|
||||
@@ -21,11 +22,11 @@ def get(name, default_value=None, implied_value=None):
|
||||
|
||||
global options
|
||||
|
||||
matches = b2.util.regex.transform(sys.argv, "--$(name)=(.*)")
|
||||
matches = b2.util.regex.transform(sys.argv, "--" + re.escape(name) + "=(.*)")
|
||||
if matches:
|
||||
return matches[-1]
|
||||
else:
|
||||
m = b2.util.regex.transform(sys.argv, "--$(name)")
|
||||
m = b2.util.regex.transform(sys.argv, "--" + re.escape(name))
|
||||
if m and implied_value:
|
||||
return implied_value
|
||||
elif options.has_key(name):
|
||||
|
||||
Reference in New Issue
Block a user