import rtconfig
from building import *

# get current directory
cwd = GetCurrentDir()

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

src = Glob('STM32F3xx_HAL_Driver/Src/*.c')
src += Split('''
CMSIS/Device/ST/STM32F3xx/Source/Templates/system_stm32F3xx.c
''')

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

path = [cwd + '/STM32F3xx_HAL_Driver/Inc',
    cwd + '/CMSIS/Device/ST/STM32F3xx/Include',
    cwd + '/CMSIS/Include']

LOCAL_CCFLAGS = ''
if rtconfig.CROSS_TOOL == 'gcc':
    LOCAL_CCFLAGS += ' -std=c99'
elif rtconfig.CROSS_TOOL == 'keil':
    LOCAL_CCFLAGS += ' --c99'

CPPDEFINES = ['STM32F303xE', 'USE_HAL_DRIVER']

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

Return('group')
