2022-11-10 22:22:48 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import rtconfig
|
2023-11-21 17:42:23 +08:00
|
|
|
import subprocess
|
2022-11-10 22:22:48 +08:00
|
|
|
|
|
|
|
IS_EXPORTED = False
|
|
|
|
|
|
|
|
# setup RT-Thread Root Path
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
|
|
|
else:
|
|
|
|
RTT_ROOT = os.getcwd() + '/../../..'
|
|
|
|
|
|
|
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
|
|
|
try:
|
|
|
|
from building import *
|
|
|
|
except:
|
|
|
|
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
|
|
|
|
print(RTT_ROOT)
|
|
|
|
exit(-1)
|
|
|
|
|
|
|
|
if RTT_ROOT == 'rt-thread':
|
|
|
|
IS_EXPORTED = True # if kenrel and bsp has been exported by export_project.py
|
|
|
|
|
|
|
|
# setup Phytium BSP Root Path
|
|
|
|
if IS_EXPORTED:
|
|
|
|
BSP_ROOT = '.'
|
|
|
|
else:
|
|
|
|
BSP_ROOT = RTT_ROOT + '/bsp/phytium'
|
|
|
|
|
|
|
|
TARGET = 'rtthread_a32.' + rtconfig.TARGET_EXT
|
|
|
|
|
|
|
|
DefaultEnvironment(tools=[])
|
|
|
|
env = Environment(tools = ['mingw'],
|
|
|
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
|
|
|
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
|
|
|
|
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
|
|
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
|
|
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
|
|
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
|
|
|
env['ASCOM'] = env['ASPPCOM']
|
|
|
|
|
|
|
|
Export('RTT_ROOT')
|
|
|
|
Export('BSP_ROOT')
|
|
|
|
Export('rtconfig')
|
|
|
|
|
2023-11-21 17:42:23 +08:00
|
|
|
def is_phytium_sdk_installed():
|
|
|
|
py_target_folder = os.getcwd() + "/../libraries/phytium_standalone_sdk"
|
|
|
|
return os.path.exists(py_target_folder)
|
|
|
|
|
|
|
|
def install_phytium_sdk():
|
|
|
|
if is_phytium_sdk_installed():
|
|
|
|
return 0
|
|
|
|
print("Checking for the presence of phytium_standalone_sdk_install.py script...")
|
|
|
|
sconstruct_dir = os.getcwd()
|
|
|
|
install_script_path = os.path.join(sconstruct_dir, "phytium_standalone_sdk_install.py")
|
2023-12-08 17:57:55 +08:00
|
|
|
if os.path.exists(install_script_path):
|
|
|
|
subprocess.call(["rm","-rf", install_script_path])
|
2023-11-21 17:42:23 +08:00
|
|
|
|
|
|
|
try:
|
|
|
|
subprocess.call(["wget", "https://gitee.com/phytium_embedded/phytium-standalone-sdk/raw/Standalone-Sdk_RT-thread/phytium_standalone_sdk_install.py"])
|
|
|
|
except:
|
|
|
|
print("Please refer to the ./README and manual download phytium_standalone_sdk_install.py, place in current folder")
|
|
|
|
if os.path.exists(install_script_path):
|
|
|
|
try:
|
|
|
|
subprocess.call(["python", install_script_path])
|
|
|
|
except:
|
|
|
|
subprocess.call(["python3", install_script_path])
|
|
|
|
|
|
|
|
if not is_phytium_sdk_installed():
|
|
|
|
print("Error: phytium_standalone_sdk install failed")
|
|
|
|
exit(0)
|
|
|
|
else:
|
|
|
|
print("Error: phytium_standalone_sdk_install.py is not exists, exit compilation")
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
install_phytium_sdk()
|
|
|
|
|
2022-11-10 22:22:48 +08:00
|
|
|
# prepare building environment
|
|
|
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
|
|
|
|
|
|
|
|
if not IS_EXPORTED: # if project is not exported, libraries and board need to manually add
|
|
|
|
# include libraries
|
|
|
|
objs.extend(SConscript(os.path.join(BSP_ROOT + '/libraries', 'SConscript')))
|
|
|
|
|
|
|
|
# include board
|
|
|
|
objs.extend(SConscript(os.path.join(BSP_ROOT + '/board', 'SConscript')))
|
|
|
|
|
2023-05-11 10:25:21 +08:00
|
|
|
if GetDepend('RT_USING_SMART'):
|
|
|
|
# use smart link.lds
|
|
|
|
env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds')
|
|
|
|
|
2022-11-10 22:22:48 +08:00
|
|
|
# make a building
|
|
|
|
DoBuilding(TARGET, objs)
|
|
|
|
|