1# Copyright Pedro Ferreira 2005. Distributed under the Boost 2# Software License, Version 1.0. (See accompanying 3# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 5import bjam 6 7# To simplify implementation of tools level, we'll 8# have a global variable keeping the current manager. 9the_manager = None 10def get_manager(): 11 return the_manager 12 13class Manager: 14 """ This class is a facade to the Boost.Build system. 15 It serves as the root to access all data structures in use. 16 """ 17 18 def __init__ (self, engine, global_build_dir): 19 """ Constructor. 20 engine: the build engine that will actually construct the targets. 21 """ 22 from build.virtual_target import VirtualTargetRegistry 23 from build.targets import TargetRegistry 24 from build.project import ProjectRegistry 25 from build.scanner import ScannerRegistry 26 from build.errors import Errors 27 from b2.util.logger import NullLogger 28 from build import build_request, property_set, feature 29 30 self.engine_ = engine 31 self.virtual_targets_ = VirtualTargetRegistry (self) 32 self.projects_ = ProjectRegistry (self, global_build_dir) 33 self.targets_ = TargetRegistry () 34 self.logger_ = NullLogger () 35 self.scanners_ = ScannerRegistry (self) 36 self.argv_ = bjam.variable("ARGV") 37 self.boost_build_path_ = bjam.variable("BOOST_BUILD_PATH") 38 self.errors_ = Errors() 39 self.command_line_free_features_ = property_set.empty() 40 41 global the_manager 42 the_manager = self 43 44 def scanners (self): 45 return self.scanners_ 46 47 def engine (self): 48 return self.engine_ 49 50 def virtual_targets (self): 51 return self.virtual_targets_ 52 53 def targets (self): 54 return self.targets_ 55 56 def projects (self): 57 return self.projects_ 58 59 def argv (self): 60 return self.argv_ 61 62 def logger (self): 63 return self.logger_ 64 65 def set_logger (self, logger): 66 self.logger_ = logger 67 68 def errors (self): 69 return self.errors_ 70 71 def getenv(self, name): 72 return bjam.variable(name) 73 74 def boost_build_path(self): 75 return self.boost_build_path_ 76 77 def command_line_free_features(self): 78 return self.command_line_free_features_ 79 80 def set_command_line_free_features(self, v): 81 self.command_line_free_features_ = v 82 83 def construct (self, properties = [], targets = []): 84 """ Constructs the dependency graph. 85 properties: the build properties. 86 targets: the targets to consider. If none is specified, uses all. 87 """ 88 if not targets: 89 for name, project in self.projects ().projects (): 90 targets.append (project.target ()) 91 92 property_groups = build_request.expand_no_defaults (properties) 93 94 virtual_targets = [] 95 build_prop_sets = [] 96 for p in property_groups: 97 build_prop_sets.append (property_set.create (feature.split (p))) 98 99 if not build_prop_sets: 100 build_prop_sets = [property_set.empty ()] 101 102 for build_properties in build_prop_sets: 103 for target in targets: 104 result = target.generate (build_properties) 105 virtual_targets.extend (result.targets ()) 106 107 actual_targets = [] 108 for virtual_target in virtual_targets: 109 actual_targets.extend (virtual_target.actualize ()) 110 111