Subversion Repositories idreammicro-avr

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 jlesech 1
"""
2
Build project.
3
"""
4
def BuildProject(env, libraries, sources, target_name):
5
    # Build libraries.
6
    for library in libraries:
7
        SConscript(
8
            '#libraries/' + library + '/SConscript',
9
            exports = { 'env' : env },
10
            duplicate = 0
11
        )
12
 
13
    # Build program.
14
    env.Program(target = target_name + '.elf', source = sources)
15
 
16
    # Create hex binary file.
17
    env.Command(
18
        target_name + '.hex',
19
        target_name + '.elf',
20
        env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
21
    )
22
 
23
AddMethod(Environment, BuildProject)
24
 
25
"""
26
Build library.
27
"""
28
def BuildLibrary(env, sources, target_name):
29
    # Build static library.
30
    env.StaticLibrary(target = target_name, source = sources)
31
 
32
    # Append LIBPATH and LIBS.
33
    env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
34
    env.Append(LIBS = [ target_name ])
35
 
36
AddMethod(Environment, BuildLibrary)
37
 
38
"""
39
Compute memory usage.
40
"""
41
def ComputeMemoryUsage(env, target_name):
42
    # Compute memory usage.
43
    env.Command(
44
        None,
45
        target_name + '.elf',
46
        env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
47
    )
48
 
49
AddMethod(Environment, ComputeMemoryUsage)