summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprife <[email protected]>2013-02-27 00:37:57 +0800
committerprife <[email protected]>2013-02-27 00:37:57 +0800
commita64ec10e68cbc17db2aaf736205cda2ada45ac65 (patch)
tree161c30f2da7bd289b104a86d5393a3263817c3eb
parent242574a36ff05d6d109c09144b6f7fab8c88c407 (diff)
app module support for simlator, first version
-rwxr-xr-xbsp/simulator/SConstruct41
-rw-r--r--bsp/simulator/applications/SConscript2
-rw-r--r--bsp/simulator/applications/dfs_win32.c8
-rw-r--r--bsp/simulator/dummy.c4
-rwxr-xr-xbsp/simulator/rtconfig.h3
-rwxr-xr-xbsp/simulator/rtconfig.py6
-rw-r--r--include/rtm.h5
7 files changed, 64 insertions, 5 deletions
diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct
index 875bef1e3a..6f35921ba9 100755
--- a/bsp/simulator/SConstruct
+++ b/bsp/simulator/SConstruct
@@ -106,8 +106,45 @@ if GetDepend('RT_USING_RTGUI'):
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)
+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',
+ nargs=1, type='string',
+ action='store',
+ metavar='DIR',
+ help='installation prefix')
+ res = GetOption('def')
+ if res is None:
+ program = env.Program(TARGET, objs)
+ elif res == 'update':
+ env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
+ env.SharedLibrary("rtthread.dll", objs)
+ program = ''
+ elif res == 'yes':
+ if rtconfig.PLATFORM == 'cl':
+ objs += ['rtthread.def']
+ env.SharedLibrary("rtthread.dll", objs)
+ program = env.Program(TARGET, 'dummy.c', LIBS='rtthread', LIBPATH='.')
+ else:
+ print "bad arguments, you can use the following command:"
+ print "\t --def=update to create .def"
+ print "\t --def=yes to create final exe"
+ exit()
+
+else:
+ # env.SharedLibrary("rtthread.dll", objs)
+ program = env.Program(TARGET, objs)
# end building
EndBuilding(TARGET, program)
diff --git a/bsp/simulator/applications/SConscript b/bsp/simulator/applications/SConscript
index 828b49f77f..6dbd985812 100644
--- a/bsp/simulator/applications/SConscript
+++ b/bsp/simulator/applications/SConscript
@@ -6,6 +6,8 @@ src = Glob('*.c')
# remove no need file.
if GetDepend('RT_USING_DFS_WINSHAREDIR') == False:
SrcRemove(src, 'dfs_win32.c')
+if GetDepend('RT_USING_MODULE') == False:
+ SrcRemove(src, ['module_win32.c'])
CPPPATH = [cwd, str(Dir('#'))]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
diff --git a/bsp/simulator/applications/dfs_win32.c b/bsp/simulator/applications/dfs_win32.c
index acc8a3cb0a..8601df7239 100644
--- a/bsp/simulator/applications/dfs_win32.c
+++ b/bsp/simulator/applications/dfs_win32.c
@@ -148,6 +148,14 @@ static char *winpath_dirdup(char *des, const char *src)
return path;
}
+/* This function can convert the path in rt-thread/dfs to the path in windows */
+char * dfs_win32_dirdup(char * path)
+{
+ char * file_path;
+ file_path = winpath_dirdup(WIN32_DIRDISK_ROOT, path);
+ return file_path;
+}
+
static int dfs_win32_open(struct dfs_fd *file)
{
int fd;
diff --git a/bsp/simulator/dummy.c b/bsp/simulator/dummy.c
new file mode 100644
index 0000000000..67a38866cb
--- /dev/null
+++ b/bsp/simulator/dummy.c
@@ -0,0 +1,4 @@
+int dummy_main()
+{
+ return 0;
+}
diff --git a/bsp/simulator/rtconfig.h b/bsp/simulator/rtconfig.h
index d37e3877b8..5e0f9ead12 100755
--- a/bsp/simulator/rtconfig.h
+++ b/bsp/simulator/rtconfig.h
@@ -99,6 +99,9 @@
/* SECTION: component options */
#define RT_USING_COMPONENTS_INIT
+/* SECTION: APP MODULE */
+#define RT_USING_MODULE
+
/* SECTION: MTD interface options */
/* using mtd nand flash */
#define RT_USING_MTD_NAND
diff --git a/bsp/simulator/rtconfig.py b/bsp/simulator/rtconfig.py
index 3d0c641ef6..2b396c5455 100755
--- a/bsp/simulator/rtconfig.py
+++ b/bsp/simulator/rtconfig.py
@@ -71,10 +71,10 @@ elif PLATFORM == 'mingw':
DEVICE = ' -ffunction-sections -fdata-sections'
DEVICE = ' '
- CFLAGS = ' -Wl,--output-def '
+ CFLAGS = DEVICE
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp'
- #LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map -T mingw.ld'
- LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map --gc-sections,--whole-archive -T mingw.ld '
+ DEFFILE_LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map,--output-def,rtthread.def -T mingw.ld '
+ LFLAGS = DEVICE + ' -Wl,-Map=rtthread-win32.map -T mingw.ld '
CPATH = ''
LPATH = ''
diff --git a/include/rtm.h b/include/rtm.h
index 92ba6a381a..4bf7951a90 100644
--- a/include/rtm.h
+++ b/include/rtm.h
@@ -21,6 +21,9 @@ struct rt_module_symtab
const char *name;
};
+#if defined(_MSC_VER) || defined(__MINGW32__)
+#define RTM_EXPORT(symbol)
+#else
#define RTM_EXPORT(symbol) \
const char __rtmsym_##symbol##_name[] = #symbol; \
const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \
@@ -28,6 +31,8 @@ const struct rt_module_symtab __rtmsym_##symbol SECTION("RTMSymTab")= \
(void *)&symbol, \
__rtmsym_##symbol##_name \
};
+#endif
+
#else
#define RTM_EXPORT(symbol)
#endif