mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-25 04:03:07 +00:00
6b6ea44802
* fbt: added separate script for Windows env setup; moved flash targets from firmware.scons to SConstruct; added Blackmagic support with automatic probe port resolution; added apps.c rebuild on any manifest.fam changes; fixed simultaneous flash & debug ops * fbt: added networked BlackmagicResolver mode; added `get_blackmagic` target for IDE integration * fbt: cleanup * fbt: docs update; fixed blackmagic lookup on certain usb hubs * fbt: removed explicit python serial port import * fbt: cleanup * fbt: raising exception on multiple serial blackmagic probes
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import SCons
|
|
from SCons.Subst import quote_spaces
|
|
|
|
import re
|
|
import os
|
|
import random
|
|
import string
|
|
|
|
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")}'
|
|
|
|
|
|
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):
|
|
raise Exception(f"Source directory {source_path} is not a directory")
|
|
|
|
if not os.path.exists(target_path):
|
|
_winapi.CreateJunction(source_path, target_path)
|
|
else:
|
|
os.symlink(source_path, target_path)
|
|
|
|
|
|
def random_alnum(length):
|
|
return "".join(
|
|
random.choice(string.ascii_letters + string.digits) for _ in range(length)
|
|
)
|
|
|
|
|
|
def single_quote(arg_list):
|
|
return " ".join(f"'{arg}'" if " " in arg else str(arg) for arg in arg_list)
|