Skip to content

Commit 7273e20

Browse files
authored
framework: avoid forced path suffixing (#1346)
1 parent 7e0fafb commit 7273e20

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

foreign_cc/private/framework.bzl

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,23 @@ def _correct_path_variable(toolchain, env):
724724
corrected_env[key] = ";".join(path_paths)
725725
env = corrected_env
726726

727-
value = env.get("PATH", "")
728-
if not value:
727+
value = env.get("PATH")
728+
if value == None:
729+
# avoid setting PATH if it isn't set, and vice-versa
729730
return env
730-
value = _normalize_path(env.get("PATH", ""))
731-
env["PATH"] = "$PATH:" + value
731+
732+
value = _normalize_path(value)
733+
734+
if "$PATH" not in value:
735+
# Since we end up overriding the value of PATH here, we need to make
736+
# sure we preserve the current value of the PATH (in case
737+
# strict_action_env is not in use). If one of the toolchains has
738+
# already overridden where the PATH self-reference falls (in order to
739+
# put toolchain items first, for example) we want to trust that, but
740+
# otherwise we need to make sure it's referenced _somewhere_.
741+
value = "$PATH:" + value
742+
743+
env["PATH"] = value
732744
return env
733745

734746
def _list(item):

0 commit comments

Comments
 (0)