diff --git a/bsp/simulator/SConstruct b/bsp/simulator/SConstruct index 875bef1e3a14473a0e4f91874338750435e3c1c1..6f35921ba9e66a2d34c016433b0bbad819d26bb0 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 828b49f77f9592fe37e67b2e40016d20e64062bf..6dbd985812698abb936ebfcb0f686a868e348e2d 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 acc8a3cb0ab95b80ba360a075fe24f09bdd25f7a..8601df7239cbde0156e21dbdeba8737f0a2f0670 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 0000000000000000000000000000000000000000..67a38866cbc00b536b45ba5e872df995fffac966 --- /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 d37e3877b88eccd2cf0addf6f9459975bc3c0b5e..5e0f9ead12fa8d3a5d26f75de135a426d90f36e3 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 3d0c641ef653624ee0ee62b829deb36279e0b815..2b396c5455f3eb3b9ceaeceb755de0bb3bc6926c 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 92ba6a381ab77635817432abe9cf69ce2a646d6d..4bf7951a90b9dfc5e48dbc2a76dec723eb9b4faa 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