mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
tools/run_node: only create 'node_modules' symlink once
Previously run_node.py would always attempt to remove and then re-create the 'target/xx/node_modules' symlink. This causes sporadic build errors on windows when multiple build targets that use run_node.py are being built concurrently.
This commit is contained in:
parent
860be9f0de
commit
ee29ed79a7
2 changed files with 6 additions and 22 deletions
|
@ -5,15 +5,13 @@ gn can only run python scripts. This launches a subprocess Node process.
|
||||||
The working dir of this program is out/Debug/ (AKA root_build_dir)
|
The working dir of this program is out/Debug/ (AKA root_build_dir)
|
||||||
Before running node, we symlink js/node_modules to out/Debug/node_modules.
|
Before running node, we symlink js/node_modules to out/Debug/node_modules.
|
||||||
"""
|
"""
|
||||||
import subprocess
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
from os import path
|
||||||
from util import remove_and_symlink, root_path, run
|
from util import symlink, root_path, run
|
||||||
|
|
||||||
tools_path = os.path.join(root_path, "tools")
|
if not path.exists("node_modules"):
|
||||||
third_party_path = os.path.join(root_path, "third_party")
|
target_abs = path.join(root_path, "third_party/node_modules")
|
||||||
target_abs = os.path.join(third_party_path, "node_modules")
|
target_rel = path.relpath(target_abs)
|
||||||
target_rel = os.path.relpath(target_abs)
|
symlink(target_rel, "node_modules", True)
|
||||||
|
|
||||||
remove_and_symlink(target_rel, "node_modules", True)
|
|
||||||
run(["node"] + sys.argv[1:], quiet=True)
|
run(["node"] + sys.argv[1:], quiet=True)
|
||||||
|
|
|
@ -93,20 +93,6 @@ def green_ok():
|
||||||
return "%sok%s" % (FG_GREEN, RESET)
|
return "%sok%s" % (FG_GREEN, RESET)
|
||||||
|
|
||||||
|
|
||||||
def remove_and_symlink(target, name, target_is_dir=False):
|
|
||||||
if os.name != "nt" and os.path.islink(name):
|
|
||||||
return
|
|
||||||
try:
|
|
||||||
# On Windows, directory symlink can only be removed with rmdir().
|
|
||||||
if os.name == "nt" and os.path.isdir(name):
|
|
||||||
os.rmdir(name)
|
|
||||||
else:
|
|
||||||
os.unlink(name)
|
|
||||||
except OSError:
|
|
||||||
pass
|
|
||||||
symlink(target, name, target_is_dir)
|
|
||||||
|
|
||||||
|
|
||||||
def symlink(target, name, target_is_dir=False):
|
def symlink(target, name, target_is_dir=False):
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
from ctypes import WinDLL, WinError, GetLastError
|
from ctypes import WinDLL, WinError, GetLastError
|
||||||
|
|
Loading…
Add table
Reference in a new issue