File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 4848COVERAGE_INSTRUMENTED = "%coverage_instrumented%" == "1"
4949
5050# runfiles-root-relative path to a file with binary-specific build information
51+ # It uses forward slashes, so must be converted for proper usage on Windows.
5152BUILD_DATA_FILE = "%build_data_file%"
5253
5354# ===== Template substitutions end =====
@@ -64,9 +65,23 @@ def get_build_data(self):
6465 import runfiles
6566 except ImportError :
6667 from python .runfiles import runfiles
67- path = runfiles .Create ().Rlocation (self .BUILD_DATA_FILE )
68- with open (path ) as fp :
69- return fp .read ()
68+ rlocation_path = self .BUILD_DATA_FILE
69+ if is_windows ():
70+ rlocation_path = rlocation_path .replace ("/" , "" )
71+ path = runfiles .Create ().Rlocation (rlocation_path )
72+ if is_windows ():
73+ path = os .path .normpath (path )
74+ try :
75+ # Use utf-8-sig to handle Windows BOM
76+ with open (path , encoding = 'utf-8-sig' ) as fp :
77+ return fp .read ()
78+ except Exception as exc :
79+ if hasattr (exc , "add_note" ):
80+ exc .add_note (f"runfiles lookup path: { rlocation_path } " )
81+ exc .add_note (f"exists: { os .path .exists (path )} " )
82+ can_read = os .access (path , os .R_OK )
83+ exc .add_note (f"readable: { can_read } " )
84+ raise
7085
7186
7287sys .modules ["bazel_binary_info" ] = BazelBinaryInfoModule ("bazel_binary_info" )
You can’t perform that action at this time.
0 commit comments