mirror of https://github.com/ARMmbed/mbed-os.git
Correct path handling after calls to `win_to_unix`
parent
b170e1c44d
commit
f9c6f21f2e
|
@ -137,8 +137,8 @@ class Resources(object):
|
||||||
self._label_paths = []
|
self._label_paths = []
|
||||||
self._labels = {"TARGET": [], "TOOLCHAIN": [], "FEATURE": []}
|
self._labels = {"TARGET": [], "TOOLCHAIN": [], "FEATURE": []}
|
||||||
|
|
||||||
# Should we convert all paths to unix-style?
|
# Path seperator style (defaults to OS-specific seperator)
|
||||||
self._win_to_unix = False
|
self._sep = sep
|
||||||
|
|
||||||
# Ignore patterns from .mbedignore files and add_ignore_patters
|
# Ignore patterns from .mbedignore files and add_ignore_patters
|
||||||
self._ignore_patterns = []
|
self._ignore_patterns = []
|
||||||
|
@ -181,11 +181,12 @@ class Resources(object):
|
||||||
return count
|
return count
|
||||||
|
|
||||||
def win_to_unix(self):
|
def win_to_unix(self):
|
||||||
self._win_to_unix = True
|
self._sep = "/"
|
||||||
for file_type in self.ALL_FILE_TYPES:
|
if self._sep != sep:
|
||||||
v = [f._replace(name=f.name.replace('\\', '/')) for
|
for file_type in self.ALL_FILE_TYPES:
|
||||||
f in self.get_file_refs(file_type)]
|
v = [f._replace(name=f.name.replace(sep, self._sep)) for
|
||||||
self._file_refs[file_type] = v
|
f in self.get_file_refs(file_type)]
|
||||||
|
self._file_refs[file_type] = v
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
s = []
|
s = []
|
||||||
|
@ -262,8 +263,8 @@ class Resources(object):
|
||||||
dirname[len(label_type) + 1:] not in self._labels[label_type])
|
dirname[len(label_type) + 1:] not in self._labels[label_type])
|
||||||
|
|
||||||
def add_file_ref(self, file_type, file_name, file_path):
|
def add_file_ref(self, file_type, file_name, file_path):
|
||||||
if self._win_to_unix:
|
if sep != self._sep:
|
||||||
ref = FileRef(file_name.replace("\\", "/"), file_path)
|
ref = FileRef(file_name.replace(sep, self._sep), file_path)
|
||||||
else:
|
else:
|
||||||
ref = FileRef(file_name, file_path)
|
ref = FileRef(file_name, file_path)
|
||||||
self._file_refs[file_type].add(ref)
|
self._file_refs[file_type].add(ref)
|
||||||
|
@ -272,12 +273,11 @@ class Resources(object):
|
||||||
"""Return a list of FileRef for every file of the given type"""
|
"""Return a list of FileRef for every file of the given type"""
|
||||||
return list(self._file_refs[file_type])
|
return list(self._file_refs[file_type])
|
||||||
|
|
||||||
@staticmethod
|
def _all_parents(self, files):
|
||||||
def _all_parents(files):
|
|
||||||
for name in files:
|
for name in files:
|
||||||
components = name.split(sep)
|
components = name.split(self._sep)
|
||||||
for n in range(1, len(components)):
|
for n in range(1, len(components)):
|
||||||
parent = join(*components[:n])
|
parent = self._sep.join(components[:n])
|
||||||
yield parent
|
yield parent
|
||||||
|
|
||||||
def _get_from_refs(self, file_type, key):
|
def _get_from_refs(self, file_type, key):
|
||||||
|
|
Loading…
Reference in New Issue