-#ifdef _WIN32
-void
-generate_borland_project(borland_project_t project)
-{
- char* binary_path; /* the path of the generated binary file */
- char* obj_path; /* the path of the generated object file */
- char* lib_files; /* a list of the libraries used in the borland project */
- char* main_source; /* the name of the bpf file used by the borland project */
- char* file_name; /* the file name of the main source file */
-
-
- /* create the borland project file */
- borland_project_create(project);
-
- /* write the xml document header */
- borland_project_write_xml_header(project);
-
- /* write the xml comment to identify a borland project file */
- borland_project_write_xml_comment(project);
-
- /* write the begin of the node PROJECT */
- borland_project_begin_xml_node(project,"PROJECT");
-
- /* write the begin of node MACRO */
- borland_project_begin_xml_node(project,"MACRO");
-
- /* write the borland project version */
- borland_project_write_xml_element(project,"VERSION",project->version);
-
- /* construct and write the borland project binary path */
- binary_path = 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 generated file path */
- obj_path = xbt_new0(char,strlen(project->name) + strlen(project->obj_dir) + 6);
- sprintf(binary_path,"%s\\%s.obj",project->obj_dir,project->name);
- borland_project_write_xml_element(project,"OBJFILES",obj_path);
- xbt_free(obj_path);
-
- /* write the RESFILES element (not used) */
- borland_project_write_xml_element(project,"RESFILES","");
-
- /* write the IDLFILES element (not used) */
- borland_project_write_xml_element(project,"IDLFILES","");
-
- /* write the IDLGENFILES element (not used) */
- borland_project_write_xml_element(project,"IDLGENFILES","");
-
- /* write the DEFFILE element (not used) */
- borland_project_write_xml_element(project,"DEFFILE","");
-
- /* write the RESDEPEN element (not used) */
- borland_project_write_xml_element(project,"RESDEPEN","$(RESFILES)");
-
- /* construct and write the LIBFILES element */
- lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + strlen("libgras.lib") + 2);
- sprintf(lib_files,"%s\\simgrid.lib %s\\libgras.lib",project->lib_dir,project->lib_dir);
- borland_project_write_xml_element(project,"LIBFILES",lib_files);
- xbt_free(lib_files);
-
- /* write the SPARELIBS element (not used) */
- borland_project_write_xml_element(project,"SPARELIBS","");
-
- /* write the PACKAGES element (not used) */
- borland_project_write_xml_element(project,"PACKAGES","");
-
- /* write the PATHCPP element */
- borland_project_write_xml_element(project,"PATHCPP",".;");
-
- /* write the PATHPAS element (not used) */
- borland_project_write_xml_element(project,"PATHPAS","");
-
- /* write the PATHRC element (not used) */
- borland_project_write_xml_element(project,"PATHRC","");
-
- /* write the PATHASM element (not used) */
- borland_project_write_xml_element(project,"PATHASM","");
-
- /* write the DEBUGLIBPATH element */
- borland_project_write_xml_element(project,"DEBUGLIBPATH","$(BCB)\\lib\\debug");
-
- /* write the RELEASELIBPATH element */
- borland_project_write_xml_element(project,"RELEASELIBPATH","$(BCB)\\lib\\release");
-
- /* write the LINKER element*/
- borland_project_write_xml_element(project,"LINKER","ilink32");
-
- /* write the USERDEFINES element */
- borland_project_write_xml_element(project,"USERDEFINES","_DEBUG");
-
- /* write the SYSDEFINES element */
- borland_project_write_xml_element(project,"SYSDEFINES","NO_STRICT;_NO_VCL");
-
- /* construct and write the MAINSOURCE element */
-
- main_source = xbt_new0(char,strlen(project->name) + 5);
- sprintf(main_source,"%s.bpf",project->name);
-
- borland_project_write_xml_element(project,"MAINSOURCE",main_source);
-
- /* create the bpf file used by the borland project */
- borland_project_create_main_file(main_source);
-
- /* FIXME resolve the include path */
- /* write the INCLUDEPATH element */
- borland_project_write_xml_element(project,"INCLUDEPATH","");
-
- /* FIXME check the lib path */
- /* write the LIBPATH element */
- borland_project_write_xml_element(project,"LIBPATH","");
-
- /* write the WARNINGS element */
- borland_project_write_xml_element(project,"WARNINGS","-w-sus -w-rvl -w-rch -w-pia -w-pch -w-par -w-csu -w-ccc -w-aus");
-
- /* write the OTHERFILES element (not used) */
- borland_project_write_xml_element(project,"OTHERFILES","");
-
- /* write the end of the node MACRO */
- borland_project_end_xml_node(project,"MACRO");
-
- /* write the begin of the node OPTIONS */
- borland_project_begin_xml_node(project,"OPTIONS");
-
- /* FIXME check the idlcflags
- /* write the IDLCFLAGS element */
- borland_project_write_xml_element(project,"IDLCFLAGS","");
-
- /* write the CFLAG1 element */
- borland_project_write_xml_element(project,"CFLAG1","-Od -H=$(BCB)\\lib\\vcl60.csm -Hc -Vx -Ve -X- -r- -a1 -b- -k -y -v -vi- -tWC -tWM- -c");
-
- /* write the PFLAGS element */
- borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE -M");
-
- /* write the RFLAGS element */
- borland_project_write_xml_element(project,"RFLAGS","");
-
- /* write the AFLAGS element (not used)*/
- borland_project_write_xml_element(project,"AFLAGS","/mx /w2 /zd");
-
- /* write the LFLAGS element */
- borland_project_write_xml_element(project,"LFLAGS","-Iobj -D"" -ap -Tpe -x -Gn -v");
-
- /* write the OTHERFILES element (not used)*/
- borland_project_write_xml_element(project,"OTHERFILES","");
-
- /* write the end of the node OPTIONS */
- borland_project_end_xml_node(project,"OPTIONS");
-
- /* write the begin of the node LINKER */
- borland_project_begin_xml_node(project,"LINKER");
-
- /* write the ALLOBJ element */
- borland_project_write_xml_element(project,"ALLOBJ","c0x32.obj $(OBJFILES)");
-
- /* write the ALLRES element (not used) */
- borland_project_write_xml_element(project,"ALLRES","");
-
- /* write the ALLLIB element */
- borland_project_write_xml_element(project,"ALLLIB","$(LIBFILES) $(LIBRARIES) import32.lib cw32.lib");
-
- /* write the OTHERFILES element (not used) */
- borland_project_write_xml_element(project,"OTHERFILES","");
-
- /* write the end of the node LINKER */
- borland_project_end_xml_node(project,"LINKER");
-
- /* write the begin of the node FILELIST */
- borland_project_begin_xml_node(project,"FILELIST");
-
- /* 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","","");
- 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) + 4);
- sprintf(file_name,"%s\\%s.c",project->src_dir,project->name);
- borland_project_write_file_element(project,file_name,"",project->name,"CCompiler","","");
- xbt_free(file_name);
-
- /* FIXME : check the libraries directory */
- /* add the simgrid library to the list */
- file_name = 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","","");
- xbt_free(file_name);
-
- /* add the libgras library to the list */
- file_name = 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","","");
- xbt_free(file_name);
-
- /* write the end of the node FILELIST */
- borland_project_end_xml_node(project,"FILELIST");
-
- /* write the begin of the node BUILDTOOLS (not used)*/
- borland_project_begin_xml_node(project,"BUILDTOOLS");
-
- /* write the end of the node BUILDTOOLS (not used)*/
- borland_project_end_xml_node(project,"BUILDTOOLS");
-
- /* write the begin of the node IDEOPTIONS */
- borland_project_begin_xml_node(project,"IDEOPTIONS");
-
- /* write all of the option of the IDE of Borland C++ Builder */
- borland_project_write_ide_options(project);
-
- /* write the end of the node IDEOPTIONS */
- borland_project_end_xml_node(project,"IDEOPTIONS");
-
- /* write the end of the node PROJECT */
- borland_project_end_xml_node(project,"PROJECT");
-
- /* close the borland project file */
- borland_project_close(project);
-}
-
-void
-borland_project_write_tabs(borland_project_t project,unsigned int count)
-{
- unsigned int pos;
-
- for(pos = 0; pos < count; pos++)
- fprintf(project->stream,"\t");
-}
-
-void
-borland_project_begin_xml_node(borland_project_t project, const char* name)
-{
- if(level)
- borland_project_write_tabs(project,level);
-
- fprintf(project->stream,"<%s>\n",name);
-
- level++;
-}
-
-void
-borland_project_end_xml_node(borland_project_t project, const char* name)
-{
- level--;
-
- if(level)
- borland_project_write_tabs(project,level);
-
- fprintf(project->stream,"</%s>\n",name);
-}
-
-
-void
-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);
-}
-
-void
-borland_project_write_xml_header(borland_project_t project)
-{
- fprintf(project->stream,"<?xml version='%s' encoding='%s' ?>\n",project->xml_version, project->encoding);
-}
-
-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");
-
- fclose(stream);
-}
-
-void
-borland_project_create(borland_project_t project)
-{
- char* file_name = xbt_new0(char,strlen(project->name) + 5);
- sprintf(file_name,"%s.bpr",project->name);
- project->stream = fopen(file_name,"w+");
- xbt_free(file_name);
-}
-
-void
-borland_project_write_xml_comment(borland_project_t project)
-{
- fprintf(project->stream,"<!-- %s -->\n",project->comment);
-}
-void
-borland_project_write_file_element( borland_project_t project,
- const char* file_name,
- const char* form_name,
- const char* unit_name,
- const char* container_id,
- const char* design_class,
- const char* local_command)
-{
- borland_project_write_tabs(project,level);
-
- fprintf(project->stream,"<FILE FILENAME=\"%s\" FORMNAME=\"%s\" UNITNAME=\"%s\" CONTAINERID=\"%s\" DESIGNCLASS=\"%s\" LOCALCOMMAND=\"%s\"/>\n",file_name,form_name,unit_name,container_id,design_class,local_command);
-}
-
-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";
-
- fprintf(project->stream,ide_options);
-}
-
-void
-borland_project_close(borland_project_t project)
-{
- fclose(project->stream);
-}
-
-void
-generate_borland_simulation_project(const char* name)
-{
- char buffer[MAX_PATH] = {0};
-
- HANDLE hDir;
- WIN32_FIND_DATA wfd = {0};
-
- s_borland_project_t borland_project = {0};
- borland_project.xml_version = "1.0";
- borland_project.encoding ="utf-8";
- borland_project.comment ="C++Builder XML Project";
- borland_project.version = "BCB.06.00";
-
- borland_project.lib_dir = xbt_new0(char,MAX_PATH);
-
- FindFilePath("C:\\","simgrid.lib",borland_project.lib_dir);
-
-
- GetCurrentDirectory(MAX_PATH,buffer);
-
- borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
-
- strcpy(borland_project.src_dir,buffer);
-
- borland_project.lib_dir = " ";
-
- borland_project.name = 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);
- sprintf(borland_project.bin_dir,"%s\\bin",buffer);
-
- hDir = FindFirstFile(borland_project.bin_dir,&wfd);
-
- if(!hDir)
- CreateDirectory(borland_project.bin_dir,NULL);
-
- borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
- sprintf(borland_project.obj_dir,"%s\\obj",buffer);
-
- hDir = FindFirstFile(borland_project.obj_dir,&wfd);
-
- if(INVALID_HANDLE_VALUE == hDir)
- CreateDirectory(borland_project.obj_dir,NULL);
-
- generate_borland_project(&borland_project);
-
- xbt_free(borland_project.name);
- xbt_free(borland_project.src_dir);
- xbt_free(borland_project.bin_dir);
- xbt_free(borland_project.obj_dir);
- xbt_free(borland_project.lib_dir);
-}
-
-void
-generate_borland_real_life_project(const char* name)
-{
- HANDLE hDir;
- WIN32_FIND_DATA wfd = {0};
- char buffer[MAX_PATH] = {0};
- xbt_dict_cursor_t cursor = NULL;
- char *key = NULL;
- void *data = NULL;
- s_borland_project_t borland_project = {0};
-
- borland_project.xml_version = "1.0";
- borland_project.encoding ="utf-8";
- borland_project.comment ="C++Builder XML Project";
- borland_project.version = "BCB.06.00";
- borland_project.lib_dir = " ";
-
- borland_project.lib_dir = xbt_new0(char,MAX_PATH);
-
- FindFilePath("C:\\","simgrid.lib",borland_project.lib_dir);
-
- GetCurrentDirectory(MAX_PATH,buffer);
-
- borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
-
- strcpy(borland_project.src_dir,buffer);
-
- borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
- sprintf(borland_project.bin_dir,"%s\\bin",buffer);
-
- hDir = FindFirstFile(borland_project.bin_dir,&wfd);
-
- if(INVALID_HANDLE_VALUE == hDir)
- CreateDirectory(borland_project.bin_dir,NULL);
-
- borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
- sprintf(borland_project.obj_dir,"%s\\obj",buffer);
-
- hDir = FindFirstFile(borland_project.obj_dir,&wfd);
-
- if(!hDir)
- CreateDirectory(borland_project.obj_dir,NULL);
-
-
- xbt_dict_foreach(process_function_set,cursor,key,data) {
- borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 3);
-
- sprintf(borland_project.name,"_%s_%s",name,key);
-
- generate_borland_project(&borland_project);
- xbt_free(borland_project.name);
- }
-
- xbt_free(borland_project.src_dir);
- xbt_free(borland_project.bin_dir);
- xbt_free(borland_project.obj_dir);
- xbt_free(borland_project.lib_dir);
-}
-int
-FindFilePath(const char* root_dir,const char* file_name,char* path)
-{
- HANDLE hFind;
- WIN32_FIND_DATA wfd;
- char* prev_dir = (char*)calloc(MAX_PATH,sizeof(char));
- GetCurrentDirectory(MAX_PATH,prev_dir);
- SetCurrentDirectory(root_dir);
-
- // begining of the scan
- hFind=FindFirstFile ("*.*", &wfd);
-
- if(hFind!=INVALID_HANDLE_VALUE){
-
- /* it's a file */
- if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
-
- if(!strcmp(file_name,wfd.cFileName)){
- GetCurrentDirectory(MAX_PATH,path);
- SetCurrentDirectory(prev_dir);
- free(prev_dir);
- FindClose(hFind);
- return 1;
- }
-
- }
- /* it's a directory, scan it*/
- else {
-
- if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
- if(FindFilePath(wfd.cFileName,file_name,path)){
- FindClose(hFind);
- SetCurrentDirectory(prev_dir);
- return 1;
- }
- }
- }
-
- /* next file or directory */
- while(FindNextFile (hFind,&wfd))
- {
- /* it's a file */
- if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
- {
- if(!strcmp(file_name,wfd.cFileName)){
- GetCurrentDirectory(MAX_PATH,path);
- SetCurrentDirectory(prev_dir);
- free(prev_dir);
- FindClose(hFind);
- return 1;
- }
- }
- /* it's a file scan it */
- else {
-
- if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
-
- if(FindFilePath(wfd.cFileName,file_name,path)){
- SetCurrentDirectory(prev_dir);
- FindClose(hFind);
- return 1;
- }
-
- }
-
- }
- }
- }
-
- SetCurrentDirectory(prev_dir);
- free(prev_dir);
- FindClose (hFind);
- return 0;
-}
-#endif
-
-
-
-
-