- 
                Notifications
    
You must be signed in to change notification settings  - Fork 14
 
Description
This is just something I spotted when looking into something else. Consider this an idea for improvement.
We have this code in kconfiglib.py, def _enter_file(self, filename) 
Line 2147 in e8e83f0
| if filename.startswith(self._srctree_prefix): | 
# Path relative to $srctree, stored in e.g. self.filename (which makes
# it indirectly show up in MenuNode.filename). Equals 'filename' for
# absolute paths passed to 'source'.
if filename.startswith(self._srctree_prefix):
    # Relative path (or a redundant absolute path to within $srctree,
    # but it's probably fine to reduce those too)
    rel_filename = filename[len(self._srctree_prefix):]
else:
    # Absolute path
    rel_filename = filename
self.kconfig_filenames.append(rel_filename)On Windows I see that:
self._srctree_prefix = C:\folder1\folder2\zephyr\
While at the same time
filename = C:/folder1/folder2/nrf\samples/Kconfig
In this case what we want is for this if statement to be True: filename.startswith(self._srctree_prefix), but due to the path separators not being consistent it doesn't. And the full absolute path is loaded into memory in variables like self.kconfig_filenames.append(rel_filename)
Source of inconsistency
I investigated this a bit and found that the source of the inconsistency is from pattern = self._expect_str_and_eol() 
Line 2960 in e8e83f0
| pattern = self._expect_str_and_eol() | 
/ is always used even though \ would be expected for a filepath in Windows.
I do not understand the Tokenizer code enough to find where the / was coming from. At least at the time of writing this.