Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
87c3e98d9bb739e239e7d2f7b87610414c7b3149
[simgrid.git] / tools / gras / stub_generator.c
1 /*      $Id$     */
2
3 /* gras_stub_generator - creates the main() to use a GRAS program           */
4
5 /* Copyright (c) 2003-2007 Martin Quinson, Arnaud Legrand, Malek Cherier.   */
6 /* All rights reserved.                                                     */
7
8 /* This program is free software; you can redistribute it and/or modify it
9  * under the terms of the license (GNU LGPL) which comes with this package. */
10
11 /* specific to Borland Compiler */
12 #ifdef __BORLANDDC__
13 #pragma hdrstop
14 #endif
15
16 #include <stdio.h>
17 #include "xbt/sysdep.h"
18 #include "xbt/function_types.h"
19 #include "xbt/log.h"
20 #include "surf/surfxml_parse.h"
21 #include "surf/surf.h"
22 #include "portable.h" /* Needed for the time of the SIMIX convertion */
23
24 #include <stdarg.h>
25
26
27
28 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator");
29
30 #ifdef _WIN32
31
32 /* tabulation level (used to indent the lines of the borland project file */
33 static unsigned int level = 0;
34
35
36
37 /* the gras.h header directory */
38 static char* __gras_path = NULL;
39
40
41 #ifndef MAX_PATH
42 #define MAX_PATH 260
43 #endif
44
45 /*
46  * A structure which represents a borland project file.
47  */
48 typedef struct s_borland_project
49 {
50     const char* xml_version;/* the xml version used to write the borland project file                   */
51     const char* encoding;   /* the encoding used to write the borland project file                      */
52     const char* comment;    /* the xml comment to write at the begining of the borland project file     */
53         char* name;                     /* the name of the borland project file                                                                         */
54         FILE* stream;                   /* the stream to the borland project file                                                                       */
55         const char* version;    /* the builder version of the borland project file                                                      */
56         char* bin_dir;          /* the directory used to store the generated program                                            */
57         char* obj_dir;          /* the directory used to store the generated object files                                       */
58         char* lib_dir;          /* the directory used to store the librairies used in the borland project       */
59         char* src_dir;          /* the directory use to store the source files of the project                           */
60 }s_borland_project_t,* borland_project_t;
61
62
63 /*
64  * A structure which represents a visual C++ project file.
65  */
66 typedef struct s_dsp
67 {
68         FILE* stream;
69         char* lib_dir;
70         char* src_dir;
71         char* name;
72 }s_dsp_t,* dsp_t;
73
74 /*
75  * Write tabs in a borland project file.
76  * @param project The project concerned by the operation.
77  * @param count The count tab to write
78  */
79 void
80 borland_project_write_tabs(borland_project_t project,unsigned int count);
81
82 /*
83  * Write the begin of an xml node in the borland project file.
84  * @param project The borland project concerned by this operation.
85  * @param name The name of the node.
86  */
87 void
88 borland_project_begin_xml_node(borland_project_t project, const char* name);
89
90
91 /*
92  * Write the end of an xml node in the borland project file.
93  * @param project The borland project concerned by this operation.
94  * @param name The name of the node.
95  */
96 void
97 borland_project_end_xml_node(borland_project_t project, const char* name);
98
99 /*
100  * Write an xml element in a borland project file.
101  * @param project The borland project concerned by this operation.
102  * @param name The name of the element to write
103  * @param value The value of the element  
104  */
105 void
106 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value);
107
108 /*
109  * Write a FILE xml element in the borland project file.
110  * @param project The borland project concerned by this operation.
111  * @param file_name The value of the attribute FILENAME.
112  * @param form_name The value of the attribute FORMNAME.
113  * @param unit_name The value of the attribute UNITNAME.
114  * @param container_id The value of the attribute CONTAINERID.
115  * @param design_claas The value of the attribute DESIGNCLASS.
116  * @param local_command The value of the attribute LOCALCOMMAND.
117  */
118 void
119 borland_project_write_file_element(     borland_project_t project,
120                                                                         const char* file_name,
121                                                                         const char* form_name,
122                                                                         const char* unit_name,
123                                                                         const char* container_id,
124                                                                         const char* design_class,
125                                                                         const char* local_command);
126 /*
127  * Write all options of the IDE of the Borland Builder C++ compiler.
128  * @ param project The project concerned by this operation.
129  */
130
131 void
132 borland_project_write_ide_options(borland_project_t project);
133
134 /*
135  * Write the xml header of the xml document.
136  * @param project The project concerned by the operation.
137  */
138 void
139 borland_project_write_xml_header(borland_project_t project);
140
141 /*
142  * Write an xml comment in a borland project file
143  * @param project The project concerned by this operation.
144  */
145 void
146 borland_project_write_xml_comment(borland_project_t project);
147
148 /*
149  * Create a bpf file used by a borland project file.
150  * @param name The name of the bpf file to create.
151  */
152 void
153 borland_project_create_main_file(const char* name);
154
155 /*
156  * Create a borland project file.
157  * @param project The project concerned by this operation.
158  */
159 void
160 borland_project_create(borland_project_t project);
161
162 /*
163  * Close a borland project file.
164  * @param project the borland project file to close.
165  */
166 void
167 borland_project_close(borland_project_t project);
168
169
170 /*
171  * Generate a borland simulation poject file.
172  * @param name The name of the simulation project
173  */
174 void
175 generate_borland_simulation_project(const char* name);
176
177 /*
178  * Generate a borland project file for real life.
179  * @param name The name of the project to create.
180  */
181 void
182 generate_borland_real_life_project(const char* name);
183
184 /*
185  * Generate a borland project file.
186  * @param project The borland project to generate.
187  */
188 void
189 generate_borland_project(borland_project_t project,int is_rl,const char* name);
190
191 /*
192  * Find the path of a file.
193  * @param file_name The file name to find.
194  * @path path If founded this parameter will contain the path of file.
195  * @return If successful the function returns 1. Otherwise the function
196  *  retruns 0;
197  */
198 int
199 find_file_path(const char* root_dir,const char* file_name,char* path);
200
201
202 /*
203  * Functions used to create a Microsoft Visual C++ project file (*.dsp).
204  */
205
206 /*
207  * Create the Microsoft visual C++ file project for the simulation.
208  */
209 int
210 generate_simulation_dsp_file(const char* project_name);
211
212 /*
213  * Create the Microsoft visual C++ real life project file.
214  */
215 int
216 generate_real_live_dsp_file(const char* project_name);
217
218 /*
219  * generate a Microsoft Visual project file*/
220 void
221 generate_dsp_project(dsp_t project,int is_rl,const char* name);
222
223 #endif
224
225
226
227 #define WARN "/***********\n * DO NOT EDIT! THIS FILE HAS BEEN AUTOMATICALLY GENERATED FROM %s BY gras_stub_generator\n ***********/\n"
228 #define SIM_SOURCENAME  "_%s_simulator.c"
229 #define SIM_OBJNAME  "_%s_simulator.o"
230 #define SIM_BINARYNAME  "%s_simulator"
231 #define SIM_SOURCENAME_LDADD  "%s_simulator_LDADD"
232 #define SIM_SOURCENAME_SOURCES  "%s_simulator_SOURCES"
233 #define RL_SOURCENAME  "_%s_%s.c"
234 #define RL_OBJNAME  "_%s_%s.o"
235 #define RL_BINARYNAME  "%s_%s"
236 #define RL_SOURCENAME_LDADD  "%s_%s_LDADD"
237 #define RL_SOURCENAME_SOURCES  "%s_%s_SOURCES"
238 #define MAKEFILE_FILENAME_AM  "%s.Makefile.am"
239 #define MAKEFILE_FILENAME_LOCAL  "%s.mk"
240 #define MAKEFILE_FILENAME_REMOTE  "%s.Makefile.remote"
241 #define DEPLOYMENT  "%s.deploy.sh"
242
243 char *warning = NULL;
244
245 /**********************************************/
246 /**** Generate the file for the simulator *****/
247 /**********************************************/
248
249 const char *SIM_PREEMBULE =
250 "/* specific to Borland Compiler */\n"
251 "#ifdef __BORLANDC__\n"
252 "#pragma hdrstop\n"
253 "#endif\n\n"
254 "#include <stdlib.h>\n"
255 "#include <stdio.h>\n"
256 "#include \"msg/msg.h\"\n"
257 "#include <gras.h>\n"
258 "\n"
259 "char *gras_log=NULL;\n";
260
261
262 #define SIM_LAUNCH_FUNC  \
263 "int launch_%s(int argc, char **argv) {\n" \
264 "  char **myargv=argv;\n" \
265 "  int myargc=argc;\n" \
266 "  int i;\n" \
267 "  int retcode;\n"\
268 "    \n"\
269 "  if (gras_log) {\n"\
270 "    myargv=malloc((argc+1) * sizeof(char**));\n" \
271 "    for (i=0; i<argc; i++)\n" \
272 "      myargv[i] = argv[i];\n" \
273 "    myargv[myargc++] = gras_log;\n" \
274 "  }\n" \
275 "  retcode = %s(myargc,myargv);\n" \
276 "  if (myargv != argv)\n" \
277 "    free(myargv);\n" \
278 "  return retcode;\n" \
279 "}\n"
280
281 const char *SIM_MAIN_POSTEMBULE = "\n"
282 "\n"
283 "  gras_launch_application(argv[2]);\n"
284 "\n"
285 "  /*  Run the simulation */\n"
286 "  gras_main();\n"
287 "\n"
288 "  /* cleanup the place */\n"
289 "  gras_clean();\n"
290 "  if (gras_log)\n"
291 "    free(gras_log);\n"
292 "  return 0;\n"
293 "}\n";
294
295
296
297 /**********************************************/
298 /********* Parse XML deployment file **********/
299 /**********************************************/
300 xbt_dict_t process_function_set = NULL;
301 xbt_dynar_t process_list = NULL;
302 xbt_dict_t machine_set = NULL;
303
304 typedef struct s_process_t {
305   int argc;
306   char **argv;
307   char *host;
308 } s_process_t;
309
310 static void s_process_free(void *process)
311 {
312   s_process_t*p = (s_process_t*)process;
313   int i;
314   for (i=0; i<p->argc ; i++)
315     free(p->argv[i]);
316   free(p->argv);
317   free(p->host);
318 }
319
320 static s_process_t process;
321
322 static void parse_process_init(void)
323 {
324   xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
325   xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL);
326   process.argc = 1 ;
327   process.argv = xbt_new(char*,1);
328   process.argv[0] = xbt_strdup(A_surfxml_process_function);
329   process.host=strdup(A_surfxml_process_host);
330   /*VERB1("Function: %s",A_surfxml_process_function);*/
331 }
332
333 static void parse_argument(void)
334 {
335   process.argc++;
336   process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
337   process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value);
338 }
339
340 static void parse_process_finalize(void)
341 {
342   xbt_dynar_push(process_list,&process);
343   /*VERB1("Function: %s",process.argv[0]);*/
344 }
345
346 static void generate_sim(char *project) {
347    xbt_dict_cursor_t cursor=NULL;
348    char *key = NULL;
349    void *data = NULL;
350    char *filename = NULL;
351    FILE *OUT = NULL;
352    
353    /* Output file: <projet>_simulator.c */
354    filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME));
355    sprintf(filename,SIM_SOURCENAME,project);
356    
357    OUT=fopen(filename,"w");
358    
359    xbt_assert1(OUT, "Unable to open %s for writing",filename);
360    
361    fprintf(OUT, "%s\n",warning);
362    fprintf(OUT, "%s", SIM_PREEMBULE);
363    
364    xbt_dict_foreach(process_function_set,cursor,key,data) {
365       fprintf(OUT,"int %s(int argc,char *argv[]);\n",key);
366    }
367    
368    fprintf(OUT,"\n");
369    
370    xbt_dict_foreach(process_function_set,cursor,key,data) {
371       fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key);
372    }
373    
374    fprintf(OUT, "\n%s\n",warning);
375    
376    xbt_dict_foreach(process_function_set,cursor,key,data) {
377       fprintf(OUT,SIM_LAUNCH_FUNC,key,key);
378    }
379    fprintf(OUT, "\n%s\n",warning);
380    
381    fprintf(OUT,"%s", "/* specific to Borland Compiler */\n"
382            "#ifdef __BORLANDDC__\n"
383            "#pragma argsused\n"
384            "#endif\n\n");
385    
386    fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n"
387            "\n" 
388            "  /*  Simulation setup */\n" 
389            "  gras_global_init(&argc,argv);\n"
390            "  if (argc != 3) {\n" 
391            "    fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n" 
392            "    exit(1);\n" 
393            "  }\n"
394            "\n");
395    fprintf(OUT,
396            "  gras_create_environment(argv[1]);\n" 
397            "\n" 
398            "  /*  Application deployment */\n"
399            );
400    xbt_dict_foreach(process_function_set,cursor,key,data) {
401       fprintf(OUT,"  gras_function_register(\"%s\", launch_%s);\n",key,key);
402    }
403    fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
404    fclose(OUT);
405    free(filename);
406 }
407
408 /**********************************************/
409 /**** Generate the file for the real life *****/
410 /**********************************************/
411 static void generate_rl(char *project)
412 {
413   xbt_dict_cursor_t cursor=NULL;
414   char *key = NULL;
415   void *data = NULL;
416   char *filename = NULL;
417   FILE *OUT = NULL;
418
419   xbt_dict_foreach(process_function_set,cursor,key,data) {
420     filename = xbt_new(char,strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
421
422         sprintf(filename,RL_SOURCENAME,project,key);
423
424     OUT=fopen(filename,"w");
425     xbt_assert1(OUT, "Unable to open %s for writing",filename);
426
427     fprintf(OUT, "\n%s\n",warning);
428     fprintf(OUT, "/* specific to Borland Compiler */\n" \
429                  "#ifdef __BORLANDC__\n" \
430                  "#pragma hdrstop\n" \
431                  "#endif\n\n" \
432                  "#include <stdio.h>\n" \
433                  "#include <signal.h>\n" \
434                  "#include <gras.h>\n" \
435                  "\n" \
436                  "XBT_PUBLIC_DATA(const char *) _gras_procname;\n" \
437                  "/* user code */\n" \
438                  "int %s(int argc, char *argv[]);\n" \
439                  "\n" \
440                  "/* specific to Borland Compiler */\n" \
441                 "#ifdef __BORLANDC__\n" \
442                 "#pragma argsused\n" \
443                 "#endif\n\n" \
444                  "int main(int argc, char *argv[]){\n" \
445                  "  int errcode;\n" \
446                  "\n" \
447                  "  _gras_procname = \"%s\";\n" \
448                  "  errcode=%s(argc,argv);\n"\
449                  " \n" \
450                  "  return errcode;\n"\
451                  "}\n",
452             key,key,key);
453     fprintf(OUT, "\n%s\n",warning);
454     fclose(OUT);
455     free(filename);
456   }
457 }
458
459 static void generate_makefile_am(char *project, char *deployment)
460 {
461   xbt_dict_cursor_t cursor=NULL;
462   char *key = NULL;
463   void *data = NULL;
464   char *filename = NULL;
465   FILE *OUT = NULL;
466
467   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_AM));
468   sprintf(filename,MAKEFILE_FILENAME_AM, project);
469
470   OUT=fopen(filename,"w");
471   xbt_assert1(OUT, "Unable to open %s for writing",filename);
472
473   fprintf(OUT, "# AUTOMAKE variable definition\n");
474   fprintf(OUT, "INCLUDES= @CFLAGS_SimGrid@\n\n");
475   fprintf(OUT, "PROGRAMS=");
476   fprintf(OUT, SIM_BINARYNAME,project);
477
478   xbt_dict_foreach(process_function_set,cursor,key,data) {
479     fprintf(OUT, " ");
480     fprintf(OUT, RL_BINARYNAME, project, key);
481   }
482
483   fprintf(OUT, "\n\n");
484   fprintf(OUT, SIM_SOURCENAME_SOURCES,project);
485   fprintf(OUT, "=\t");
486   fprintf(OUT, SIM_SOURCENAME,project);
487   fprintf(OUT, " %s.c\n", project);
488   fprintf(OUT, SIM_SOURCENAME_LDADD, project);
489   fprintf(OUT, "=\tpath/to/libsimgrid.a\n\n");
490
491   xbt_dict_foreach(process_function_set,cursor,key,data) {
492     fprintf(OUT, RL_SOURCENAME_SOURCES, project,key);
493     fprintf(OUT, "=\t");
494     fprintf(OUT, RL_SOURCENAME, project,key);
495     fprintf(OUT, " %s.c\n", project);
496     fprintf(OUT, RL_SOURCENAME_LDADD, project, key);
497     fprintf(OUT, "=\tpath/to/libgras.a\n\n");
498   }
499
500   fprintf(OUT, "\n# cleanup temps\n");
501   fprintf(OUT, "CLEANFILES= ");
502   fprintf(OUT, SIM_SOURCENAME, project);
503   
504   xbt_dict_foreach(process_function_set,cursor,key,data) {
505     fprintf(OUT, " ");
506     fprintf(OUT, RL_SOURCENAME, project,key);
507   }
508   fprintf(OUT, "\n");
509
510   fprintf(OUT, "\n# generate temps\n");
511   fprintf(OUT, "\n# A rule to generate the source file each time the deployment file changes\n");
512
513   xbt_dict_foreach(process_function_set,cursor,key,data) {
514     fprintf(OUT, RL_SOURCENAME, project,key);
515     fprintf(OUT, " ");
516   }
517   fprintf(OUT, SIM_SOURCENAME, project);
518   fprintf(OUT, ": %s\n", deployment);
519   fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
520   fclose(OUT);
521 }
522
523 static void generate_makefile_local(char *project, char *deployment)
524 {
525   xbt_dict_cursor_t cursor=NULL;
526   char *key = NULL;
527   void *data = NULL;
528   char *filename = NULL;
529   FILE *OUT = NULL;
530
531   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
532   sprintf(filename,MAKEFILE_FILENAME_LOCAL, project);
533   
534   OUT=fopen(filename,"w");
535   xbt_assert1(OUT, "Unable to open %s for writing",filename);
536   free(filename);
537    
538   fprintf(OUT,
539           "\n"
540           "####\n"
541           "#### THIS FILE WAS GENERATED, DO NOT EDIT BEFORE RENAMING IT\n"
542           "####\n\n\n");
543
544   fprintf(OUT,"## Variable declarations\n"
545               "PROJECT_NAME=%s\n"
546               "DISTDIR=gras-$(PROJECT_NAME)\n\n"
547           ,project);
548    
549   fprintf(OUT,
550           "# Set the GRAS_ROOT environment variable to the path under which you installed SimGrid\n"
551           "# Compilation will fail if you don't do so\n" 
552           "GRAS_ROOT?= $(shell echo \"\\\"<<<< GRAS_ROOT undefined !!! >>>>\\\"\")\n\n"
553           "# You can fiddle the following to make it fit your taste\n"
554           "INCLUDES = -I$(GRAS_ROOT)/include\n"
555           "CFLAGS ?= -O3 -w -g\n"
556           "LIBS_SIM = -lm  -L$(GRAS_ROOT)/lib/ -lsimgrid\n"
557           "LIBS_RL = -lm  -L$(GRAS_ROOT)/lib/ -lgras\n"
558           "LIBS = \n"
559           "\n");
560
561   fprintf(OUT, "PRECIOUS_C_FILES ?= %s.c\n", project);
562
563   fprintf(OUT, "GENERATED_C_FILES = ");
564   fprintf(OUT, SIM_SOURCENAME" ",project);
565   xbt_dict_foreach(process_function_set,cursor,key,data) {
566     fprintf(OUT, RL_SOURCENAME " ",project, key);
567   }
568   fprintf(OUT, "\n");
569
570   fprintf(OUT,"OBJ_FILES = $(patsubst %%.c,%%.o,$(PRECIOUS_C_FILES))\n");
571
572   fprintf(OUT, "BIN_FILES = ");
573
574   fprintf(OUT, SIM_BINARYNAME " ",project);
575   xbt_dict_foreach(process_function_set,cursor,key,data) {
576     fprintf(OUT, RL_BINARYNAME " ", project, key);
577   }
578   fprintf(OUT, "\n");
579
580   fprintf(OUT,
581           "\n"
582           "## By default, build all the binaries\n"
583           "all: $(BIN_FILES)\n"
584           "\n");
585    
586   fprintf(OUT, "\n## generate temps: regenerate the source file each time the deployment file changes\n");
587   xbt_dict_foreach(process_function_set,cursor,key,data) {
588     fprintf(OUT, RL_SOURCENAME, project,key);
589     fprintf(OUT, " ");
590   }
591   fprintf(OUT, SIM_SOURCENAME, project);
592   fprintf(OUT, ": %s\n", deployment);
593   fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
594
595   fprintf(OUT, "\n## Generate the binaries\n");
596   fprintf(OUT, SIM_BINARYNAME ": " SIM_OBJNAME " $(OBJ_FILES)\n",project, project);
597   fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ \n");
598   xbt_dict_foreach(process_function_set,cursor,key,data) {
599     fprintf(OUT, RL_BINARYNAME " : " RL_OBJNAME " $(OBJ_FILES)\n", project, key, project, key);
600     fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ \n");
601   }  
602   fprintf(OUT, 
603           "\n"
604           "%%: %%.o\n"
605           "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ \n"
606           "\n"
607           "%%.o: %%.c\n"
608           "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<\n"
609           "\n");
610    
611   fprintf(OUT,
612           "## Rules for tarballs and cleaning\n"
613           "DIST_FILES= $(EXTRA_DIST) $(GENERATED_C_FILES) $(PRECIOUS_C_FILES) "MAKEFILE_FILENAME_LOCAL" " /*MAKEFILE_FILENAME_REMOTE*/"\n"
614           "distdir: $(DIST_FILES)\n"
615           "\trm -rf $(DISTDIR)\n"
616           "\tmkdir -p $(DISTDIR)\n"
617           "\tcp $^ $(DISTDIR)\n"
618           "\n"
619           "dist: clean distdir\n"
620           "\ttar c $(DISTDIR) | gzip -c9 > $(DISTDIR).tar.gz\n"
621           "\n", project /*, project*/);
622
623   fprintf(OUT,
624           "clean:\n"
625           "\trm -f $(BIN_FILES) $(OBJ_FILES) *~ %s.o " SIM_OBJNAME, project, project);
626   xbt_dict_foreach(process_function_set,cursor,key,data) {
627      fprintf(OUT, " " RL_OBJNAME, project, key);
628   }
629   fprintf(OUT,   
630           "\n"
631           "\trm -rf $(DISTDIR)\n"
632           "\n"
633           ".SUFFIXES:\n"
634           ".PHONY : clean\n"
635           "\n");
636   /* 
637   fprintf(OUT, "############ REMOTE COMPILING #########\n");
638   fprintf(OUT, 
639           "MACHINES ?= ");
640   xbt_dict_foreach(machine_set,cursor,key,data) {
641     fprintf(OUT, "%s ",key);
642   }
643   fprintf(OUT,"\n");
644
645   fprintf(OUT, 
646           "INSTALL_PATH ?='$$HOME/tmp/src' ### Has to be an absolute path !!! \n"
647           "GRAS_ROOT ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! \n"
648           "SRCDIR ?= ./\n"
649           "SIMGRID_URL ?=http://gcl.ucsd.edu/simgrid/dl/\n"
650           "SIMGRID_VERSION ?=2.92\n"
651           "GRAS_PROJECT ?= %s\n"
652           "GRAS_PROJECT_URL ?= http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
653           "\n"
654           "remote:\n"
655           "\t@echo;echo \"----[ Compile the package on remote hosts ]----\"\n"
656           "\t@test -e $(SRCDIR)/buildlogs/ || mkdir -p $(SRCDIR)/buildlogs/\n"
657           "\t for site in $(MACHINES) ; do \\\n"
658           "\t   machine=`echo $$site |sed 's/^\\([^%%]*\\)%%.*$$/\\1/'`;\\\n"
659           "\t   machine2=`echo $$site |sed 's/^\\([^%%]*\\)%%\\(.*\\)$$/\\2/'`;\\\n"
660           "\t   cmd_mkdir=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
661           "\t                        SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
662           "\t                        GRAS_PROJECT_URL=$(GRAS_PROJECT_URL)  mkdir -p $(INSTALL_PATH) 2>&1'\\\"\";\\\n"
663           "\t   cmd_make=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
664           "\t                        SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
665           "\t                        GRAS_PROJECT_URL=$(GRAS_PROJECT_URL)  make -C $(INSTALL_PATH) -f "MAKEFILE_FILENAME_REMOTE" $(ACTION) 2>&1'\\\"\";\\\n"
666           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
667           "\t     echo \"----[ Compile on $$machine2 (behind $$machine) ]----\";\\\n"
668           "\t   else \\\n"
669           "\t     machine=$$site;\\\n"
670           "\t     echo \"----[ Compile on $$machine ]----\";\\\n"
671           "\t   fi;\\\n"
672           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
673           "\t     if ssh $$machine \"ssh -A $$machine2 $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log;\\\n"
674           "\t     then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;\\\n"
675           "\t   else \\\n"
676           "\t     if ssh $$machine \"eval $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log ;\\\n"
677           "\t     then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi; \\\n"
678           "\t   fi;\\\n"
679           "\t   echo \"-- Copy the data over\"; \\\n"
680           "\t   scp "MAKEFILE_FILENAME_REMOTE" $$site:$(INSTALL_PATH) ;\\\n"
681           "\t   echo \"-- Compiling... (the output gets into $(SRCDIR)/buildlogs/$$site.log)\"; \\\n"
682           "\t   if echo $$site | grep  '%%' >/dev/null ; then \\\n"
683           "\t     if ssh $$machine \"ssh -A $$machine2 $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log;\\\n"
684           "\t     then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
685           "\t   else \\\n"
686           "\t     if ssh $$machine \"eval $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log ;\\\n"
687           "\t     then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
688           "\t   fi;\\\n"
689           "\t done;\n",project,project,project);
690 */
691   fclose(OUT);
692 }
693
694 static void generate_makefile_remote(char *project, char *deployment)
695 {
696   char *filename = NULL;
697   FILE *OUT = NULL;
698
699   filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_REMOTE));
700   sprintf(filename,MAKEFILE_FILENAME_REMOTE, project);
701   
702   OUT=fopen(filename,"w");
703   xbt_assert1(OUT, "Unable to open %s for writing",filename);
704
705   fprintf(OUT, 
706           "INSTALL_PATH ?= $(shell pwd)\n"
707           "\n"
708           "compile-simgrid:\n"
709           "\tcd $$GRAS_ROOT ; \\\n"
710           "\tretrieved=`LANG=C;wget -N $(SIMGRID_URL)/simgrid-$(SIMGRID_VERSION).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
711           "\techo $$retrieved; \\\n"
712           "\tif test \"x$$retrieved\" = x; then \\\n"
713           "\t  tar zxf simgrid-$(SIMGRID_VERSION).tar.gz ; \\\n"
714           "\t  cd simgrid-$(SIMGRID_VERSION)/; \\\n"
715           "\t  ./configure --prefix=$$GRAS_ROOT ; \\\n"
716           "\t  make all install ;\\\n"
717            "\tfi\n"
718           "\n"
719           "compile-gras: compile-simgrid\n"
720           "\tnot_retrieved=`LANG=C;wget -N $(GRAS_PROJECT_URL)/gras-$(GRAS_PROJECT).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
721           "\techo $$not_retrieved; \\\n"
722           "\tif test \"x$$not_retrieved\" != xyes; then \\\n"
723           "\t  tar zxf gras-$(GRAS_PROJECT).tar.gz ; \\\n"
724           "\t  make -C gras-$(GRAS_PROJECT)/ -f $(GRAS_PROJECT).Makefile.local all ; \\\n"
725           "\tfi\n"
726           "\n"
727           "clean-simgrid:\n"
728           "\trm -rf simgrid-$(SIMGRID_VERSION)*\n"
729           "clean-gras clean-gras-$(GRAS_PROJECT):\n"
730           "\trm -rf gras-$(GRAS_PROJECT)*\n"
731           "clean: clean-simgrid clean-gras-$(GRAS_PROJECT)\n"
732           "\n"
733           ".PHONY: clean clean-simgrid clean-gras clean-gras-$(GRAS_PROJECT) \\\n"
734           "        compile-simgrid compile-gras\n"
735           );
736   fclose(OUT);
737 }
738
739 static void print(void *p)
740 {
741   printf("%p",p);
742 }
743
744
745 #ifdef _WIN32
746 #include <windows.h>
747 #endif
748
749 /* specific to Borland Compiler */
750 #ifdef __BORLANDDC__
751 #pragma argsused
752 #endif
753
754 int main(int argc, char *argv[])
755 {
756   char *project_name = NULL;
757   char *deployment_file = NULL;
758   int i;
759    
760   surf_init(&argc, argv);
761   process_function_set = xbt_dict_new();
762   process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free);
763   machine_set = xbt_dict_new();
764
765   for (i=1; i<argc; i++) {
766      int need_removal = 0;
767      if (!strncmp("--extra-process=",argv[i], strlen("--extra-process="))) {
768         xbt_dict_set(process_function_set, argv[i]+strlen("--extra-process="), NULL, NULL);
769         need_removal = 1;
770      }
771      
772      
773      if (need_removal) { /* remove the handled argument from argv */
774         int j;  
775         for (j=i+1; j<argc; j++) {
776            argv[j-1] = argv[j];
777         }
778         argv[j-1] = NULL;
779         argc--;
780         i--; /* compensate effect of next loop incrementation */
781      }
782   }
783         
784   xbt_assert1((argc >= 3),"Usage: %s project_name deployment_file [deployment_file...]\n",argv[0]);
785
786   project_name = argv[1];
787
788   STag_surfxml_process_fun = parse_process_init;
789   ETag_surfxml_argument_fun = parse_argument;
790   ETag_surfxml_process_fun = parse_process_finalize;
791   
792   for(i=2; i<argc; i++) {
793      deployment_file = argv[i];
794      surf_parse_open(deployment_file);
795      if(surf_parse()) 
796         xbt_assert1(0,"Parse error in %s",deployment_file);
797      
798      surf_parse_close();
799   }
800
801
802   warning = xbt_new(char,strlen(WARN)+strlen(deployment_file)+10);
803   sprintf(warning,WARN,deployment_file);
804
805   /*if(XBT_LOG_ISENABLED(stubgen, xbt_log_priority_debug)) {
806     xbt_dict_cursor_t cursor=NULL;
807     char *key = NULL;
808     void *data = NULL;
809
810     for (cursor=NULL, xbt_dict_cursor_first((process_function_set),&(cursor)) ;
811          xbt_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));
812          xbt_dict_cursor_step(cursor) ) {
813       DEBUG1("Function %s", key);      
814     }
815     
816     xbt_dict_dump(process_function_set,print);
817   }*/
818
819   generate_sim(project_name);
820   generate_rl(project_name);
821   generate_makefile_local(project_name, deployment_file);
822   #ifdef _WIN32
823   generate_borland_simulation_project(project_name);
824   generate_borland_real_life_project(project_name);
825   generate_simulation_dsp_file(project_name);
826   generate_real_live_dsp_file(project_name);
827
828   if(__gras_path)
829     xbt_free(__gras_path);
830   
831
832   #endif
833 //  generate_makefile_remote(project_name, deployment_file);
834 //  generate_deployment(project_name, deployment_file);
835
836   free(warning);
837   surf_exit();
838   return 0;
839 }
840 #ifdef _WIN32
841 void
842 generate_borland_project(borland_project_t project,int is_rl,const char* name)
843 {
844         char* binary_path;      /* the path of the generated binary file                                */
845         char* obj_path;         /* the path of the generated object file                                */
846         char* lib_files;        /* a list of the libraries used in the borland project  */
847         char* main_source;      /* the name of the bpf file used by the borland project */
848         char* file_name;        /* the file name of the main source file                                */
849     char* include_path; /* the include path                                     */
850         char* buffer;
851
852     /* create the borland project file */
853     borland_project_create(project);
854
855     /* write the xml document header */
856     borland_project_write_xml_header(project);
857
858     /* write the xml comment to identify a borland project file */
859     borland_project_write_xml_comment(project);
860         
861         /* write the begin of the node PROJECT */
862         borland_project_begin_xml_node(project,"PROJECT");
863         
864         /* write the begin of node MACROS */
865         borland_project_begin_xml_node(project,"MACROS");
866         
867         /* write the borland project version */
868         borland_project_write_xml_element(project,"VERSION",project->version);
869         
870         /* construct and write the borland project binary path */
871         binary_path = xbt_new0(char,strlen(project->name) + strlen(project->bin_dir) + 6);
872         sprintf(binary_path,"%s\\%s.exe",project->bin_dir,project->name);
873         borland_project_write_xml_element(project,"PROJECT",binary_path);
874         xbt_free(binary_path);
875         
876         /* construct an write the object files to generate by the compiler */
877         obj_path = xbt_new0(char,strlen(project->name) + strlen(name) + (2*strlen(project->obj_dir)) + 11);
878         sprintf(binary_path,"%s\\%s.obj\n%s\\%s.obj",project->obj_dir,project->name,project->obj_dir,name);
879         borland_project_write_xml_element(project,"OBJFILES",obj_path);
880         xbt_free(obj_path);
881         
882         /* write the resource files used by the compiler (no resource file used) */
883         borland_project_write_xml_element(project,"RESFILES","");
884         
885         /* write the IDL files of the project (no IDL files used) */
886         borland_project_write_xml_element(project,"IDLFILES","");
887         
888         /* write the IDLGENFILES element (not used) */
889         borland_project_write_xml_element(project,"IDLGENFILES","");
890         
891         /* write the DEFFILE element (not used) */
892         borland_project_write_xml_element(project,"DEFFILE","");
893         
894         /* write the RESDEPEN element (not used, no resource file used) */
895         borland_project_write_xml_element(project,"RESDEPEN","$(RESFILES)");
896
897         /* construct and write the list of libraries used by the project */
898         /*
899     lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + strlen("libgras.lib") + 3);
900         sprintf(lib_files,"%s\\simgrid.lib %s\\libgras.lib",project->lib_dir,project->lib_dir);
901     */
902         
903         if(is_rl){
904                 lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("libgras.lib") + 2);
905                 sprintf(lib_files,"%s\\libgras.lib",project->lib_dir);  
906         }else{
907         lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + 2);
908                 sprintf(lib_files,"%s\\simgrid.lib",project->lib_dir);
909         }
910
911         borland_project_write_xml_element(project,"LIBFILES",lib_files);
912         xbt_free(lib_files);
913         
914         /* write the SPARELIBS element (not used) */
915         borland_project_write_xml_element(project,"SPARELIBS","");
916         
917         /* write the PACKAGES element (no package used) */
918         borland_project_write_xml_element(project,"PACKAGES","");
919         
920         /* write the PATHCPP element (the path of the source files of the project)*/
921         borland_project_write_xml_element(project,"PATHCPP",".;");
922         
923         /* write the PATHPAS element (not used) */
924         borland_project_write_xml_element(project,"PATHPAS","");
925         
926         /* write the PATHRC element (not used) */
927         borland_project_write_xml_element(project,"PATHRC","");
928         
929         /* write the PATHASM element (not used) */
930         borland_project_write_xml_element(project,"PATHASM","");
931         
932         /* write the DEBUGLIBPATH element (the path for debug) */
933         borland_project_write_xml_element(project,"DEBUGLIBPATH","$(BCB)\\lib\\debug");
934         
935         /* write the RELEASELIBPATH element (the path for release) */
936         borland_project_write_xml_element(project,"RELEASELIBPATH","$(BCB)\\lib\\release");
937         
938         /* specify the linker to use */
939         borland_project_write_xml_element(project,"LINKER","ilink32");
940         
941         /* write the USERDEFINES element (user definitions (#define _DEBUG))*/
942         borland_project_write_xml_element(project,"USERDEFINES","_DEBUG");
943         
944         /* write the SYSDEFINES element (use the system definitions, not used strict ANSI and no use the VCL)*/
945         borland_project_write_xml_element(project,"SYSDEFINES","NO_STRICT;_NO_VCL");
946
947         /* construct and write the MAINSOURCE element */
948         main_source = xbt_new0(char,strlen(project->name) + 5);
949         sprintf(main_source,"%s.bpf",project->name);
950     /* write the main source file to use in the borland project file */
951         borland_project_write_xml_element(project,"MAINSOURCE",main_source);
952
953         /* create the bpf file used by the borland project */
954         borland_project_create_main_file(main_source);
955
956         /* FIXME resolve the include path */
957         /* write the INCLUDEPATH element  */
958
959     if(!__gras_path){
960         buffer =xbt_new0(char,MAX_PATH);
961         GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
962         
963                 __gras_path = xbt_new0(char,MAX_PATH);
964                 sprintf(__gras_path,"%s\\simgrid\\include",buffer);
965                 free(buffer);
966
967         /*find_file_path("C:\\","gras.h",__gras_path);*/
968     }
969
970     include_path = xbt_new0(char,strlen("$(BCB)\\include") + strlen(__gras_path) + 2);
971     sprintf(include_path,"$(BCB)\\include;%s",__gras_path);
972
973         borland_project_write_xml_element(project,"INCLUDEPATH",include_path);
974
975     xbt_free(include_path);
976
977         /* write the LIBPATH element (no librarie paths specified)*/
978         borland_project_write_xml_element(project,"LIBPATH","$(BCB)\\lib;$(BCB)\\lib\\obj");
979
980         /*
981      * write the WARNINGS element :
982      *  -w-sus (-w-8075) disabled the suspect conversion pointer warning
983      *  -w-rvl (-w-8070) disabled the function must return warning
984      *  -w-rch (-w-8066) disabled the warning which specify that we can't attain the code
985      *  -w-pia (-w-8060) disabled the warning that detect a possible bad assignement
986      *  -w-pch (-w-8058) disabled the warning throw when the compiler can't precompile a header file
987      *  -w-par (-w-8057) disabled the warning that detect an unused variable
988      *  -w-csu (-w-8012) disabled the warning that detect a comparison between a signed number and an unsigned number
989      *  -w-ccc (-w-8008) disabled the warning that detect une conditon which is always true
990      *  -w-aus (-w-8008) disabled the warning that detect an affected value which is never used
991      */
992         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");
993
994         /* write the OTHERFILES element (no other files used used) */
995         borland_project_write_xml_element(project,"OTHERFILES","");
996
997         /* write the end of the node MACROS */
998         borland_project_end_xml_node(project,"MACROS");
999
1000         /* write the begin of the node OPTIONS */
1001         borland_project_begin_xml_node(project,"OPTIONS");
1002
1003         /* FIXME check the idlcflags */
1004         /* write the IDLCFLAGS element */
1005         borland_project_write_xml_element(project,"IDLCFLAGS","");
1006
1007         /*
1008      * write the CFLAG1 element (compiler options ) :
1009      *
1010      *  -Od     this flag disable all compiler optimisation
1011      *  -H      this flag specify the name of the file which will contain the precompiled header
1012      *  -Hc     this flag specify to the compiler to cach the precompiled header
1013      *  -Vx     this flag specify to the compiler to allow the empty structures
1014      *  -Ve     this flag specify to the compiler to allow the empty base classes
1015      *  -X-     this flag activate the auto-depend informations of the compiler
1016      *  -r-     this flag disabled the use of the processor register
1017      *  -a1     this flag specify that the data must be aligned on one byte
1018      *  -b-     this flag specify that the enums are the smallest size of the integer
1019      *  -k      (used during debug)
1020      *  -y      this flag generate the line number for debug
1021      *  -v      this flag enabled the debugging of the source files
1022      *  -vi     check the expansion of the inline functions
1023      *  -tWC    specify that it's a console application
1024      *  -tWM-   specify that the application is not multithread
1025      *  -c      generate the object file, no link
1026      */
1027         borland_project_write_xml_element(project,"CFLAG1","-Od -H=$(BCB)\\lib\\vcl60.csm -Hc -Vx -Ve -X- -r- -a8 -b- -k -y -v -vi- -tWC -tWM- -c");
1028
1029         /* write the PFLAGS element */
1030         borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE ");
1031
1032         /* write the RFLAGS element */
1033         borland_project_write_xml_element(project,"RFLAGS","");
1034
1035         /* write the AFLAGS element (assembler flags) :
1036      *
1037      *  /mx (not documented)
1038      *  /w2 (not documented)
1039      *  /zd (not documented)
1040      *
1041      */
1042         borland_project_write_xml_element(project,"AFLAGS","/mx /w2 /zd");
1043
1044         /* write the LFLAGS element (linker flags) :
1045      *
1046      *  -I      specify the output directory for object files
1047      *  -D      register the specified description (no description "")
1048      *  -ap     build a win32 console application
1049      *  -Tpe    generate a exe file
1050      *  -x      do not create the map file
1051      *  -Gn     do not generate the state file
1052      *  -v      include the complete debug informations  
1053      */
1054         borland_project_write_xml_element(project,"LFLAGS","-Iobj -D&quot;&quot; -ap -Tpe -x -Gn -v");
1055
1056         /* write the OTHERFILES element (not used)*/
1057         borland_project_write_xml_element(project,"OTHERFILES","");
1058
1059         /* write the end of the node OPTIONS */
1060         borland_project_end_xml_node(project,"OPTIONS");
1061
1062         /* write the begin of the node LINKER */
1063         borland_project_begin_xml_node(project,"LINKER");
1064
1065         /* write the ALLOBJ element */
1066         borland_project_write_xml_element(project,"ALLOBJ","c0x32.obj $(OBJFILES)");
1067
1068         /* write the ALLRES element (not used) */
1069         borland_project_write_xml_element(project,"ALLRES","");
1070
1071         /* write the ALLLIB element */
1072         borland_project_write_xml_element(project,"ALLLIB","$(LIBFILES) $(LIBRARIES) import32.lib cw32.lib");
1073
1074         /* write the OTHERFILES element (not used) */
1075         borland_project_write_xml_element(project,"OTHERFILES","");
1076
1077         /* write the end of the node LINKER */
1078         borland_project_end_xml_node(project,"LINKER");
1079
1080         /* write the begin of the node FILELIST */
1081         borland_project_begin_xml_node(project,"FILELIST");
1082         
1083         /* construct and write the list of file elements */
1084         
1085         /* add the bpf file to the list */
1086         borland_project_write_file_element(project,main_source,"",project->name,"BPF","","");
1087         xbt_free(main_source);
1088         
1089         /* FIXME : check the source file directory */
1090         /* add the generated source file to the list */
1091         
1092         file_name = xbt_new0(char,strlen(project->src_dir) + strlen(project->name) + 5);
1093         sprintf(file_name,"%s\\_%s.c",project->src_dir,project->name);
1094         borland_project_write_file_element(project,file_name,"",project->name,"CCompiler","","");
1095
1096         memset(file_name,0,strlen(project->src_dir) + strlen(project->name) + 4);
1097         sprintf(file_name,"%s\\%s.c",project->src_dir,name);
1098         borland_project_write_file_element(project,file_name,"",name,"CCompiler","","");
1099
1100         xbt_free(file_name);
1101
1102         /* FIXME : check the libraries directory */
1103         /* add the simgrid library to the list */
1104         
1105         if(is_rl){
1106                 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("libgras.lib") + 2);
1107                 sprintf(file_name,"%s\\libgras.lib",project->lib_dir);
1108                 borland_project_write_file_element(project,file_name,"","libgras.lib","LibTool","","");
1109         }else
1110         {
1111                 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
1112                 sprintf(file_name,"%s\\simgrid.lib",project->lib_dir);
1113                 borland_project_write_file_element(project,file_name,"","simgrid.lib","LibTool","","");
1114         }
1115         
1116         
1117         xbt_free(file_name);
1118
1119         /* write the end of the node FILELIST */
1120         borland_project_end_xml_node(project,"FILELIST");
1121         
1122         /* write the begin of the node BUILDTOOLS (not used)*/
1123         borland_project_begin_xml_node(project,"BUILDTOOLS");
1124         
1125         /* write the end of the node BUILDTOOLS (not used)*/
1126         borland_project_end_xml_node(project,"BUILDTOOLS");
1127         
1128         /* write the begin of the node IDEOPTIONS */
1129         borland_project_begin_xml_node(project,"IDEOPTIONS");
1130         
1131         /* write all of the option of the IDE of Borland C++ Builder */
1132         borland_project_write_ide_options(project);
1133         
1134         /* write the end of the node IDEOPTIONS */
1135         borland_project_end_xml_node(project,"IDEOPTIONS");
1136
1137     /* write the end of the node PROJECT */
1138         borland_project_end_xml_node(project,"PROJECT");
1139
1140     /* close the borland project file */
1141     borland_project_close(project);
1142 }
1143
1144 void
1145 borland_project_write_tabs(borland_project_t project,unsigned int count)
1146 {
1147         unsigned int pos;
1148         
1149         for(pos = 0; pos < count; pos++)
1150                 fprintf(project->stream,"\t");          
1151 }
1152
1153 void
1154 borland_project_begin_xml_node(borland_project_t project, const char* name)
1155 {
1156         if(level)
1157                 borland_project_write_tabs(project,level);
1158                 
1159         fprintf(project->stream,"<%s>\n",name);
1160         
1161         level++;
1162 }
1163
1164 void
1165 borland_project_end_xml_node(borland_project_t project, const char* name)
1166 {
1167         level--;
1168         
1169         if(level)
1170                 borland_project_write_tabs(project,level);
1171         
1172         fprintf(project->stream,"</%s>\n",name);        
1173 }
1174
1175
1176 void
1177 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value)
1178 {
1179         borland_project_write_tabs(project,level);
1180         fprintf(project->stream,"<%s value=\"%s\"/>\n",name,value);
1181 }
1182
1183 void
1184 borland_project_write_xml_header(borland_project_t project)
1185 {
1186     fprintf(project->stream,"<?xml version='%s' encoding='%s' ?>\n",project->xml_version, project->encoding);
1187 }
1188
1189 void
1190 borland_project_create_main_file(const char* name)
1191 {
1192         FILE* stream = fopen(name,"w+");
1193
1194         fprintf(stream,"Ce fichier est uniquement utilisé par le gestionnaire de projets et doit Ãªtre traité comme le fichier projet\n\n\nmain\n");
1195
1196         fclose(stream);
1197 }
1198
1199 void
1200 borland_project_create(borland_project_t project)
1201 {
1202     char* file_name = xbt_new0(char,strlen(project->name ) + 5);
1203     sprintf(file_name,"%s.bpr",project->name);
1204     project->stream = fopen(file_name,"w+");
1205     xbt_free(file_name);
1206 }
1207
1208 void
1209 borland_project_write_xml_comment(borland_project_t project)
1210 {
1211     fprintf(project->stream,"<!-- %s -->\n",project->comment);
1212 }
1213 void
1214 borland_project_write_file_element(     borland_project_t project,
1215                                                                         const char* file_name,
1216                                                                         const char* form_name,
1217                                                                         const char* unit_name,
1218                                                                         const char* container_id,
1219                                                                         const char* design_class,
1220                                                                         const char* local_command)
1221 {
1222         borland_project_write_tabs(project,level);
1223
1224         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);
1225 }
1226
1227 void
1228 borland_project_write_ide_options(borland_project_t project)
1229 {
1230
1231         const char* ide_options =
1232         "[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"  \
1233         "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n" \
1234         "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n" \
1235         "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n" \
1236         "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n" \
1237         "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n" \
1238         "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n" \
1239         "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n" \
1240         "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n" \
1241         "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n" \
1242         "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n" \
1243         "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n" \
1244         "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n" \
1245         "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n" \
1246         "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n";
1247
1248         fprintf(project->stream,ide_options);
1249 }
1250
1251 void
1252 borland_project_close(borland_project_t project)
1253 {
1254     fclose(project->stream);
1255 }
1256
1257 void
1258 generate_borland_simulation_project(const char* name)
1259 {
1260     char buffer[MAX_PATH] = {0};
1261
1262     HANDLE hDir;
1263     WIN32_FIND_DATA wfd = {0};
1264
1265     s_borland_project_t borland_project = {0};
1266     borland_project.xml_version = "1.0";
1267     borland_project.encoding ="utf-8";
1268     borland_project.comment ="C++Builder XML Project";
1269     borland_project.version = "BCB.06.00";
1270
1271     borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1272
1273     
1274     GetEnvironmentVariable("LIB_SIMGRID_PATH",borland_project.lib_dir,MAX_PATH);
1275                 
1276
1277     GetCurrentDirectory(MAX_PATH,buffer);
1278
1279     borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1280
1281     strcpy(borland_project.src_dir,buffer);
1282
1283     borland_project.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
1284     sprintf(borland_project.name,"%s_simulator",name);
1285
1286     borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1287     sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1288
1289     hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1290
1291     if(!hDir)
1292         CreateDirectory(borland_project.bin_dir,NULL);
1293
1294     borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1295     sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1296
1297     hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1298
1299     if(INVALID_HANDLE_VALUE == hDir)
1300         CreateDirectory(borland_project.obj_dir,NULL);
1301
1302     generate_borland_project(&borland_project,0,name);
1303
1304     xbt_free(borland_project.name);
1305     xbt_free(borland_project.src_dir);
1306     xbt_free(borland_project.bin_dir);
1307     xbt_free(borland_project.obj_dir);
1308     xbt_free(borland_project.lib_dir);
1309 }
1310
1311 void
1312 generate_borland_real_life_project(const char* name)
1313 {
1314     HANDLE hDir;
1315     WIN32_FIND_DATA wfd = {0};
1316     char buffer[MAX_PATH] = {0};
1317     xbt_dict_cursor_t cursor = NULL;
1318     char *key = NULL;
1319     void *data = NULL;
1320         s_borland_project_t borland_project = {0};
1321
1322         borland_project.xml_version = "1.0";
1323     borland_project.encoding ="utf-8";
1324     borland_project.comment ="C++Builder XML Project";
1325     borland_project.version = "BCB.06.00";
1326     borland_project.lib_dir = " ";
1327
1328     borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1329
1330     GetEnvironmentVariable("LIB_GRAS_PATH",borland_project.lib_dir,MAX_PATH);
1331        
1332     GetCurrentDirectory(MAX_PATH,buffer);
1333
1334     borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1335
1336     strcpy(borland_project.src_dir,buffer);
1337
1338     borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1339     sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1340
1341     hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1342
1343     if(INVALID_HANDLE_VALUE == hDir)
1344         CreateDirectory(borland_project.bin_dir,NULL);
1345
1346     borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1347     sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1348
1349     hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1350
1351     if(!hDir)
1352         CreateDirectory(borland_project.obj_dir,NULL);
1353
1354
1355         xbt_dict_foreach(process_function_set,cursor,key,data) {
1356         borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
1357
1358         sprintf(borland_project.name,"%s_%s",name,key);
1359
1360         generate_borland_project(&borland_project,1,name);
1361         xbt_free(borland_project.name);
1362     }
1363
1364     xbt_free(borland_project.src_dir);
1365     xbt_free(borland_project.bin_dir);
1366     xbt_free(borland_project.obj_dir);
1367     xbt_free(borland_project.lib_dir);
1368 }
1369 int
1370 find_file_path(const char* root_dir,const char* file_name,char* path)
1371 {
1372         HANDLE hFind;
1373         WIN32_FIND_DATA wfd;
1374         char* prev_dir = xbt_new(char,MAX_PATH);
1375         GetCurrentDirectory(MAX_PATH,prev_dir);
1376         SetCurrentDirectory(root_dir);
1377         
1378         // begining of the scan
1379         hFind=FindFirstFile ("*.*", &wfd);
1380         
1381         if(hFind!=INVALID_HANDLE_VALUE){
1382         
1383                 /* it's a file */
1384                 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1385                 
1386                         if(!strcmp(file_name,wfd.cFileName)){
1387                                 GetCurrentDirectory(MAX_PATH,path);
1388                                 SetCurrentDirectory(prev_dir);
1389                                 xbt_free(prev_dir);
1390                                 FindClose(hFind);
1391                                 return 1;
1392                         }
1393                 
1394                 }
1395                 /* it's a directory, scan it*/
1396                 else {
1397                 
1398                         if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1399                                 if(find_file_path(wfd.cFileName,file_name,path)){
1400                                         FindClose(hFind);
1401                                         SetCurrentDirectory(prev_dir);
1402                                         return 1;
1403                                 }
1404                         }
1405                 }
1406                 
1407                 /* next file or directory */
1408                 while(FindNextFile(hFind,&wfd))
1409                 {
1410                         /* it's a file */
1411                         if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
1412                         {
1413                                 if(!strcmp(file_name,wfd.cFileName)){
1414                                         GetCurrentDirectory(MAX_PATH,path);
1415                                         SetCurrentDirectory(prev_dir);
1416                                         xbt_free(prev_dir);
1417                                         FindClose(hFind);
1418                                         return 1;
1419                                 }
1420                         }
1421                         /* it's a file scan it */
1422                         else {
1423                 
1424                                 if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1425                 
1426                                         if(find_file_path(wfd.cFileName,file_name,path)){
1427                                                 SetCurrentDirectory(prev_dir);
1428                                                 FindClose(hFind);
1429                                                 return 1;
1430                                         }
1431                 
1432                                 }
1433                 
1434                         }
1435                 }
1436         }
1437         
1438         SetCurrentDirectory(prev_dir);
1439         xbt_free(prev_dir);
1440         FindClose (hFind);
1441         return 0;
1442 }
1443
1444 /* Implementation of the functions used to create a Visual C++ project.*/
1445
1446 int
1447 generate_simulation_dsp_file(const char* name)
1448 {
1449         char buffer[MAX_PATH] = {0};
1450     s_dsp_t dsp = {0};
1451     dsp.lib_dir = xbt_new0(char,MAX_PATH);
1452
1453     GetEnvironmentVariable("LIB_SIMGRID_PATH",dsp.lib_dir,MAX_PATH);
1454     GetCurrentDirectory(MAX_PATH,buffer);
1455
1456     dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
1457     strcpy(dsp.src_dir,buffer);
1458         dsp.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
1459         sprintf(dsp.name,"%s_simulator",name);
1460
1461     generate_dsp_project(&dsp,0,name);
1462
1463     xbt_free(dsp.name);
1464     xbt_free(dsp.src_dir);
1465         xbt_free(dsp.lib_dir);
1466     
1467     return 0;           
1468 }
1469
1470 /*
1471  * Create the Microsoft visual C++ real life project file.
1472  */
1473 int
1474 generate_real_live_dsp_file(const char* name)
1475 {
1476         
1477     char buffer[MAX_PATH] = {0};
1478     xbt_dict_cursor_t cursor = NULL;
1479     char *key = NULL;
1480     void *data = NULL;
1481         s_dsp_t dsp = {0};
1482
1483         
1484     dsp.lib_dir = xbt_new0(char,MAX_PATH);
1485
1486     GetEnvironmentVariable("LIB_GRAS_PATH",dsp.lib_dir,MAX_PATH);
1487        
1488     GetCurrentDirectory(MAX_PATH,buffer);
1489
1490     dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
1491
1492     strcpy(dsp.src_dir,buffer);
1493
1494
1495         xbt_dict_foreach(process_function_set,cursor,key,data) {
1496         dsp.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
1497
1498         sprintf(dsp.name,"%s_%s",name,key);
1499
1500         generate_dsp_project(&dsp,1,name);
1501         xbt_free(dsp.name);
1502     }
1503
1504     xbt_free(dsp.src_dir);
1505     xbt_free(dsp.lib_dir);
1506         return 0;
1507 }
1508
1509 void
1510 generate_dsp_project(dsp_t project,int is_rl,const char* name)
1511 {
1512         /* create the visual C++ project file */
1513         char* buffer;
1514         char* file_name = xbt_new0(char,strlen(project->name) + 5);
1515     sprintf(file_name,"%s.dsp",project->name);
1516     project->stream = fopen(file_name,"w+");
1517     xbt_free(file_name);
1518     
1519     if(!__gras_path)
1520         {
1521         buffer =xbt_new0(char,MAX_PATH);
1522         GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
1523         
1524                 __gras_path = xbt_new0(char,MAX_PATH);
1525                 sprintf(__gras_path,"%s\\simgrid\\include",buffer);
1526                 free(buffer);
1527     }
1528     
1529     /* dsp file header */
1530     fprintf(project->stream,"# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\n",project->name);
1531         fprintf(project->stream,"# Microsoft Developer Studio Generated Build File, Format Version 6.00\n");
1532         fprintf(project->stream,"# ** DO NOT EDIT **\n\n");
1533         
1534         /* target type is a win32 x86 console application */
1535         fprintf(project->stream,"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\n");
1536         
1537         /* the current config is win32-debug */
1538         fprintf(project->stream,"CFG=%s - Win32 Debug\n",project->name);
1539         
1540         /* warning */
1541         fprintf(project->stream,"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n");
1542         
1543         /* NMAKE usage */
1544         fprintf(project->stream,"!MESSAGE use the Export Makefile command and run\n");
1545         fprintf(project->stream,"!MESSAGE\n");
1546         fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\".\n",project->name);
1547         fprintf(project->stream,"!MESSAGE\n");
1548         fprintf(project->stream,"!MESSAGE You can specify a configuration when running NMAKE\n");
1549         fprintf(project->stream,"!MESSAGE by defining the macro CFG on the command line. For example:\n");
1550         fprintf(project->stream,"!MESSAGE\n"); 
1551         fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\n",project->name,project->name);
1552         fprintf(project->stream,"!MESSAGE\n");
1553         fprintf(project->stream,"!MESSAGE Possible choices for configuration are:\n");
1554         fprintf(project->stream,"!MESSAGE\n"); 
1555         fprintf(project->stream,"!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n",project->name);
1556         fprintf(project->stream,"!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n",project->name);
1557         fprintf(project->stream,"!MESSAGE\n\n"); 
1558         
1559         fprintf(project->stream,"# Begin Project\n\n");
1560         fprintf(project->stream,"# PROP AllowPerConfigDependencies 0\n");
1561         fprintf(project->stream,"# PROP Scc_ProjName\n");
1562         fprintf(project->stream,"# PROP Scc_LocalPath\n");
1563         fprintf(project->stream,"CPP=cl.exe\n");
1564         fprintf(project->stream,"RSC=rc.exe\n\n");
1565         
1566         fprintf(project->stream,"!IF  \"$(CFG)\" == \"%s - Win32 Release\"\n\n",project->name);
1567         
1568         fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
1569         fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 0\n");
1570         fprintf(project->stream,"# PROP BASE Output_Dir \"Release\"\n");
1571         fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Release\"\n");
1572         fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
1573         fprintf(project->stream,"# PROP Use_MFC 0\n");
1574         fprintf(project->stream,"# PROP Use_Debug_Libraries 0\n");
1575         fprintf(project->stream,"# PROP Output_Dir \"Release\"\n");
1576         fprintf(project->stream,"# PROP Intermediate_Dir \"Release\"\n");
1577         fprintf(project->stream,"# PROP Target_Dir \"\"\n");
1578         /* TODO : the include directory */
1579         /*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);*/
1580         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);
1581         fprintf(project->stream,"# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n");
1582         fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"NDEBUG\"\n");
1583         fprintf(project->stream,"# ADD RSC /l 0x40c /d \"NDEBUG\n");
1584         fprintf(project->stream,"BSC32=bscmake.exe\n");
1585         fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
1586         fprintf(project->stream,"# ADD BSC32 /nologo\n");
1587         fprintf(project->stream,"LINK32=link.exe\n");
1588         fprintf(project->stream,"# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n");
1589         
1590         if(is_rl)
1591                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib libgras.lib /nologo /subsystem:console /machine:I386\n\n");
1592         else
1593                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib /nologo /subsystem:console /machine:I386\n\n");
1594                         
1595         fprintf(project->stream,"!ELSEIF  \"$(CFG)\" == \"%s - Win32 Debug\"\n",project->name);
1596
1597         fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
1598         fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 1\n");
1599         fprintf(project->stream,"# PROP BASE Output_Dir \"Debug\"\n");
1600         fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Debug\"\n");
1601         fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
1602         fprintf(project->stream,"# PROP Use_MFC 0\n");
1603         fprintf(project->stream,"# PROP Use_Debug_Libraries 1\n");
1604         fprintf(project->stream,"# PROP Output_Dir \"Debug\"\n");
1605         fprintf(project->stream,"# PROP Intermediate_Dir \"Debug\"\n");
1606         fprintf(project->stream,"# PROP Ignore_Export_Lib 0\n");
1607         fprintf(project->stream,"# PROP Target_Dir \"\"\n");
1608         /* TODO : the include directory */
1609         /*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);*/
1610         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);
1611         fprintf(project->stream,"# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ  /c\n");
1612         fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"_DEBUG\"\n");
1613         fprintf(project->stream,"# ADD RSC /l 0x40c /d \"_DEBUG\"\n");
1614         fprintf(project->stream,"BSC32=bscmake.exe\n");
1615         fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
1616         fprintf(project->stream,"# ADD BSC32 /nologo\n");
1617         fprintf(project->stream,"LINK32=link.exe\n");
1618         fprintf(project->stream,"# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n");
1619         
1620         if(is_rl)
1621                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib  libgras.lib  /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n");
1622         else
1623                 fprintf(project->stream,"# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib simgrid.lib  simgrid.lib  /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n");
1624                         
1625         fprintf(project->stream,"!ENDIF\n\n");
1626         
1627         fprintf(project->stream,"# Begin Target\n\n");
1628         fprintf(project->stream,"# Name \"%s - Win32 Release\"\n",project->name);
1629         fprintf(project->stream,"# Name \"%s - Win32 Debug\"\n",project->name);
1630         fprintf(project->stream,"# Begin Group \"Source Files\"\n\n");
1631         fprintf(project->stream,"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n\n");
1632         
1633         fprintf(project->stream,"# Begin Source File\n");
1634         fprintf(project->stream,"SOURCE=%s\\_%s.c\n",project->src_dir,project->name);
1635         fprintf(project->stream,"# End Source File\n\n");
1636         
1637         fprintf(project->stream,"# Begin Source File\n");
1638         fprintf(project->stream,"SOURCE=%s\\%s.c\n",project->src_dir,name);
1639         fprintf(project->stream,"# End Source File\n\n");
1640         
1641         fprintf(project->stream,"# End Group\n");
1642         fprintf(project->stream,"# Begin Group \"Header Files\"\n\n");
1643         fprintf(project->stream,"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n");
1644         fprintf(project->stream,"# End Group\n");
1645         fprintf(project->stream,"# Begin Group \"Resource Files\"\n\n");
1646         fprintf(project->stream,"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n");
1647         fprintf(project->stream,"# End Group\n");
1648         fprintf(project->stream,"# End Target\n");
1649         fprintf(project->stream,"# End Project\n");
1650         
1651 }
1652
1653 #endif
1654
1655
1656
1657
1658