2009-12-11 17:42:01 +08:00
|
|
|
import os
|
2010-04-19 13:42:12 +08:00
|
|
|
import sys
|
2009-12-11 17:42:01 +08:00
|
|
|
import rtconfig
|
|
|
|
|
|
|
|
RTT_ROOT = os.path.normpath(os.getcwd() + '/../..')
|
2010-04-19 13:42:12 +08:00
|
|
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
|
|
|
import mdk
|
|
|
|
|
2009-12-18 14:06:42 +08:00
|
|
|
target = 'rtthread-mini2440'
|
2010-04-19 13:42:12 +08:00
|
|
|
projects = []
|
|
|
|
|
|
|
|
AddOption('--target',
|
|
|
|
dest='target',
|
|
|
|
type='string',
|
|
|
|
help='set target project: mdk')
|
2009-12-11 17:42:01 +08:00
|
|
|
|
2010-04-19 13:42:12 +08:00
|
|
|
if GetOption('target'):
|
|
|
|
SetOption('no_exec', 1)
|
2009-12-11 17:42:01 +08:00
|
|
|
|
2010-08-03 16:50:06 +08:00
|
|
|
TARGET = target + '.' + rtconfig.TARGET_EXT
|
|
|
|
|
2009-12-11 17:42:01 +08:00
|
|
|
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.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
|
|
|
|
|
|
|
Export('env')
|
|
|
|
Export('RTT_ROOT')
|
|
|
|
Export('rtconfig')
|
2010-04-19 13:42:12 +08:00
|
|
|
Export('projects')
|
2010-08-03 16:50:06 +08:00
|
|
|
Export('TARGET')
|
|
|
|
|
|
|
|
if env['PLATFORM'] == 'win32' and rtconfig.PLATFORM == 'gcc':
|
|
|
|
import win32file
|
|
|
|
import win32event
|
|
|
|
import win32process
|
|
|
|
import win32security
|
|
|
|
|
|
|
|
def my_spawn(sh, escape, cmd, args, spawnenv):
|
|
|
|
for var in spawnenv:
|
|
|
|
spawnenv[var] = spawnenv[var].encode('ascii', 'replace')
|
|
|
|
|
|
|
|
sAttrs = win32security.SECURITY_ATTRIBUTES()
|
|
|
|
StartupInfo = win32process.STARTUPINFO()
|
|
|
|
newargs = ' '.join(map(escape, args[1:]))
|
|
|
|
cmdline = cmd + " " + newargs
|
|
|
|
|
|
|
|
# check for any special operating system commands
|
|
|
|
if cmd == 'del':
|
|
|
|
for arg in args[1:]:
|
|
|
|
win32file.DeleteFile(arg)
|
|
|
|
exit_code = 0
|
|
|
|
else:
|
|
|
|
# otherwise execute the command.
|
|
|
|
hProcess, hThread, dwPid, dwTid = win32process.CreateProcess(None, cmdline, None, None, 1, 0, spawnenv, None, StartupInfo)
|
|
|
|
win32event.WaitForSingleObject(hProcess, win32event.INFINITE)
|
|
|
|
exit_code = win32process.GetExitCodeProcess(hProcess)
|
|
|
|
win32file.CloseHandle(hProcess);
|
|
|
|
win32file.CloseHandle(hThread);
|
|
|
|
return exit_code
|
|
|
|
|
|
|
|
env['SPAWN'] = my_spawn
|
2009-12-11 17:42:01 +08:00
|
|
|
|
|
|
|
objs = SConscript(RTT_ROOT + '/src/SConscript', variant_dir='build/src', duplicate=0)
|
|
|
|
objs = objs + SConscript(RTT_ROOT + '/libcpu/SConscript', variant_dir='build/libcpu', duplicate=0)
|
|
|
|
|
2010-01-10 23:15:27 +08:00
|
|
|
if rtconfig.RT_USING_WEBSERVER:
|
2010-04-19 13:42:12 +08:00
|
|
|
objs = objs + SConscript(RTT_ROOT + '/components/net/webserver/SConscript', variant_dir='build/net/webserver', duplicate=0)
|
2010-01-10 23:15:27 +08:00
|
|
|
|
2009-12-27 21:17:09 +08:00
|
|
|
if rtconfig.RT_USING_RTGUI:
|
2010-02-01 07:51:09 +08:00
|
|
|
objs = objs + SConscript(RTT_ROOT + '/examples/gui/SConscript', variant_dir='build/examples/gui', duplicate=0)
|
2009-12-27 21:17:09 +08:00
|
|
|
|
2010-04-19 13:42:12 +08:00
|
|
|
# board build script
|
|
|
|
objs = objs + SConscript('SConscript', variant_dir='build/bsp', duplicate=0)
|
2009-12-29 23:08:26 +08:00
|
|
|
|
2010-04-19 13:42:12 +08:00
|
|
|
# component script
|
|
|
|
Repository(RTT_ROOT)
|
|
|
|
objs = objs + SConscript('components/SConscript')
|
2009-12-11 17:42:01 +08:00
|
|
|
|
|
|
|
env.Program(TARGET, objs)
|
|
|
|
env.AddPostAction(TARGET, rtconfig.POST_ACTION)
|
2010-04-16 14:19:24 +08:00
|
|
|
|
2010-04-19 13:42:12 +08:00
|
|
|
if GetOption('target') == 'mdk':
|
2010-04-19 13:54:21 +08:00
|
|
|
mdk.MDKProject('project.uV2', projects)
|