diff options
author | Simon Glass <sjg@chromium.org> | 2021-02-03 16:00:52 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-03-22 09:23:27 +0300 |
commit | 36b2220cbd62c7829b8e845777318f323a963e47 (patch) | |
tree | 8054740ca697d6e38cf84dc3af9c6761a25eed41 /tools/dtoc | |
parent | a32eb7dca7c3ea8d23e1bc0ce927ad2a00d8bf45 (diff) | |
download | u-boot-36b2220cbd62c7829b8e845777318f323a963e47.tar.xz |
dtoc: Ignore unwanted files when scanning for drivers
We should ignore anything in the .git directory or any of the
build-sandbox, etc. directories created by 'make check'. These can confuse
dtoc. Update the code to ignore these.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc')
-rw-r--r-- | tools/dtoc/src_scan.py | 5 | ||||
-rw-r--r-- | tools/dtoc/test_src_scan.py | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py index 095fb6d476..761164a9c9 100644 --- a/tools/dtoc/src_scan.py +++ b/tools/dtoc/src_scan.py @@ -345,6 +345,11 @@ class Scanner: This procedure will populate self._drivers and self._driver_aliases """ for (dirpath, _, filenames) in os.walk(self._basedir): + rel_path = dirpath[len(self._basedir):] + if rel_path.startswith('/'): + rel_path = rel_path[1:] + if rel_path.startswith('build') or rel_path.startswith('.git'): + continue for fname in filenames: if not fname.endswith('.c'): continue diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py index 25e4866f20..ada49fb704 100644 --- a/tools/dtoc/test_src_scan.py +++ b/tools/dtoc/test_src_scan.py @@ -117,7 +117,9 @@ class TestSrcScan(unittest.TestCase): fname_list = [] add_file('fname.c') + add_file('.git/ignoreme.c') add_file('dir/fname2.c') + add_file('build-sandbox/ignoreme2.c') # Mock out scan_driver and check that it is called with the # expected files @@ -127,7 +129,8 @@ class TestSrcScan(unittest.TestCase): self.assertEqual(2, len(mocked.mock_calls)) self.assertEqual(mock.call(fname_list[0]), mocked.mock_calls[0]) - self.assertEqual(mock.call(fname_list[1]), + # .git file should be ignored + self.assertEqual(mock.call(fname_list[2]), mocked.mock_calls[1]) finally: shutil.rmtree(indir) |