Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions bsp/tm4c123bsp/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ if os.getenv('RTT_ROOT'):
else:
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')

# set RTT_ROOT
#if not os.getenv("RTT_ROOT"):
#RTT_ROOT="rt-thread"

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
try:
from building import *
Expand Down
30 changes: 20 additions & 10 deletions tools/mkdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ def do_copy_file(src, dst):
shutil.copy2(src, dst)

def do_copy_folder(src_dir, dst_dir, ignore=None):
import shutil
import shutil, stat

def _remove_readonly(func, path, excinfo):
os.chmod(path, stat.S_IWRITE)
func(path)

# check source directory
if not os.path.exists(src_dir):
return

try:
if os.path.exists(dst_dir):
shutil.rmtree(dst_dir)
except:
print('Deletes folder: %s failed.' % dst_dir)
shutil.rmtree(dst_dir, onerror = _remove_readonly)
except Exception as e:
print('Deletes folder: %s failed: %s\n' % (dst_dir, e))
return

shutil.copytree(src_dir, dst_dir, ignore = ignore)
Expand Down Expand Up @@ -102,14 +107,19 @@ def bsp_copy_files(bsp_root, dist_dir):
ignore_patterns('build', '__pycache__', 'dist', '*.pyc', '*.old', '*.map', 'rtthread.bin', '.sconsign.dblite', '*.elf', '*.axf', 'cconfig.h'))

def bsp_update_sconstruct(dist_dir):
with open(os.path.join(dist_dir, 'SConstruct'), 'r') as f:
sconstruct_path = os.path.join(dist_dir, 'SConstruct')
with open(sconstruct_path, 'r') as f:
data = f.readlines()
with open(os.path.join(dist_dir, 'SConstruct'), 'w') as f:
# idempotency: skip when the injection is already effective. Match only the uncommented
# form, because some BSPs ship a commented-out copy of this block as source residue, and
# treating it as injected would leave the dist project RTT_ROOT pointing at the BSP dir.
if any(line.lstrip().startswith('if not os.getenv("RTT_ROOT"):') for line in data):
return
with open(sconstruct_path, 'w') as f:
for line in data:
if line.find('RTT_ROOT') != -1:
if line.find('sys.path') != -1:
f.write('# set RTT_ROOT\n')
f.write('if not os.getenv("RTT_ROOT"): \n RTT_ROOT="rt-thread"\n\n')
if line.find('RTT_ROOT') != -1 and line.find('sys.path') != -1:
f.write('# set RTT_ROOT\n')
f.write('if not os.getenv("RTT_ROOT"): \n RTT_ROOT="rt-thread"\n\n')
f.write(line)

def bsp_update_kconfig_testcases(dist_dir):
Expand Down
Loading