Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# In code review, collapse generated files
docs/*.md linguist-generated=true

# cmd.exe finds batch labels by byte offset and fails on LF-only .cmd files,
# so these launcher templates must stay CRLF.
ruby/private/**/*.cmd.tpl text eol=crlf
7 changes: 5 additions & 2 deletions ruby/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/
"""

# https://github.com/aspect-build/bazel-lib/blob/ddac9c46c3bff4cf8d0118a164c75390dbec2da9/lib/windows_utils.bzl
# Normalized to CRLF; cmd.exe can't reliably find batch labels in LF-only .cmd files.
BATCH_RLOCATION_FUNCTION = r"""
rem Usage of rlocation function:
rem call :rlocation <runfile_path> <abs_path>
Expand Down Expand Up @@ -76,7 +77,7 @@ set %~2=!abs_path!
exit /b 0
:rlocation_end
:: End of rlocation
"""
""".replace("\r\n", "\n").replace("\n", "\r\n")

def is_windows(ctx):
windows_constraint = ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]
Expand All @@ -95,14 +96,16 @@ def convert_env_to_script(ctx, env):
environment = []
if is_windows(ctx):
export_command = "set"
newline = "\r\n" # keep the generated .cmd CRLF; see BATCH_RLOCATION_FUNCTION
else:
export_command = "export"
newline = "\n"

for (name, value) in env.items():
command = "{command} {name}={value}".format(command = export_command, name = name, value = value)
environment.append(command)

return "\n".join(environment)
return newline.join(environment)

def normalize_path(ctx, path):
"""Converts path to an OS-specific equivalent.
Expand Down
Loading