Subversion Repositories idreammicro-avr

Rev

Blame | Last modification | View Log | Download | RSS feed

"""
Build project.
"""

def BuildProject(env, libraries, sources, target_name):
    # Build libraries.
    for library in libraries:
        SConscript(
            '#libraries/' + library + '/SConscript',
            exports = { 'env' : env },
            duplicate = 0
        )
   
    # Build program.
    env.Program(target = target_name + '.elf', source = sources)
   
    # Create hex binary file.
    env.Command(
        target_name + '.hex',
        target_name + '.elf',
        env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
    )
   
AddMethod(Environment, BuildProject)

"""
Build library.
"""

def BuildLibrary(env, sources, target_name):
    # Build static library.
    env.StaticLibrary(target = target_name, source = sources)
   
    # Append LIBPATH and LIBS.
    env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
    env.Append(LIBS = [ target_name ])

AddMethod(Environment, BuildLibrary)

"""
Compute memory usage.
"""

def ComputeMemoryUsage(env, target_name):
    # Compute memory usage.
    env.Command(
        None,
        target_name + '.elf',
        env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
    )
   
AddMethod(Environment, ComputeMemoryUsage)