'''
Description: 
Date: 2022-01-06 14:31:32
LastEditors: CK.Zh
LastEditTime: 2022-01-10 11:30:42
FilePath: /rt-thread/bsp/hc32l073/Libraries/SConscript
'''
# RT-Thread building script for bridge

import rtconfig
Import('RTT_ROOT')
from building import *

# get current directory
cwd = GetCurrentDir()

# The set of source files associated with this SConscript file.
# src = Split("""
# HC32L073_StdPeriph_Driver/src/adc.c
# HC32L073_StdPeriph_Driver/src/gpio.c
# HC32L073_StdPeriph_Driver/src/uart.c
# HC32L073_StdPeriph_Driver/src/lpuart.c
# HC32L073_StdPeriph_Driver/src/rtc.c
# HC32L073_StdPeriph_Driver/src/sysctrl.c
# HC32L073_StdPeriph_Driver/src/timer3.c
# HC32L073_StdPeriph_Driver/src/trim.c
# HC32L073_StdPeriph_Driver/src/flash.c
# HC32L073_StdPeriph_Driver/src/ddl.c
# CMSIS/Device/HDSC/HC32L073/Source/system_hc32l07x.c
# CMSIS/Device/HDSC/HC32L073/Source/interrupts_hc32l07x.c
# """)

src = Glob('HC32L073_StdPeriph_Driver/src/*.c')
src += Glob('CMSIS/Device/HDSC/HC32L073/Source/*.c')

if GetDepend(['RT_USING_WDT']):
    src += ['HC32L073_StdPeriph_Driver/src/wdt.c']

#add for startup script 
if rtconfig.CROSS_TOOL == 'gcc':
    src = src + ['CMSIS/Device/HDSC/HC32L073/Source/GCC/startup_hc32l07x.s']
elif rtconfig.CROSS_TOOL == 'keil':
    src = src + ['CMSIS/Device/HDSC/HC32L073/Source/ARM/startup_hc32l07x.s']
elif rtconfig.CROSS_TOOL == 'iar':
    src = src + ['CMSIS/Device/HDSC/HC32L073/Source/IAR/startup_hc32l07x.s']

#add headfile script 
path = [cwd + '/CMSIS/Include', 
    cwd + '/CMSIS/Device/HDSC/HC32L073/Include',
    cwd + '/HC32L073_StdPeriph_Driver/inc']

CPPDEFINES = ['USE_DDL_DRIVER', rtconfig.MCU_TYPE, '__DEBUG']

group = DefineGroup('HC32_StdPeriph', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

Return('group')
