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