Skip to content

build: namespace generated headers with zephyr/#63973

Merged
henrikbrixandersen merged 4 commits intozephyrproject-rtos:mainfrom
ycsin:pr/zephyr_version_h
May 28, 2024
Merged

build: namespace generated headers with zephyr/#63973
henrikbrixandersen merged 4 commits intozephyrproject-rtos:mainfrom
ycsin:pr/zephyr_version_h

Conversation

@ycsin
Copy link
Member

@ycsin ycsin commented Oct 16, 2023

Namespaced the generated headers with zephyr/ to prevent potential conflict with other headers.

Introduced a Kconfig (CONFIG_LEGACY_GENERATED_INCLUDE_PATH) to support legacy generated header include paths in the mean time.

Documentation preview

Fixes #60377
Fixes #68035

Automation script:

#!/usr/bin/env python

from pathlib import Path
import re

EXTENSIONS = ("c", "h", "cpp", "rst", "md", "S", "ld", "py", "svg")

HEADERS = [
    "app_version",
    # "autoconf",
    "cmake_intdef",
    "core-isa-dM",
    "devicetree_generated",
    "driver-validation",
    "kobj-types-enum",
    "linker-kobject-prebuilt-data",
    "linker-kobject-prebuilt-priv-stacks",
    "linker-kobject-prebuilt-rodata",
    "mcuboot_version",
    "offsets",
    "otype-to-size",
    "otype-to-str",
    "strerror_table",
    "strsignal_table",
    "syscall_list",
    "version",
    "zsr",
]

HEADERS_H = [hdr + ".h" for hdr in HEADERS]

for p in Path(".").glob("zephyr/**/*"):
    if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
        continue

    # skip git & github folders
    if (str(p).startswith("zephyr/.git")):
        continue

    # skip release docs
    if (str(p).startswith("zephyr/doc/releases")):
        continue

    content = ""
    with open(p, 'r', newline='', errors="surrogateescape") as f:
        for line in f:
            # for lines in sources
            m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
            # for lines in docs
            n = re.match(r"^(.*)include/generated/(.*)\.h(.*)$", line)
            if (m and (m.group(2).startswith("syscalls/") or m.group(2) in HEADERS_H)):
                content += (m.group(1) + "#include <zephyr/" +
                            m.group(2) + ">" + m.group(3) + "\n")
            elif (n and n.group(2) in HEADERS):
                content += (n.group(1) + "include/generated/zephyr/" +
                            n.group(2) + ".h" + n.group(3) + "\n")
            else:
                content += line

    with open(p, "w", newline='') as f:
        f.write(content)

Requirements for Treewide Changes

  • The zephyr repository must apply the ‘treewide’ GitHub label to any issues or pull requests that are treewide changes
  • The person proposing a treewide change must create an RFC issue describing the change, its rationale and impact, etc. before any pull requests related to the change can be merged
  • The project’s Architecture Working Group (WG) must include the issue on the agenda and discuss whether the project will accept or reject the change before any pull requests related to the change can be merged (with escalation to the TSC if consensus is not reached at the WG)
  • The Architecture WG must specify the procedure for merging any PRs associated with each individual treewide change, including any required approvals for pull requests affecting specific subsystems or extra review time requirements
  • The person proposing a treewide change must email devel@lists.zephyrproject.org about the RFC if it is accepted by the Architecture WG before any pull requests related to the change can be merged

@ycsin ycsin requested a review from cfriedt October 16, 2023 09:42
nordicjm
nordicjm previously approved these changes Oct 16, 2023
@ycsin ycsin force-pushed the pr/zephyr_version_h branch 2 times, most recently from d11cd32 to 6f4c80f Compare October 17, 2023 05:15
@ycsin
Copy link
Member Author

ycsin commented Oct 17, 2023

this PR is getting more involved than I initially expected

EDIT:
And CI is complaining about some lines that are not modified in this PR:

