from building import *
import os

cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.S')
path = [cwd]

def recursive_listdir(dir):
    global path
    path += [dir]

    files = os.listdir(dir)

    for file in files:
        file_path = os.path.join(dir, file)

        if os.path.isfile(file_path):
            if file.endswith('.c') or file.endswith('.S'):
                rel_path = os.path.relpath(file_path, cwd)
                global src
                src += Glob(rel_path)
        elif os.path.isdir(file_path):
            recursive_listdir(file_path)

# 定义编译组
group = DefineGroup('Soc', src, depend=[''], CPPPATH=path)

Return('group')
