2022-06-26 15:00:03 +03:00
|
|
|
import SCons
|
|
|
|
from SCons.Subst import quote_spaces
|
2022-07-14 19:24:26 +03:00
|
|
|
from SCons.Errors import StopError
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
import re
|
2022-06-30 19:06:12 +03:00
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import string
|
2022-06-26 15:00:03 +03:00
|
|
|
|
|
|
|
WINPATHSEP_RE = re.compile(r"\\([^\"'\\]|$)")
|
|
|
|
|
|
|
|
|
|
|
|
def tempfile_arg_esc_func(arg):
|
|
|
|
arg = quote_spaces(arg)
|
|
|
|
if SCons.Platform.platform_default() != "win32":
|
|
|
|
return arg
|
|
|
|
# GCC requires double Windows slashes, let's use UNIX separator
|
|
|
|
return WINPATHSEP_RE.sub(r"/\1", arg)
|
|
|
|
|
|
|
|
|
|
|
|
def wrap_tempfile(env, command):
|
|
|
|
env[command] = '${TEMPFILE("' + env[command] + '","$' + command + 'STR")}'
|
2022-06-30 19:06:12 +03:00
|
|
|
|
|
|
|
|
|
|
|
def link_dir(target_path, source_path, is_windows):
|
|
|
|
# print(f"link_dir: {target_path} -> {source_path}")
|
|
|
|
if os.path.lexists(target_path) or os.path.exists(target_path):
|
|
|
|
os.unlink(target_path)
|
|
|
|
if is_windows:
|
|
|
|
# Crete junction
|
|
|
|
import _winapi
|
|
|
|
|
|
|
|
if not os.path.isdir(source_path):
|
2022-07-14 19:24:26 +03:00
|
|
|
raise StopError(f"Source directory {source_path} is not a directory")
|
2022-06-30 19:06:12 +03:00
|
|
|
|
|
|
|
if not os.path.exists(target_path):
|
|
|
|
_winapi.CreateJunction(source_path, target_path)
|
|
|
|
else:
|
|
|
|
os.symlink(source_path, target_path)
|
|
|
|
|
|
|
|
|
2022-07-04 19:53:04 +03:00
|
|
|
def single_quote(arg_list):
|
|
|
|
return " ".join(f"'{arg}'" if " " in arg else str(arg) for arg in arg_list)
|