コード例 #1
0
ファイル: ExpanderThread.cpp プロジェクト: AmirAbrams/haiku
status_t
ExpanderThread::ThreadStartup()
{
	status_t status = B_OK;
	entry_ref srcRef;
	entry_ref destRef;
	BString cmd;

	if ((status = GetDataStore()->FindRef("srcRef", &srcRef)) != B_OK)
		return status;

	if ((status = GetDataStore()->FindRef("destRef", &destRef)) == B_OK) {
		BPath path(&destRef);
		chdir(path.Path());
	}

	if ((status = GetDataStore()->FindString("cmd", &cmd)) != B_OK)
		return status;

	BPath path(&srcRef);
	BString pathString(path.Path());
	pathString.CharacterEscape("\\\"$`", '\\');
	pathString.Prepend("\"");
	pathString.Append("\"");
	cmd.ReplaceAll("%s", pathString.String());

	int32 argc = 3;
	const char** argv = new const char * [argc + 1];

	argv[0] = strdup("/bin/sh");
	argv[1] = strdup("-c");
	argv[2] = strdup(cmd.String());
	argv[argc] = NULL;

	fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr);

	delete [] argv;

	if (fThreadId < 0)
		return fThreadId;

	// lower the command priority since it is a background task.
	set_thread_priority(fThreadId, B_LOW_PRIORITY);

	resume_thread(fThreadId);

	int flags = fcntl(fStdOut, F_GETFL, 0);
	flags |= O_NONBLOCK;
	fcntl(fStdOut, F_SETFL, flags);
	flags = fcntl(fStdErr, F_GETFL, 0);
	flags |= O_NONBLOCK;
	fcntl(fStdErr, F_SETFL, flags);

	fExpanderOutput = fdopen(fStdOut, "r");
	fExpanderError = fdopen(fStdErr, "r");

	return B_OK;
}
コード例 #2
0
ファイル: FilterIO.cpp プロジェクト: AmirAbrams/haiku
status_t
FilterIO::InitData(int argc, const char** argv, const char** envp)
{
	fStdIn = fStdOut = fStdErr = -1;
	fInitErr = B_OK;

	fThreadId = PipeCommand(argc, argv, fStdIn, fStdOut, fStdErr, envp);
	if (fThreadId < 0)
		fInitErr = fThreadId;

	// lower the command priority since it is a background task.
	set_thread_priority(fThreadId, B_LOW_PRIORITY);
	resume_thread(fThreadId);

	return fInitErr;
}
コード例 #3
0
ファイル: Project.cpp プロジェクト: passick/Paladin
void
Project::UpdateResources(void)
{
	DPath targetpath(fPath.GetFolder());
	targetpath.Append(GetTargetName());
	
	BString resFileString;
	int32 resCount = 0;

	for (int32 i = 0; i < CountGroups(); i++)
	{
		SourceGroup *group = GroupAt(i);
		
		for (int32 j = 0; j < group->filelist.CountItems(); j++)
		{
			SourceFile *file = group->filelist.ItemAt(j);
			
			if (file->GetResourcePath(fBuildInfo).GetFullPath())
			{
				resFileString << "'" << file->GetResourcePath(fBuildInfo).GetFullPath() << "' ";
				resCount++;
			}
		}
	}
	
	if (resCount > 0)
	{
		BString resString = "xres -o ";
		resString << "'" << targetpath.GetFullPath() << "' " << resFileString;		
		BString errmsg;
		PipeCommand(resString.String(),errmsg);
		
		STRACE(1,("Resources for %s:\n%s\nErrors:%s\n",GetName(),resString.String(),errmsg.String()));
		
		if (errmsg.CountChars() > 0)
			printf("Resource errors: %s\n",errmsg.String());
	}
	else
	{
		STRACE(1,("Resources for %s: No resource files to add\n",GetName()));
	}
}
コード例 #4
0
ファイル: Project.cpp プロジェクト: passick/Paladin
void
Project::Link(void)
{
	BString linkString;
	
	if (TargetType() == TARGET_STATIC_LIB)
	{
		linkString = "ar rcs '";
		linkString << GetPath().GetFolder() << "/" << GetTargetName() << "' ";
		for (int32 i = 0; i < CountGroups(); i++)
		{
			SourceGroup *group = GroupAt(i);
			
			for (int32 j = 0; j < group->filelist.CountItems(); j++)
			{
				SourceFile *file = group->filelist.ItemAt(j);
				if (file->GetObjectPath(fBuildInfo).GetFullPath())
					linkString << "'" << file->GetObjectPath(fBuildInfo).GetFullPath() << "' ";
			}
		}
	
	}
	else
	{
		linkString = "gcc -o '";
		linkString << GetPath().GetFolder() << "/" << GetTargetName() << "' ";
			
		for (int32 i = 0; i < CountGroups(); i++)
		{
			SourceGroup *group = GroupAt(i);
			
			for (int32 j = 0; j < group->filelist.CountItems(); j++)
			{
				SourceFile *file = group->filelist.ItemAt(j);
				if (file->GetObjectPath(fBuildInfo).GetFullPath())
					linkString << "'" << file->GetObjectPath(fBuildInfo).GetFullPath() << "' ";
			}
		}
	
		for (int32 i = 0; i < CountGroups(); i++)
		{
			SourceGroup *group = GroupAt(i);
			
			for (int32 j = 0; j < group->filelist.CountItems(); j++)
			{
				SourceFile *file = group->filelist.ItemAt(j);
				if (file->GetLibraryPath(fBuildInfo).GetFullPath())
					linkString << "'" << file->GetLibraryPath(fBuildInfo).GetFullPath() << "' ";
			}
		}
	
		for (int32 i = 0; i < CountLibraries(); i++)
		{
			SourceFile *file = LibraryAt(i);
			if (!file)
				continue;
			
			BString filenamebase;
			filenamebase = file->GetPath().GetBaseName();
			if (filenamebase.FindFirst("lib") == 0)
				filenamebase.RemoveFirst("lib");
			
			linkString << "-l" << filenamebase << " ";
		}
		
		if (TargetType() == TARGET_DRIVER)
			linkString << "/boot/develop/lib/x86/_KERNEL_ ";
		
		linkString << "-L/boot/home/config/lib ";
		
		switch (TargetType())
		{
			case TARGET_DRIVER:
			{
				linkString << "-Xlinker -nostdlib ";
				break;
			}
			case TARGET_SHARED_LIB:
			{
				linkString << "-nostart -Xlinker -soname=" << GetTargetName() << " ";
				break;
			}
			default:
			{
				// Application
				linkString << "-Xlinker -soname=_APP_ ";
				break;
			}
		}
	}
	
	linkString << " 2>&1";
	
	BString errmsg;
	PipeCommand(linkString.String(),errmsg);

	STRACE(1,("Linking %s:\n%s\nErrors:\n%s\n",GetName(),linkString.String(),errmsg.String()));
	
	if (errmsg.CountChars() > 0)
		ParseLDErrors(errmsg.String(),fBuildInfo.errorList);
}