Run if [[ ! -s "compliance.xml" ]]; then
Error: See https://www.pylint.org/ for more details

 C03[25](https://github.com/zephyrproject-rtos/zephyr/actions/runs/6542835611/job/17766473397?pr=63973#step:9:26):Unnecessary parens after '=' keyword (superfluous-parens)
File:scripts/kconfig/kconfiglib.py
Line:2931
Column:0
 C0325:Unnecessary parens after '=' keyword (superfluous-parens)
File:scripts/kconfig/kconfiglib.py
Line:4310
Column:0
 C0325:Unnecessary parens after '=' keyword (superfluous-parens)
File:scripts/kconfig/kconfiglib.py
Line:4448
Column:0
Error: Process completed with exit code 1.

node.is_menuconfig = (t0 is _T_MENUCONFIG)

self._write_to_conf = (vis != 0)

self._write_to_conf = (vis != 0)

This is fixed in the last commit

@ycsin ycsin force-pushed the pr/zephyr_version_h branch 3 times, most recently from 4c025dc to d0ab838 Compare October 17, 2023 09:57
@ycsin ycsin changed the title build: namespace the generated version.h build: namespace generated headers Oct 17, 2023
@ycsin ycsin force-pushed the pr/zephyr_version_h branch 2 times, most recently from 89a285d to 5fb8545 Compare October 17, 2023 14:59
@ycsin ycsin changed the title build: namespace generated headers build: namespace generated headers with zephyr/ Oct 18, 2023
@ycsin ycsin marked this pull request as ready for review October 18, 2023 15:52
@henrikbrixandersen henrikbrixandersen merged commit 3570408 into zephyrproject-rtos:main May 28, 2024
@ycsin
Copy link
Member Author

ycsin commented May 29, 2024

🥳🍀🤞

@ycsin ycsin deleted the pr/zephyr_version_h branch May 29, 2024 09:42
@marc-hb
Copy link
Contributor

marc-hb commented May 29, 2024

Just FYI https://github.com/thesofproject/sof/actions/runs/9278328176/job/25529164408

FileNotFoundError:  No such file or directory:
  '/zep_workspace/build-lnl/zephyr/include/generated/autoconf.h'

That's because one Python script in SOF extracts values from autoconf.h after the build.

The C compilation was fine and the CONFIG_LEGACY_GENERATED_INCLUDE_PATH warning was printed by CMake as expected.

Just FYI.

besmarsh added a commit to besmarsh/zephyr that referenced this pull request Jul 8, 2024
PR zephyrproject-rtos#63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
nashif pushed a commit that referenced this pull request Jul 11, 2024
PR #63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
AlienSarlak pushed a commit to AlienSarlak/zephyr that referenced this pull request Jul 13, 2024
PR zephyrproject-rtos#63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
Chenhongren pushed a commit to Chenhongren/zephyr that referenced this pull request Aug 26, 2024
PR zephyrproject-rtos#63973 namespaced generated headers with zephyr/, including generated
syscall headers.

Since then, some new generated syscall header includes have been added
without the zephyr/ prefix, breaking builds when
CONFIG_LEGACY_GENERATED_INCLUDE_PATH is disabled.

This commit adds the zephyr/ prefix to includes for generated syscall
headers where it has been missed.

(cherry picked from commit 74c871d)

Original-Signed-off-by: Ben Marsh <ben.marsh@helvar.com>
GitOrigin-RevId: 74c871d
Change-Id: I8e595ded94f2900d6c4bcc60ac078aa56f80f22d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5702156
Commit-Queue: Keith Short <keithshort@chromium.org>
Tested-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
TD-JBL added a commit to JB-Lighting/zephyr that referenced this pull request Dec 4, 2025
Update include path note for app_version.h to match changes from PR zephyrproject-rtos#63973

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
TD-JBL added a commit to JB-Lighting/zephyr that referenced this pull request Dec 4, 2025
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
TD-JBL added a commit to JB-Lighting/zephyr that referenced this pull request Dec 4, 2025
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
TD-JBL added a commit to JB-Lighting/zephyr that referenced this pull request Dec 4, 2025
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
TD-JBL added a commit to JB-Lighting/zephyr that referenced this pull request Dec 4, 2025
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
nashif pushed a commit that referenced this pull request Dec 8, 2025
Update include path note for app_version.h to match changes from PR #63973

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
nashif pushed a commit that referenced this pull request Dec 8, 2025
Fix include of app_version.h (see PR #63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
nashif pushed a commit that referenced this pull request Dec 8, 2025
Fix include of app_version.h (see PR #63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
nashif pushed a commit that referenced this pull request Dec 8, 2025
Fix include of app_version.h (see PR #63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
JHKim8212 pushed a commit to InvenSenseInc/fork.zephyr-rtos that referenced this pull request Jan 19, 2026
Update include path note for app_version.h to match changes from PR zephyrproject-rtos#63973

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
JHKim8212 pushed a commit to InvenSenseInc/fork.zephyr-rtos that referenced this pull request Jan 19, 2026
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
JHKim8212 pushed a commit to InvenSenseInc/fork.zephyr-rtos that referenced this pull request Jan 19, 2026
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
JHKim8212 pushed a commit to InvenSenseInc/fork.zephyr-rtos that referenced this pull request Jan 19, 2026
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
gellhaar pushed a commit to gellhaar/zephyr that referenced this pull request Feb 16, 2026
Fix include of app_version.h (see PR zephyrproject-rtos#63973).

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[RFC] build: namespace generated headers with zephyr/ posix: uname: follow up enhancements