#include <stdio.h>
#include <string.h>
#include "chpllaunch.h"
#include "chpl_mem.h"
#include "error.h"


static char* chpl_launch_create_command(int argc, char* argv[],
                                        int32_t numLocales) {
  int i;
  int size;
  char baseCommand[256];
  char* command;

  chpl_compute_real_binary_name(argv[0]);

  sprintf(baseCommand, "zebra -fast -r %s", chpl_get_real_binary_name());

  size = strlen(baseCommand) + 1;

  for (i=1; i<argc; i++) {
    size += strlen(argv[i]) + 3;
  }

  command = chpl_malloc(size, sizeof(char), CHPL_RT_MD_COMMAND_BUFFER, -1, "");
  
  sprintf(command, "%s", baseCommand);
  for (i=1; i<argc; i++) {
    strcat(command, " '");
    strcat(command, argv[i]);
    strcat(command, "'");
  }

  if (strlen(command)+1 > size) {
    chpl_internal_error("buffer overflow");
  }

  return command;
}


int chpl_launch(int argc, char* argv[], int32_t numLocales) {
  return chpl_launch_using_system(chpl_launch_create_command(argc, argv, numLocales),
                                  argv[0]);
}


int chpl_launch_handle_arg(int argc, char* argv[], int argNum,
                           int32_t lineno, chpl_string filename) {
  return 0;
}


void chpl_launch_print_help(void) {
}

#include <stdio.h>
#include <string.h>
#include "chpllaunch.h"
#include "chpl_mem.h"
#include "error.h"


static char** chpl_launch_create_argv(int argc, char* argv[]) {
  const int largc = 3;
  char *largv[largc];

  largv[0] = (char *) "zebra";
  largv[1] = (char *) "-fast";
  largv[2] = (char *) "-r";

  return chpl_bundle_exec_args(argc, argv, largc, largv);
}


int chpl_launch(int argc, char* argv[], int32_t numLocales) {
  if (numLocales != 1) {
    // This error should be taken care of before we get to this point
    chpl_internal_error("The XMT launcher only supports numLocales==1");
  }

  return chpl_launch_using_exec("zebra",
                                chpl_launch_create_argv(argc, argv),
                                argv[0]);
}


int chpl_launch_handle_arg(int argc, char* argv[], int argNum,
                           int32_t lineno, chpl_string filename) {
  return 0;
}


void chpl_launch_print_help(void) {
}

Update the zebra launcher to use chpl_launch_using_exec() as implemented in r18010.
Update the zebra launcher to use chpl_launch_using_exec() as
implemented in r18010.



git-svn-id: 88467cb1fb04b8a755be7e1ee1026be4190196ef@18032 3a8e244f-b0f2-452b-bcba-4c88e055c3ca
