summaryrefslogtreecommitdiff
path: root/bsp/simulator
diff options
context:
space:
mode:
authorbernard <[email protected]>2013-09-17 11:07:36 +0800
committerbernard <[email protected]>2013-09-17 11:07:36 +0800
commit0bf7ed76cff8071718f50ebeb68ba3bb2544a7cb (patch)
tree81db6eaa0424dc1c10355b5b4c8fe56c763c1cfd /bsp/simulator
parent77096894f9d53cb0742adb5330fed4966e956cd1 (diff)
parent47c152ee7fdcf8b101a08bacebbafb52d2c8d3a7 (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'bsp/simulator')
-rwxr-xr-xbsp/simulator/SConstruct11
-rwxr-xr-xbsp/simulator/applications/application.c6
-rw-r--r--bsp/simulator/applications/platform.c5
-rw-r--r--bsp/simulator/drivers/SConscript14
-rwxr-xr-xbsp/simulator/drivers/sdl_fb.c18
-rwxr-xr-xbsp/simulator/rtconfig.py15
6 files changed, 50 insertions, 19 deletions
diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct
index af6534906b..4db7328f2a 100755
--- a/bsp/simulator/SConstruct
+++ b/bsp/simulator/SConstruct
@@ -73,6 +73,10 @@ elif rtconfig.PLATFORM == 'mingw':
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env['LIBS']=libs
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
+elif rtconfig.CROSS_TOOL == 'clang-analyze':
+ TARGET = 'rtthread'
+ env = Environment(toolpath=[os.path.join(RTT_ROOT, 'tools', 'tools')],
+ tools = [rtconfig.CROSS_TOOL])
else:
TARGET = 'rtthread'
env['CC']=rtconfig.CC
@@ -84,13 +88,6 @@ else:
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',
diff --git a/bsp/simulator/applications/application.c b/bsp/simulator/applications/application.c
index 4abecb872e..ea07f01c5f 100755
--- a/bsp/simulator/applications/application.c
+++ b/bsp/simulator/applications/application.c
@@ -30,6 +30,12 @@ void rt_init_thread_entry(void *parameter)
/* initialization RT-Thread Components */
rt_components_init();
+#ifdef RT_USING_RTGUI
+ /* start sdl thread to simulate an LCD. SDL may depend on DFS and should be
+ * called after rt_components_init. */
+ rt_hw_sdl_start();
+#endif /* RT_USING_RTGUI */
+
#if defined(RT_USING_COMPONENTS_INIT) && defined(__GNUC__) && defined(RT_USING_FINSH)
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
#endif
diff --git a/bsp/simulator/applications/platform.c b/bsp/simulator/applications/platform.c
index 3c7ffdb541..fbc1003d2a 100644
--- a/bsp/simulator/applications/platform.c
+++ b/bsp/simulator/applications/platform.c
@@ -17,11 +17,6 @@ void rt_platform_init(void)
#endif /* RT_USING_DFS */
-#ifdef RT_USING_RTGUI
- /* start sdl thread to simulate an LCD */
- rt_hw_sdl_start();
-#endif /* RT_USING_RTGUI */
-
#ifdef _WIN32
rt_thread_idle_sethook(rt_hw_win32_low_cpu);
#endif
diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript
index d939535da8..eb491b810e 100644
--- a/bsp/simulator/drivers/SConscript
+++ b/bsp/simulator/drivers/SConscript
@@ -3,10 +3,19 @@ from building import *
cwd = GetCurrentDir()
src = Glob('*.c')
+LIBS = []
+LIBPATH = []
+CPPPATH = [cwd]
# remove no need file.
if GetDepend('RT_USING_RTGUI') == False:
SrcRemove(src, 'sdl_fb.c')
+else:
+ LIBS.append('SDL')
+ if sys.platform == 'win32':
+ LIBPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/lib/x86')))
+ CPPPATH.append(os.path.abspath(os.path.join(cwd, '../SDL/include')))
+
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_DFS_ELMFAT') == False:
SrcRemove(src, 'sd_sim.c')
if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MTD_NAND') == False:
@@ -20,8 +29,7 @@ if GetDepend('RT_USING_MODULE') == False:
if sys.platform[0:5]=="linux": #check whether under linux
SrcRemove(src, ['module_win32.c', 'dfs_win32.c'])
-CPPPATH = [cwd]
-
-group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
+group = DefineGroup('Drivers', src, depend = [''],
+ CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH)
Return('group')
diff --git a/bsp/simulator/drivers/sdl_fb.c b/bsp/simulator/drivers/sdl_fb.c
index d7ebbc8245..78bca6f07f 100755
--- a/bsp/simulator/drivers/sdl_fb.c
+++ b/bsp/simulator/drivers/sdl_fb.c
@@ -152,8 +152,12 @@ static void sdlfb_hw_init(void)
#ifdef _WIN32
static HANDLE sdl_ok_event = NULL;
+
static DWORD WINAPI sdl_loop(LPVOID lpParam)
#else
+static pthread_mutex_t sdl_ok_mutex;
+static pthread_cond_t sdl_ok_event;
+
static void *sdl_loop(void *lpParam)
#endif
{
@@ -167,14 +171,19 @@ static void *sdl_loop(void *lpParam)
/* set the getchar without buffer */
sigfillset(&sigmask);
pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
+ pthread_mutex_lock(&sdl_ok_mutex);
#endif
sdlfb_hw_init();
device = rt_device_find("sdl");
+ RT_ASSERT(device);
rtgui_graphic_set_device(device);
#ifdef _WIN32
SetEvent(sdl_ok_event);
+#else
+ pthread_cond_signal(&sdl_ok_event);
+ pthread_mutex_unlock(&sdl_ok_mutex);
#endif
/* handle SDL event */
while (!quit)
@@ -338,11 +347,20 @@ void rt_hw_sdl_start(void)
/* Linux */
pthread_t pid;
int res;
+
+ pthread_mutex_init(&sdl_ok_mutex, NULL);
+ pthread_cond_init(&sdl_ok_event, NULL);
+
res = pthread_create(&pid, NULL, &sdl_loop, NULL);
if (res)
{
printf("pthread create sdl thread faild, <%d>\n", res);
exit(EXIT_FAILURE);
}
+ pthread_mutex_lock(&sdl_ok_mutex);
+ pthread_cond_wait(&sdl_ok_event, &sdl_ok_mutex);
+
+ pthread_mutex_destroy(&sdl_ok_mutex);
+ pthread_cond_destroy(&sdl_ok_event);
#endif
}
diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py
index 7a42bddbcf..d3ed2599d5 100755
--- a/bsp/simulator/rtconfig.py
+++ b/bsp/simulator/rtconfig.py
@@ -1,3 +1,5 @@
+import os
+
# toolchains options
ARCH='sim'
#CROSS_TOOL='msvc' or 'gcc' or 'mingw'
@@ -5,12 +7,15 @@ ARCH='sim'
# 'gcc' is for linux
CROSS_TOOL='msvc'
+if os.getenv('RTT_CC'):
+ CROSS_TOOL = os.getenv('RTT_CC')
+
# cross_tool provides the cross compiler
# EXEC_PATH is the compiler execute path
-if CROSS_TOOL == 'gcc':
+if CROSS_TOOL == 'gcc' or CROSS_TOOL == 'clang-analyze':
CPU = 'posix'
PLATFORM = 'gcc'
- EXEC_PATH = '/usr/bin/gcc'
+ EXEC_PATH = ''
elif CROSS_TOOL == 'mingw':
CPU = 'win32'
@@ -21,11 +26,13 @@ elif CROSS_TOOL == 'msvc':
CPU = 'win32'
PLATFORM = 'cl'
EXEC_PATH = ''
-
-else :
+else:
print "bad CROSS TOOL!"
exit(1)
+if os.getenv('RTT_EXEC_PATH'):
+ EXEC_PATH = os.getenv('RTT_EXEC_PATH')
+
BUILD = 'debug'
#BUILD = ''