simulator: add createdef.py to generate def file for VS

Now we can get rid off Mingw to create def file. To create def file, one
should run:

    scons --def

in the bsp/simulator.
This commit is contained in:
prife 2013-10-01 17:43:38 +08:00
parent ca9b83c68f
commit 5641360b49
5 changed files with 37 additions and 1438 deletions

View File

@ -122,13 +122,12 @@ if GetDepend('RT_USING_MODULE'):
default=False,
help='create rthread.def of rtthread.dll on windows')
if GetOption('def'):
if rtconfig.PLATFORM != 'mingw':
print "scons error: `--def' can only work with mingw"
exit(1)
if rtconfig.PLATFORM == 'mingw':
env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
else:
rtconfig.POST_ACTION = 'createdef.py $TARGET rtthread.def'
env['LINKFLAGS'] = rtconfig.DEFFILE_LFLAGS
env.SharedLibrary("rtthread.dll", objs)
program = ''
program = env.Program(TARGET, objs)
else:
if rtconfig.PLATFORM == 'cl':
objs += ['rtthread.def']

View File

@ -0,0 +1,23 @@
import re
import sys
fsrc = "rtthread.dll"
fname ="rtthread.def"
prefix = "__vs_rtm_"
if len(sys.argv) >= 2:
fsrc = sys.argv[1]
fname = sys.argv[2]
#restr = r"__vs_rtm_.*?\0"
restr = prefix + r".*?\0"
s = open(fsrc, 'rb').read()
l = re.findall(restr, s, re.S)
lines = [i[len(prefix):-1] for i in l]
s = '\n'.join(lines)
fout = open(fname, 'w')
fout.write('EXPORTS\n')
fout.write('main\n')
fout.write(s)

View File

@ -128,7 +128,7 @@ void rt_module_unload_sethook(void (*hook)(rt_module_t module))
*
* This function will initialize system module
*/
void rt_system_module_init(void)
int rt_system_module_init(void)
{
}

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,15 @@ struct rt_module_symtab
const char *name;
};
#if defined(_MSC_VER) || defined(__MINGW32__)
#if defined(_MSC_VER)
#pragma section("RTMSymTab$f",read)
#define RTM_EXPORT(symbol) \
__declspec(allocate("RTMSymTab$f"))const char __rtmsym_##symbol##_name[] = "__vs_rtm_"#symbol;
#pragma comment(linker, "/merge:RTMSymTab=mytext")
#elif defined(__MINGW32__)
#define RTM_EXPORT(symbol)
#else
#define RTM_EXPORT(symbol) \
const char __rtmsym_##symbol##_name[] = #symbol; \