2023-05-09 22:30:49 +08:00
|
|
|
|
import os
|
|
|
|
|
import sys
|
|
|
|
|
import rtconfig
|
|
|
|
|
|
|
|
|
|
if os.getenv('RTT_ROOT'):
|
|
|
|
|
RTT_ROOT = 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 *
|
|
|
|
|
except:
|
|
|
|
|
print('Cannot found RT-Thread root directory, please check RTT_ROOT')
|
|
|
|
|
print(RTT_ROOT)
|
|
|
|
|
exit(-1)
|
|
|
|
|
|
|
|
|
|
TARGET = 'rt-thread.' + rtconfig.TARGET_EXT
|
|
|
|
|
|
|
|
|
|
# Enviroment包含了编译过程用到的工具
|
|
|
|
|
DefaultEnvironment(tools=[])
|
|
|
|
|
env = Environment(tools = ['mingw'],
|
|
|
|
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
|
|
|
|
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
|
|
|
|
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
|
|
|
|
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
|
|
|
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
|
|
|
|
|
|
|
|
|
# 向环境变量中添加路径
|
|
|
|
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
|
|
|
|
|
|
|
|
|
if rtconfig.PLATFORM in ['iccarm']:
|
|
|
|
|
env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
|
|
|
|
|
env.Replace(ARFLAGS = [''])
|
|
|
|
|
env.Replace(LINKCOM = env["LINKCOM"] + ' --map rt-thread.map')
|
|
|
|
|
|
|
|
|
|
Export('RTT_ROOT')
|
|
|
|
|
Export('rtconfig')
|
|
|
|
|
|
|
|
|
|
# 添加依赖库函数
|
|
|
|
|
SDK_ROOT = os.path.abspath('.')
|
|
|
|
|
if os.path.exists(SDK_ROOT + '/libraries'):
|
|
|
|
|
libraries_path_prefix = SDK_ROOT + '/libraries'
|
|
|
|
|
else:
|
|
|
|
|
libraries_path_prefix = os.path.dirname(SDK_ROOT) + '/libraries'
|
|
|
|
|
|
|
|
|
|
SDK_LIB = libraries_path_prefix
|
|
|
|
|
Export('SDK_LIB')
|
|
|
|
|
|
2023-05-10 14:45:15 +08:00
|
|
|
|
# 准备编译环境,并输出rtt的编译文件,prepare building environment
|
2023-05-09 22:30:49 +08:00
|
|
|
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
|
|
|
|
|
|
2023-05-10 11:34:01 +08:00
|
|
|
|
# 设置stm32驱动库路径
|
2023-05-09 22:30:49 +08:00
|
|
|
|
stm32_library = 'STM32F1xx_HAL'
|
|
|
|
|
rtconfig.BSP_LIBRARY_TYPE = stm32_library
|
|
|
|
|
|
2023-05-10 14:45:15 +08:00
|
|
|
|
# 编译libraries include libraries
|
2023-05-09 22:30:49 +08:00
|
|
|
|
objs.extend(SConscript(os.path.join(libraries_path_prefix, stm32_library, 'SConscript')))
|
|
|
|
|
|
2023-05-10 14:45:15 +08:00
|
|
|
|
# 编译driver include drivers
|
2023-05-09 22:30:49 +08:00
|
|
|
|
objs.extend(SConscript(os.path.join(libraries_path_prefix, 'HAL_Drivers', 'SConscript')))
|
|
|
|
|
|
2023-05-10 14:45:15 +08:00
|
|
|
|
# 将所有编译完成的.o文件链接成为program,make a building
|
2023-05-09 22:30:49 +08:00
|
|
|
|
DoBuilding(TARGET, objs)
|