From ec4faf2601638bb092cb32a70ee6d67cee5b8afd Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Mon, 27 Jun 2022 11:37:32 -0700 Subject: [PATCH] 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. --- node/build_node_bridge.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/node/build_node_bridge.py b/node/build_node_bridge.py index 9d86dbee4..334e35f06 100755 --- a/node/build_node_bridge.py +++ b/node/build_node_bridge.py @@ -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())