Skip to content

Fix matching of "components" dir when there's a symlink in the path to .platformio #1599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions builder/frameworks/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import os
import re
import platform as sys_platform
from pathlib import Path

import click
import semantic_version
Expand Down Expand Up @@ -760,7 +761,12 @@ def compile_source_files(
):
build_envs = prepare_build_envs(config, default_env, debug_allowed)
objects = []
components_dir = fs.to_unix_path(os.path.join(FRAMEWORK_DIR, "components"))
# The source "path" will have had any symlinks resolved, so resolve any
# symlinks in components_dir in order for the .startswith() to work as
# expected below.
components_dir = str(
Path(fs.to_unix_path(os.path.join(FRAMEWORK_DIR, "components"))).resolve()
)
for source in config.get("sources", []):
if source["path"].endswith(".rule"):
continue
Expand All @@ -775,7 +781,7 @@ def compile_source_files(
src_path = os.path.join(project_src_dir, src_path)

obj_path = os.path.join("$BUILD_DIR", prepend_dir or "")
if src_path.lower().startswith(components_dir.lower()):
if str(Path(src_path).resolve()).lower().startswith(components_dir.lower()):
obj_path = os.path.join(
obj_path, os.path.relpath(src_path, components_dir)
)
Expand Down