1 //---------------------------------------------------------------------------
3 /* specific to Borland Compiler */
10 /* gras_stub_generator - creates the main() to use a GRAS program */
12 /* Copyright (c) 2003,2004,2005 Martin Quinson, Arnaud Legrand.
13 All rights reserved. */
15 /* This program is free software; you can redistribute it and/or modify it
16 * under the terms of the license (GNU LGPL) which comes with this package. */
20 #include "xbt/sysdep.h"
21 #include "xbt/function_types.h"
23 #include "surf/surfxml_parse.h"
24 #include "surf/surf.h"
28 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator");
32 /* tabulation level (used to indent the lines of the borland project file */
33 static unsigned int level = 0;
40 * A structure which represents a borland project file.
42 typedef struct s_borland_project
44 const char* xml_version;/* the xml version used to write the borland project file */
45 const char* encoding; /* the encoding used to write the borland project file */
46 const char* comment; /* the xml comment to write at the begining of the borland project file */
47 char* name; /* the name of the borland project file */
48 FILE* stream; /* the stream to the borland project file */
49 const char* version; /* the builder version of the borland project file */
50 char* bin_dir; /* the directory used to store the generated program */
51 char* obj_dir; /* the directory used to store the generated object files */
52 char* lib_dir; /* the directory used to store the librairies used in the borland project */
53 char* src_dir; /* the directory use to store the source files of the project */
54 }s_borland_project_t,* borland_project_t;
57 * Write tabs in a borland project file.
58 * @param project The project concerned by the operation.
59 * @param count The count tab to write
62 borland_project_write_tabs(borland_project_t project,unsigned int count);
65 * Write the begin of an xml node in the borland project file.
66 * @param project The borland project concerned by this operation.
67 * @param name The name of the node.
70 borland_project_begin_xml_node(borland_project_t project, const char* name);
74 * Write the end of an xml node in the borland project file.
75 * @param project The borland project concerned by this operation.
76 * @param name The name of the node.
79 borland_project_end_xml_node(borland_project_t project, const char* name);
82 * Write an xml element in a borland project file.
83 * @param project The borland project concerned by this operation.
84 * @param name The name of the element to write
85 * @param value The value of the element
88 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value);
91 * Write a FILE xml element in the borland project file.
92 * @param project The borland project concerned by this operation.
93 * @param file_name The value of the attribute FILENAME.
94 * @param form_name The value of the attribute FORMNAME.
95 * @param unit_name The value of the attribute UNITNAME.
96 * @param container_id The value of the attribute CONTAINERID.
97 * @param design_claas The value of the attribute DESIGNCLASS.
98 * @param local_command The value of the attribute LOCALCOMMAND.
101 borland_project_write_file_element( borland_project_t project,
102 const char* file_name,
103 const char* form_name,
104 const char* unit_name,
105 const char* container_id,
106 const char* design_class,
107 const char* local_command);
109 * Write all options of the IDE of the Borland Builder C++ compiler.
110 * @ param project The project concerned by this operation.
114 borland_project_write_ide_options(borland_project_t project);
117 * Write the xml header of the xml document.
118 * @param project The project concerned by the operation.
121 borland_project_write_xml_header(borland_project_t project);
124 * Write an xml comment in a borland project file
125 * @param project The project concerned by this operation.
128 borland_project_write_xml_comment(borland_project_t project);
131 * Create a bpf file used by a borland project file.
132 * @param name The name of the bpf file to create.
135 borland_project_create_main_file(const char* name);
138 * Create a borland project file.
139 * @param project The project concerned by this operation.
142 borland_project_create(borland_project_t project);
145 * Close a borland project file.
146 * @param project the borland project file to close.
149 borland_project_close(borland_project_t project);
153 * Generate a borland simulation poject file.
154 * @param name The name of the simulation project
157 generate_borland_simulation_project(const char* name);
160 * Generate a borland project file for real life.
161 * @param name The name of the project to create.
164 generate_borland_real_life_project(const char* name);
167 * Generate a borland project file.
168 * @param project The borland project to generate.
171 generate_borland_project(borland_project_t project);
174 * Find the path of a file.
175 * @param file_name The file name to find.
176 * @path path If founded this parameter will contain the path of file.
177 * @return If successful the function returns 1. Otherwise the function
181 FindFilePath(const char* root_dir,const char* file_name,char* path);
187 #define WARN "/***********\n * DO NOT EDIT! THIS FILE HAS BEEN AUTOMATICALLY GENERATED FROM %s BY gras_stub_generator\n ***********/\n"
188 #define SIM_SOURCENAME "_%s_simulator.c"
189 #define SIM_OBJNAME "_%s_simulator.o"
190 #define SIM_BINARYNAME "%s_simulator"
191 #define SIM_SOURCENAME_LDADD "%s_simulator_LDADD"
192 #define SIM_SOURCENAME_SOURCES "%s_simulator_SOURCES"
193 #define RL_SOURCENAME "_%s_%s.c"
194 #define RL_OBJNAME "_%s_%s.o"
195 #define RL_BINARYNAME "%s_%s"
196 #define RL_SOURCENAME_LDADD "%s_%s_LDADD"
197 #define RL_SOURCENAME_SOURCES "%s_%s_SOURCES"
198 #define MAKEFILE_FILENAME_AM "%s.Makefile.am"
199 #define MAKEFILE_FILENAME_LOCAL "%s.mk"
200 #define MAKEFILE_FILENAME_REMOTE "%s.Makefile.remote"
201 #define DEPLOYMENT "%s.deploy.sh"
203 char *warning = NULL;
205 /**********************************************/
206 /**** Generate the file for the simulator *****/
207 /**********************************************/
209 const char *SIM_PREEMBULE =
210 "/* specific to Borland Compiler */\n"
211 "#ifdef __BORLANDC__\n"
214 "#include <stdlib.h>\n"
215 "#include <stdio.h>\n"
216 "#include \"msg/msg.h\"\n"
217 "#include <gras.h>\n"
219 "char *gras_log=NULL;\n";
222 #define SIM_LAUNCH_FUNC \
223 "int launch_%s(int argc, char **argv) {\n" \
224 " char **myargv=argv;\n" \
225 " int myargc=argc;\n" \
229 " if (gras_log) {\n"\
230 " myargv=malloc((argc+1) * sizeof(char**));\n" \
231 " for (i=0; i<argc; i++)\n" \
232 " myargv[i] = argv[i];\n" \
233 " myargv[myargc++] = gras_log;\n" \
235 " retcode = %s(myargc,myargv);\n" \
236 " if (myargv != argv)\n" \
238 " return retcode;\n" \
241 const char *SIM_MAIN_POSTEMBULE = "\n"
243 " MSG_launch_application(argv[2]);\n"
245 " /* Run the simulation */\n"
248 " /* cleanup the place */\n"
257 /**********************************************/
258 /********* Parse XML deployment file **********/
259 /**********************************************/
260 xbt_dict_t process_function_set = NULL;
261 xbt_dynar_t process_list = NULL;
262 xbt_dict_t machine_set = NULL;
264 typedef struct s_process_t {
270 static void s_process_free(void *process)
273 for(i=0;i<((s_process_t*)process)->argc; i++)
274 free(((s_process_t*)process)->argv[i]);
275 free(((s_process_t*)process)->host);
278 static s_process_t process;
281 * Création de deux dictionnaires
283 static void parse_process_init(void)
285 xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
286 xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL);
288 process.argv = xbt_new(char*,1);
289 process.argv[0] = xbt_strdup(A_surfxml_process_function);
290 process.host=strdup(A_surfxml_process_host);
291 /*VERB1("Function: %s",A_surfxml_process_function);*/
294 static void parse_argument(void)
297 process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
298 process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value);
301 static void parse_process_finalize(void)
303 xbt_dynar_push(process_list,&process);
304 /*VERB1("Function: %s",process.argv[0]);*/
307 static void generate_sim(char *project)
309 xbt_dict_cursor_t cursor=NULL;
312 char *filename = NULL;
316 * Creation d'un fichier nommé : <projet>_simulator.c
318 filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME));
319 sprintf(filename,SIM_SOURCENAME,project);
321 OUT=fopen(filename,"w");
324 xbt_assert1(OUT, "Unable to open %s for writing",filename);
327 * Ecriture du message d'avertissement.
329 fprintf(OUT, "%s\n",warning);
332 * Ecriture du préambule (inclusion de certains fichiers d'en-tête
334 fprintf(OUT, "%s", SIM_PREEMBULE);
337 * Déclaration des fonction int <process>(int argc,char *argv[]);
339 xbt_dict_foreach(process_function_set,cursor,key,data) {
340 fprintf(OUT,"int %s(int argc,char *argv[]);\n",key);
346 * Déclaration des fonction int launch_<process>(int argc,char *argv[]);
348 xbt_dict_foreach(process_function_set,cursor,key,data) {
349 fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key);
353 * Ecriture du message d'avertissement.
355 fprintf(OUT, "\n%s\n",warning);
357 xbt_dict_foreach(process_function_set,cursor,key,data) {
358 fprintf(OUT,SIM_LAUNCH_FUNC,key,key);
360 fprintf(OUT, "\n%s\n",warning);
362 fprintf(OUT,"%s", "/* specific to Borland Compiler */\n"
363 "#ifdef __BORLANDDC__\n"
367 fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n"
369 " /* Simulation setup */\n"
370 " MSG_global_init(&argc,argv);\n"
371 " if (argc != 3) {\n"
372 " fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n"
377 " MSG_paje_output(\"%s.trace\");\n"
378 " MSG_set_channel_number(XBT_MAX_CHANNEL); /* Using at most 10 channel (ports) per host. Change it here if needed */\n"
379 " MSG_create_environment(argv[1]);\n"
381 " /* Application deployment */\n",
383 xbt_dict_foreach(process_function_set,cursor,key,data) {
384 fprintf(OUT," MSG_function_register(\"%s\", launch_%s);\n",key,key);
386 fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
391 /**********************************************/
392 /**** Generate the file for the real life *****/
393 /**********************************************/
394 static void generate_rl(char *project)
396 xbt_dict_cursor_t cursor=NULL;
399 char *filename = NULL;
402 xbt_dict_foreach(process_function_set,cursor,key,data) {
403 filename = xbt_new(char,strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
404 sprintf(filename,RL_SOURCENAME,project,key);
406 OUT=fopen(filename,"w");
407 xbt_assert1(OUT, "Unable to open %s for writing",filename);
409 fprintf(OUT, "\n%s\n",warning);
410 fprintf(OUT, "/* specific to Borland Compiler */\n" \
411 "#ifdef __BORLANDC__\n" \
412 "#pragma hdrstop\n" \
414 "#include <stdio.h>\n" \
415 "#include <signal.h>\n" \
416 "#include <gras.h>\n" \
418 "extern const char *_gras_procname;\n" \
419 "/* user code */\n" \
420 "int %s(int argc, char *argv[]);\n" \
422 "/* specific to Borland Compiler */\n" \
423 "#ifdef __BORLANDC__\n" \
424 "#pragma argsused\n" \
426 "int main(int argc, char *argv[]){\n" \
429 " _gras_procname = \"%s\";\n" \
430 " errcode=%s(argc,argv);\n"\
432 " return errcode;\n"\
435 fprintf(OUT, "\n%s\n",warning);
441 static void generate_makefile_am(char *project, char *deployment)
443 xbt_dict_cursor_t cursor=NULL;
446 char *filename = NULL;
449 filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_AM));
450 sprintf(filename,MAKEFILE_FILENAME_AM, project);
452 OUT=fopen(filename,"w");
453 xbt_assert1(OUT, "Unable to open %s for writing",filename);
455 fprintf(OUT, "# AUTOMAKE variable definition\n");
456 fprintf(OUT, "INCLUDES= @CFLAGS_SimGrid@\n\n");
457 fprintf(OUT, "PROGRAMS=");
458 fprintf(OUT, SIM_BINARYNAME,project);
460 xbt_dict_foreach(process_function_set,cursor,key,data) {
462 fprintf(OUT, RL_BINARYNAME, project, key);
465 fprintf(OUT, "\n\n");
466 fprintf(OUT, SIM_SOURCENAME_SOURCES,project);
468 fprintf(OUT, SIM_SOURCENAME,project);
469 fprintf(OUT, " %s.c\n", project);
470 fprintf(OUT, SIM_SOURCENAME_LDADD, project);
471 fprintf(OUT, "=\tpath/to/libsimgrid.a\n\n");
473 xbt_dict_foreach(process_function_set,cursor,key,data) {
474 fprintf(OUT, RL_SOURCENAME_SOURCES, project,key);
476 fprintf(OUT, RL_SOURCENAME, project,key);
477 fprintf(OUT, " %s.c\n", project);
478 fprintf(OUT, RL_SOURCENAME_LDADD, project, key);
479 fprintf(OUT, "=\tpath/to/libgras.a\n\n");
482 fprintf(OUT, "\n# cleanup temps\n");
483 fprintf(OUT, "CLEANFILES= ");
484 fprintf(OUT, SIM_SOURCENAME, project);
486 xbt_dict_foreach(process_function_set,cursor,key,data) {
488 fprintf(OUT, RL_SOURCENAME, project,key);
492 fprintf(OUT, "\n# generate temps\n");
493 fprintf(OUT, "\n# A rule to generate the source file each time the deployment file changes\n");
495 xbt_dict_foreach(process_function_set,cursor,key,data) {
496 fprintf(OUT, RL_SOURCENAME, project,key);
499 fprintf(OUT, SIM_SOURCENAME, project);
500 fprintf(OUT, ": %s\n", deployment);
501 fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
505 static void generate_makefile_local(char *project, char *deployment)
507 xbt_dict_cursor_t cursor=NULL;
510 char *filename = NULL;
513 filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_LOCAL));
514 sprintf(filename,MAKEFILE_FILENAME_LOCAL, project);
516 OUT=fopen(filename,"w");
517 xbt_assert1(OUT, "Unable to open %s for writing",filename);
523 "#### THIS FILE WAS GENERATED, DO NOT EDIT BEFORE RENAMING IT\n"
526 fprintf(OUT,"## Variable declarations\n"
528 "DISTDIR=gras-$(PROJECT_NAME)\n\n"
532 "# Set the GRAS_ROOT environment variable to the path under which you installed SimGrid\n"
533 "# Compilation will fail if you don't do so\n"
534 "GRAS_ROOT?= $(shell echo \"\\\"<<<< GRAS_ROOT undefined !!! >>>>\\\"\")\n\n"
535 "# You can fiddle the following to make it fit your taste\n"
536 "INCLUDES = -I$(GRAS_ROOT)/include\n"
537 "CFLAGS ?= -O3 -w -g\n"
538 "LIBS_SIM = -lm -L$(GRAS_ROOT)/lib/ -lsimgrid\n"
539 "LIBS_RL = -lm -L$(GRAS_ROOT)/lib/ -lgras\n"
543 fprintf(OUT, "PRECIOUS_C_FILES ?= %s.c\n", project);
545 fprintf(OUT, "GENERATED_C_FILES = ");
546 fprintf(OUT, SIM_SOURCENAME" ",project);
547 xbt_dict_foreach(process_function_set,cursor,key,data) {
548 fprintf(OUT, RL_SOURCENAME " ",project, key);
552 fprintf(OUT,"OBJ_FILES = $(patsubst %%.c,%%.o,$(PRECIOUS_C_FILES))\n");
554 fprintf(OUT, "BIN_FILES = ");
556 fprintf(OUT, SIM_BINARYNAME " ",project);
557 xbt_dict_foreach(process_function_set,cursor,key,data) {
558 fprintf(OUT, RL_BINARYNAME " ", project, key);
564 "## By default, build all the binaries\n"
565 "all: $(BIN_FILES)\n"
568 fprintf(OUT, "\n## generate temps: regenerate the source file each time the deployment file changes\n");
569 xbt_dict_foreach(process_function_set,cursor,key,data) {
570 fprintf(OUT, RL_SOURCENAME, project,key);
573 fprintf(OUT, SIM_SOURCENAME, project);
574 fprintf(OUT, ": %s\n", deployment);
575 fprintf(OUT, "\tgras_stub_generator %s %s >/dev/null\n", project, deployment);
577 fprintf(OUT, "\n## Generate the binaries\n");
578 fprintf(OUT, SIM_BINARYNAME ": " SIM_OBJNAME " $(OBJ_FILES)\n",project, project);
579 fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_SIM) $(LIBS) $(LDADD) -o $@ \n");
580 xbt_dict_foreach(process_function_set,cursor,key,data) {
581 fprintf(OUT, RL_BINARYNAME " : " RL_OBJNAME " $(OBJ_FILES)\n", project, key, project, key);
582 fprintf(OUT, "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS_RL) $(LIBS) $(LDADD) -o $@ \n");
587 "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ \n"
590 "\t$(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<\n"
594 "##Â Rules for tarballs and cleaning\n"
595 "DIST_FILES= $(EXTRA_DIST) $(GENERATED_C_FILES) $(PRECIOUS_C_FILES) "MAKEFILE_FILENAME_LOCAL" " /*MAKEFILE_FILENAME_REMOTE*/"\n"
596 "distdir: $(DIST_FILES)\n"
597 "\trm -rf $(DISTDIR)\n"
598 "\tmkdir -p $(DISTDIR)\n"
599 "\tcp $^ $(DISTDIR)\n"
601 "dist: clean distdir\n"
602 "\ttar c $(DISTDIR) | gzip -c9 > $(DISTDIR).tar.gz\n"
603 "\n", project /*, project*/);
607 "\trm -f $(BIN_FILES) $(OBJ_FILES) *~ %s.o " SIM_OBJNAME, project, project);
608 xbt_dict_foreach(process_function_set,cursor,key,data) {
609 fprintf(OUT, " " RL_OBJNAME, project, key);
613 "\trm -rf $(DISTDIR)\n"
619 fprintf(OUT, "############ REMOTE COMPILING #########\n");
622 xbt_dict_foreach(machine_set,cursor,key,data) {
623 fprintf(OUT, "%s ",key);
628 "INSTALL_PATH ?='$$HOME/tmp/src' ### Has to be an absolute path !!! \n"
629 "GRAS_ROOT ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! \n"
631 "SIMGRID_URL ?=http://gcl.ucsd.edu/simgrid/dl/\n"
632 "SIMGRID_VERSION ?=2.92\n"
633 "GRAS_PROJECT ?= %s\n"
634 "GRAS_PROJECT_URL ?= http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
637 "\t@echo;echo \"----[ Compile the package on remote hosts ]----\"\n"
638 "\t@test -e $(SRCDIR)/buildlogs/ || mkdir -p $(SRCDIR)/buildlogs/\n"
639 "\t for site in $(MACHINES) ; do \\\n"
640 "\t machine=`echo $$site |sed 's/^\\([^%%]*\\)%%.*$$/\\1/'`;\\\n"
641 "\t machine2=`echo $$site |sed 's/^\\([^%%]*\\)%%\\(.*\\)$$/\\2/'`;\\\n"
642 "\t cmd_mkdir=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
643 "\t SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
644 "\t GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) mkdir -p $(INSTALL_PATH) 2>&1'\\\"\";\\\n"
645 "\t cmd_make=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n"
646 "\t SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n"
647 "\t GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) make -C $(INSTALL_PATH) -f "MAKEFILE_FILENAME_REMOTE" $(ACTION) 2>&1'\\\"\";\\\n"
648 "\t if echo $$site | grep '%%' >/dev/null ; then \\\n"
649 "\t echo \"----[ Compile on $$machine2 (behind $$machine) ]----\";\\\n"
651 "\t machine=$$site;\\\n"
652 "\t echo \"----[ Compile on $$machine ]----\";\\\n"
654 "\t if echo $$site | grep '%%' >/dev/null ; then \\\n"
655 "\t if ssh $$machine \"ssh -A $$machine2 $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log;\\\n"
656 "\t then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;\\\n"
658 "\t if ssh $$machine \"eval $$cmd_mkdir\" 2>&1 > $(SRCDIR)/buildlogs/$$site.log ;\\\n"
659 "\t then true; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi; \\\n"
661 "\t echo \"-- Copy the data over\"; \\\n"
662 "\t scp "MAKEFILE_FILENAME_REMOTE" $$site:$(INSTALL_PATH) ;\\\n"
663 "\t echo \"-- Compiling... (the output gets into $(SRCDIR)/buildlogs/$$site.log)\"; \\\n"
664 "\t if echo $$site | grep '%%' >/dev/null ; then \\\n"
665 "\t if ssh $$machine \"ssh -A $$machine2 $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log;\\\n"
666 "\t then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
668 "\t if ssh $$machine \"eval $$cmd_make\" 2>&1 >> $(SRCDIR)/buildlogs/$$site.log ;\\\n"
669 "\t then echo \"Sucessful\"; else failed=1;echo \"Failed (check $(SRCDIR)/buildlogs/$$site.log)\"; fi;echo; \\\n"
671 "\t done;\n",project,project,project);
676 static void generate_makefile_remote(char *project, char *deployment)
678 char *filename = NULL;
681 filename = xbt_new(char,strlen(project) + strlen(MAKEFILE_FILENAME_REMOTE));
682 sprintf(filename,MAKEFILE_FILENAME_REMOTE, project);
684 OUT=fopen(filename,"w");
685 xbt_assert1(OUT, "Unable to open %s for writing",filename);
688 "INSTALL_PATH ?= $(shell pwd)\n"
691 "\tcd $$GRAS_ROOT ; \\\n"
692 "\tretrieved=`LANG=C;wget -N $(SIMGRID_URL)/simgrid-$(SIMGRID_VERSION).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
693 "\techo $$retrieved; \\\n"
694 "\tif test \"x$$retrieved\" = x; then \\\n"
695 "\t tar zxf simgrid-$(SIMGRID_VERSION).tar.gz ; \\\n"
696 "\t cd simgrid-$(SIMGRID_VERSION)/; \\\n"
697 "\t ./configure --prefix=$$GRAS_ROOT ; \\\n"
698 "\t make all install ;\\\n"
701 "compile-gras: compile-simgrid\n"
702 "\tnot_retrieved=`LANG=C;wget -N $(GRAS_PROJECT_URL)/gras-$(GRAS_PROJECT).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n"
703 "\techo $$not_retrieved; \\\n"
704 "\tif test \"x$$not_retrieved\" != xyes; then \\\n"
705 "\t tar zxf gras-$(GRAS_PROJECT).tar.gz ; \\\n"
706 "\t make -C gras-$(GRAS_PROJECT)/ -f $(GRAS_PROJECT).Makefile.local all ; \\\n"
710 "\trm -rf simgrid-$(SIMGRID_VERSION)*\n"
711 "clean-gras clean-gras-$(GRAS_PROJECT):\n"
712 "\trm -rf gras-$(GRAS_PROJECT)*\n"
713 "clean: clean-simgrid clean-gras-$(GRAS_PROJECT)\n"
715 ".PHONY: clean clean-simgrid clean-gras clean-gras-$(GRAS_PROJECT) \\\n"
716 " compile-simgrid compile-gras\n"
722 static void generate_deployment(char *project, char *deployment)
724 xbt_dict_cursor_t cursor=NULL;
727 char *filename = NULL;
733 filename = xbt_new(char,strlen(project) + strlen(DEPLOYMENT));
734 sprintf(filename,DEPLOYMENT, project);
736 OUT=fopen(filename,"w");
737 xbt_assert1(OUT, "Unable to open %s for writing",filename);
739 fprintf(OUT, "#!/bin/sh\n");
740 fprintf(OUT, "############ DEPLOYMENT FILE #########\n");
742 "if test \"${MACHINES+set}\" != set; then \n"
743 " export MACHINES='");
744 xbt_dict_foreach(machine_set,cursor,key,data) {
745 fprintf(OUT, "%s ",key);
750 "if test \"${INSTALL_PATH+set}\" != set; then \n"
751 " export INSTALL_PATH='`echo $HOME`/tmp/src'\n"
753 "if test \"${GRAS_ROOT+set}\" != set; then \n"
754 " export GRAS_ROOT='`echo $INSTALL_PATH`'\n"
756 "if test \"${SRCDIR+set}\" != set; then \n"
757 " export SRCDIR=./\n"
759 "if test \"${SIMGRID_URL+set}\" != set; then \n"
760 " export SIMGRID_URL=http://gcl.ucsd.edu/simgrid/dl/\n"
762 "if test \"${SIMGRID_VERSION+set}\" != set; then \n"
763 " export SIMGRID_VERSION=2.91\n"
765 "if test \"${GRAS_PROJECT+set}\" != set; then \n"
766 " export GRAS_PROJECT=%s\n"
768 "if test \"${GRAS_PROJECT_URL+set}\" != set; then \n"
769 " export GRAS_PROJECT_URL=http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
772 "test -e runlogs/ || mkdir -p runlogs/\n",
776 "cmd_prolog=\"env INSTALL_PATH=$INSTALL_PATH GRAS_ROOT=$GRAS_ROOT \\\n"
777 " SIMGRID_URL=$SIMGRID_URL SIMGRID_VERSION=$SIMGRID_VERSION GRAS_PROJECT=$GRAS_PROJECT \\\n"
778 " GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$GRAS_ROOT/lib/ sh -c \";\n");
780 xbt_dynar_foreach (process_list,cpt,proc) {
781 fprintf(OUT,"cmd=\"\\$INSTALL_PATH/gras-%s/"RL_BINARYNAME" ",project,project,proc.argv[0]);
782 for(i=1;i<proc.argc;i++) {
783 fprintf(OUT,"%s ",proc.argv[i]);
785 fprintf(OUT,"\";\n");
786 fprintf(OUT,"ssh %s \"$cmd_prolog 'export LD_LIBRARY_PATH=\\$INSTALL_PATH/lib:\\$LD_LIBRARY_PATH; echo \\\"$cmd\\\" ; $cmd 2>&1'\" > runlogs/%s_%d.log &\n",proc.host,proc.host,cpt);
792 static void print(void *p)
802 /* specific to Borland Compiler */
807 int main(int argc, char *argv[])
809 char *project_name = NULL;
810 char *deployment_file = NULL;
813 surf_init(&argc, argv);
815 xbt_assert1((argc >= 3),"Usage: %s project_name deployment_file [deployment_file...]\n",argv[0]);
817 project_name = argv[1];
819 process_function_set = xbt_dict_new();
820 process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free);
821 machine_set = xbt_dict_new();
823 STag_surfxml_process_fun = parse_process_init;
824 ETag_surfxml_argument_fun = parse_argument;
825 ETag_surfxml_process_fun = parse_process_finalize;
827 for(i=2; i<argc; i++) {
828 deployment_file = argv[i];
829 surf_parse_open(deployment_file);
831 xbt_assert1(0,"Parse error in %s",deployment_file);
837 warning = xbt_new(char,strlen(WARN)+strlen(deployment_file)+10);
838 sprintf(warning,WARN,deployment_file);
840 /*if(XBT_LOG_ISENABLED(stubgen, xbt_log_priority_debug)) {
841 xbt_dict_cursor_t cursor=NULL;
845 for (cursor=NULL, xbt_dict_cursor_first((process_function_set),&(cursor)) ;
846 xbt_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));
847 xbt_dict_cursor_step(cursor) ) {
848 DEBUG1("Function %s", key);
851 xbt_dict_dump(process_function_set,print);
854 generate_sim(project_name);
855 generate_rl(project_name);
856 generate_makefile_local(project_name, deployment_file);
858 generate_borland_simulation_project(project_name);
859 generate_borland_real_life_project(project_name);
861 // generate_makefile_remote(project_name, deployment_file);
862 // generate_deployment(project_name, deployment_file);
870 generate_borland_project(borland_project_t project)
872 char* binary_path; /* the path of the generated binary file */
873 char* obj_path; /* the path of the generated object file */
874 char* lib_files; /* a list of the libraries used in the borland project */
875 char* main_source; /* the name of the bpf file used by the borland project */
876 char* file_name; /* the file name of the main source file */
879 /* create the borland project file */
880 borland_project_create(project);
882 /* write the xml document header */
883 borland_project_write_xml_header(project);
885 /* write the xml comment to identify a borland project file */
886 borland_project_write_xml_comment(project);
888 /* write the begin of the node PROJECT */
889 borland_project_begin_xml_node(project,"PROJECT");
891 /* write the begin of node MACRO */
892 borland_project_begin_xml_node(project,"MACRO");
894 /* write the borland project version */
895 borland_project_write_xml_element(project,"VERSION",project->version);
897 /* construct and write the borland project binary path */
898 binary_path = xbt_new0(char,strlen(project->name) + strlen(project->bin_dir) + 6);
899 sprintf(binary_path,"%s\\%s.exe",project->bin_dir,project->name);
900 borland_project_write_xml_element(project,"PROJECT",binary_path);
901 xbt_free(binary_path);
903 /* construct an write the object generated file path */
904 obj_path = xbt_new0(char,strlen(project->name) + strlen(project->obj_dir) + 6);
905 sprintf(binary_path,"%s\\%s.obj",project->obj_dir,project->name);
906 borland_project_write_xml_element(project,"OBJFILES",obj_path);
909 /* write the RESFILES element (not used) */
910 borland_project_write_xml_element(project,"RESFILES","");
912 /* write the IDLFILES element (not used) */
913 borland_project_write_xml_element(project,"IDLFILES","");
915 /* write the IDLGENFILES element (not used) */
916 borland_project_write_xml_element(project,"IDLGENFILES","");
918 /* write the DEFFILE element (not used) */
919 borland_project_write_xml_element(project,"DEFFILE","");
921 /* write the RESDEPEN element (not used) */
922 borland_project_write_xml_element(project,"RESDEPEN","$(RESFILES)");
924 /* construct and write the LIBFILES element */
925 lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + strlen("libgras.lib") + 2);
926 sprintf(lib_files,"%s\\simgrid.lib %s\\libgras.lib",project->lib_dir,project->lib_dir);
927 borland_project_write_xml_element(project,"LIBFILES",lib_files);
930 /* write the SPARELIBS element (not used) */
931 borland_project_write_xml_element(project,"SPARELIBS","");
933 /* write the PACKAGES element (not used) */
934 borland_project_write_xml_element(project,"PACKAGES","");
936 /* write the PATHCPP element */
937 borland_project_write_xml_element(project,"PATHCPP",".;");
939 /* write the PATHPAS element (not used) */
940 borland_project_write_xml_element(project,"PATHPAS","");
942 /* write the PATHRC element (not used) */
943 borland_project_write_xml_element(project,"PATHRC","");
945 /* write the PATHASM element (not used) */
946 borland_project_write_xml_element(project,"PATHASM","");
948 /* write the DEBUGLIBPATH element */
949 borland_project_write_xml_element(project,"DEBUGLIBPATH","$(BCB)\\lib\\debug");
951 /* write the RELEASELIBPATH element */
952 borland_project_write_xml_element(project,"RELEASELIBPATH","$(BCB)\\lib\\release");
954 /* write the LINKER element*/
955 borland_project_write_xml_element(project,"LINKER","ilink32");
957 /* write the USERDEFINES element */
958 borland_project_write_xml_element(project,"USERDEFINES","_DEBUG");
960 /* write the SYSDEFINES element */
961 borland_project_write_xml_element(project,"SYSDEFINES","NO_STRICT;_NO_VCL");
963 /* construct and write the MAINSOURCE element */
965 main_source = xbt_new0(char,strlen(project->name) + 5);
966 sprintf(main_source,"%s.bpf",project->name);
968 borland_project_write_xml_element(project,"MAINSOURCE",main_source);
970 /* create the bpf file used by the borland project */
971 borland_project_create_main_file(main_source);
973 /* FIXME resolve the include path */
974 /* write the INCLUDEPATH element */
975 borland_project_write_xml_element(project,"INCLUDEPATH","");
977 /* FIXME check the lib path */
978 /* write the LIBPATH element */
979 borland_project_write_xml_element(project,"LIBPATH","");
981 /* write the WARNINGS element */
982 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");
984 /* write the OTHERFILES element (not used) */
985 borland_project_write_xml_element(project,"OTHERFILES","");
987 /* write the end of the node MACRO */
988 borland_project_end_xml_node(project,"MACRO");
990 /* write the begin of the node OPTIONS */
991 borland_project_begin_xml_node(project,"OPTIONS");
993 /* FIXME check the idlcflags
994 /* write the IDLCFLAGS element */
995 borland_project_write_xml_element(project,"IDLCFLAGS","");
997 /* write the CFLAG1 element */
998 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");
1000 /* write the PFLAGS element */
1001 borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE -M");
1003 /* write the RFLAGS element */
1004 borland_project_write_xml_element(project,"RFLAGS","");
1006 /* write the AFLAGS element (not used)*/
1007 borland_project_write_xml_element(project,"AFLAGS","/mx /w2 /zd");
1009 /* write the LFLAGS element */
1010 borland_project_write_xml_element(project,"LFLAGS","-Iobj -D"" -ap -Tpe -x -Gn -v");
1012 /* write the OTHERFILES element (not used)*/
1013 borland_project_write_xml_element(project,"OTHERFILES","");
1015 /* write the end of the node OPTIONS */
1016 borland_project_end_xml_node(project,"OPTIONS");
1018 /* write the begin of the node LINKER */
1019 borland_project_begin_xml_node(project,"LINKER");
1021 /* write the ALLOBJ element */
1022 borland_project_write_xml_element(project,"ALLOBJ","c0x32.obj $(OBJFILES)");
1024 /* write the ALLRES element (not used) */
1025 borland_project_write_xml_element(project,"ALLRES","");
1027 /* write the ALLLIB element */
1028 borland_project_write_xml_element(project,"ALLLIB","$(LIBFILES) $(LIBRARIES) import32.lib cw32.lib");
1030 /* write the OTHERFILES element (not used) */
1031 borland_project_write_xml_element(project,"OTHERFILES","");
1033 /* write the end of the node LINKER */
1034 borland_project_end_xml_node(project,"LINKER");
1036 /* write the begin of the node FILELIST */
1037 borland_project_begin_xml_node(project,"FILELIST");
1039 /* construct and write the list of file elements */
1041 /* add the bpf file to the list */
1042 borland_project_write_file_element(project,main_source,"",project->name,"BPF","","");
1043 xbt_free(main_source);
1045 /* FIXME : check the source file directory */
1046 /* add the generated source file to the list */
1047 file_name = xbt_new0(char,strlen(project->src_dir) + strlen(project->name) + 4);
1048 sprintf(file_name,"%s\\%s.c",project->src_dir,project->name);
1049 borland_project_write_file_element(project,file_name,"",project->name,"CCompiler","","");
1050 xbt_free(file_name);
1052 /* FIXME : check the libraries directory */
1053 /* add the simgrid library to the list */
1054 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
1055 sprintf(file_name,"%s\\simgrid.lib",project->lib_dir);
1056 borland_project_write_file_element(project,file_name,"","simgrid.lib","LibTool","","");
1057 xbt_free(file_name);
1059 /* add the libgras library to the list */
1060 file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("libgras.lib") + 2);
1061 sprintf(file_name,"%s\\libgras.lib",project->lib_dir);
1062 borland_project_write_file_element(project,file_name,"","libgras.lib","LibTool","","");
1063 xbt_free(file_name);
1065 /* write the end of the node FILELIST */
1066 borland_project_end_xml_node(project,"FILELIST");
1068 /* write the begin of the node BUILDTOOLS (not used)*/
1069 borland_project_begin_xml_node(project,"BUILDTOOLS");
1071 /* write the end of the node BUILDTOOLS (not used)*/
1072 borland_project_end_xml_node(project,"BUILDTOOLS");
1074 /* write the begin of the node IDEOPTIONS */
1075 borland_project_begin_xml_node(project,"IDEOPTIONS");
1077 /* write all of the option of the IDE of Borland C++ Builder */
1078 borland_project_write_ide_options(project);
1080 /* write the end of the node IDEOPTIONS */
1081 borland_project_end_xml_node(project,"IDEOPTIONS");
1083 /* write the end of the node PROJECT */
1084 borland_project_end_xml_node(project,"PROJECT");
1086 /* close the borland project file */
1087 borland_project_close(project);
1091 borland_project_write_tabs(borland_project_t project,unsigned int count)
1095 for(pos = 0; pos < count; pos++)
1096 fprintf(project->stream,"\t");
1100 borland_project_begin_xml_node(borland_project_t project, const char* name)
1103 borland_project_write_tabs(project,level);
1105 fprintf(project->stream,"<%s>\n",name);
1111 borland_project_end_xml_node(borland_project_t project, const char* name)
1116 borland_project_write_tabs(project,level);
1118 fprintf(project->stream,"</%s>\n",name);
1123 borland_project_write_xml_element(borland_project_t project,const char* name,const char* value)
1125 borland_project_write_tabs(project,level);
1127 fprintf(project->stream,"<%s value=\"%s\"/>\n",name,value);
1131 borland_project_write_xml_header(borland_project_t project)
1133 fprintf(project->stream,"<?xml version='%s' encoding='%s' ?>\n",project->xml_version, project->encoding);
1137 borland_project_create_main_file(const char* name)
1139 FILE* stream = fopen(name,"w+");
1141 fprintf(stream,"Ce fichier est uniquement utilisé par le gestionnaire de projets et doit être traité comme le fichier projet\n\n\nmain\n");
1147 borland_project_create(borland_project_t project)
1149 char* file_name = xbt_new0(char,strlen(project->name) + 5);
1150 sprintf(file_name,"%s.bpr",project->name);
1151 project->stream = fopen(file_name,"w+");
1152 xbt_free(file_name);
1156 borland_project_write_xml_comment(borland_project_t project)
1158 fprintf(project->stream,"<!-- %s -->\n",project->comment);
1161 borland_project_write_file_element( borland_project_t project,
1162 const char* file_name,
1163 const char* form_name,
1164 const char* unit_name,
1165 const char* container_id,
1166 const char* design_class,
1167 const char* local_command)
1169 borland_project_write_tabs(project,level);
1171 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);
1175 borland_project_write_ide_options(borland_project_t project)
1178 const char* ide_options =
1179 "[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" \
1180 "[Version Info Keys]\nCompanyName=\nFileDescription=\nFileVersion=1.0.0.0\nInternalName=\nLegalCopyright=\nLegalTrademarks=\nOriginalFilename=\nProductName=\nProductVersion=1.0.0.0\nComments=\n\n" \
1181 "[Excluded Packages]\n$(BCB)\\dclclxdb60.bpl=Composants BD CLX Borland\n$(BCB)\\Bin\\dclclxstd60.bpl=Composants Standard CLX Borland\n\n" \
1182 "[HistoryLists\\hlIncludePath]\nCount=1\nItem0=$(BCB)\\include;$(BCB)\\include\\vcl;\n\n" \
1183 "[HistoryLists\\hlLibraryPath]\nCount=1\nItem0=$(BCB)\\lib\\obj;$(BCB)\\lib\n\n" \
1184 "[HistoryLists\\hlDebugSourcePath]\nCount=1\nItem0=$(BCB)\\source\\vcl\\\n\n" \
1185 "[HistoryLists\\hlConditionals]\nCount=1\nItem0=_DEBUG\n\n" \
1186 "[HistoryLists\\hlIntOutputDir]\nCount=0\n\n" \
1187 "[HistoryLists\\hlFinalOutputDir]\nCount=0\n\n" \
1188 "[HistoryLists\\hIBPIOutputDir]\nCount=0\n\n" \
1189 "[Debugging]\nDebugSourceDirs=$(BCB)\\source\\vcl\n\n" \
1190 "[Parameters]\nRunParams=\nLauncher=\nUseLauncher=0\nDebugCWD=\nHostApplication=\nRemoteHost=\nRemotePath=\nRemoteLauncher=\nRemoteCWD=\nRemoteDebug=0\n\n" \
1191 "[Compiler]\nShowInfoMsgs=0\nLinkDebugVcl=0\nLinkCGLIB=0\n\n" \
1192 "[CORBA]\nAddServerUnit=1\nAddClientUnit=1\nPrecompiledHeaders=1\n\n" \
1193 "[Language]\nActiveLang=\nProjectLang=\nRootDir=\n";
1195 fprintf(project->stream,ide_options);
1199 borland_project_close(borland_project_t project)
1201 fclose(project->stream);
1205 generate_borland_simulation_project(const char* name)
1207 char buffer[MAX_PATH] = {0};
1210 WIN32_FIND_DATA wfd = {0};
1212 s_borland_project_t borland_project = {0};
1213 borland_project.xml_version = "1.0";
1214 borland_project.encoding ="utf-8";
1215 borland_project.comment ="C++Builder XML Project";
1216 borland_project.version = "BCB.06.00";
1218 borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1220 FindFilePath("C:\\","simgrid.lib",borland_project.lib_dir);
1223 GetCurrentDirectory(MAX_PATH,buffer);
1225 borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1227 strcpy(borland_project.src_dir,buffer);
1229 borland_project.lib_dir = " ";
1231 borland_project.name = xbt_new0(char,strlen(name) + strlen("_simulator") + 2);
1232 sprintf(borland_project.name,"_%s_simulator",name);
1234 borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1235 sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1237 hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1240 CreateDirectory(borland_project.bin_dir,NULL);
1242 borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1243 sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1245 hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1247 if(INVALID_HANDLE_VALUE == hDir)
1248 CreateDirectory(borland_project.obj_dir,NULL);
1250 generate_borland_project(&borland_project);
1252 xbt_free(borland_project.name);
1253 xbt_free(borland_project.src_dir);
1254 xbt_free(borland_project.bin_dir);
1255 xbt_free(borland_project.obj_dir);
1256 xbt_free(borland_project.lib_dir);
1260 generate_borland_real_life_project(const char* name)
1263 WIN32_FIND_DATA wfd = {0};
1264 char buffer[MAX_PATH] = {0};
1265 xbt_dict_cursor_t cursor = NULL;
1268 s_borland_project_t borland_project = {0};
1270 borland_project.xml_version = "1.0";
1271 borland_project.encoding ="utf-8";
1272 borland_project.comment ="C++Builder XML Project";
1273 borland_project.version = "BCB.06.00";
1274 borland_project.lib_dir = " ";
1276 borland_project.lib_dir = xbt_new0(char,MAX_PATH);
1278 FindFilePath("C:\\","simgrid.lib",borland_project.lib_dir);
1280 GetCurrentDirectory(MAX_PATH,buffer);
1282 borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
1284 strcpy(borland_project.src_dir,buffer);
1286 borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
1287 sprintf(borland_project.bin_dir,"%s\\bin",buffer);
1289 hDir = FindFirstFile(borland_project.bin_dir,&wfd);
1291 if(INVALID_HANDLE_VALUE == hDir)
1292 CreateDirectory(borland_project.bin_dir,NULL);
1294 borland_project.obj_dir = xbt_new0(char,strlen(buffer) + strlen("\\obj") + 1);
1295 sprintf(borland_project.obj_dir,"%s\\obj",buffer);
1297 hDir = FindFirstFile(borland_project.obj_dir,&wfd);
1300 CreateDirectory(borland_project.obj_dir,NULL);
1303 xbt_dict_foreach(process_function_set,cursor,key,data) {
1304 borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 3);
1306 sprintf(borland_project.name,"_%s_%s",name,key);
1308 generate_borland_project(&borland_project);
1309 xbt_free(borland_project.name);
1312 xbt_free(borland_project.src_dir);
1313 xbt_free(borland_project.bin_dir);
1314 xbt_free(borland_project.obj_dir);
1315 xbt_free(borland_project.lib_dir);
1318 FindFilePath(const char* root_dir,const char* file_name,char* path)
1321 WIN32_FIND_DATA wfd;
1322 char* prev_dir = (char*)calloc(MAX_PATH,sizeof(char));
1323 GetCurrentDirectory(MAX_PATH,prev_dir);
1324 SetCurrentDirectory(root_dir);
1326 // begining of the scan
1327 hFind=FindFirstFile ("*.*", &wfd);
1329 if(hFind!=INVALID_HANDLE_VALUE){
1332 if (!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
1334 if(!strcmp(file_name,wfd.cFileName)){
1335 GetCurrentDirectory(MAX_PATH,path);
1336 SetCurrentDirectory(prev_dir);
1343 /* it's a directory, scan it*/
1346 if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1347 if(FindFilePath(wfd.cFileName,file_name,path)){
1349 SetCurrentDirectory(prev_dir);
1355 /* next file or directory */
1356 while(FindNextFile (hFind,&wfd))
1359 if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
1361 if(!strcmp(file_name,wfd.cFileName)){
1362 GetCurrentDirectory(MAX_PATH,path);
1363 SetCurrentDirectory(prev_dir);
1369 /* it's a file scan it */
1372 if(strcmp(wfd.cFileName,".") && strcmp(wfd.cFileName,"..")){
1374 if(FindFilePath(wfd.cFileName,file_name,path)){
1375 SetCurrentDirectory(prev_dir);
1386 SetCurrentDirectory(prev_dir);