Skip to content

build(meson): normalize -I paths to absolute forward-slash form (#2328) - #2332

Merged
zackees merged 1 commit into
masterfrom
feat/meson-path-normalize
Apr 18, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/meson-path-normalize

Conversation

@zackees

@zackees zackees commented Apr 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #2328. On Windows, Meson's include_directories() propagates -I flags using native backslash + relative-path spellings (e.g. -I..\..\src\platforms\stub). Clang keys #pragma once deduplication on the raw resolved path string — if the same directory reaches a TU via two different spellings, the header appears to be two different files and #pragma once is silently defeated, producing double-definition errors (this is what caused #2324 / #2325 — the vibe.h double-definition that was papered over with a manual #ifndef guard).

This change makes every -I flag we generate be absolute + forward-slash + spelled identically everywhere.

  • Canonical path_norm_* -I args in ci/meson/shared/meson.build — every consumer meson.build references these instead of redeclaring.
  • Replaced every project-wide include_directories(...) consumer with explicit absolute cpp_args. Stops Meson from injecting relative backslash -I flags into propagated compile lines.
  • Per-example discovered include dirs are now built from path_norm_root / <rel> instead of include_directories(inc_dir_fixed).
  • Removed the #ifndef FL_AUDIO_DETECTOR_VIBE_H belt-and-suspenders guard added in fix(audio): add #ifndef guards to vibe.h for PCH-safe inclusion #2325 — verified with bash test --cpp: 300/300 tests pass.
  • New CI check ci/tests/test_meson_include_paths.py parses .build/meson*/compile_commands.json after setup and fails if any non-Meson-auto -I flag contains a backslash or is not absolute.

Before / after (compile_commands.json on Windows)

Before — 346 distinct backslash -I flags, e.g.:

-I..\..\src\platforms\stub
-I..\..\examples\Blink
-I..\..\src

After — all our own -I flags are absolute forward-slash:

-IC:/Users/.../src
-IC:/Users/.../src/platforms/stub
-IC:/Users/.../examples/Blink

(Meson still auto-injects a handful of -I<subdir> / -I<target>.p flags that reference private scratch dirs and source subdirs. These are empty of user headers and can't defeat #pragma once because our canonical absolute paths resolve first during header search. The CI check whitelists exactly these Meson-internal shapes.)

Test plan

  • bash test --cpp — 300/300 pass with vibe.h guard removed
  • bash lint — all linters pass
  • uv run pytest ci/tests/test_meson_include_paths.py -v — passes against current .build/meson-quick + .build/meson-wasm-quick
  • Verified the CI check rejects the pre-fix spellings (..\..\src, ..\..\src\fl, etc.) in a unit check

Files changed

File Change
ci/meson/shared/meson.build Export canonical path_norm_root + path_norm_I_{root,src,tests,stub}
ci/meson/native/meson.build Use path_norm_I_* instead of inline absolute paths
ci/meson/wasm/meson.build Use path_norm_I_*
meson.build (root) Drop global include_directories() objects
tests/meson.build runner_exe + test PCH use absolute cpp_args -I
examples/meson.build example_runner_exe + per-example DLLs use absolute cpp_args -I
tests/profile/meson.build Profile exes use absolute cpp_args -I
src/fl/audio/detector/vibe.h Remove #ifndef FL_AUDIO_DETECTOR_VIBE_H guard
ci/tests/test_meson_include_paths.py NEW: CI check for backslash / relative -I flags

Run the new check directly with:

uv run pytest ci/tests/test_meson_include_paths.py -v

Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved build-system include path handling for consistent, absolute forward-slash includes to reduce cross-platform/build inconsistencies.
  • Tests
    • Added automated unit tests that validate normalized include-paths in generated build metadata.
  • Bug Fixes
    • Updated a header to rely on pragma once to prevent duplicate-inclusion issues caused by inconsistent include-path spelling on some platforms.

@coderabbitai

coderabbitai Bot commented Apr 18, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Centralizes and normalizes Meson-generated absolute include paths (forward-slash -I flags) via exported path_norm_I_* variables, replaces project-wide include_directories() with explicit cpp_args, adds a unittest validating compile_commands.json include paths, and removes traditional header guards from one header leaving #pragma once.

Changes

Cohort / File(s) Summary
Shared build exports
ci/meson/shared/meson.build
Adds Windows-aware canonical project root and exports normalized absolute -I argument strings (path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub).
Native/WASM build updates
ci/meson/native/meson.build, ci/meson/wasm/meson.build
Replace inline '-I' + meson.project_source_root() / ... constructions with precomputed path_norm_I_* variables for include args in target cpp_args.
Top-level / examples / tests build files
meson.build, examples/meson.build, tests/meson.build, tests/profile/meson.build
Remove/stop using global include_directories(); propagate include paths via explicit cpp_args using path_norm_I_* and normalize per-example include -I args.
Include guard change
src/fl/audio/detector/vibe.h
Removed traditional #ifndef/#define/#endif guard macros; retains #pragma once with explanatory comment about Meson include normalization.
Validation test
ci/tests/test_meson_include_paths.py
New unittest that scans compile_commands.json in build dirs, extracts -I flags, and fails on backslashes or non-absolute include paths (skips known Meson-injected auto-includes).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Poem

🐰
I hop through paths both near and far,
I stitch each include with a forward-slash star.
No backslash tangles, no duplicate plight,
path_norm guides the build just right.
A little hop, a tidy beam — compiler dreams gleam.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: normalizing Meson -I include paths to absolute forward-slash form, directly addressing the referenced issue #2328.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/meson-path-normalize

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
ci/meson/shared/meson.build (1)

41-48: Use .replace() for cleaner forward-slash normalization.

meson.project_source_root() / '.' normalizes to forward slashes on Windows but doesn't collapse the trailing ., resulting in paths like C:/Users/.../FastLED/. and downstream -I flags like -IC:/Users/.../FastLED/./src. While still absolute and forward-slash-only (satisfying the invariant), the embedded /./ is cosmetically noisy in compile_commands.json and compiler diagnostics. Since every consumer derives from path_norm_root, consistency is preserved regardless.

Using .replace('\\', '/') directly produces a literally normalized path without the /./ segment:

♻️ Proposed refactor
-path_norm_root = meson.project_source_root() / '.'
+path_norm_root = meson.project_source_root().replace('\\', '/')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/meson/shared/meson.build` around lines 41 - 48, path_norm_root currently
uses meson.project_source_root() / '.' which yields a trailing "/." on some
platforms; change it to call .replace('\\', '/') on meson.project_source_root()
(e.g., path_norm_root = meson.project_source_root().replace('\\', '/')) so the
root is a clean forward-slash-normalized string, and keep the existing derived
constants path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub
concatenating '-I' with that normalized path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/tests/test_meson_include_paths.py`:
- Around line 112-124: The _is_absolute_forward_slash function currently treats
paths with dot-segments (e.g. C:/repo/./src or /repo/../repo/src) as absolute;
update it to reject any path that contains dot-segments by checking for '/.' or
'/..' segments after verifying there are no backslashes and it is absolute.
Specifically, inside _is_absolute_forward_slash add a check (after the existing
absolute checks) that splits the path on '/' or uses a regex like
r'(^|/)\.(\Z|/)|(^|/)\.\.(\Z|/)' to detect '.' or '..' path components and
return False if found; keep the existing drive-letter check (re.match(...)),
POSIX check (path.startswith('/')), and the initial backslash guard.
- Around line 31-41: Replace the hard-coded _MESON_BUILD_DIRS list with a
dynamic glob that enumerates BUILD.glob("meson*") (or equivalent) and filter for
directories that actually contain compile_commands.json; then change the test
skip logic so that if running under CI (detect via os.environ.get("CI") or
pytest.config) and no compile DBs are found the test fails (pytest.fail or raise
AssertionError) while only allowing a developer-friendly pytest.skip outside CI;
apply the same change to the other static list/logic referenced around lines
191-205 so both uses use the glob + CI-fail behavior.
- Line 47: The current _I_FLAG_RE approach rebuilds the command string and
misses split forms like ["-I", "../bad\\path"] or "-I ../bad\\path"; update the
parser in test_meson_include_paths.py to detect -I when the command is already
split (i.e., look for list elements equal to "-I" and take the next element) and
combine both detection modes instead of relying solely on _I_FLAG_RE; when you
need to reconstruct commands for assertions, use subprocess.list2cmdline() per
guidelines rather than " ".join so all argument quoting/escaping is preserved
(apply the same fix to the other occurrence around lines 85-92).
- Around line 101-104: The Meson `.p` whitelist is being applied to any path
ending with `.p`, including absolute paths; update the check around
_MESON_P_SCRATCH_RE so it only matches relative Meson scratch dirs by first
rejecting absolute paths (e.g. after normalizing with norm =
include_path.replace("\\", "/").rstrip("/"), ensure norm is not absolute: not
starting with '/' and not matching Windows drive-letter patterns like
'^[A-Za-z]:/'). Only if the path is relative should you then apply
_MESON_P_SCRATCH_RE and return True.

---

Nitpick comments:
In `@ci/meson/shared/meson.build`:
- Around line 41-48: path_norm_root currently uses meson.project_source_root() /
'.' which yields a trailing "/." on some platforms; change it to call
.replace('\\', '/') on meson.project_source_root() (e.g., path_norm_root =
meson.project_source_root().replace('\\', '/')) so the root is a clean
forward-slash-normalized string, and keep the existing derived constants
path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub
concatenating '-I' with that normalized path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3b4435ef-1c23-4716-b982-3babf768984c

📥 Commits

Reviewing files that changed from the base of the PR and between 2230aa4 and 9aaa0ed.

📒 Files selected for processing (9)
  • ci/meson/native/meson.build
  • ci/meson/shared/meson.build
  • ci/meson/wasm/meson.build
  • ci/tests/test_meson_include_paths.py
  • examples/meson.build
  • meson.build
  • src/fl/audio/detector/vibe.h
  • tests/meson.build
  • tests/profile/meson.build

Comment on lines +31 to +41
# Directories under .build/ where meson may have written a compile_commands.json.
# We check whichever ones exist at test time; we do NOT invoke meson setup here
# (that is done by the `bash test` driver / developer). Test is a no-op if no
# compile_commands.json files are present, so fresh clones don't fail here.
_MESON_BUILD_DIRS = [
BUILD / "meson",
BUILD / "meson-quick",
BUILD / "meson-debug",
BUILD / "meson-release",
BUILD / "meson-wasm-quick",
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Discover Meson compile DBs dynamically and fail in CI when none are checked.

The fixed list can miss .build/meson-* directories, and the final skip lets CI pass without enforcing this regression if setup changes. Glob the generated compile DBs and only keep the developer-friendly skip outside CI.

Suggested fix
+import os
 import json
 import re
 import unittest
@@
-# Directories under .build/ where meson may have written a compile_commands.json.
-# We check whichever ones exist at test time; we do NOT invoke meson setup here
-# (that is done by the `bash test` driver / developer). Test is a no-op if no
-# compile_commands.json files are present, so fresh clones don't fail here.
-_MESON_BUILD_DIRS = [
-    BUILD / "meson",
-    BUILD / "meson-quick",
-    BUILD / "meson-debug",
-    BUILD / "meson-release",
-    BUILD / "meson-wasm-quick",
-]
+def _meson_build_dirs() -> list[Path]:
+    """Return Meson build dirs that have a compile_commands.json."""
+    build_dirs: list[Path] = []
+    if not BUILD.exists():
+        return build_dirs
+    for cc_json in sorted(BUILD.glob("meson*/compile_commands.json")):
+        build_dirs.append(cc_json.parent)
+    return build_dirs
@@
         """Check every known meson build dir. Skip any that don't exist yet."""
         checked_any = False
-        for build_dir in _MESON_BUILD_DIRS:
-            if not (build_dir / "compile_commands.json").exists():
-                continue
+        for build_dir in _meson_build_dirs():
             checked_any = True
             with self.subTest(build_dir=build_dir.name):
                 self._check_build_dir(build_dir)
 
         if not checked_any:
-            self.skipTest(
-                "No meson compile_commands.json found under .build/; "
-                "run `bash test --cpp` first to generate one."
-            )
+            message = (
+                "No meson compile_commands.json found under .build/; "
+                "run `bash test --cpp` first to generate one."
+            )
+            if os.environ.get("CI"):
+                self.fail(message)
+            self.skipTest(message)

As per coding guidelines, never use silent fallbacks for missing critical resources; always fail fast with descriptive errors.

Also applies to: 191-205

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_meson_include_paths.py` around lines 31 - 41, Replace the
hard-coded _MESON_BUILD_DIRS list with a dynamic glob that enumerates
BUILD.glob("meson*") (or equivalent) and filter for directories that actually
contain compile_commands.json; then change the test skip logic so that if
running under CI (detect via os.environ.get("CI") or pytest.config) and no
compile DBs are found the test fails (pytest.fail or raise AssertionError) while
only allowing a developer-friendly pytest.skip outside CI; apply the same change
to the other static list/logic referenced around lines 191-205 so both uses use
the glob + CI-fail behavior.

# emit tokens wrapped in double-quotes like `"-Ici/foo"` or `"-IC:/foo"` on
# Windows, so we match between quotes as well as bare -Ifoo. The captured
# path value never includes the surrounding quotes.
_I_FLAG_RE = re.compile(r'"-I([^"]+)"|(?<!\S)-I(\S+)')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Parse split -I arguments instead of rebuilding the command string.

This misses compile DB entries shaped as ["-I", "../bad\\path"] or command strings like -I ../bad\\path, so the regression test can pass while a non-normalized include remains.

Suggested fix
-_I_FLAG_RE = re.compile(r'"-I([^"]+)"|(?<!\S)-I(\S+)')
+_I_FLAG_RE = re.compile(r'"-I([^"]+)"|(?<!\S)-I(?:\s+"([^"]+)"|\s+(\S+)|(\S+))')
@@
 def _extract_includes_from_entry(entry: dict[str, object]) -> list[str]:
     """Extract -I <path> values from a compile_commands.json entry."""
-    raw = entry.get("command") or " ".join(entry.get("arguments", []))  # type: ignore[arg-type]
-    assert isinstance(raw, str)
     out: list[str] = []
+
+    arguments = entry.get("arguments")
+    if isinstance(arguments, list):
+        i = 0
+        while i < len(arguments):
+            arg = arguments[i]
+            assert isinstance(arg, str)
+            if arg == "-I":
+                if i + 1 >= len(arguments):
+                    raise AssertionError("compile_commands entry contains '-I' without a path")
+                next_arg = arguments[i + 1]
+                assert isinstance(next_arg, str)
+                out.append(next_arg)
+                i += 2
+                continue
+            if arg.startswith("-I") and len(arg) > 2:
+                out.append(arg[2:])
+            i += 1
+        return out
+
+    raw = entry.get("command")
+    assert isinstance(raw, str)
     for m in _I_FLAG_RE.finditer(raw):
-        out.append(m.group(1) or m.group(2))
+        for group in m.groups():
+            if group:
+                out.append(group)
+                break
     return out

As per coding guidelines, use subprocess.list2cmdline() for all command line construction instead of string join.

Also applies to: 85-92

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_meson_include_paths.py` at line 47, The current _I_FLAG_RE
approach rebuilds the command string and misses split forms like ["-I",
"../bad\\path"] or "-I ../bad\\path"; update the parser in
test_meson_include_paths.py to detect -I when the command is already split
(i.e., look for list elements equal to "-I" and take the next element) and
combine both detection modes instead of relying solely on _I_FLAG_RE; when you
need to reconstruct commands for assertions, use subprocess.list2cmdline() per
guidelines rather than " ".join so all argument quoting/escaping is preserved
(apply the same fix to the other occurrence around lines 85-92).

Comment on lines +101 to +104
norm = include_path.replace("\\", "/").rstrip("/")
# (a) Private per-target scratch dir (contains only .obj files)
if _MESON_P_SCRATCH_RE.search(norm):
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Keep the .p whitelist scoped to relative Meson scratch dirs.

Right now any include ending in .p is ignored, including absolute/backslash paths. Since the comment says these Meson paths are always relative, reject absolute paths before applying this whitelist.

Suggested fix
 def _is_meson_auto_include(include_path: str) -> bool:
@@
     """
     norm = include_path.replace("\\", "/").rstrip("/")
+    if norm.startswith("/") or re.match(r"^[A-Za-z]:/", norm):
+        return False
     # (a) Private per-target scratch dir (contains only .obj files)
     if _MESON_P_SCRATCH_RE.search(norm):
         return True
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_meson_include_paths.py` around lines 101 - 104, The Meson `.p`
whitelist is being applied to any path ending with `.p`, including absolute
paths; update the check around _MESON_P_SCRATCH_RE so it only matches relative
Meson scratch dirs by first rejecting absolute paths (e.g. after normalizing
with norm = include_path.replace("\\", "/").rstrip("/"), ensure norm is not
absolute: not starting with '/' and not matching Windows drive-letter patterns
like '^[A-Za-z]:/'). Only if the path is relative should you then apply
_MESON_P_SCRATCH_RE and return True.

Comment on lines +112 to +124
def _is_absolute_forward_slash(path: str) -> bool:
"""Return True if `path` is absolute (POSIX `/...` or Windows `X:/...`)
and contains no backslashes.
"""
if "\\" in path:
return False
# Windows drive letter
if re.match(r"^[A-Za-z]:/", path):
return True
# POSIX absolute
if path.startswith("/"):
return True
return False

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Reject dot-segment spellings too.

This accepts absolute forward-slash paths like C:/repo/./src or /repo/../repo/src, even though the header comment calls out /./ spelling differences as part of the #pragma once failure mode.

Suggested fix
 def _is_absolute_forward_slash(path: str) -> bool:
     """Return True if `path` is absolute (POSIX `/...` or Windows `X:/...`)
     and contains no backslashes.
     """
     if "\\" in path:
         return False
+    parts = path.split("/")
+    if "." in parts or ".." in parts:
+        return False
     # Windows drive letter
     if re.match(r"^[A-Za-z]:/", path):
         return True
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/tests/test_meson_include_paths.py` around lines 112 - 124, The
_is_absolute_forward_slash function currently treats paths with dot-segments
(e.g. C:/repo/./src or /repo/../repo/src) as absolute; update it to reject any
path that contains dot-segments by checking for '/.' or '/..' segments after
verifying there are no backslashes and it is absolute. Specifically, inside
_is_absolute_forward_slash add a check (after the existing absolute checks) that
splits the path on '/' or uses a regex like r'(^|/)\.(\Z|/)|(^|/)\.\.(\Z|/)' to
detect '.' or '..' path components and return False if found; keep the existing
drive-letter check (re.match(...)), POSIX check (path.startswith('/')), and the
initial backslash guard.

On Windows, Meson's `include_directories()` propagates `-I` flags using
native backslash + relative-path spellings (e.g. `-I..\..\src\platforms\stub`).
Clang keys `#pragma once` deduplication on the raw resolved path string —
if the same directory reaches a translation unit via two different
spellings (forward slash vs backslash, absolute vs relative), the header
appears to be two different files and `#pragma once` is silently defeated,
producing double-definition errors (#2324, #2325).

This change ensures every `-I` flag we generate is absolute +
forward-slash + spelled identically everywhere:

* Add canonical `path_norm_*` -I args in ci/meson/shared/meson.build
  (path_norm_I_root, path_norm_I_src, path_norm_I_tests, path_norm_I_stub).
  Every consumer meson.build references these instead of redeclaring.
* Replace every project-wide `include_directories(...)` consumer
  (`include_directories: [src_dir, stub_dir, ...]`) with explicit absolute
  cpp_args. This stops Meson from injecting relative backslash `-I` flags
  into the propagated compile lines.
* For per-example discovered include dirs, build absolute forward-slash
  `-I` args from the discovered relative path via the `/` operator and
  the canonical `path_norm_root` prefix, replacing the previous
  `include_directories(inc_dir_fixed)` call.
* Remove the `#ifndef FL_AUDIO_DETECTOR_VIBE_H` belt-and-suspenders guard
  added in #2325. With all `-I` flags normalized, `#pragma once` alone
  is sufficient. Verified with `bash test --cpp`: 300/300 tests pass.
* Add ci/tests/test_meson_include_paths.py — a CI check that parses
  `.build/meson*/compile_commands.json` after setup and fails if any
  non-Meson-auto `-I` flag contains a backslash or is not absolute.

Fixes #2328.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees force-pushed the feat/meson-path-normalize branch from 9aaa0ed to 5aee970 Compare April 18, 2026 20:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ci/meson/shared/meson.build`:
- Around line 41-45: The path_norm_root currently appends '/.' which creates a
trailing dot and leads to inconsistent -I spellings (path_norm_root =
meson.project_source_root() / '.'); change how path_norm_root is computed so it
does not include the '.' suffix—e.g. use meson.project_source_root() directly or
compute a sentinel subdir then take its parent—so path_norm_I_root ('-I' +
path_norm_root) and related flags (path_norm_I_src, etc.) all produce identical
canonical -I paths and avoid the '/.' variant.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63ea7508-b6ec-4db8-bb93-9cc6672313c3

📥 Commits

Reviewing files that changed from the base of the PR and between 9aaa0ed and 5aee970.

📒 Files selected for processing (9)
  • ci/meson/native/meson.build
  • ci/meson/shared/meson.build
  • ci/meson/wasm/meson.build
  • ci/tests/test_meson_include_paths.py
  • examples/meson.build
  • meson.build
  • src/fl/audio/detector/vibe.h
  • tests/meson.build
  • tests/profile/meson.build
✅ Files skipped from review due to trivial changes (3)
  • ci/meson/native/meson.build
  • tests/meson.build
  • meson.build
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/fl/audio/detector/vibe.h
  • tests/profile/meson.build
  • ci/meson/wasm/meson.build
  • ci/tests/test_meson_include_paths.py
  • examples/meson.build

Comment on lines +41 to +45
path_norm_root = meson.project_source_root() / '.'

# Canonical absolute forward-slash -I args for the four project-wide
# include roots. Use these everywhere instead of redeclaring.
path_norm_I_root = '-I' + path_norm_root

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm whether meson's '/' operator collapses a trailing '.' component.
# Also inspect any existing compile_commands.json fixture in the repo for the shape.
fd -t f 'compile_commands.json' | xargs -I{} sh -c 'echo "== {} =="; grep -oE "\-I[^ \"]+" "{}" | sort -u | head -50'
echo "---"
cat ci/tests/test_meson_include_paths.py 2>/dev/null | sed -n '1,120p'

Repository: FastLED/FastLED

Length of output: 5002


🏁 Script executed:

cat -n ci/meson/shared/meson.build | sed -n '35,55p'

Repository: FastLED/FastLED

Length of output: 898


🏁 Script executed:

# Search for any test or example showing how Meson's '/' operator handles '.'
rg -A 3 -B 3 "project_source_root\(\)" --type meson

Repository: FastLED/FastLED

Length of output: 6232


🏁 Script executed:

# Check for any compile_commands.json files that might show current behavior
find . -type f -name "compile_commands.json" 2>/dev/null | head -5

Repository: FastLED/FastLED

Length of output: 41


🏁 Script executed:

# Check if there's any CI output or test results showing what the current code produces
find . -type f \( -name "*.log" -o -name "test_*.py" \) | xargs grep -l "path_norm\|compile_commands" 2>/dev/null | head -10

Repository: FastLED/FastLED

Length of output: 144


🏁 Script executed:

# Search for any discussion or references to the trailing '.' behavior in the codebase
rg "/ '\.'" --type meson -B 2 -A 2

Repository: FastLED/FastLED

Length of output: 447


🏁 Script executed:

# Check what Meson documentation or inline comments say about path normalization
rg -i "meson.*project_source_root.*\/" --type meson -B 1 -A 1 | head -40

Repository: FastLED/FastLED

Length of output: 183


🏁 Script executed:

# Look at how path_norm_root is actually used in the codebase to infer its format
rg "path_norm_root" -B 1 -A 1

Repository: FastLED/FastLED

Length of output: 1474


🏁 Script executed:

cat ci/tests/test_meson_include_paths.py | tail -n +60 | head -100

Repository: FastLED/FastLED

Length of output: 3733


🏁 Script executed:

# Check if there's any build output or test results
find .build -type f -name "compile_commands.json" 2>/dev/null | head -3 | xargs cat 2>/dev/null | head -50

Repository: FastLED/FastLED

Length of output: 41


🏁 Script executed:

# Look at the rest of the test to see what it's actually validating
wc -l ci/tests/test_meson_include_paths.py

Repository: FastLED/FastLED

Length of output: 99


🏁 Script executed:

tail -30 ci/tests/test_meson_include_paths.py

Repository: FastLED/FastLED

Length of output: 1287


🏁 Script executed:

# Now let's understand what the validation actually checks
# The key is whether path_norm_root with '.' will produce a path that fails the validation
python3 << 'EOF'
import re

# Simulate Meson's '/' operator behavior with '.'
# Most path libraries preserve the '.' component in string form
example_root_windows = r"C:\Users\repo"
example_root_posix = "/home/repo"

# When Meson normalizes Windows to forward slashes via '/'
normalized_win = example_root_windows.replace("\\", "/")  # "C:/Users/repo"
# Then appends '.'
with_dot_win = normalized_win + "/" + "."  # "C:/Users/repo/."

normalized_posix = example_posix_root = "/home/repo"
with_dot_posix = normalized_posix + "/" + "."  # "/home/repo/."

# Test if regex for absolute path with forward slashes catches this
absolute_fwd_slash_re = r"^[A-Za-z]:/|^/"

print(f"Windows with dot: {with_dot_win}")
print(f"  Matches absolute fwd-slash pattern: {bool(re.match(absolute_fwd_slash_re, with_dot_win))}")
print(f"  Contains backslash: {chr(92) in with_dot_win}")
print()

# The key question: Does Meson's '/' operator collapse the '.' or leave it?
# We need to check what the actual behavior is by looking at how it's used
print("Simulating path_norm_I_root construction:")
print(f"  '-I' + '{with_dot_win}' = '-I{with_dot_win}'")
print()
print("This would pass the validation if:")
print("  1. It doesn't contain backslashes ✓")
print("  2. It's absolute ✓")
print()
print("But the concern is the /. suffix means different spelling from")
print("  '-IC:/Users/repo' (without the /.)")
EOF

Repository: FastLED/FastLED

Length of output: 451


🏁 Script executed:

# Let's look for any Meson documentation or real behavior test
# Check if there's a way Meson actually handles the '/' operator
rg -i "meson.*build.*string\|path.*concat" docs/ 2>/dev/null | head -20

Repository: FastLED/FastLED

Length of output: 41


🏁 Script executed:

# Check if path_norm_I_root is actually used or exported in a way that could affect compilation
rg "path_norm_I_root[^_]" --type meson -B 1 -A 1

Repository: FastLED/FastLED

Length of output: 1576


🏁 Script executed:

# Check if the root path is ever used without the '/' subpath
rg "path_norm_root\s*[^/]" --type meson -B 1 -A 1 | head -30

Repository: FastLED/FastLED

Length of output: 1384


🏁 Script executed:

# Verify: Does the use pattern show that path_norm_root is ONLY used via path_norm_I_*?
rg "path_norm_I_" --type meson | wc -l

Repository: FastLED/FastLED

Length of output: 61


🏁 Script executed:

# Check the actual behavior by seeing how these are exported/used across files
rg "path_norm_I_root\b" --type meson

Repository: FastLED/FastLED

Length of output: 686


Trailing /. in path_norm_I_root creates inconsistent spelling across -I flags.

path_norm_root = meson.project_source_root() / '.' results in a path ending with /. (e.g., C:/Users/.../repo/.). When used directly in path_norm_I_root = '-I' + path_norm_root, this produces -IC:/Users/.../repo/., which is a different spelling from the root without the suffix. Other uses like path_norm_I_src = '-I' + path_norm_root / 'src' overwrite the trailing /. with a subdirectory, resulting in identical -IC:/.../repo/src. This spelling inconsistency contradicts the comment's stated goal to use these "everywhere instead of redeclaring" and being "spelled identically everywhere"—and risks defeating #pragma once deduplication if the same header is reached via both -IC:/repo and -IC:/repo/..

Compute path_norm_root without the . suffix so all four -I flags maintain consistent spelling. For example, join with a sentinel subdir, then remove it; or refactor to avoid the need for a normalization trick altogether.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ci/meson/shared/meson.build` around lines 41 - 45, The path_norm_root
currently appends '/.' which creates a trailing dot and leads to inconsistent -I
spellings (path_norm_root = meson.project_source_root() / '.'); change how
path_norm_root is computed so it does not include the '.' suffix—e.g. use
meson.project_source_root() directly or compute a sentinel subdir then take its
parent—so path_norm_I_root ('-I' + path_norm_root) and related flags
(path_norm_I_src, etc.) all produce identical canonical -I paths and avoid the
'/.' variant.

@zackees
zackees merged commit 8bb5d7c into master Apr 18, 2026
2 of 86 checks passed
zackees added a commit that referenced this pull request Apr 18, 2026
… path

The esbuild alias `three=./vendor/three/three.module.js` and the direct
relative imports in app.ts and fastled_background_worker.ts (both of
which use `./vendor/three/build/three.module.js`) both pointed at
paths that were never populated — the original vendor commit 7d5bb4e
committed only `vendor/three/examples/jsm/` and missed the runtime
module. Every WASM CI build has been failing at the esbuild step with
"Could not resolve ./vendor/three/three.module.js".

Fixes by:
  - Committing three.module.js (three.js v0.170.0, MIT) under
    vendor/three/build/, matching the actual import paths.
  - Adding an unignore rule so vendor/three/build/ isn't swept by the
    project-wide build/ ignore (follows the existing precedent for
    !src/fl/build/).
  - Updating the esbuild alias to the same path so bare `three` imports
    from examples/jsm files resolve to the identical module instance as
    the direct relative imports (no double-bundle).
  - Vendoring LICENSE alongside for attribution.

Verified locally: bash compile wasm --examples AudioUrl now produces
fastled.js + fastled.wasm + index.html (previously the final esbuild
step failed, leaving those artifacts missing and breaking the
"Check for required artifacts" step in build.yml).

Unblocks CI for #2331, #2332, #2335, and every future PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the feat/meson-path-normalize branch April 19, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build: normalize all Meson -I paths to forward-slash absolute form

1 participant