diff --git a/tools/check_kconfigs.py b/tools/check_kconfigs.py index bdc3953e4..93754b705 100755 --- a/tools/check_kconfigs.py +++ b/tools/check_kconfigs.py @@ -94,11 +94,12 @@ class SourceChecker(BaseChecker): raise InputError(self.path_in_idf, line_number, '"source" has to been followed by space', line.replace('source', 'source ')) path = m.group(2) + filename = os.path.basename(path) if path in ['$COMPONENT_KCONFIGS_PROJBUILD', '$COMPONENT_KCONFIGS']: pass - elif not path.endswith('/Kconfig.in') and path != 'Kconfig.in': - raise InputError(self.path_in_idf, line_number, "only Kconfig.in can be sourced", - line.replace(path, os.path.join(os.path.dirname(path), 'Kconfig.in'))) + elif not filename.startswith('Kconfig.'): + raise InputError(self.path_in_idf, line_number, "only filenames starting with Kconfig.* can be sourced", + line.replace(path, os.path.join(os.path.dirname(path), 'Kconfig.' + filename))) class LineRuleChecker(BaseChecker): diff --git a/tools/test_check_kconfigs.py b/tools/test_check_kconfigs.py index a38f16ab9..b8541e4a6 100755 --- a/tools/test_check_kconfigs.py +++ b/tools/test_check_kconfigs.py @@ -80,10 +80,10 @@ class TestSourceChecker(unittest.TestCase, ApplyLine): pass def test_source_file_name(self): - self.expect_error('source "Kconfig.test"', expect='source "Kconfig.in"') - self.expect_error('source "/tmp/Kconfig.test"', expect='source "/tmp/Kconfig.in"') - self.expect_error('source "Kconfig"', expect='source "Kconfig.in"') + self.expect_error('source "notKconfig.test"', expect='source "Kconfig.notKconfig.test"') + self.expect_error('source "Kconfig"', expect='source "Kconfig.Kconfig"') self.expt_success('source "Kconfig.in"') + self.expt_success('source "/tmp/Kconfig.test"') self.expt_success('source "/tmp/Kconfig.in"') self.expect_error('source"Kconfig.in"', expect='source "Kconfig.in"') self.expt_success('source "/tmp/Kconfig.in" # comment')