Choose the correct file extensions when cross-compiling for Windows
When building a shared lib for the host tools toolchain, use .so on
Linux, .dylib on Mac and .dll on Windows. Don't use the target's
file extension.
When building a batch file to run the rust unit tests on Windows, use
the .exe extension even if building that batch file on a Linux
machine.
[email protected], [email protected]
Bug: 1271215
Change-Id: If90ea0013655a6c89e96688c9f9610b6539eb149
Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,mac-rust-x64-dbg,linux-rust-x64-dbg,linux-rust-x64-rel,win-rust-x64-dbg,win-rust-x64-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4619088
Commit-Queue: danakj <[email protected]>
Reviewed-by: Bruce Dawson <[email protected]>
Reviewed-by: Ćukasz Anforowicz <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1158785}
NOKEYCHECK=True
GitOrigin-RevId: 9f9c029d53ed4e8a1a0cdeff70a9e21e41f840ce
diff --git a/generate_script.py b/generate_script.py
index eb57652..2cd58c7 100755
--- a/generate_script.py
+++ b/generate_script.py
@@ -47,19 +47,19 @@
with open(input_filepath) as f:
for line in f:
exe_name = line.strip()
- # TODO(https://crbug.com/1271215): Append ".exe" extension when
- # *targeting* Windows. (The "targeting" part means that we can't
- # just detect whether the build is *hosted* on Windows.)
+ # Append ".exe" extension when *targeting* Windows, not when this
+ # script is running on windows. We do that by using `args.make_bat`
+ # as a signal.
if exe_name in exes:
- raise ValueError("Duplicate entry ('{}') in {}".format(
- exe_name, input_filepath))
- if sys.platform == 'win32':
+ raise ValueError(
+ f'Duplicate entry "{exe_name}" in {input_filepath}')
+ if args.make_bat:
suffix = ".exe"
else:
suffix = ""
exes.add(f'{exe_name}{suffix}')
if not exes:
- raise ValueError("Unexpectedly empty file: {}".format(input_filepath))
+ raise ValueError(f'Unexpectedly empty file: {input_filepath}')
exes = sorted(exes) # For stable results in unit tests.
return exes
@@ -67,7 +67,7 @@
def _validate_if_test_executables_exist(exes):
for exe in exes:
if not os.path.isfile(exe):
- raise ValueError("File not found: {}".format(exe))
+ raise ValueError(f'File not found: {exe}')
def _generate_script(args, should_validate_if_exes_exist=True):
diff --git a/generate_script_unittests.py b/generate_script_unittests.py
index ba91e80..f875dac 100755
--- a/generate_script_unittests.py
+++ b/generate_script_unittests.py
@@ -81,8 +81,8 @@
expected = '''
@echo off
vpython3 "%~dp0\\../../../testing/scripts/rust\\rust_main_program.py" ^
- "--rust-test-executable=%~dp0\\..\\bar" ^
- "--rust-test-executable=%~dp0\\..\\foo" ^
+ "--rust-test-executable=%~dp0\\..\\bar.exe" ^
+ "--rust-test-executable=%~dp0\\..\\foo.exe" ^
%*
'''.strip()