Node: On Windows in GitHub CI, use $TMP as the build directory

Otherwise, we can run into paths that exceed the classic Windows path
limit due to the nesting of build systems (GitHub Actions > node-gyp >
Cargo > CMake > Visual Studio). Unfortunately, at least some of Visual
Studio's tools are not long-path-aware.
This commit is contained in:
Jordan Rose
2022-06-27 11:37:32 -07:00
parent e54685b281
commit ec4faf2601

View File

@@ -81,6 +81,21 @@ def main(args=None):
# Link it statically to avoid propagating that dependency.
cargo_env['RUSTFLAGS'] = '-C target-feature=+crt-static'
abs_build_dir = os.path.abspath(options.cargo_build_dir)
if 'GITHUB_WORKSPACE' in cargo_env and len(abs_build_dir) > 100:
# Avoid long build directory paths on GitHub Actions,
# breaking the old Win32 limit of 260 characters.
# (https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation)
# We don't do this everywhere because it breaks cleaning.
#
# In the long run, Visual Studio's CLI tools will become long-path aware and this should
# become unnecessary.
# It would be nice if using extended-length path syntax `\\?\` was sufficient,
# but that also isn't accepted by all of Visual Studio's CLI tools.
tmpdir = cargo_env['RUNNER_TEMP']
if len(tmpdir) < len(abs_build_dir):
cargo_env['CARGO_BUILD_TARGET_DIR'] = os.path.join(tmpdir, "libsignal")
cmd = subprocess.Popen(cmdline, env=cargo_env)
cmd.wait()
@@ -88,7 +103,7 @@ def main(args=None):
print('ERROR: cargo failed')
return 1
libs_in = os.path.join(options.cargo_build_dir,
libs_in = os.path.join(cargo_env['CARGO_BUILD_TARGET_DIR'],
cargo_target,
configuration_name.lower())