Ejemplo n.º 1
0
  ObjectInfo Resolver::FindPath(const string &path) const
  {
    ObjectInfo oi = ParsePath(path);

    if (oi.object.id != "")
    {
      if (oi.project.id == "")
        oi.project.id = FindProject(oi.project.name);

      DescribeObject(oi.project.id, oi.object.id, oi);

      oi.project.name = GetProjectName(oi.project.id);
    }
    else
    {
      if (oi.project.id == "")
        oi.project.id = FindProject(oi.project.name);
      else
        oi.project.name = GetProjectName(oi.project.id);

      if (oi.project.id != "")
        LookupPath(oi.project.id, oi.object.name, oi.object.folder, oi);
    }
    return oi;
  }
Ejemplo n.º 2
0
void Workspace::ExportProjectToSketch(QString projectName, QString path)
{
	Project * project = FindProject(projectName);
	if (project == NULL) {
		ErrorMessage("Current project not defined!");
		return;
	}

	path = path + "/" + project->name;
	QDir().mkpath(path);

	bool ok = true;
	bool main = false;
	
	for (int i=0; i < project->files.size(); i++) {
		ProjectFile *pfile = &(project->files.at(i));
		if (pfile->type != ptSource) {
			continue;
		}
		QString src = config.workspace + "/" + project->name + "/source/" + pfile->name;
		QString dst = path + "/" + pfile->name;
		if (pfile->name.toUpper() == (project->name.toUpper() + ".CPP")) { //"MAIN.CPP") {
			dst = path + "/" + project->name + ".ino"; 
			main = true;		
		}
		ok = ok & QFile::copy(src, dst);
	}
	ok = ok && main;
	if (ok == false) {
		ErrorMessage("Error while exporting Arduino sketch");
	}
}
Ejemplo n.º 3
0
void Workspace::RenameProject(QString projectName)
{
	Project * project = FindProject(projectName);
	if (project == NULL) {
		return;
	}

	GetUserString * user = new GetUserString();
	QString newName = user->GetNewName(projectName, false);
	if (newName == "") {
		return;
	}
	newName = QFileInfo(newName).baseName();

	QString newPath = QFileInfo(newName).baseName();
	QString oldPath = config.workspace + "/" + projectName;

	if (QDir().rename(oldPath, config.workspace + "/" + newPath) == false) {
		ErrorMessage("Error while renaming the project!\n");
		return;
	}

	oldPath = config.workspace + "/" + newPath + "/" + projectName + ".mmproj";
	newPath = config.workspace + "/" + newPath + "/" + newName + ".mmproj";
	

	if (QFile(oldPath).rename(newPath) == false) {
		ErrorMessage("Error while renaming the project definiton file. You'll need to do that manually.\n\nYou won't be able to load this project while this is not fixed");		
	}

	project->name = newName;
	SetCurrentProject(newName);
	modified = true;
}
Ejemplo n.º 4
0
void Workspace::RemoveProject(QString projectName)
{

	Project * project = FindProject(projectName);
	if (project == NULL) {
		return;
	}

	if (GetUserConfirmation("Confirm deleting this whole project?\n\n" + projectName) == false) {
		return;
	}

	QString path = config.workspace + "/" + projectName;
	QDir(path).removeRecursively();

	if (QDir(path).exists()) {
		ErrorMessage("Could not remove the project files. Please delete them manually.");
		return;
	}

	for (int i=0; i < projects.size(); i++) {
		if (projects.at(i).name == projectName) {
			projects.erase(projects.begin() + i);
			break;
		}
	}

	if (projects.size() > 0) {
		SetCurrentProject(projects.at(0).name);
	}
	
	modified = true;
}
Ejemplo n.º 5
0
  string Resolver::EnsureProject(const string &project) const
  {
    string project_id = FindProject(project);
    if (project_id == "")
      project_id = CreateProject(project);

    return project_id;
  }
Ejemplo n.º 6
0
  ObjectInfo Resolver::DestinationPath(const string &path) const
  {
    ObjectInfo oi = ObjectInfo(path, default_project);
    if (oi.project.id == "")
      oi.project.id = FindProject(oi.project.name);

    return oi;
  }
