/* 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/surf_parse_private.h"
#include "surf/surf.h"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen,gras,"Stub generator");
" 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"
}
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(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",
+ project);
xbt_dict_foreach(process_function_set,cursor,key,data) {
fprintf(OUT," MSG_function_register(\"%s\", launch_%s);\n",key,key);
}
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");
"\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 ?= ");
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"
"\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"
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;
"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"
"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"
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]);
generate_deployment(project_name, deployment_file);
free(warning);
- surf_finalize();
+ surf_exit();
return 0;
}