Exemplo n.º 1
0
bool CompilerFactory::find_tool_type (const char* argv0,bool option,const std::string &appli_path,std::string &option_tool_name, bool &profile_inactive) 
{
  FUNCTION_TRACE;
  DEBUG4("find_tool_type (argv0=%s,option=%s,appli_path=%s)\n",argv0,(option?"true":"false"),appli_path.c_str());
  std::string exe_param=System::appendExecSuffix(argv0);
  if (name_check(exe_param,std::string(),!option))
  {
    std::string name;
    profile_inactive=false;
    if (option)
      name=exe_param;
    else
      extract_tool_name(exe_param,name,true,profile_inactive);
    option_tool_name=name;
    struct stat info;
    DEBUG2("option_tool_name=%s\n",option_tool_name.c_str());
    std::string pf=profile_name(option_tool_name,appli_path);
    DEBUG2("pf=%s\n",pf.c_str());
    if (stat(pf.c_str(),&info)!=0)
    {
      option_tool_name=findFileInPath(name);
      DEBUG2("option_tool_name=%s\n",option_tool_name.c_str());
      std::string pf=profile_name(option_tool_name,appli_path);
      DEBUG2("pf=%s\n",pf.c_str());
      if (pf.length()>0 && (stat(pf.c_str(),&info)!=0) )
      {
         DEBUG2("profile (%s) not found\n",option_tool_name.c_str());
         option_tool_name.clear();
      }
    }
    return true;
  }
  return false;
}
Exemplo n.º 2
0
bool CompilerFactory::profile_existing(const std::string &prof, const std::string &additional_path) 
{
  std::string profile_file(prof);
  if (profile_file.length()>4 && (strcasecmp(profile_file.substr(profile_file.length()-4).c_str(),".exe")==0))
    profile_file = profile_file.substr(0,profile_file.length()-4);
  profile_file+=".cspro";
  { // Search directly
    if (additional_path.length()>0)
    {
      std::string prof_path=additional_path+FILE_SEPARATOR_CHAR+profile_file;
      FILE *f=fopen(prof_path.c_str(),"r");
      if (f)
      {
        fclose(f);
        return true;
      }
    }
  }

  { // Search in path
    std::string found_file=findFileInPath(profile_file,0);
    if (!found_file.empty())
      return true;
  }
  return false;
}
Exemplo n.º 3
0
std::string  CompilerFactory::findNativeTool(const std::string &profile_tool_name,const Argv & _args) 
{
  FUNCTION_TRACE;
  Argv arg(_args);
  bool tool_found=false;
  std::string file;
  struct stat info_me;
  std::string exe_param=System::appendExecSuffix(arg[0]);
  std::string appli=application_path(exe_param);
  DEBUG3("exe_param %s -> %s\n",exe_param.c_str(),appli.c_str());
  if (profile_tool_name.empty())
  {
     file=appli;
  }
  else
  {
     if (stat(appli.c_str(),&info_me)!=0)
        FATAL2("Could not get information from %s\n",appli.c_str());
     exe_param=System::appendExecSuffix(profile_tool_name);
     int index=-1;
     file=application_path(exe_param);
     while (!file.empty())
     {
        struct stat info;
        DEBUG2("Tool: %s\n",file.c_str());
        char file_abs[MAX_PATH];
        if (realPath(file.c_str(),file_abs)!=NULL)
        {
           DEBUG2("Tool abs: %s\n",file_abs);
           if (stat(file_abs,&info)==0)
           {
              if ( ! (info.st_ctime==info_me.st_ctime
                       && info.st_size==info_me.st_size) )
              { // tool found
                 tool_found=true;
                 DEBUG2("Tool found: %s\n",file.c_str());
                 break;
              }
              else
              { // suppress path entry
#if SUPPRESS_PATH_ENTRY
                 suppressPathEntry(file.c_str());
#endif
                 setenv("COVERAGESCANNER_ARGS","",1);
              }
           }
        }
        index++;
        file=findFileInPath(exe_param,index);
     } 

     if (!tool_found)
        FATAL2("Could not find application: %s\n",exe_param.c_str());
  }
  return file;
}
Exemplo n.º 4
0
Bool
applyConfig(char *name)
{
    FILE *fp;
    Bool ok;

    if ((fp = findFileInPath(name)) == NULL)
        return False;
    ok = XkbCFParse(fp, XkbCFDflts, NULL, &cfgResult);
    fclose(fp);
    if (!ok)
    {
        ERR1("Couldn't find configuration file \"%s\"\n", name);
        return False;
    }
    if (cfgResult.rules_file)
    {
        trySetString(&settings.rules, cfgResult.rules_file, FROM_CONFIG);
        cfgResult.rules_file = NULL;
    }
    if (cfgResult.model)
    {
        trySetString(&settings.model, cfgResult.model, FROM_CONFIG);
        cfgResult.model = NULL;
    }
    if (cfgResult.layout)
    {
        trySetString(&settings.layout, cfgResult.layout, FROM_CONFIG);
        cfgResult.layout = NULL;
    }
    if (cfgResult.variant)
    {
        trySetString(&settings.variant, cfgResult.variant, FROM_CONFIG);
        cfgResult.variant = NULL;
    }
    if (cfgResult.options)
    {
        addStringToOptions(cfgResult.options, &options);
        cfgResult.options = NULL;
    }
    if (cfgResult.keymap)
    {
        trySetString(&settings.keymap, cfgResult.keymap, FROM_CONFIG);
        cfgResult.keymap = NULL;
    }
    if (cfgResult.keycodes)
    {
        trySetString(&settings.keycodes, cfgResult.keycodes, FROM_CONFIG);
        cfgResult.keycodes = NULL;
    }
    if (cfgResult.geometry)
    {
        trySetString(&settings.geometry, cfgResult.geometry, FROM_CONFIG);
        cfgResult.geometry = NULL;
    }
    if (cfgResult.symbols)
    {
        trySetString(&settings.symbols, cfgResult.symbols, FROM_CONFIG);
        cfgResult.symbols = NULL;
    }
    if (cfgResult.types)
    {
        trySetString(&settings.types, cfgResult.types, FROM_CONFIG);
        cfgResult.types = NULL;
    }
    if (cfgResult.compat)
    {
        trySetString(&settings.compat, cfgResult.compat, FROM_CONFIG);
        cfgResult.compat = NULL;
    }
    if (verbose > 5)
    {
        MSG("After config file:\n");
        dumpNames(True, True);
    }
    return True;
}
Exemplo n.º 5
0
Bool
applyConfig(char *name)
{
    FILE *fp;
    Bool ok;

    if ((fp = findFileInPath(name, "")) == NULL)
        return False;
    ok = XkbCFParse(fp, XkbCFDflts, NULL, &cfgResult);
    fclose(fp);
    if (!ok)
    {
        ERR1("Couldn't find configuration file \"%s\"\n", name);
        return False;
    }
    if (cfgResult.rules_file)
    {
        trySetString(RULES_NDX, cfgResult.rules_file, FROM_CONFIG);
        cfgResult.rules_file = NULL;
    }
    if (cfgResult.model)
    {
        trySetString(MODEL_NDX, cfgResult.model, FROM_CONFIG);
        cfgResult.model = NULL;
    }
    if (cfgResult.layout)
    {
        trySetString(LAYOUT_NDX, cfgResult.layout, FROM_CONFIG);
        cfgResult.layout = NULL;
    }
    if (cfgResult.variant)
    {
        trySetString(VARIANT_NDX, cfgResult.variant, FROM_CONFIG);
        cfgResult.variant = NULL;
    }
    if (cfgResult.options)
    {
        addStringToOptions(cfgResult.options, &szOptions, &numOptions,
                           &options);
        cfgResult.options = NULL;
    }
    if (cfgResult.keymap)
    {
        trySetString(KEYMAP_NDX, cfgResult.keymap, FROM_CONFIG);
        cfgResult.keymap = NULL;
    }
    if (cfgResult.keycodes)
    {
        trySetString(KEYCODES_NDX, cfgResult.keycodes, FROM_CONFIG);
        cfgResult.keycodes = NULL;
    }
    if (cfgResult.geometry)
    {
        trySetString(GEOMETRY_NDX, cfgResult.geometry, FROM_CONFIG);
        cfgResult.geometry = NULL;
    }
    if (cfgResult.symbols)
    {
        trySetString(SYMBOLS_NDX, cfgResult.symbols, FROM_CONFIG);
        cfgResult.symbols = NULL;
    }
    if (cfgResult.types)
    {
        trySetString(TYPES_NDX, cfgResult.types, FROM_CONFIG);
        cfgResult.types = NULL;
    }
    if (cfgResult.compat)
    {
        trySetString(COMPAT_NDX, cfgResult.compat, FROM_CONFIG);
        cfgResult.compat = NULL;
    }
    if (verbose > 5)
    {
        MSG("After config file:\n");
        dumpNames(True, True);
    }
    return True;
}