Ejemplo n.º 7
0
void Workspace::RemoveFile(QString projectName, QString file, bool isExternal)
{
	Project * project = FindProject(projectName);
	if (project == NULL) {
		return;
	}

	QString msg;
	QString fullPath = GetFullFilePath(projectName, file);
	if (isExternal) {
		msg = "Confirm removing reference to this external file?\nThe file will NOT be deleted!\n\n"
			+ file;
	} else {
		msg = "Confirm deleting this file: \n\n" + fullPath;
	}
	
	if (GetUserConfirmation(msg) == false) {
		return;
	}

	int index = -1;
	for (int i=0; i < project->files.size(); i++) {
		if (isExternal) {
			if ( (project->files.at(i).type == ptExternal) && (project->files.at(i).name == file) ) {
				index = i;
				break;
			}
		} else {
			if ( (project->files.at(i).type == ptSource) && (project->files.at(i).name == file) ) {
				index = i;
				break;
			}
		}
	}

	if (index < 0 ) {
		ErrorMessage("Could not delete the file!\n");
		return;
	}

	if (isExternal == false) {
		bool ok = QFile(fullPath).remove();
		if (ok == false) {
			ErrorMessage("Error deleting the file!\n");
			return;
		}		
	}

	project->files.erase(project->files.begin() + index);
	modified = true;
}
Ejemplo n.º 8
0
void Workspace::RenameFile(QString projectName, QString file)
{
	Project * project = FindProject(projectName);
	if (project == NULL) {
		return;
	}

	int index = -1;
	for (int i=0; i < project->files.size(); i++) {
		if ( (project->files.at(i).type != ptExternal) && (project->files.at(i).name == file) ) {
			index = i;
			break;
		}
	}

	if (index < 0 ) {
		ErrorMessage("Could not rename the file!\n");
		return;
	}

	GetUserString * user = new GetUserString();
	QString newName = user->GetNewName(QFileInfo(file).baseName(), true);
	if (newName == "") {
		return;
	}

	QString ext = QFileInfo(file).suffix();
	newName = QFileInfo(newName).baseName();
	newName = config.workspace + "/" + project->name + "/source/" + newName + "." + ext;

	QString oldName = GetFullFilePath(projectName, file);

	if (QFile(oldName).rename(newName) == false) {
		ErrorMessage("Error while renaming the file!\n");
		return;
	}

	project->files.at(index).name = QFileInfo(newName).fileName();
	modified = true;
}
Ejemplo n.º 9
0
void
App::ArgvReceived(int32 argc,char **argv)
{
	bool showUsage = false;
	bool verbose = false;
	int32 i = 1;
	for (i = 1; i < argc; i++)
	{
		int arglen = strlen(argv[i]);
		char *arg = argv[i];
		
		char opt;
		if (arglen == 2 && arg[0] == '-')
			opt = arg[1];
		else
			break;
			
		switch (opt)
		{
			case 'b':
			{
				gBuildMode = true;
				break;
			}
			case 'm':
			{
				gMakeMode = true;
				break;
			}
			case 'r':
			{
				gBuildMode = true;
				fBuildCleanMode = true;
				break;
			}
			case 's':
			{
				gSingleThreadedBuild = true;
				break;
			}
			
			#ifdef USE_TRACE_TOOLS
			case 'v':
			{
				verbose = true;
				break;
			}
			case 'd':
			{
				gPrintDebugMode = 1;
				break;
			}
			#endif
			
			default:
			{
				showUsage = true;
				break;
			}
		}
	}

	if (gPrintDebugMode > 0 && verbose)
		gPrintDebugMode = 2;
	
	if (showUsage)
	{
		PrintUsage();
		
		// A quick hack to not show the start window before
		// the quit request has been processed
		sWindowCount++;
		
		PostMessage(B_QUIT_REQUESTED);
		return;
	}
	
	if (gPrintDebugMode == 1)
		printf(B_TRANSLATE("Printing debug output\n"));
	else if (gPrintDebugMode == 2)
		printf(B_TRANSLATE("Printing debug output with extra detail\n"));
	
	if (gSingleThreadedBuild)
		STRACE(1,("Disabling multithreaded project building\n"));

		
	BMessage refmsg;
	int32 refcount = 0;

	// No initialization -- keep the value from the previous loop
	BEntry projfolder(gProjectPath.GetFullPath());
	entry_ref projref;
	projfolder.GetRef(&projref);
	for (; i < argc; i++)
	{
		// See if the project specified lacks an extension and append it
		BString projPath(argv[i]);
		if (projPath.FindLast(".pld") != projPath.CountChars() - 4)
		{
			projPath << ".pld";
			printf(B_TRANSLATE("Attempting to open %s\n"), projPath.String());
		}
		
		BEntry entry(projPath.String());
		
		entry_ref ref;
		
		if (!entry.Exists())
		{
			ref = FindProject(projref,projPath.String());
			if (!ref.name)
			{
				printf(B_TRANSLATE("Can't find file %s\n"),argv[i]);
				continue;
			}
		}
		else
			entry.GetRef(&ref);
		
		refmsg.AddRef("refs",&ref);
		refcount++;
		optind++;
		
		if (refcount == 1 && (gBuildMode || gMakeMode))
			break;
	}
	
	if (refcount > 0)
		RefsReceived(&refmsg);
	else if (gBuildMode || gMakeMode)
		Quit();
}