import rtconfig
from building import *

# get current directory
cwd = GetCurrentDir()

# The set of source files associated with this SConscript file.

src = Glob('STM32L4xx_HAL_Driver/Src/*.c')
src += Split('''
CMSIS/Device/ST/STM32L4xx/Source/Templates/system_stm32l4xx.c
''')

#add for startup script
if rtconfig.CROSS_TOOL == 'gcc':
     src = src + ['CMSIS/Device/ST/STM32L4xx/Source/Templates/gcc/startup_stm32l476xx.s']
elif rtconfig.CROSS_TOOL == 'keil':
     src = src + ['CMSIS/Device/ST/STM32L4xx/Source/Templates/arm/startup_stm32l476xx.s']
elif rtconfig.CROSS_TOOL == 'iar':
    src = src + ['CMSIS/Device/ST/STM32L4xx/Source/Templates/iar/startup_stm32l476xx.s']

path = [cwd + '/STM32L4xx_HAL_Driver/Inc',
    cwd + '/CMSIS/Device/ST/STM32L4xx/Include',
    cwd + '/CMSIS/Include']

CPPDEFINES = ['STM32L476xx', 'USE_HAL_DRIVER', 'USE_STM32L4XX_NUCLEO', rtconfig.STM32_TYPE]

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

Return('group')