def process(self, target, matches, binding): binding = binding[0] angle = regex.transform(matches, "#include[ ]*<([^<]+)>") quoted = regex.transform(matches, "#include[ ]*\"([^\"]+)\"") res = regex.transform(matches, "[^ ]+[ ]+(BITMAP|CURSOR|FONT|ICON|MESSAGETABLE|RT_MANIFEST)" +\ "[ ]+(([^ \"]+)|\"([^\"]+)\")", [3, 4]) # Icons and other includes may referenced as # # IDR_MAINFRAME ICON "res\\icon.ico" # # so we have to replace double backslashes to single ones. res = [ re.sub(r'\\\\', '/', match) for match in res if match is not None ] # CONSIDER: the new scoping rule seem to defeat "on target" variables. g = bjam.call('get-target-variable', target, 'HDRGRIST')[0] b = os.path.normpath(os.path.dirname(binding)) # Attach binding of including file to included targets. # When target is directly created from virtual target # this extra information is unnecessary. But in other # cases, it allows to distinguish between two headers of the # same name included from different places. # We don't need this extra information for angle includes, # since they should not depend on including file (we can't # get literal "." in include path). g2 = g + "#" + b g = "<" + g + ">" g2 = "<" + g2 + ">" angle = [g + x for x in angle] quoted = [g2 + x for x in quoted] res = [g2 + x for x in res] all = angle + quoted bjam.call('mark-included', target, all) engine = get_manager().engine() engine.add_dependency(target, res) bjam.call('NOCARE', all + res) engine.set_target_variable( angle, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable( quoted, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes]) engine.set_target_variable( res, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes]) # Just propagate current scanner to includes, in a hope # that includes do not change scanners. get_manager().scanners().propagate(self, angle + quoted)
def actualize_location(self, target): assert isinstance(target, basestring) engine = self.project_.manager_.engine() if self.action_: # This is a derived file. path = self.path() engine.set_target_variable(target, 'LOCATE', path) # Make sure the path exists. engine.add_dependency(target, path) common.mkdir(engine, path) # It's possible that the target name includes a directory # too, for example when installing headers. Create that # directory. d = os.path.dirname(get_value(target)) if d: d = os.path.join(path, d) engine.add_dependency(target, d) common.mkdir(engine, d) # For real file target, we create a fake target that # depends on the real target. This allows to run # # bjam hello.o # # without trying to guess the name of the real target. # Note the that target has no directory name, and a special # grist <e>. # # First, that means that "bjam hello.o" will build all # known hello.o targets. # Second, the <e> grist makes sure this target won't be confused # with other targets, for example, if we have subdir 'test' # with target 'test' in it that includes 'test.o' file, # then the target for directory will be just 'test' the target # for test.o will be <ptest/bin/gcc/debug>test.o and the target # we create below will be <e>test.o engine.add_dependency("<e>%s" % get_value(target), target) # Allow bjam <path-to-file>/<file> to work. This won't catch all # possible ways to refer to the path (relative/absolute, extra ".", # various "..", but should help in obvious cases. engine.add_dependency( "<e>%s" % (os.path.join(path, get_value(target))), target) else: # This is a source file. engine.set_target_variable(target, 'SEARCH', self.project_.get('source-location'))
def process(self, target, matches, binding): binding = binding[0] angle = regex.transform(matches, "#include[ ]*<([^<]+)>") quoted = regex.transform(matches, "#include[ ]*\"([^\"]+)\"") res = regex.transform(matches, "[^ ]+[ ]+(BITMAP|CURSOR|FONT|ICON|MESSAGETABLE|RT_MANIFEST)" +\ "[ ]+(([^ \"]+)|\"([^\"]+)\")", [3, 4]) # Icons and other includes may referenced as # # IDR_MAINFRAME ICON "res\\icon.ico" # # so we have to replace double backslashes to single ones. res = [ re.sub(r'\\\\', '/', match) for match in res if match is not None ] # CONSIDER: the new scoping rule seem to defeat "on target" variables. g = bjam.call('get-target-variable', target, 'HDRGRIST')[0] b = os.path.normpath(os.path.dirname(binding)) # Attach binding of including file to included targets. # When target is directly created from virtual target # this extra information is unnecessary. But in other # cases, it allows to distinguish between two headers of the # same name included from different places. # We don't need this extra information for angle includes, # since they should not depend on including file (we can't # get literal "." in include path). g2 = g + "#" + b g = "<" + g + ">" g2 = "<" + g2 + ">" angle = [g + x for x in angle] quoted = [g2 + x for x in quoted] res = [g2 + x for x in res] all = angle + quoted bjam.call('mark-included', target, all) engine = get_manager().engine() engine.add_dependency(target, res) bjam.call('NOCARE', all + res) engine.set_target_variable(angle, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable(quoted, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes]) engine.set_target_variable(res, 'SEARCH', [b + utility.get_value(inc) for inc in self.includes]) # Just propagate current scanner to includes, in a hope # that includes do not change scanners. get_manager().scanners().propagate(self, angle + quoted)
def actualize_location (self, target): assert isinstance(target, basestring) engine = self.project_.manager_.engine () if self.action_: # This is a derived file. path = self.path () engine.set_target_variable (target, 'LOCATE', path) # Make sure the path exists. engine.add_dependency (target, path) common.mkdir(engine, path) # It's possible that the target name includes a directory # too, for example when installing headers. Create that # directory. d = os.path.dirname(get_value(target)) if d: d = os.path.join(path, d) engine.add_dependency(target, d) common.mkdir(engine, d) # For real file target, we create a fake target that # depends on the real target. This allows to run # # bjam hello.o # # without trying to guess the name of the real target. # Note the that target has no directory name, and a special # grist <e>. # # First, that means that "bjam hello.o" will build all # known hello.o targets. # Second, the <e> grist makes sure this target won't be confused # with other targets, for example, if we have subdir 'test' # with target 'test' in it that includes 'test.o' file, # then the target for directory will be just 'test' the target # for test.o will be <ptest/bin/gcc/debug>test.o and the target # we create below will be <e>test.o engine.add_dependency("<e>%s" % get_value(target), target) # Allow bjam <path-to-file>/<file> to work. This won't catch all # possible ways to refer to the path (relative/absolute, extra ".", # various "..", but should help in obvious cases. engine.add_dependency("<e>%s" % (os.path.join(path, get_value(target))), target) else: # This is a source file. engine.set_target_variable (target, 'SEARCH', self.project_.get ('source-location'))
def process(self, target, matches, binding): included_angle = regex.transform(matches, self.re_include_angle) included_quoted = regex.transform(matches, self.re_include_quoted) imported = regex.transform(matches, self.re_import, [1, 3]) imported_tlbs = regex.transform(matches, self.re_importlib, [1, 3]) # CONSIDER: the new scoping rule seem to defeat "on target" variables. g = bjam.call('get-target-variable', target, 'HDRGRIST')[0] b = os.path.normpath(os.path.dirname(binding)) # Attach binding of including file to included targets. # When target is directly created from virtual target # this extra information is unnecessary. But in other # cases, it allows to distinguish between two headers of the # same name included from different places. g2 = g + "#" + b g = "<" + g + ">" g2 = "<" + g2 + ">" included_angle = [g + x for x in included_angle] included_quoted = [g + x for x in included_quoted] imported = [g + x for x in imported] imported_tlbs = [g + x for x in imported_tlbs] all = included_angle + included_quoted + imported bjam.call('INCLUDES', [target], all) bjam.call('DEPENDS', [target], imported_tlbs) bjam.call('NOCARE', all + imported_tlbs) engine.set_target_variable( included_angle, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable( included_quoted, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable( imported, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable( imported_tlbs, 'SEARCH', [utility.get_value(inc) for inc in self.includes]) get_manager().scanners().propagate( type.get_scanner('CPP', PropertySet(self.includes)), included_angle + included_quoted) get_manager().scanners().propagate(self, imported)
def process(self, target, matches, binding): included_angle = regex.transform(matches, self.re_include_angle) included_quoted = regex.transform(matches, self.re_include_quoted) imported = regex.transform(matches, self.re_import, [1, 3]) imported_tlbs = regex.transform(matches, self.re_importlib, [1, 3]) # CONSIDER: the new scoping rule seem to defeat "on target" variables. g = bjam.call("get-target-variable", target, "HDRGRIST")[0] b = os.path.normpath(os.path.dirname(binding)) # Attach binding of including file to included targets. # When target is directly created from virtual target # this extra information is unnecessary. But in other # cases, it allows to distinguish between two headers of the # same name included from different places. g2 = g + "#" + b g = "<" + g + ">" g2 = "<" + g2 + ">" included_angle = [g + x for x in included_angle] included_quoted = [g + x for x in included_quoted] imported = [g + x for x in imported] imported_tlbs = [g + x for x in imported_tlbs] all = included_angle + included_quoted + imported bjam.call("INCLUDES", [target], all) bjam.call("DEPENDS", [target], imported_tlbs) bjam.call("NOCARE", all + imported_tlbs) engine.set_target_variable(included_angle, "SEARCH", [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable(included_quoted, "SEARCH", [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable(imported, "SEARCH", [utility.get_value(inc) for inc in self.includes]) engine.set_target_variable(imported_tlbs, "SEARCH", [utility.get_value(inc) for inc in self.includes]) get_manager().scanners().propagate( type.get_scanner("CPP", PropertySet(self.includes)), included_angle + included_quoted ) get_manager().scanners().propagate(self, imported)