#include "xbt/log.h"
#include "surf/surfxml_parse.h"
#include "surf/surf.h"
+#include "portable.h" /* Needed for the time of the SIMIX convertion */
+
+#include <stdarg.h>
/* tabulation level (used to indent the lines of the borland project file */
static unsigned int level = 0;
-/* the library path for simgrid.lib and libras.lib. */
-static char* __lib_dir = NULL;
+
/* the gras.h header directory */
static char* __gras_path = NULL;
char* src_dir; /* the directory use to store the source files of the project */
}s_borland_project_t,* borland_project_t;
+
+/*
+ * A structure which represents a visual C++ project file.
+ */
+typedef struct s_dsp
+{
+ FILE* stream;
+ char* lib_dir;
+ char* src_dir;
+ char* name;
+}s_dsp_t,* dsp_t;
+
/*
* Write tabs in a borland project file.
* @param project The project concerned by the operation.
* @param project The borland project to generate.
*/
void
-generate_borland_project(borland_project_t project);
+generate_borland_project(borland_project_t project,int is_rl,const char* name);
/*
* Find the path of a file.
int
find_file_path(const char* root_dir,const char* file_name,char* path);
+
+/*
+ * Functions used to create a Microsoft Visual C++ project file (*.dsp).
+ */
+
+/*
+ * Create the Microsoft visual C++ file project for the simulation.
+ */
+int
+generate_simulation_dsp_file(const char* project_name);
+
+/*
+ * Create the Microsoft visual C++ real life project file.
+ */
+int
+generate_real_live_dsp_file(const char* project_name);
+
+/*
+ * generate a Microsoft Visual project file*/
+void
+generate_dsp_project(dsp_t project,int is_rl,const char* name);
+
#endif
const char *SIM_MAIN_POSTEMBULE = "\n"
"\n"
-" MSG_launch_application(argv[2]);\n"
+" gras_launch_application(argv[2]);\n"
"\n"
" /* Run the simulation */\n"
-" MSG_main();\n"
+" gras_main();\n"
"\n"
" /* cleanup the place */\n"
-" MSG_clean();\n"
+" gras_clean();\n"
" if (gras_log)\n"
" free(gras_log);\n"
" return 0;\n"
static void s_process_free(void *process)
{
+ s_process_t*p = (s_process_t*)process;
int i;
- for(i=0;i<((s_process_t*)process)->argc; i++)
- free(((s_process_t*)process)->argv[i]);
- free(((s_process_t*)process)->host);
+ for (i=0; i<p->argc ; i++)
+ free(p->argv[i]);
+ free(p->argv);
+ free(p->host);
}
static s_process_t process;
-/*
- * Création de deux dictionnaires
- */
static void parse_process_init(void)
{
xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
/*VERB1("Function: %s",process.argv[0]);*/
}
-static void generate_sim(char *project)
-{
- xbt_dict_cursor_t cursor=NULL;
- char *key = NULL;
- void *data = NULL;
- char *filename = NULL;
- FILE *OUT = NULL;
-
- /*
- * Creation d'un fichier nommé : <projet>_simulator.c
- */
- filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME));
- sprintf(filename,SIM_SOURCENAME,project);
-
- OUT=fopen(filename,"w");
-
-
- xbt_assert1(OUT, "Unable to open %s for writing",filename);
-
- /*
- * Ecriture du message d'avertissement.
- */
- fprintf(OUT, "%s\n",warning);
-
- /*
- * Ecriture du préambule (inclusion de certains fichiers d'en-tête
- */
- fprintf(OUT, "%s", SIM_PREEMBULE);
-
- /*
- * Déclaration des fonction int <process>(int argc,char *argv[]);
- */
- xbt_dict_foreach(process_function_set,cursor,key,data) {
- fprintf(OUT,"int %s(int argc,char *argv[]);\n",key);
- }
-
- fprintf(OUT,"\n");
-
- /*
- * Déclaration des fonction int launch_<process>(int argc,char *argv[]);
- */
- xbt_dict_foreach(process_function_set,cursor,key,data) {
- fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key);
- }
-
- /*
- * Ecriture du message d'avertissement.
- */
- fprintf(OUT, "\n%s\n",warning);
-
- xbt_dict_foreach(process_function_set,cursor,key,data) {
- fprintf(OUT,SIM_LAUNCH_FUNC,key,key);
- }
- fprintf(OUT, "\n%s\n",warning);
-
- fprintf(OUT,"%s", "/* specific to Borland Compiler */\n"
- "#ifdef __BORLANDDC__\n"
- "#pragma argsused\n"
- "#endif\n\n");
-
- 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.xml deployment.xml [--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);
- }
- fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
- fclose(OUT);
- free(filename);
+static void generate_sim(char *project) {
+ xbt_dict_cursor_t cursor=NULL;
+ char *key = NULL;
+ void *data = NULL;
+ char *filename = NULL;
+ FILE *OUT = NULL;
+
+ /* Output file: <projet>_simulator.c */
+ filename = xbt_new(char,strlen(project) + strlen(SIM_SOURCENAME));
+ sprintf(filename,SIM_SOURCENAME,project);
+
+ OUT=fopen(filename,"w");
+
+ xbt_assert1(OUT, "Unable to open %s for writing",filename);
+
+ fprintf(OUT, "%s\n",warning);
+ fprintf(OUT, "%s", SIM_PREEMBULE);
+
+ xbt_dict_foreach(process_function_set,cursor,key,data) {
+ fprintf(OUT,"int %s(int argc,char *argv[]);\n",key);
+ }
+
+ fprintf(OUT,"\n");
+
+ xbt_dict_foreach(process_function_set,cursor,key,data) {
+ fprintf(OUT,"int launch_%s(int argc,char *argv[]);\n",key);
+ }
+
+ fprintf(OUT, "\n%s\n",warning);
+
+ xbt_dict_foreach(process_function_set,cursor,key,data) {
+ fprintf(OUT,SIM_LAUNCH_FUNC,key,key);
+ }
+ fprintf(OUT, "\n%s\n",warning);
+
+ fprintf(OUT,"%s", "/* specific to Borland Compiler */\n"
+ "#ifdef __BORLANDDC__\n"
+ "#pragma argsused\n"
+ "#endif\n\n");
+
+ fprintf(OUT, "%s", "int main (int argc,char *argv[]) {\n"
+ "\n"
+ " /* Simulation setup */\n"
+ " gras_global_init(&argc,argv);\n"
+ " if (argc != 3) {\n"
+ " fprintf(stderr, \"Usage: %s platform.xml deployment.xml [--gras-log=...]\\n\",argv[0]);\n"
+ " exit(1);\n"
+ " }\n"
+ "\n");
+ fprintf(OUT,
+ " gras_create_environment(argv[1]);\n"
+ "\n"
+ " /* Application deployment */\n"
+ );
+ xbt_dict_foreach(process_function_set,cursor,key,data) {
+ fprintf(OUT," gras_function_register(\"%s\", launch_%s);\n",key,key);
+ }
+ fprintf(OUT, "%s", SIM_MAIN_POSTEMBULE);
+ fclose(OUT);
+ free(filename);
}
/**********************************************/
xbt_dict_foreach(process_function_set,cursor,key,data) {
filename = xbt_new(char,strlen(project) + strlen(RL_SOURCENAME) + strlen(key));
- sprintf(filename,RL_SOURCENAME,project,key);
+
+ sprintf(filename,RL_SOURCENAME,project,key);
OUT=fopen(filename,"w");
xbt_assert1(OUT, "Unable to open %s for writing",filename);
"#include <signal.h>\n" \
"#include <gras.h>\n" \
"\n" \
- "extern const char *_gras_procname;\n" \
+ "XBT_PUBLIC_DATA(const char *) _gras_procname;\n" \
"/* user code */\n" \
"int %s(int argc, char *argv[]);\n" \
"\n" \
fclose(OUT);
}
-
-static void generate_deployment(char *project, char *deployment)
-{
- xbt_dict_cursor_t cursor=NULL;
- char *key = NULL;
- void *data = NULL;
- char *filename = NULL;
- FILE *OUT = NULL;
-
- int cpt,i;
- s_process_t proc;
-
- filename = xbt_new(char,strlen(project) + strlen(DEPLOYMENT));
- sprintf(filename,DEPLOYMENT, project);
-
- OUT=fopen(filename,"w");
- xbt_assert1(OUT, "Unable to open %s for writing",filename);
-
- fprintf(OUT, "#!/bin/sh\n");
- fprintf(OUT, "############ DEPLOYMENT FILE #########\n");
- fprintf(OUT,
- "if test \"${MACHINES+set}\" != set; then \n"
- " export MACHINES='");
- xbt_dict_foreach(machine_set,cursor,key,data) {
- fprintf(OUT, "%s ",key);
- }
- fprintf(OUT,
- "';\n"
- "fi\n"
- "if test \"${INSTALL_PATH+set}\" != set; then \n"
- " export INSTALL_PATH='`echo $HOME`/tmp/src'\n"
- "fi\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"
- "fi\n"
- "if test \"${SIMGRID_URL+set}\" != set; then \n"
- " export SIMGRID_URL=http://gcl.ucsd.edu/simgrid/dl/\n"
- "fi\n"
- "if test \"${SIMGRID_VERSION+set}\" != set; then \n"
- " export SIMGRID_VERSION=2.91\n"
- "fi\n"
- "if test \"${GRAS_PROJECT+set}\" != set; then \n"
- " export GRAS_PROJECT=%s\n"
- "fi\n"
- "if test \"${GRAS_PROJECT_URL+set}\" != set; then \n"
- " export GRAS_PROJECT_URL=http://www-id.imag.fr/Laboratoire/Membres/Legrand_Arnaud/gras_test/\n"
- "fi\n"
- "\n"
- "test -e runlogs/ || mkdir -p runlogs/\n",
- project);
-
- fprintf(OUT,
- "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=$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]);
- for(i=1;i<proc.argc;i++) {
- fprintf(OUT,"%s ",proc.argv[i]);
- }
- fprintf(OUT,"\";\n");
- 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);
- }
-
- fclose(OUT);
-}
-
static void print(void *p)
{
printf("%p",p);
int i;
surf_init(&argc, argv);
+ process_function_set = xbt_dict_new();
+ process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free);
+ machine_set = xbt_dict_new();
+ for (i=1; i<argc; i++) {
+ int need_removal = 0;
+ if (!strncmp("--extra-process=",argv[i], strlen("--extra-process="))) {
+ xbt_dict_set(process_function_set, argv[i]+strlen("--extra-process="), NULL, NULL);
+ need_removal = 1;
+ }
+
+
+ if (need_removal) { /* remove the handled argument from argv */
+ int j;
+ for (j=i+1; j<argc; j++) {
+ argv[j-1] = argv[j];
+ }
+ argv[j-1] = NULL;
+ argc--;
+ i--; /* compensate effect of next loop incrementation */
+ }
+ }
+
xbt_assert1((argc >= 3),"Usage: %s project_name deployment_file [deployment_file...]\n",argv[0]);
project_name = argv[1];
- process_function_set = xbt_dict_new();
- process_list = xbt_dynar_new(sizeof(s_process_t),s_process_free);
- machine_set = xbt_dict_new();
-
STag_surfxml_process_fun = parse_process_init;
ETag_surfxml_argument_fun = parse_argument;
ETag_surfxml_process_fun = parse_process_finalize;
#ifdef _WIN32
generate_borland_simulation_project(project_name);
generate_borland_real_life_project(project_name);
-
- if(__lib_dir)
- xbt_free(__lib_dir);
+ generate_simulation_dsp_file(project_name);
+ generate_real_live_dsp_file(project_name);
if(__gras_path)
xbt_free(__gras_path);
}
#ifdef _WIN32
void
-generate_borland_project(borland_project_t project)
+generate_borland_project(borland_project_t project,int is_rl,const char* name)
{
char* binary_path; /* the path of the generated binary file */
char* obj_path; /* the path of the generated object file */
char* main_source; /* the name of the bpf file used by the borland project */
char* file_name; /* the file name of the main source file */
char* include_path; /* the include path */
-
+ char* buffer;
/* create the borland project file */
borland_project_create(project);
xbt_free(binary_path);
/* construct an write the object files to generate by the compiler */
- obj_path = xbt_new0(char,strlen(project->name) + strlen(project->obj_dir) + 6);
- sprintf(binary_path,"%s\\%s.obj",project->obj_dir,project->name);
+ obj_path = xbt_new0(char,strlen(project->name) + strlen(name) + (2*strlen(project->obj_dir)) + 11);
+ sprintf(binary_path,"%s\\%s.obj\n%s\\%s.obj",project->obj_dir,project->name,project->obj_dir,name);
borland_project_write_xml_element(project,"OBJFILES",obj_path);
xbt_free(obj_path);
lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + strlen("libgras.lib") + 3);
sprintf(lib_files,"%s\\simgrid.lib %s\\libgras.lib",project->lib_dir,project->lib_dir);
*/
-
- lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + 2);
- sprintf(lib_files,"%s\\simgrid.lib",project->lib_dir);
+
+ if(is_rl){
+ lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("libgras.lib") + 2);
+ sprintf(lib_files,"%s\\libgras.lib",project->lib_dir);
+ }else{
+ lib_files = xbt_new0(char,(2 * (strlen(project->lib_dir) + 1)) + strlen("simgrid.lib") + 2);
+ sprintf(lib_files,"%s\\simgrid.lib",project->lib_dir);
+ }
borland_project_write_xml_element(project,"LIBFILES",lib_files);
xbt_free(lib_files);
/* write the INCLUDEPATH element */
if(!__gras_path){
- __gras_path = xbt_new0(char,MAX_PATH);
- find_file_path("C:\\","gras.h",__gras_path);
+ buffer =xbt_new0(char,MAX_PATH);
+ GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
+
+ __gras_path = xbt_new0(char,MAX_PATH);
+ sprintf(__gras_path,"%s\\simgrid\\include",buffer);
+ free(buffer);
+
+ /*find_file_path("C:\\","gras.h",__gras_path);*/
}
include_path = xbt_new0(char,strlen("$(BCB)\\include") + strlen(__gras_path) + 2);
* -tWM- specify that the application is not multithread
* -c generate the object file, no link
*/
- 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");
+ 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");
/* write the PFLAGS element */
- borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE -M");
+ borland_project_write_xml_element(project,"PFLAGS","-N2obj -N0obj -$YD -$W -$O- -$A8 -v -JPHNE ");
/* write the RFLAGS element */
borland_project_write_xml_element(project,"RFLAGS","");
/* FIXME : check the source file directory */
/* add the generated source file to the list */
- file_name = xbt_new0(char,strlen(project->src_dir) + strlen(project->name) + 4);
- sprintf(file_name,"%s\\%s.c",project->src_dir,project->name);
+
+ file_name = xbt_new0(char,strlen(project->src_dir) + strlen(project->name) + 5);
+ sprintf(file_name,"%s\\_%s.c",project->src_dir,project->name);
borland_project_write_file_element(project,file_name,"",project->name,"CCompiler","","");
+
+ memset(file_name,0,strlen(project->src_dir) + strlen(project->name) + 4);
+ sprintf(file_name,"%s\\%s.c",project->src_dir,name);
+ borland_project_write_file_element(project,file_name,"",name,"CCompiler","","");
+
xbt_free(file_name);
/* FIXME : check the libraries directory */
/* add the simgrid library to the list */
- file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
- sprintf(file_name,"%s\\simgrid.lib",project->lib_dir);
- borland_project_write_file_element(project,file_name,"","simgrid.lib","LibTool","","");
+
+ if(is_rl){
+ file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("libgras.lib") + 2);
+ sprintf(file_name,"%s\\libgras.lib",project->lib_dir);
+ borland_project_write_file_element(project,file_name,"","libgras.lib","LibTool","","");
+ }else
+ {
+ file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("simgrid.lib") + 2);
+ sprintf(file_name,"%s\\simgrid.lib",project->lib_dir);
+ borland_project_write_file_element(project,file_name,"","simgrid.lib","LibTool","","");
+ }
+
+
xbt_free(file_name);
- /*
- add the libgras library to the list
-
- file_name = xbt_new0(char,strlen(project->lib_dir) + strlen("libgras.lib") + 2);
- sprintf(file_name,"%s\\libgras.lib",project->lib_dir);
-
- borland_project_write_file_element(project,file_name,"","libgras.lib","LibTool","","");
- xbt_free(file_name);
- */
-
/* write the end of the node FILELIST */
borland_project_end_xml_node(project,"FILELIST");
borland_project_write_xml_element(borland_project_t project,const char* name,const char* value)
{
borland_project_write_tabs(project,level);
-
fprintf(project->stream,"<%s value=\"%s\"/>\n",name,value);
}
void
borland_project_create(borland_project_t project)
{
- char* file_name = xbt_new0(char,strlen(project->name) + 5);
+ char* file_name = xbt_new0(char,strlen(project->name ) + 5);
sprintf(file_name,"%s.bpr",project->name);
project->stream = fopen(file_name,"w+");
xbt_free(file_name);
borland_project.lib_dir = xbt_new0(char,MAX_PATH);
- if(!__lib_dir){
- find_file_path("C:\\","simgrid.lib",borland_project.lib_dir);
- __lib_dir = strdup(borland_project.lib_dir);
- }
- else
- borland_project.lib_dir = strdup(__lib_dir);
+
+ GetEnvironmentVariable("LIB_SIMGRID_PATH",borland_project.lib_dir,MAX_PATH);
+
GetCurrentDirectory(MAX_PATH,buffer);
strcpy(borland_project.src_dir,buffer);
- borland_project.name = xbt_new0(char,strlen(name) + strlen("_simulator") + 2);
- sprintf(borland_project.name,"_%s_simulator",name);
+ borland_project.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
+ sprintf(borland_project.name,"%s_simulator",name);
borland_project.bin_dir = xbt_new0(char,strlen(buffer) + strlen("\\bin") + 1);
sprintf(borland_project.bin_dir,"%s\\bin",buffer);
if(INVALID_HANDLE_VALUE == hDir)
CreateDirectory(borland_project.obj_dir,NULL);
- generate_borland_project(&borland_project);
+ generate_borland_project(&borland_project,0,name);
xbt_free(borland_project.name);
xbt_free(borland_project.src_dir);
borland_project.lib_dir = xbt_new0(char,MAX_PATH);
- if(!__lib_dir){
- find_file_path("C:\\","simgrid.lib",borland_project.lib_dir);
- __lib_dir = strdup(borland_project.lib_dir);
- }
- else
- borland_project.lib_dir = strdup(__lib_dir);
-
+ GetEnvironmentVariable("LIB_GRAS_PATH",borland_project.lib_dir,MAX_PATH);
+
GetCurrentDirectory(MAX_PATH,buffer);
borland_project.src_dir = xbt_new0(char,strlen(buffer) + 1);
xbt_dict_foreach(process_function_set,cursor,key,data) {
- borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 3);
+ borland_project.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
- sprintf(borland_project.name,"_%s_%s",name,key);
+ sprintf(borland_project.name,"%s_%s",name,key);
- generate_borland_project(&borland_project);
+ generate_borland_project(&borland_project,1,name);
xbt_free(borland_project.name);
}
FindClose (hFind);
return 0;
}
+
+/* Implementation of the functions used to create a Visual C++ project.*/
+
+int
+generate_simulation_dsp_file(const char* name)
+{
+ char buffer[MAX_PATH] = {0};
+ s_dsp_t dsp = {0};
+ dsp.lib_dir = xbt_new0(char,MAX_PATH);
+
+ GetEnvironmentVariable("LIB_SIMGRID_PATH",dsp.lib_dir,MAX_PATH);
+ GetCurrentDirectory(MAX_PATH,buffer);
+
+ dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
+ strcpy(dsp.src_dir,buffer);
+ dsp.name = xbt_new0(char,strlen(name) + strlen("simulator") + 2);
+ sprintf(dsp.name,"%s_simulator",name);
+
+ generate_dsp_project(&dsp,0,name);
+
+ xbt_free(dsp.name);
+ xbt_free(dsp.src_dir);
+ xbt_free(dsp.lib_dir);
+
+ return 0;
+}
+
+/*
+ * Create the Microsoft visual C++ real life project file.
+ */
+int
+generate_real_live_dsp_file(const char* name)
+{
+
+ char buffer[MAX_PATH] = {0};
+ xbt_dict_cursor_t cursor = NULL;
+ char *key = NULL;
+ void *data = NULL;
+ s_dsp_t dsp = {0};
+
+
+ dsp.lib_dir = xbt_new0(char,MAX_PATH);
+
+ GetEnvironmentVariable("LIB_GRAS_PATH",dsp.lib_dir,MAX_PATH);
+
+ GetCurrentDirectory(MAX_PATH,buffer);
+
+ dsp.src_dir = xbt_new0(char,strlen(buffer) + 1);
+
+ strcpy(dsp.src_dir,buffer);
+
+
+ xbt_dict_foreach(process_function_set,cursor,key,data) {
+ dsp.name = xbt_new0(char,strlen(name) + strlen(key) + 2);
+
+ sprintf(dsp.name,"%s_%s",name,key);
+
+ generate_dsp_project(&dsp,1,name);
+ xbt_free(dsp.name);
+ }
+
+ xbt_free(dsp.src_dir);
+ xbt_free(dsp.lib_dir);
+ return 0;
+}
+
+void
+generate_dsp_project(dsp_t project,int is_rl,const char* name)
+{
+ /* create the visual C++ project file */
+ char* buffer;
+ char* file_name = xbt_new0(char,strlen(project->name) + 5);
+ sprintf(file_name,"%s.dsp",project->name);
+ project->stream = fopen(file_name,"w+");
+ xbt_free(file_name);
+
+ if(!__gras_path)
+ {
+ buffer =xbt_new0(char,MAX_PATH);
+ GetEnvironmentVariable("SG_INSTALL_DIR",buffer,MAX_PATH);
+
+ __gras_path = xbt_new0(char,MAX_PATH);
+ sprintf(__gras_path,"%s\\simgrid\\include",buffer);
+ free(buffer);
+ }
+
+ /* dsp file header */
+ fprintf(project->stream,"# Microsoft Developer Studio Project File - Name=\"%s\" - Package Owner=<4>\n",project->name);
+ fprintf(project->stream,"# Microsoft Developer Studio Generated Build File, Format Version 6.00\n");
+ fprintf(project->stream,"# ** DO NOT EDIT **\n\n");
+
+ /* target type is a win32 x86 console application */
+ fprintf(project->stream,"# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\n");
+
+ /* the current config is win32-debug */
+ fprintf(project->stream,"CFG=%s - Win32 Debug\n",project->name);
+
+ /* warning */
+ fprintf(project->stream,"!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n");
+
+ /* NMAKE usage */
+ fprintf(project->stream,"!MESSAGE use the Export Makefile command and run\n");
+ fprintf(project->stream,"!MESSAGE\n");
+ fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\".\n",project->name);
+ fprintf(project->stream,"!MESSAGE\n");
+ fprintf(project->stream,"!MESSAGE You can specify a configuration when running NMAKE\n");
+ fprintf(project->stream,"!MESSAGE by defining the macro CFG on the command line. For example:\n");
+ fprintf(project->stream,"!MESSAGE\n");
+ fprintf(project->stream,"!MESSAGE NMAKE /f \"%s.mak\" CFG=\"%s - Win32 Debug\"\n",project->name,project->name);
+ fprintf(project->stream,"!MESSAGE\n");
+ fprintf(project->stream,"!MESSAGE Possible choices for configuration are:\n");
+ fprintf(project->stream,"!MESSAGE\n");
+ fprintf(project->stream,"!MESSAGE \"%s - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n",project->name);
+ fprintf(project->stream,"!MESSAGE \"%s - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n",project->name);
+ fprintf(project->stream,"!MESSAGE\n\n");
+
+ fprintf(project->stream,"# Begin Project\n\n");
+ fprintf(project->stream,"# PROP AllowPerConfigDependencies 0\n");
+ fprintf(project->stream,"# PROP Scc_ProjName\n");
+ fprintf(project->stream,"# PROP Scc_LocalPath\n");
+ fprintf(project->stream,"CPP=cl.exe\n");
+ fprintf(project->stream,"RSC=rc.exe\n\n");
+
+ fprintf(project->stream,"!IF \"$(CFG)\" == \"%s - Win32 Release\"\n\n",project->name);
+
+ fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
+ fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 0\n");
+ fprintf(project->stream,"# PROP BASE Output_Dir \"Release\"\n");
+ fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Release\"\n");
+ fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
+ fprintf(project->stream,"# PROP Use_MFC 0\n");
+ fprintf(project->stream,"# PROP Use_Debug_Libraries 0\n");
+ fprintf(project->stream,"# PROP Output_Dir \"Release\"\n");
+ fprintf(project->stream,"# PROP Intermediate_Dir \"Release\"\n");
+ fprintf(project->stream,"# PROP Target_Dir \"\"\n");
+ /* TODO : the include directory */
+ /*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);*/
+ 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);
+ fprintf(project->stream,"# ADD CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n");
+ fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"NDEBUG\"\n");
+ fprintf(project->stream,"# ADD RSC /l 0x40c /d \"NDEBUG\n");
+ fprintf(project->stream,"BSC32=bscmake.exe\n");
+ fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
+ fprintf(project->stream,"# ADD BSC32 /nologo\n");
+ fprintf(project->stream,"LINK32=link.exe\n");
+ 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");
+
+ if(is_rl)
+ 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");
+ else
+ 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");
+
+ fprintf(project->stream,"!ELSEIF \"$(CFG)\" == \"%s - Win32 Debug\"\n",project->name);
+
+ fprintf(project->stream,"# PROP BASE Use_MFC 0\n");
+ fprintf(project->stream,"# PROP BASE Use_Debug_Libraries 1\n");
+ fprintf(project->stream,"# PROP BASE Output_Dir \"Debug\"\n");
+ fprintf(project->stream,"# PROP BASE Intermediate_Dir \"Debug\"\n");
+ fprintf(project->stream,"# PROP BASE Target_Dir \"\"\n");
+ fprintf(project->stream,"# PROP Use_MFC 0\n");
+ fprintf(project->stream,"# PROP Use_Debug_Libraries 1\n");
+ fprintf(project->stream,"# PROP Output_Dir \"Debug\"\n");
+ fprintf(project->stream,"# PROP Intermediate_Dir \"Debug\"\n");
+ fprintf(project->stream,"# PROP Ignore_Export_Lib 0\n");
+ fprintf(project->stream,"# PROP Target_Dir \"\"\n");
+ /* TODO : the include directory */
+ /*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);*/
+ 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);
+ fprintf(project->stream,"# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n");
+ fprintf(project->stream,"# ADD BASE RSC /l 0x40c /d \"_DEBUG\"\n");
+ fprintf(project->stream,"# ADD RSC /l 0x40c /d \"_DEBUG\"\n");
+ fprintf(project->stream,"BSC32=bscmake.exe\n");
+ fprintf(project->stream,"# ADD BASE BSC32 /nologo\n");
+ fprintf(project->stream,"# ADD BSC32 /nologo\n");
+ fprintf(project->stream,"LINK32=link.exe\n");
+ 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");
+
+ if(is_rl)
+ 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");
+ else
+ 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");
+
+ fprintf(project->stream,"!ENDIF\n\n");
+
+ fprintf(project->stream,"# Begin Target\n\n");
+ fprintf(project->stream,"# Name \"%s - Win32 Release\"\n",project->name);
+ fprintf(project->stream,"# Name \"%s - Win32 Debug\"\n",project->name);
+ fprintf(project->stream,"# Begin Group \"Source Files\"\n\n");
+ fprintf(project->stream,"# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n\n");
+
+ fprintf(project->stream,"# Begin Source File\n");
+ fprintf(project->stream,"SOURCE=%s\\_%s.c\n",project->src_dir,project->name);
+ fprintf(project->stream,"# End Source File\n\n");
+
+ fprintf(project->stream,"# Begin Source File\n");
+ fprintf(project->stream,"SOURCE=%s\\%s.c\n",project->src_dir,name);
+ fprintf(project->stream,"# End Source File\n\n");
+
+ fprintf(project->stream,"# End Group\n");
+ fprintf(project->stream,"# Begin Group \"Header Files\"\n\n");
+ fprintf(project->stream,"# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n");
+ fprintf(project->stream,"# End Group\n");
+ fprintf(project->stream,"# Begin Group \"Resource Files\"\n\n");
+ fprintf(project->stream,"# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n");
+ fprintf(project->stream,"# End Group\n");
+ fprintf(project->stream,"# End Target\n");
+ fprintf(project->stream,"# End Project\n");
+
+}
+
#endif