X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6e0150d5daca2aec9489343953d189b793f553f0..0f5509273af174fc845f00268eb6430cf22d8ee0:/tools/gras/stub_generator.c diff --git a/tools/gras/stub_generator.c b/tools/gras/stub_generator.c index 36474e12dd..8e0cb51e16 100644 --- a/tools/gras/stub_generator.c +++ b/tools/gras/stub_generator.c @@ -8,11 +8,9 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include"xbt/sysdep.h" -#include"xbt/dict.h" -#include"xbt/dynar.h" -#include"xbt/error.h" -#include "surf/surf_parse.h" +#include "xbt/sysdep.h" +#include "xbt/log.h" +#include "surf/surfxml_parse.h" #include "surf/surf.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator"); @@ -67,23 +65,6 @@ const char *SIM_PREEMBULE = " return retcode;\n" \ "}\n" -#define SIM_MAIN_PREEMBULE \ -"int main (int argc,char *argv[]) {\n" \ -" int i,j;\n" \ -"\n" \ -" /* Simulation setup */\n" \ -" MSG_global_init_args(&argc,argv);\n" \ -" if (argc != 3) {\n" \ -" fprintf(stderr, \"Usage: %%s platform_file application_description.txt [--gras-log=...]\\n\",argv[0]);\n" \ -" exit(1);\n" \ -" }\n" \ -"\n" \ -" MSG_paje_output(\"%s.trace\");\n" \ -" MSG_set_channel_number(10); // Using at most 10 channel (ports) per host. Change it here if needed\n" \ -" MSG_create_environment(argv[1]);\n" \ -"\n" \ -" /* Application deployment */\n" - const char *SIM_MAIN_POSTEMBULE = "\n" "\n" " MSG_launch_application(argv[2]);\n" @@ -181,7 +162,22 @@ static void generate_sim(char *project) } fprintf(OUT, "\n%s\n",warning); - fprintf(OUT, SIM_MAIN_PREEMBULE, project); + fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n" + "\n" + " /* Simulation setup */\n" + " MSG_global_init(&argc,argv);\n" + " if (argc != 3) {\n" + " fprintf(stderr, \"Usage: %s platform_file application_description.txt [--gras-log=...]\\n\",argv[0]);\n" + " exit(1);\n" + " }\n" + "\n"); + fprintf(OUT, + " MSG_paje_output(\"%s.trace\");\n" + " MSG_set_channel_number(XBT_MAX_CHANNEL); /* Using at most 10 channel (ports) per host. Change it here if needed */\n" + " MSG_create_environment(argv[1]);\n" + "\n" + " /* Application deployment */\n", + project); xbt_dict_foreach(process_function_set,cursor,key,data) { fprintf(OUT," MSG_function_register(\"%s\", launch_%s);\n",key,key); } @@ -315,11 +311,11 @@ static void generate_makefile_local(char *project, char *deployment) fprintf(OUT, "PROJECT_NAME=%s\n",project); fprintf(OUT, "DISTDIR=gras-$(PROJECT_NAME)\n\n" - "SIMGRID_INSTALL_PATH?= $(shell echo \"\\\"<<<< SIMGRID_INSTALL_PATH undefined !!! >>>>\\\"\")\n" - "CFLAGS = -O3 -w\n" - "INCLUDES = -I$(SIMGRID_INSTALL_PATH)/include\n" - "LIBS_SIM = -lm -L$(SIMGRID_INSTALL_PATH)/lib/ -lsimgrid\n" - "LIBS_RL = -lm -L$(SIMGRID_INSTALL_PATH)/lib/ -lgras\n" + "GRAS_ROOT?= $(shell echo \"\\\"<<<< GRAS_ROOT undefined !!! >>>>\\\"\")\n" + "CFLAGS = -O3 -w -g\n" + "INCLUDES = -I$(GRAS_ROOT)/include\n" + "LIBS_SIM = -lm -L$(GRAS_ROOT)/lib/ -lsimgrid\n" + "LIBS_RL = -lm -L$(GRAS_ROOT)/lib/ -lgras\n" "LIBS = \n" "\n"); @@ -366,15 +362,22 @@ static void generate_makefile_local(char *project, char *deployment) "\n" "dist: clean distdir\n" "\ttar c $(DISTDIR) | gzip -c > $(DISTDIR).tar.gz\n" - "\n" + "\n", project, project); + + fprintf(OUT, "clean:\n" - "\trm -f $(BIN_FILES) $(OBJ_FILES) *~\n" + "\trm -f $(BIN_FILES) $(OBJ_FILES) *~ %s.o " SIM_OBJNAME, project, project); + xbt_dict_foreach(process_function_set,cursor,key,data) { + fprintf(OUT, " " RL_OBJNAME, project, key); + } + fprintf(OUT, + "\n" "\trm -rf $(DISTDIR)\n" "\n" ".SUFFIXES:\n" ".PHONY : clean\n" - "\n", project, project); - + "\n"); + fprintf(OUT, "############ REMOTE COMPILING #########\n"); fprintf(OUT, "MACHINES ?= "); @@ -385,7 +388,7 @@ static void generate_makefile_local(char *project, char *deployment) fprintf(OUT, "INSTALL_PATH ?='$$HOME/tmp/src' ### Has to be an absolute path !!! \n" - "SIMGRID_INSTALL_PATH ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! \n" + "GRAS_ROOT ?='$(INSTALL_PATH)' ### Has to be an absolute path !!! \n" "SRCDIR ?= ./\n" "SIMGRID_URL ?=http://gcl.ucsd.edu/simgrid/dl/\n" "SIMGRID_VERSION ?=2.92\n" @@ -398,10 +401,10 @@ static void generate_makefile_local(char *project, char *deployment) "\t for site in $(MACHINES) ; do \\\n" "\t machine=`echo $$site |sed 's/^\\([^%%]*\\)%%.*$$/\\1/'`;\\\n" "\t machine2=`echo $$site |sed 's/^\\([^%%]*\\)%%\\(.*\\)$$/\\2/'`;\\\n" - "\t cmd_mkdir=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) SIMGRID_INSTALL_PATH=$(SIMGRID_INSTALL_PATH) \\\n" + "\t cmd_mkdir=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n" "\t SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n" "\t GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) mkdir -p $(INSTALL_PATH) 2>&1'\\\"\";\\\n" - "\t cmd_make=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) SIMGRID_INSTALL_PATH=$(SIMGRID_INSTALL_PATH) \\\n" + "\t cmd_make=\"\\\"sh -c 'env INSTALL_PATH=$(INSTALL_PATH) GRAS_ROOT=$(GRAS_ROOT) \\\n" "\t SIMGRID_URL=$(SIMGRID_URL) SIMGRID_VERSION=$(SIMGRID_VERSION) GRAS_PROJECT=$(GRAS_PROJECT) \\\n" "\t GRAS_PROJECT_URL=$(GRAS_PROJECT_URL) make -C $(INSTALL_PATH) -f "MAKEFILE_FILENAME_REMOTE" $(ACTION) 2>&1'\\\"\";\\\n" "\t if echo $$site | grep '%%' >/dev/null ; then \\\n" @@ -434,9 +437,6 @@ static void generate_makefile_local(char *project, char *deployment) static void generate_makefile_remote(char *project, char *deployment) { - xbt_dict_cursor_t cursor=NULL; - char *key = NULL; - void *data = NULL; char *filename = NULL; FILE *OUT = NULL; @@ -450,13 +450,13 @@ static void generate_makefile_remote(char *project, char *deployment) "INSTALL_PATH ?= $(shell pwd)\n" "\n" "compile-simgrid:\n" - "\tcd $$SIMGRID_INSTALL_PATH ; \\\n" + "\tcd $$GRAS_ROOT ; \\\n" "\tretrieved=`LANG=C;wget -N $(SIMGRID_URL)/simgrid-$(SIMGRID_VERSION).tar.gz 2>&1 | grep newer | sed 's/.*no newer.*/yes/'`; \\\n" "\techo $$retrieved; \\\n" "\tif test \"x$$retrieved\" = x; then \\\n" "\t tar zxf simgrid-$(SIMGRID_VERSION).tar.gz ; \\\n" "\t cd simgrid-$(SIMGRID_VERSION)/; \\\n" - "\t ./configure --prefix=$$SIMGRID_INSTALL_PATH ; \\\n" + "\t ./configure --prefix=$$GRAS_ROOT ; \\\n" "\t make all install ;\\\n" "\tfi\n" "\n" @@ -512,8 +512,8 @@ static void generate_deployment(char *project, char *deployment) "if test \"${INSTALL_PATH+set}\" != set; then \n" " export INSTALL_PATH='`echo $HOME`/tmp/src'\n" "fi\n" - "if test \"${SIMGRID_INSTALL_PATH+set}\" != set; then \n" - " export SIMGRID_INSTALL_PATH='`echo $INSTALL_PATH`'\n" + "if test \"${GRAS_ROOT+set}\" != set; then \n" + " export GRAS_ROOT='`echo $INSTALL_PATH`'\n" "fi\n" "if test \"${SRCDIR+set}\" != set; then \n" " export SRCDIR=./\n" @@ -535,9 +535,9 @@ static void generate_deployment(char *project, char *deployment) project); fprintf(OUT, - "cmd_prolog=\"env INSTALL_PATH=$INSTALL_PATH SIMGRID_INSTALL_PATH=$SIMGRID_INSTALL_PATH \\\n" + "cmd_prolog=\"env INSTALL_PATH=$INSTALL_PATH GRAS_ROOT=$GRAS_ROOT \\\n" " SIMGRID_URL=$SIMGRID_URL SIMGRID_VERSION=$SIMGRID_VERSION GRAS_PROJECT=$GRAS_PROJECT \\\n" - " GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$SIMGRID_INSTALL_PATH/lib/ sh -c \";\n"); + " GRAS_PROJECT_URL=$GRAS_PROJECT_URL LD_LIBRARY_PATH=$GRAS_ROOT/lib/ sh -c \";\n"); xbt_dynar_foreach (process_list,cpt,proc) { fprintf(OUT,"cmd=\"\\$INSTALL_PATH/gras-%s/"RL_BINARYNAME" ",project,project,proc.argv[0]); @@ -603,6 +603,6 @@ int main(int argc, char *argv[]) generate_deployment(project_name, deployment_file); free(warning); - surf_finalize(); + surf_exit(); return 0; }