SConstruct 3.1 KB
Newer Older
M
Ming, Bai 已提交
1 2 3 4 5 6 7 8 9 10 11 12
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
    RTT_ROOT = os.getenv('RTT_ROOT')
else:
    RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *

13
env = Environment(TARGET_ARCH='x86')
M
Ming, Bai 已提交
14 15 16 17

Export('RTT_ROOT')
Export('rtconfig')

P
prife 已提交
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
if rtconfig.PLATFORM == 'cl':
    TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT

    libs = Split('''
    winmm
    gdi32
    winspool
    comdlg32
    advapi32
    shell32
    ole32
    oleaut32
    uuid
    odbc32
    odbccp32
    ''')
    definitions = Split('''
    WIN32
    _DEBUG
    _CONSOLE
    MSVC
    ''')
    env.Append(CCFLAGS=rtconfig.CFLAGS)
    env.Append(LINKFLAGS=rtconfig.LFLAGS)
    env['LIBS']=libs
    env['CPPDEFINES']=definitions
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
elif rtconfig.PLATFORM == 'mingw':
    libs = Split('''
        winmm
        gdi32
        winspool
        comdlg32
        advapi32
        shell32
        ole32
        oleaut32
        uuid
        odbc32
        odbccp32
        ''')
    TARGET = 'rtthread-win32.' + rtconfig.TARGET_EXT
    env = Environment(tools = ['mingw'],
        AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
        CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
        AR = rtconfig.AR, ARFLAGS = '-rc',
        LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
    env['LIBS']=libs
    env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
66 67 68 69
elif rtconfig.CROSS_TOOL == 'clang-analyze':
    TARGET = 'rtthread'
    env = Environment(toolpath=[os.path.join(RTT_ROOT, 'tools', 'tools')],
                      tools = [rtconfig.CROSS_TOOL])
P
prife 已提交
70 71
else:
    TARGET = 'rtthread'
72
    env['CC']=rtconfig.CC
P
prife 已提交
73 74
    env.Append(CCFLAGS=rtconfig.CFLAGS)
    env.Append(LINKFLAGS=rtconfig.LFLAGS)
G
Grissiom 已提交
75
    env.Append(LIBS=['m'])
P
prife 已提交
76

M
Ming, Bai 已提交
77 78
# prepare building environment

P
prife 已提交
79
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
M
Ming, Bai 已提交
80

81 82 83 84 85 86 87 88 89 90 91 92 93 94
def ObjRemove(objs, remove):
    for item in objs:
        # print type(item), os.path.basename(str(item))
        if os.path.basename(str(item)) in remove:
             objs.remove(item)
    return

# build program  -shared
if GetDepend('RT_USING_MODULE'):
    # Remove module.c in $RTT_ROOT/src
    ObjRemove(objs, ['module.obj', 'module.o'])

    AddOption('--def',
      dest='def',
95 96 97 98
      action='store_true',
      default=False,
      help='create rthread.def of rtthread.dll on windows')
    if GetOption('def'):
99 100 101 102
        if rtconfig.PLATFORM == 'mingw':
            env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
        else:
            rtconfig.POST_ACTION = 'createdef.py $TARGET rtthread.def'
103

104
        program = env.Program(TARGET, objs)
105
    else:
106 107
        if rtconfig.PLATFORM == 'cl':
            objs += ['rtthread.def']
108 109 110
        elif rtconfig.PLATFORM == 'mingw':
            rtconfig.POST_ACTION = 'del /Q rtthread.lib \n rename librtthread.a rtthread.lib\n'
            # rtconfig.POST_ACTION = 'lib /machine:i386 /def:rtthread.def /out:rtthread.lib'
111 112 113 114 115
        env.SharedLibrary("rtthread.dll", objs)
        program = env.Program(TARGET, 'dummy.c', LIBS='rtthread', LIBPATH='.')

else:
    program = env.Program(TARGET, objs)
M
Ming, Bai 已提交
116 117 118

# end building
EndBuilding(TARGET, program)