720 |
720 |
721 |
721 |
722 def Apply(self, oldValue): |
722 def Apply(self, oldValue): |
723 try: |
723 try: |
724 value = os.environ[self.name] |
724 value = os.environ[self.name] |
725 |
725 |
726 # if this value is a "path" or a "tool" then we need to make sure |
726 if value: |
727 # it is a proper absolute path in our preferred format. |
727 # if this value is a "path" or a "tool" then we need to make sure |
728 if value and (self.type == "path" or self.type == "tool"): |
728 # it is a proper absolute path in our preferred format. |
729 try: |
729 if self.type == "path" or self.type == "tool": |
730 path = generic_path.Path(value) |
730 try: |
731 value = str(path.Absolute()) |
731 path = generic_path.Path(value) |
732 except ValueError,e: |
732 value = str(path.Absolute()) |
733 raise BadToolValue("the environment variable %s is incorrect: %s" % (self.name, str(e))) |
733 except ValueError,e: |
|
734 raise BadToolValue("the environment variable %s is incorrect: %s" % (self.name, str(e))) |
|
735 # if this value ends in an un-escaped backslash, then it will be treated as a line continuation character |
|
736 # in makefile parsing - un-escaped backslashes at the end of values are therefore escaped |
|
737 elif value.endswith('\\'): |
|
738 # an odd number of backslashes means there's one to escape |
|
739 count = len(value) - len(value.rstrip('\\')) |
|
740 if count % 2: |
|
741 value += '\\' |
734 except KeyError: |
742 except KeyError: |
735 if self.default != None: |
743 if self.default != None: |
736 value = self.default |
744 value = self.default |
737 else: |
745 else: |
738 raise BadToolValue("%s is not set in the environment and has no default" % self.name) |
746 raise BadToolValue("%s is not set in the environment and has no default" % self.name) |