SConstruct 2.9 KB
Newer Older
M
Ming, Bai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
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() + '/../..')

if os.getenv('RTT_RTGUI'):
    RTT_RTGUI = os.getenv('RTT_RTGUI')
else:
    # set the rtgui root directory by hand
    # empty string means use the RTGUI in svn
P
prife 已提交
15 16
    RTT_RTGUI = os.path.normpath(r'F:\Project\git\rt-gui\components\rtgui')
    # RTT_RTGUI =''
M
Ming, Bai 已提交
17 18 19 20 21 22 23 24 25 26

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


env = Environment()

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

P
prife 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
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
    _TIME_T_DEFINED
    ''')
    env.Append(CCFLAGS=rtconfig.CFLAGS)
    env.Append(LINKFLAGS=rtconfig.LFLAGS)
    env['LIBS']=libs
    env['CPPDEFINES']=definitions
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
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)
P
prife 已提交
76 77 78 79
else:
    TARGET = 'rtthread'
    env.Append(CCFLAGS=rtconfig.CFLAGS)
    env.Append(LINKFLAGS=rtconfig.LFLAGS)
G
Grissiom 已提交
80
    env.Append(LIBS=['m'])
P
prife 已提交
81

M
Ming, Bai 已提交
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
# prepare building environment

objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False, remove_components=['rtgui'])
if GetDepend('RT_USING_RTGUI'):
    sdl_lib = ['SDL', 'SDLmain']
    sdl_lib_path = [os.path.abspath('SDL/lib/x86')]
    sdl_include_path = [os.path.abspath('SDL/include')]
    env.Append(LIBS=sdl_lib)
    env.Append(LIBPATH=sdl_lib_path)
    env.Append(CPPPATH=sdl_include_path)

    if RTT_RTGUI:
        objs += SConscript(os.path.join(RTT_RTGUI, 'SConscript'),
						   variant_dir='build/components/rtgui',
						   duplicate=0)
        objs = objs + SConscript(RTT_RTGUI+'/../../demo/examples/SConscript', 
				variant_dir='build/examples/gui', duplicate=0)
    else:
        objs += SConscript(os.path.join(RTT_ROOT + '/components/rtgui', 'SConscript'),
						   variant_dir='build/components/rtgui',
						   duplicate=0)
        objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', 
				variant_dir='build/examples/gui', duplicate=0)

if GetDepend('RT_USING_TC'):
    objs = objs + SConscript(RTT_ROOT + '/examples/kernel/SConscript', variant_dir = 'build/tc/kernel', duplicate=0)

# build program 
program = env.Program(TARGET, objs)

# end building
EndBuilding(TARGET, program)