Lines Matching +full:kconfig +full:- +full:ext
5 # SPDX-License-Identifier: Apache-2.0
57 f"{cp.stdout.decode('utf-8')}\n"
59 f"{cp.stderr.decode('utf-8')}\n")
61 return cp.stdout.decode("utf-8").rstrip()
70 return git('rev-list',
71 f'--max-count={-1 if "." in refspec else 1}', refspec).split()
74 filter_arg = (f'--diff-filter={filter}',) if filter else ()
75 paths_arg = ('--', *paths) if paths else ()
76 out = git('diff', '--name-only', *filter_arg, COMMIT_RANGE, *paths_arg)
128 - The magic string "<zephyr-base>" can be used to refer to the
131 - The magic string "<git-top>" refers to the top-level repository
132 directory. This avoids running 'git' to find the top-level directory
207 …doc = "See https://docs.zephyrproject.org/latest/contribute/guidelines.html#coding-style for more …
208 path_hint = "<git-top>"
215 diff = subprocess.Popen(('git', 'diff', '--no-ext-diff', COMMIT_RANGE),
219 subprocess.run((checkpatch, '--mailback', '--no-tree', '-'),
227 output = ex.output.decode("utf-8")
254 path_hint = "<zephyr-base>"
270 with open(os.path.join(ZEPHYR_BASE, "dts", "bindings", "vendor-prefixes.txt")) as fp:
279 self.error(f"Invalid line in vendor-prefixes.txt:\"{line}\".")
289 Check if clang-format reports any issues
292 …doc = "See https://docs.zephyrproject.org/latest/contribute/guidelines.html#clang-format for more …
293 path_hint = "<git-top>"
296 exe = f"clang-format-diff.{'exe' if platform.system() == 'Windows' else 'py'}"
302 diff = subprocess.Popen(('git', 'diff', '-U0', '--no-color', COMMIT_RANGE, '--', file),
306 subprocess.run((exe, '-p1'),
314 patchset = unidiff.PatchSet.from_string(ex.output, encoding="utf-8")
318 before = next(i for i,v in enumerate(hunk) if str(v).startswith(('-', '+')))
319 … after = next(i for i,v in enumerate(reversed(hunk)) if str(v).startswith(('-', '+')))
320 msg = "".join([str(l) for l in hunk[before:-after or None]])
324 "You may want to run clang-format on this change",
325 file, line=hunk.source_start + hunk.source_length - after,
335 path_hint = "<zephyr-base>"
367 Checks is we are introducing any new warnings/errors with Kconfig,
368 for example using undefined Kconfig variables.
370 name = "Kconfig"
371 doc = "See https://docs.zephyrproject.org/latest/build/kconfig/tips.html for more details."
372 path_hint = "<zephyr-base>"
374 def run(self, full=True, no_modules=False, filename="Kconfig", hwm=None):
391 Kconfig
393 This is needed to complete Kconfig sanity tests.
402 # not a module nor a pip-installed Python utility
406 '--kconfig-out', modules_file, '--settings-out', settings_file]
411 self.error(ex.output.decode("utf-8"))
415 os.path.exists(os.path.join(modules_dir, name, 'Kconfig'))]
423 re.sub('[^a-zA-Z0-9]', '_', module).upper(),
424 modules_dir + '/' + module + '/Kconfig'
434 # not a module nor a pip-installed Python utility
451 Generate the Kconfig.dts using dts/bindings as the source.
453 This is needed to complete Kconfig compliance tests.
457 # not a module nor a pip-installed Python utility
468 '--kconfig-out', kconfig_dts_file, '--bindings-dirs']
475 self.error(ex.output.decode("utf-8"))
479 Generate a symbol define Kconfig file.
480 This function creates a file with all Kconfig symbol definitions from
484 This is needed to complete Kconfig compliance tests.
488 # pylint: disable=undefined-variable
491 kconf_v1 = kconfiglib.Kconfig(filename=kconfig_v1_file, warn=False)
506 Kconfig
508 This is needed to complete Kconfig sanity tests.
511 kconfig_file = os.path.join(kconfig_dir, 'boards', 'Kconfig')
512 kconfig_boards_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.boards')
513 kconfig_defconfig_file = os.path.join(kconfig_dir, 'boards', 'Kconfig.defconfig')
527 fp.write('osource "' + (board_dir / 'Kconfig.defconfig').as_posix() + '"\n')
531 board_str = 'BOARD_' + re.sub(r"[^a-zA-Z0-9_]", "_", board.name).upper()
536 re.sub(r"[^a-zA-Z0-9_]", "_", qualifier)).upper()
541 'source "' + (board_dir / ('Kconfig.' + board.name)).as_posix() + '"\n'
546 'osource "' + (Path(kconfig_dir) / 'boards' / 'Kconfig.syms.v1').as_posix() + '"\n'
550 fp.write('osource "' + (board_dir / 'Kconfig').as_posix() + '"\n')
552 kconfig_defconfig_file = os.path.join(kconfig_dir, 'soc', 'Kconfig.defconfig')
553 kconfig_soc_file = os.path.join(kconfig_dir, 'soc', 'Kconfig.soc')
554 kconfig_file = os.path.join(kconfig_dir, 'soc', 'Kconfig')
562 fp.write('osource "' + (Path(folder) / 'Kconfig.defconfig').as_posix() + '"\n')
566 fp.write('source "' + (Path(folder) / 'Kconfig.soc').as_posix() + '"\n')
570 fp.write('source "' + (Path(folder) / 'Kconfig').as_posix() + '"\n')
572 kconfig_file = os.path.join(kconfig_dir, 'arch', 'Kconfig')
579 fp.write('source "' + (Path(arch['path']) / 'Kconfig').as_posix() + '"\n')
581 def parse_kconfig(self, filename="Kconfig", hwm=None):
583 Returns a kconfiglib.Kconfig object for the Kconfig files. We reuse
588 kconfig_path = os.path.join(ZEPHYR_BASE, "scripts", "kconfig")
600 # Look up Kconfig files relative to ZEPHYR_BASE
603 # Parse the entire Kconfig tree, to make sure we see all symbols
617 self.get_modules(os.path.join(kconfiglib_dir, "Kconfig.modules"),
619 # For Kconfig.dts support
620 self.get_kconfig_dts(os.path.join(kconfiglib_dir, "Kconfig.dts"),
633 # symbols within Kconfig files
641 return kconfiglib.Kconfig(filename=filename)
650 # Returns a set() with the names of the Kconfig symbols generated with
651 # logging template in samples/tests folders. The Kconfig symbols doesn't
666 # Warning: Needs to work with both --perl-regexp and the 're' module.
667 regex = r"^\s*(?:module\s*=\s*)([A-Z0-9_]+)\s*(?:#|$)"
670 grep_stdout = git("grep", "-I", "-h", "--perl-regexp", regex, "--",
683 # Returns a set() with the names of all defined Kconfig symbols (with no
685 # their own Kconfig trees. For those, just grep for 'config FOO' to find
690 # Warning: Needs to work with both --perl-regexp and the 're' module.
691 # (?:...) is a non-capturing group.
692 regex = r"^\s*(?:menu)?config\s*([A-Z0-9_]+)\s*(?:#|$)"
695 grep_stdout = git("grep", "-I", "-h", "--perl-regexp", regex, "--",
698 # Generate combined list of configs and choices from the main Kconfig tree.
701 # Symbols from the main Kconfig tree + grepped definitions from samples
710 Checks that there aren't too many items in the top-level menu (which
719 # shown in the menuconfig (outside show-all mode).
727 prompts) in the top-level Kconfig menu, found {n_top_items} items. If you're
736 # pylint: disable=undefined-variable
741 Kconfig node '{name}' found with prompt or help in {node.filename}.
750 # skip Kconfig nodes not in-tree (will present an absolute path)
755 # pylint: disable=undefined-variable
767 check Kconfig guidelines.
773 # children in the Kconfig files
778 # pylint: disable=undefined-variable
792 https://docs.zephyrproject.org/latest/build/kconfig/tips.html#menuconfig-symbols.
799 Checks that there are no references to undefined Kconfig symbols within
800 the Kconfig files
806 self.failure(f"Undefined Kconfig symbols:\n\n {undef_ref_warnings}")
817 # pylint: disable=undefined-variable
838 Checks that there are no references to undefined Kconfig symbols
839 outside Kconfig files (any CONFIG_FOO where no FOO symbol exists)
848 # 'git grep --only-matching' would get rid of the surrounding context
855 # - ##, for token pasting (CONFIG_FOO_##X)
857 # - $, e.g. for CMake variable expansion (CONFIG_FOO_${VAR})
859 # - @, e.g. for CMakes's configure_file() (CONFIG_FOO_@VAR@)
861 # - {, e.g. for Python scripts ("CONFIG_FOO_{}_BAR".format(...)")
863 # - *, meant for comments like '#endif /* CONFIG_FOO_* */
870 # Warning: Needs to work with both --perl-regexp and the 're' module
871 regex = r"\bCONFIG_[A-Z0-9_]+\b(?!\s*##|[$@{(.*])"
875 grep_stdout = git("grep", "--line-number", "-I", "--null",
876 "--perl-regexp", regex, "--", ":!/doc/releases",
890 not (sym_name.endswith("_MODULE") and sym_name[:-7] in defined_syms):
897 # String that describes all referenced but undefined Kconfig symbols,
907 Found references to undefined Kconfig symbols. If any of these are false
922 # zephyr-keep-sorted-start re(^\s+")
930 # toolchain Kconfig which is sourced based on
945 "BOOT_SERIAL_BOOT_MODE", # Used in (sysbuild-based) test/
947 "BOOT_SERIAL_CDC_ACM", # Used in (sysbuild-based) test
948 "BOOT_SERIAL_ENTRANCE_GPIO", # Used in (sysbuild-based) test
950 "BOOT_SHARE_BACKEND_RETENTION", # Used in Kconfig text
951 "BOOT_SHARE_DATA", # Used in Kconfig text
952 "BOOT_SHARE_DATA_BOOTINFO", # Used in (sysbuild-based) test
962 "BOOT_VALIDATE_SLOT0", # Used in (sysbuild-based) test
963 "BOOT_WATCHDOG_FEED", # Used in (sysbuild-based) test
969 "CMD_CACHE", # Defined in U-Boot, mentioned in docs
973 "DEEP_SLEEP", # #defined by RV32M1 in ext/
988 "LLVM_USE_LD", # Both LLVM_USE_* are in cmake/toolchain/llvm/Kconfig
995 "MCUBOOT_ACTION_HOOKS", # Used in (sysbuild-based) test
996 "MCUBOOT_CLEANUP_ARM_CORE", # Used in (sysbuild-based) test
1002 "MCUBOOT_SERIAL", # Used in (sysbuild-based) test/
1010 "NORMAL_SLEEP", # #defined by RV32M1 in ext/
1015 "PSA_H", # This is used in config-psa.h as guard for the header file
1030 "STACK_SIZE", # Used as an example in the Kconfig docs
1034 # Kconfig which is sourced based on Zephyr
1044 # zephyr-keep-sorted-stop
1050 Checks if we are introducing any new warnings/errors with Kconfig,
1051 for example using undefined Kconfig variables.
1052 This runs the basic Kconfig test, which is checking only for undefined
1053 references inside the Kconfig tree.
1056 doc = "See https://docs.zephyrproject.org/latest/build/kconfig/tips.html for more details."
1057 path_hint = "<zephyr-base>"
1064 Checks if we are introducing any new warnings/errors with Kconfig when no
1069 doc = "See https://docs.zephyrproject.org/latest/build/kconfig/tips.html for more details."
1070 path_hint = "<zephyr-base>"
1077 This runs the Kconfig test for board and SoC v2 scheme.
1080 This ensures the board and SoC trees are fully self-contained and reusable.
1083 doc = "See https://docs.zephyrproject.org/latest/guides/kconfig/index.html for more details."
1086 # Use dedicated Kconfig board / soc v2 scheme file.
1088 kconfig_file = os.path.join(os.path.dirname(__file__), "Kconfig.board.v2")
1098 …doc = "See https://docs.zephyrproject.org/latest/contribute/guidelines.html#coding-style for more …
1099 path_hint = "<git-top>"
1104 if "Kconfig" in fname:
1114 "Kconfig" in fname or \
1121 # Checks for a spammy copy-pasted header format
1123 with open(os.path.join(GIT_TOP, fname), encoding="utf-8") as f:
1126 # 'Kconfig - yada yada' has a copy-pasted redundant filename at the
1127 # top. This probably means all of the header was copy-pasted.
1128 if re.match(r"\s*#\s*(K|k)config[\w.-]*\s*-", contents):
1131 https://docs.zephyrproject.org/latest/build/kconfig/tips.html#header-comments-and-other-nits):
1136 # SPDX-License-Identifier: <License>
1138 (Kconfig definitions)
1140 Skip the "Kconfig - " part of the first line, since it's clear that the comment
1141 is about Kconfig from context. The "# Kconfig - " is what triggers this
1146 # Checks for 'source "$(ZEPHYR_BASE)/Kconfig[.zephyr]"', which can be
1147 # be simplified to 'source "Kconfig[.zephyr]"'
1149 with open(os.path.join(GIT_TOP, fname), encoding="utf-8") as f:
1152 r'^\s*(?:o|r|or)?source\s*"\$\(?ZEPHYR_BASE\)?/(Kconfig(?:\.zephyr)?)"',
1164 with open(os.path.join(GIT_TOP, fname), encoding="utf-8") as f:
1173 with open(os.path.join(GIT_TOP, fname), encoding="utf-8") as f:
1189 Checks for conflict markers or whitespace errors with git diff --check
1193 path_hint = "<git-top>"
1198 # Reason: `--check` is mutually exclusive with `--name-only` and `-s`
1202 # Ignore non-zero return status code
1203 # Reason: `git diff --check` sets the return code to the number of offending lines
1204 diff = git("diff", f"{shaidx}^!", "--check", ignore_non_zero=True)
1220 …doc = "See https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-guidelines for …
1221 path_hint = "<git-top>"
1227 subprocess.run('gitlint --commits ' + COMMIT_RANGE,
1234 self.failure(ex.output.decode("utf-8"))
1244 path_hint = "<git-top>"
1272 pylintcmd = ["pylint", "--output-format=json2", "--rcfile=" + pylintrc,
1273 "--load-plugins=argparse-checker"] + py_files
1283 output = ex.output.decode("utf-8")
1304 # Uses the python-magic library, so that we can detect Python
1305 # files that don't end in .py as well. python-magic is a frontend
1310 mime=True) == "text/x-python")]
1315 Checks if Emails of author and signed-off messages are consistent.
1318 …doc = "See https://docs.zephyrproject.org/latest/contribute/guidelines.html#commit-guidelines for …
1319 # git rev-list and git log don't depend on the current (sub)directory
1321 path_hint = "<git-top>"
1325 commit = git("log", "--decorate=short", "-n 1", shaidx)
1338 match = re.search(r"signed-off-by:\s(.*)", line, re.IGNORECASE)
1343 f"the signed-off-by entries."
1371 path_hint = "<git-top>"
1378 for stat in git("diff", "--numstat", "--diff-filter=A",
1381 if added == "-" and deleted == "-":
1394 path_hint = "<git-top>"
1424 path_hint = "<git-top>"
1444 path_hint = "<git-top>"
1479 path_hint = "<git-top>"
1492 yaml_config.rules["line-length"] = False
1493 yaml_config.rules["truthy"]["allowed-values"].extend(['on', 'off'])
1495 yaml_config.rules["truthy"]["allowed-values"].extend(['yes', 'no'])
1509 doc = "Check Sphinx/reStructuredText files with sphinx-lint."
1510 path_hint = "<git-top>"
1512 # Checkers added/removed to sphinx-lint's default set
1513 DISABLE_CHECKERS = ["horizontal-tab", "missing-space-before-default-role"]
1514 ENABLE_CHECKERS = ["default-role"]
1522 # sphinx-lint does not expose a public API so interaction is done via CLI
1524 … f"sphinx-lint -d {','.join(self.DISABLE_CHECKERS)} -e {','.join(self.ENABLE_CHECKERS)} {file}",
1533 for line in ex.output.decode("utf-8").splitlines():
1552 path_hint = "<git-top>"
1554 MARKER = "zephyr-keep-sorted"
1588 return -1
1599 start_marker = f"{self.MARKER}-start"
1600 stop_marker = f"{self.MARKER}-stop"
1627 desc = f"sorted block has out-of-order line at {start_line + idx}"
1648 path_hint = "<git-top>"
1657 f"ruff check --force-exclude --output-format=json {file}",
1665 output = ex.output.decode("utf-8")
1680 f"ruff format --force-exclude --diff {file}",
1692 Check that any text file is encoded in ascii or utf-8.
1696 path_hint = "<git-top>"
1698 ALLOWED_CHARSETS = ["us-ascii", "utf-8"]
1711 if mime_type.rsplit('=')[-1] not in self.ALLOWED_CHARSETS:
1724 console.setFormatter(logging.Formatter('%(levelname)-8s: %(message)s'))
1748 …https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#about-work…
1761 if hint == "<zephyr-base>":
1763 elif hint == "<git-top>":
1774 parser.add_argument('-c', '--commits', default=default_range,
1777 parser.add_argument('-o', '--output', default="compliance.xml",
1780 parser.add_argument('-n', '--no-case-output', action="store_true",
1782 parser.add_argument('-l', '--list', action="store_true",
1784 parser.add_argument("-v", "--loglevel", choices=['DEBUG', 'INFO', 'WARNING',
1787 parser.add_argument('-m', '--module', action="append", default=[],
1790 parser.add_argument('-e', '--exclude-module', action="append", default=[],
1793 parser.add_argument('-j', '--previous-run', default=None,
1794 help='''Pre-load JUnit results in XML format
1796 parser.add_argument('--annotate', action="store_true",
1797 help="Print GitHub Actions-compatible annotations.")
1815 # The absolute path of the top-level git directory. Initialize it here so
1818 GIT_TOP = git("rev-parse", "--show-toplevel")
1820 # The commit range passed in --commit, e.g. "HEAD~3"
1837 # (the script is currently run multiple times by the ci-pipelines
1857 # been --tests and --exclude-tests or the like, but it's awkward to
1928 # pylint: disable=unused-import
1949 # Formats the command-line arguments in the iterable 'cmd' into a string,