Пример #1
0
  static void collectDependencies(Cell const& cell, Index const& idx, std::unordered_set<Index> & deps)
  {
    if (!cell.hasExpression)
      return;

    for (auto const& expr : cell.expression)
    {
      if (expr.type_ == Expr::Cell)
      {
        const auto result = deps.insert(expr.startIndex_);
        if (result.second)
          collectDependencies(getCell(expr.startIndex_), expr.startIndex_, deps);
      }
      else if (expr.type_ == Expr::Range)
      {
        const Index startIdx = expr.startIndex_;
        const Index endIdx = expr.endIndex_;

        for (int y = startIdx.y; y <= endIdx.y; ++y)
          for (int x = startIdx.x; x <= endIdx.x; ++x)
          {
            const auto result = deps.insert(Index(x, y));
            if (result.second)
              collectDependencies(getCell(Index(x, y)), Index(x, y), deps);
          }
      }
    }
  }
Пример #2
0
void collectSubDependencies()
{
    // print status to user
    int dep_amount = deps.size();
    
    // recursively collect each dependencie's dependencies
    while(true)
    {
        dep_amount = deps.size();
        for(int n=0; n<dep_amount; n++)
        {
            std::cout << "."; fflush(stdout);
            std::vector<std::string> lines;
            collectDependencies(deps[n].getOriginalPath(), lines);
            
            const int line_amount = lines.size();
            for(int n=0; n<line_amount; n++)
            {
                if(lines[n][0] != '\t') continue; // only lines beginning with a tab interest us
                if( lines[n].find(".framework") != std::string::npos ) continue; //Ignore frameworks, we can not handle them
                
                addDependency( // trim useless info, keep only library name
                               lines[n].substr(1, lines[n].find(" (") )
                               );
            }//next
        }//next
        
        if(deps.size() == dep_amount) break; // no more dependencies were added on this iteration, stop searching
    }
}
Пример #3
0
void collectDependencies(std::string filename)
{
    std::vector<std::string> lines;
    collectDependencies(filename, lines);
       
    std::cout << "."; fflush(stdout);
    
    const int line_amount = lines.size();
    for(int n=0; n<line_amount; n++)
    {
        std::cout << "."; fflush(stdout);
        if(lines[n][0] != '\t') continue; // only lines beginning with a tab interest us
        if( lines[n].find(".framework") != std::string::npos ) continue; //Ignore frameworks, we can not handle them
        
        addDependency( // trim useless info, keep only library name
                       lines[n].substr(1, lines[n].find(" (") )
                       );
    }
}
Пример #4
0
int main (int argc, char * const argv[])
{
	
	// parse arguments	
	for(int i=0; i<argc; i++)
	{
		if(strcmp(argv[i],"-x")==0 or strcmp(argv[i],"--fix-file")==0)
		{
			i++;
            Settings::addFileToFix(argv[i]);
			continue;
		}
		else if(strcmp(argv[i],"-b")==0 or strcmp(argv[i],"--bundle-deps")==0)
		{
            Settings::bundleLibs(true);
			continue;	
		}
        else if(strcmp(argv[i],"-p")==0 or strcmp(argv[i],"--install-path")==0)
		{
			i++;
            Settings::inside_lib_path(argv[i]);
			continue;
		}
        else if(strcmp(argv[i],"-i")==0 or strcmp(argv[i],"--ignore")==0)
		{
			i++;
            Settings::ignore_prefix(argv[i]);
			continue;
		}
		else if(strcmp(argv[i],"-d")==0 or strcmp(argv[i],"--dest-dir")==0)
		{
			i++;
            Settings::destFolder(argv[i]);
			continue;
		}
		else if(strcmp(argv[i],"-of")==0 or strcmp(argv[i]," --overwrite-files")==0)
		{
            Settings::canOverwriteFiles(true);
			continue;	
		}
		else if(strcmp(argv[i],"-od")==0 or strcmp(argv[i],"--overwrite-dir")==0)
		{
            Settings::canOverwriteDir(true);
            Settings::canCreateDir(true);
			continue;	
		}
		else if(strcmp(argv[i],"-cd")==0 or strcmp(argv[i],"--create-dir")==0)
		{
            Settings::canCreateDir(true);
			continue;	
		}
		else if(strcmp(argv[i],"-h")==0 or strcmp(argv[i],"--help")==0)
		{
			showHelp();
			exit(0);	
		}
        else if(i>0)
        {
            // if we meet an unknown flag, abort
            // ignore first one cause it's usually the path to the executable
            std::cerr << "Unknown flag " << argv[i] << std::endl << std::endl;
            showHelp();
            exit(1);
        }
	}
	
	if(not Settings::bundleLibs() and Settings::fileToFixAmount()<1)
	{
		showHelp();
		exit(0);
	}
	
    std::cout << "* Collecting dependencies"; fflush(stdout);
    
    const int amount = Settings::fileToFixAmount();
    for(int n=0; n<amount; n++)
        collectDependencies(Settings::fileToFix(n));
    
    collectSubDependencies();
    doneWithDeps_go();
    
    return 0;
}