X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/dff9e15c44ab6340d27215957c56fa72fad246a2..3f0c94e70e5ee6fc659b2e1dd45c765e7afbd0fe:/tools/gras/windows_stub_generator.c diff --git a/tools/gras/windows_stub_generator.c b/tools/gras/windows_stub_generator.c index 889a240f18..ddb4299fd0 100644 --- a/tools/gras/windows_stub_generator.c +++ b/tools/gras/windows_stub_generator.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /* gras_stub_generator - creates the main() to use a GRAS program */ /* Copyright (c) 2003-2007 Martin Quinson, Arnaud Legrand, Malek Cherier. */ @@ -29,7 +27,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(stubgen); -#ifdef _WIN32 +#ifdef __BORLANDDC__ char *__gras_path = NULL; @@ -82,7 +80,8 @@ borland_project_write_tabs(borland_project_t project, unsigned int count); * @param name The name of the node. */ static void -borland_project_begin_xml_node(borland_project_t project, const char *name); +borland_project_begin_xml_node(borland_project_t project, + const char *name); /* @@ -100,8 +99,8 @@ borland_project_end_xml_node(borland_project_t project, const char *name); * @param value The value of the element */ static void -borland_project_write_xml_element(borland_project_t project, const char *name, - const char *value); +borland_project_write_xml_element(borland_project_t project, + const char *name, const char *value); /* * Write a FILE xml element in the borland project file. @@ -184,7 +183,8 @@ find_file_path(const char *root_dir, const char *file_name, char *path); /* * generate a Microsoft Visual project file*/ -static void generate_dsp_project(dsp_t project, int is_rl, const char *name); +static void generate_dsp_project(dsp_t project, int is_rl, + const char *name); static void generate_borland_project(borland_project_t project, int is_rl, @@ -218,16 +218,16 @@ generate_borland_project(borland_project_t project, int is_rl, /* construct and write the borland project binary path */ binary_path = - xbt_new0(char, strlen(project->name) + strlen(project->bin_dir) + 6); + xbt_new0(char, strlen(project->name) + strlen(project->bin_dir) + 6); sprintf(binary_path, "%s\\%s.exe", project->bin_dir, project->name); borland_project_write_xml_element(project, "PROJECT", binary_path); xbt_free(binary_path); /* construct an write the object files to generate by the compiler */ obj_path = - xbt_new0(char, - strlen(project->name) + strlen(name) + - (2 * strlen(project->obj_dir)) + 11); + xbt_new0(char, + strlen(project->name) + strlen(name) + + (2 * strlen(project->obj_dir)) + 11); sprintf(binary_path, "%s\\%s.obj\n%s\\%s.obj", project->obj_dir, project->name, project->obj_dir, name); borland_project_write_xml_element(project, "OBJFILES", obj_path); @@ -256,15 +256,15 @@ generate_borland_project(borland_project_t project, int is_rl, if (is_rl) { lib_files = - xbt_new0(char, - (2 * (strlen(project->lib_dir) + 1)) + strlen("libgras.lib") + - 2); + xbt_new0(char, + (2 * (strlen(project->lib_dir) + 1)) + + strlen("libgras.lib") + 2); sprintf(lib_files, "%s\\libgras.lib", project->lib_dir); } else { lib_files = - xbt_new0(char, - (2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + - 2); + xbt_new0(char, + (2 * (strlen(project->lib_dir) + 1)) + + strlen("simgrid.lib") + 2); sprintf(lib_files, "%s\\simgrid.lib", project->lib_dir); } @@ -331,7 +331,7 @@ generate_borland_project(borland_project_t project, int is_rl, } include_path = - xbt_new0(char, strlen("$(BCB)\\include") + strlen(__gras_path) + 2); + xbt_new0(char, strlen("$(BCB)\\include") + strlen(__gras_path) + 2); sprintf(include_path, "$(BCB)\\include;%s", __gras_path); borland_project_write_xml_element(project, "INCLUDEPATH", include_path); @@ -454,20 +454,21 @@ generate_borland_project(borland_project_t project, int is_rl, /* construct and write the list of file elements */ /* add the bpf file to the list */ - borland_project_write_file_element(project, main_source, "", project->name, - "BPF", "", ""); + borland_project_write_file_element(project, main_source, "", + project->name, "BPF", "", ""); xbt_free(main_source); /* FIXME : check the source file directory */ /* add the generated source file to the list */ file_name = - xbt_new0(char, strlen(project->src_dir) + strlen(project->name) + 5); + xbt_new0(char, strlen(project->src_dir) + strlen(project->name) + 5); sprintf(file_name, "%s\\_%s.c", project->src_dir, project->name); borland_project_write_file_element(project, file_name, "", project->name, "CCompiler", "", ""); - memset(file_name, 0, strlen(project->src_dir) + strlen(project->name) + 4); + memset(file_name, 0, + strlen(project->src_dir) + strlen(project->name) + 4); sprintf(file_name, "%s\\%s.c", project->src_dir, name); borland_project_write_file_element(project, file_name, "", name, "CCompiler", "", ""); @@ -479,16 +480,18 @@ generate_borland_project(borland_project_t project, int is_rl, if (is_rl) { file_name = - xbt_new0(char, strlen(project->lib_dir) + strlen("libgras.lib") + 2); + xbt_new0(char, + strlen(project->lib_dir) + strlen("libgras.lib") + 2); sprintf(file_name, "%s\\libgras.lib", project->lib_dir); - borland_project_write_file_element(project, file_name, "", "libgras.lib", - "LibTool", "", ""); + borland_project_write_file_element(project, file_name, "", + "libgras.lib", "LibTool", "", ""); } else { file_name = - xbt_new0(char, strlen(project->lib_dir) + strlen("simgrid.lib") + 2); + xbt_new0(char, + strlen(project->lib_dir) + strlen("simgrid.lib") + 2); sprintf(file_name, "%s\\simgrid.lib", project->lib_dir); - borland_project_write_file_element(project, file_name, "", "simgrid.lib", - "LibTool", "", ""); + borland_project_write_file_element(project, file_name, "", + "simgrid.lib", "LibTool", "", ""); } @@ -519,7 +522,8 @@ generate_borland_project(borland_project_t project, int is_rl, borland_project_close(project); } -void borland_project_write_tabs(borland_project_t project, unsigned int count) +void borland_project_write_tabs(borland_project_t project, + unsigned int count) { unsigned int pos; @@ -538,7 +542,8 @@ borland_project_begin_xml_node(borland_project_t project, const char *name) level++; } -void borland_project_end_xml_node(borland_project_t project, const char *name) +void borland_project_end_xml_node(borland_project_t project, + const char *name) { level--; @@ -550,8 +555,8 @@ void borland_project_end_xml_node(borland_project_t project, const char *name) void -borland_project_write_xml_element(borland_project_t project, const char *name, - const char *value) +borland_project_write_xml_element(borland_project_t project, + const char *name, const char *value) { borland_project_write_tabs(project, level); fprintf(project->stream, "<%s value=\"%s\"/>\n", name, value); @@ -568,7 +573,7 @@ void borland_project_create_main_file(const char *name) FILE *stream = fopen(name, "w+"); fprintf(stream, - "Ce fichier est uniquement utilisé par le gestionnaire de projets et doit être traité comme le fichier projet\n\n\nmain\n"); + "Ce fichier est uniquement utilis� par le gestionnaire de projets et doit �tre trait� comme le fichier projet\n\n\nmain\n"); fclose(stream); } @@ -607,21 +612,21 @@ void borland_project_write_ide_options(borland_project_t project) { const char *ide_options = - "[Version Info]\nIncludeVerInfo=0\nAutoIncBuild=0\nMajorVer=1\nMinorVer=0\nRelease=0\nBuild=0\nDebug=0\nPreRelease=0\nSpecial=0\nPrivate=0\nDLL=0\nLocale=1036\nCodePage=1252\n\n" - "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n" - "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n" - "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n" - "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n" - "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n" - "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n" - "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n" - "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n" - "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n" - "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n" - "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n" - "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n" - "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n" - "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n"; + "[Version Info]\nIncludeVerInfo=0\nAutoIncBuild=0\nMajorVer=1\nMinorVer=0\nRelease=0\nBuild=0\nDebug=0\nPreRelease=0\nSpecial=0\nPrivate=0\nDLL=0\nLocale=1036\nCodePage=1252\n\n" + "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n" + "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n" + "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n" + "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n" + "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n" + "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n" + "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n" + "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n" + "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n" + "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n" + "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n" + "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n" + "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n" + "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n"; fprintf(project->stream, ide_options); } @@ -653,16 +658,14 @@ void generate_borland_simulation_project(const char *name) GetCurrentDirectory(MAX_PATH, buffer); - borland_project.src_dir = xbt_new0(char, strlen(buffer) + 1); - - strcpy(borland_project.src_dir, buffer); + borland_project.src_dir = xbt_strdup(buffer); borland_project.name = - xbt_new0(char, strlen(name) + strlen("simulator") + 2); + xbt_new0(char, strlen(name) + strlen("simulator") + 2); sprintf(borland_project.name, "%s_simulator", name); borland_project.bin_dir = - xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1); + xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1); sprintf(borland_project.bin_dir, "%s\\bin", buffer); hDir = FindFirstFile(borland_project.bin_dir, &wfd); @@ -671,7 +674,7 @@ void generate_borland_simulation_project(const char *name) CreateDirectory(borland_project.bin_dir, NULL); borland_project.obj_dir = - xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1); + xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1); sprintf(borland_project.obj_dir, "%s\\obj", buffer); hDir = FindFirstFile(borland_project.obj_dir, &wfd); @@ -705,16 +708,15 @@ void generate_borland_real_life_project(const char *name) borland_project.lib_dir = xbt_new0(char, MAX_PATH); - GetEnvironmentVariable("LIB_GRAS_PATH", borland_project.lib_dir, MAX_PATH); + GetEnvironmentVariable("LIB_GRAS_PATH", borland_project.lib_dir, + MAX_PATH); GetCurrentDirectory(MAX_PATH, buffer); - borland_project.src_dir = xbt_new0(char, strlen(buffer) + 1); - - strcpy(borland_project.src_dir, buffer); + borland_project.src_dir = xbt_strdup(buffer); borland_project.bin_dir = - xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1); + xbt_new0(char, strlen(buffer) + strlen("\\bin") + 1); sprintf(borland_project.bin_dir, "%s\\bin", buffer); hDir = FindFirstFile(borland_project.bin_dir, &wfd); @@ -723,7 +725,7 @@ void generate_borland_real_life_project(const char *name) CreateDirectory(borland_project.bin_dir, NULL); borland_project.obj_dir = - xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1); + xbt_new0(char, strlen(buffer) + strlen("\\obj") + 1); sprintf(borland_project.obj_dir, "%s\\obj", buffer); hDir = FindFirstFile(borland_project.obj_dir, &wfd); @@ -830,8 +832,7 @@ int generate_simulation_dsp_file(const char *name) GetEnvironmentVariable("LIB_SIMGRID_PATH", dsp.lib_dir, MAX_PATH); GetCurrentDirectory(MAX_PATH, buffer); - dsp.src_dir = xbt_new0(char, strlen(buffer) + 1); - strcpy(dsp.src_dir, buffer); + dsp.src_dir = xbt_strdup(buffer); dsp.name = xbt_new0(char, strlen(name) + strlen("simulator") + 2); sprintf(dsp.name, "%s_simulator", name); @@ -863,9 +864,7 @@ int generate_real_live_dsp_file(const char *name) GetCurrentDirectory(MAX_PATH, buffer); - dsp.src_dir = xbt_new0(char, strlen(buffer) + 1); - - strcpy(dsp.src_dir, buffer); + dsp.src_dir = xbt_strdup(buffer); xbt_dict_foreach(process_function_set, cursor, key, data) { @@ -923,7 +922,8 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name) fprintf(project->stream, "!MESSAGE use the Export Makefile command and run\n"); fprintf(project->stream, "!MESSAGE\n"); - fprintf(project->stream, "!MESSAGE NMAKE /f \"%s.mak\".\n", project->name); + fprintf(project->stream, "!MESSAGE NMAKE /f \"%s.mak\".\n", + project->name); fprintf(project->stream, "!MESSAGE\n"); fprintf(project->stream, "!MESSAGE You can specify a configuration when running NMAKE\n"); @@ -966,12 +966,12 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name) fprintf(project->stream, "# PROP Intermediate_Dir \"Release\"\n"); fprintf(project->stream, "# PROP Target_Dir \"\"\n"); /* TODO : the include directory */ - /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"./%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path); */ + /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /GX /O2 /I \"./%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n",__gras_path); */ fprintf(project->stream, - "# ADD BASE CPP /nologo /W3 /GX /O2 /I \"%s\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n", + "# ADD BASE CPP /nologo /W3 /GX /O2 /I \"%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n", __gras_path); fprintf(project->stream, - "# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n"); + "# ADD CPP /nologo /W3 /GX /O2 /D \"_XBT_WIN32\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n"); fprintf(project->stream, "# ADD BASE RSC /l 0x40c /d \"NDEBUG\"\n"); fprintf(project->stream, "# ADD RSC /l 0x40c /d \"NDEBUG\n"); fprintf(project->stream, "BSC32=bscmake.exe\n"); @@ -1003,12 +1003,12 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name) fprintf(project->stream, "# PROP Ignore_Export_Lib 0\n"); fprintf(project->stream, "# PROP Target_Dir \"\"\n"); /* TODO : the include directory */ - /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"./%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",__gras_path); */ + /*fprintf(project->stream,"# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"./%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n",__gras_path); */ fprintf(project->stream, - "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"%s\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n", + "# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /I \"%s\" /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n", __gras_path); fprintf(project->stream, - "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n"); + "# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"_XBT_WIN32\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n"); fprintf(project->stream, "# ADD BASE RSC /l 0x40c /d \"_DEBUG\"\n"); fprintf(project->stream, "# ADD RSC /l 0x40c /d \"_DEBUG\"\n"); fprintf(project->stream, "BSC32=bscmake.exe\n"); @@ -1028,7 +1028,8 @@ void generate_dsp_project(dsp_t project, int is_rl, const char *name) fprintf(project->stream, "!ENDIF\n\n"); fprintf(project->stream, "# Begin Target\n\n"); - fprintf(project->stream, "# Name \"%s - Win32 Release\"\n", project->name); + fprintf(project->stream, "# Name \"%s - Win32 Release\"\n", + project->name); fprintf(project->stream, "# Name \"%s - Win32 Debug\"\n", project->name); fprintf(project->stream, "# Begin Group \"Source Files\"\n\n"); fprintf(project->stream,