Commit 6cb98162 authored by Yasin Ustuner's avatar Yasin Ustuner Committed by David Leach
Browse files

scripts: ci: check_compliance.py: Add out-of-tree dts/bindings



This commit includes out-of-tree dts/bindings to
temporary Kconfig.dts for compliance checks.

Signed-off-by: default avatarYasin Ustuner <yasin.ustuner@analog.com>
parent 673009f6
Loading
Loading
Loading
Loading
+23 −7
Original line number Diff line number Diff line
@@ -286,7 +286,7 @@ class KconfigCheck(ComplianceTest):
        if full:
            self.check_no_undef_outside_kconfig(kconf)

    def get_modules(self, modules_file):
    def get_modules(self, modules_file, settings_file):
        """
        Get a list of modules and put them in a file that is parsed by
        Kconfig
@@ -304,7 +304,7 @@ class KconfigCheck(ComplianceTest):
        zephyr_module_path = os.path.join(ZEPHYR_BASE, "scripts",
                                          "zephyr_module.py")
        cmd = [sys.executable, zephyr_module_path,
               '--kconfig-out', modules_file]
               '--kconfig-out', modules_file, '--settings-out', settings_file]
        try:
            subprocess.run(cmd, check=True, stdout=subprocess.PIPE,
                           stderr=subprocess.STDOUT)
@@ -326,7 +326,7 @@ class KconfigCheck(ComplianceTest):
                ))
            fp_module_file.write(content)

    def get_kconfig_dts(self, kconfig_dts_file):
    def get_kconfig_dts(self, kconfig_dts_file, settings_file):
        """
        Generate the Kconfig.dts using dts/bindings as the source.

@@ -337,9 +337,23 @@ class KconfigCheck(ComplianceTest):
        # not a module nor a pip-installed Python utility
        zephyr_drv_kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "dts",
                                               "gen_driver_kconfig_dts.py")
        binding_path = os.path.join(ZEPHYR_BASE, "dts", "bindings")
        binding_paths = []
        binding_paths.append(os.path.join(ZEPHYR_BASE, "dts", "bindings"))

        if os.path.exists(settings_file):
            with open(settings_file, 'r') as fp_setting_file:
                content = fp_setting_file.read()

            lines = content.strip().split('\n')
            for line in lines:
                if line.startswith('"DTS_ROOT":'):
                    _, dts_root_path = line.split(":")
                    binding_paths.append(os.path.join(dts_root_path.strip('"'), "dts", "bindings"))

        cmd = [sys.executable, zephyr_drv_kconfig_path,
               '--kconfig-out', kconfig_dts_file, '--bindings-dirs', binding_path]
               '--kconfig-out', kconfig_dts_file, '--bindings-dirs']
        for binding_path in binding_paths:
            cmd.append(binding_path)
        try:
            subprocess.run(cmd, check=True, stdout=subprocess.PIPE,
                           stderr=subprocess.STDOUT)
@@ -383,9 +397,11 @@ class KconfigCheck(ComplianceTest):
        os.environ["GENERATED_DTS_BOARD_CONF"] = "dummy"

        # For multi repo support
        self.get_modules(os.path.join(kconfiglib_dir, "Kconfig.modules"))
        self.get_modules(os.path.join(kconfiglib_dir, "Kconfig.modules"),
                         os.path.join(kconfiglib_dir, "settings_file.txt"))
        # For Kconfig.dts support
        self.get_kconfig_dts(os.path.join(kconfiglib_dir, "Kconfig.dts"))
        self.get_kconfig_dts(os.path.join(kconfiglib_dir, "Kconfig.dts"),
                             os.path.join(kconfiglib_dir, "settings_file.txt"))

        # Tells Kconfiglib to generate warnings for all references to undefined
        # symbols within Kconfig files