import os
import rtconfig

# Check SDK 
SIFLI_SDK = os.getenv('SIFLI_SDK')
if not SIFLI_SDK:
    print("Please run set_env.bat in root folder of SIFLI SDK to set environment.")
    exit()
from building import *

# Prepare environment.
PrepareEnv()

################################## change rtconfig.xxx to customize build ########################################

# Add bootloader project
AddBootLoader(SIFLI_SDK,rtconfig.CHIP)

# Set default compile options
SifliEnv()

TARGET = rtconfig.OUTPUT_DIR + rtconfig.TARGET_NAME + '.' + rtconfig.TARGET_EXT
# Prepare building environment
objs = PrepareBuilding(None)
env = GetCurrentEnv()

# Build application.
DoBuilding(TARGET, objs)

# Add flash table buld.
AddFTAB(SIFLI_SDK,rtconfig.CHIP)

# Generate download .bat script
GenDownloadScript(env)
