Beispiel #1
0
Project::Project(const char *name, const char *targetname)
	:	BLocker(name),
		fName(name),
		fTargetName(targetname),
		fDirtyFiles(20,false),
		fLibraryList(20,true),
		fLocalIncludeList(20,true),
		fSystemIncludeList(20,true),
		fAccessList(20,true),
		fGroupList(20,true),
		fReadOnly(false),
		fDebug(false),
		fProfile(false),
		fOpSize(false),
		fOpLevel(0),
		fTargetType(TARGET_APP),
		fSCMType(gDefaultSCM)
{
	if (name)
	{
		BString filename(name);
		filename << ".pld";
		
		fPath = PROJECT_PATH;
		fPath << name << filename;
		
		fObjectPath = PROJECT_PATH;
		BString objfoldername("(Objects.");
		objfoldername << name << ")";
		fObjectPath << name << objfoldername;
		
		STRACE(1,("Creating Project %s\nObject Path is %s\n",name,fObjectPath.GetFullPath()));
	}
	
	fPlatform = DetectPlatform();
	
	fErrorList = new ErrorList;
	UpdateBuildInfo();
}
Beispiel #2
0
status_t
Project::Load(const char *path)
{
	BEntry entry(path,true);
	status_t status = entry.InitCheck();
	if (status != B_OK)
		return status;
	
	entry_ref ref;
	entry.GetRef(&ref);
	
	fReadOnly = BVolume(ref.device).IsReadOnly();
	
	TextFile file(ref,B_READ_ONLY);
	status = file.InitCheck();
	if (status != B_OK)
		return status;
	
	fGroupList.MakeEmpty();
	
	fPath = path;
	fName = fPath.GetBaseName();
	
	platform_t actualPlatform = DetectPlatform();
	
	STRACE(2,("Loading project %s\n",path));
	
	// Set this to an out-of-bounds value to detect if
	// there is no SCM entry in the project
	fSCMType = SCM_INIT;
	
	SourceGroup *srcgroup = NULL;
	SourceFile *srcfile = NULL;
	BString line = file.ReadLine();
	while (line.CountChars() > 0)
	{
		int32 pos = line.FindFirst("=");
		if (pos < 0)
		{
			line = file.ReadLine();
			continue;
		}
		
		BString entry = line;
		entry.Truncate(pos);
		
		BString value = line.String() + pos + 1;
		
		STRACE(2,("Load Project: %s=%s\n",entry.String(),value.String()));
		
		if (value.CountChars() > 0)
		{
			if (entry[0] == '#')
				continue;
			else
			if (entry == "SOURCEFILE")
			{
				if (value.String()[0] != '/')
				{
					value.Prepend("/");
					value.Prepend(fPath.GetFolder());
				}
				srcfile = gFileFactory.CreateSourceFileItem(value.String());
				AddFile(srcfile, srcgroup);
			}
			else if (entry == "DEPENDENCY")
			{
				if (srcfile)
					srcfile->fDependencies = value;
			}
			else if (entry == "LOCALINCLUDE")
			{
				ProjectPath include(fPath.GetFolder(), value.String());
				AddLocalInclude(include.Absolute().String());
			}
			else if (entry == "SYSTEMINCLUDE")
				AddSystemInclude(value.String());
			else if (entry == "LIBRARY")
			{
				if (actualPlatform == fPlatform)
					AddLibrary(value.String());
				else
					ImportLibrary(value.String(),actualPlatform);
			}
			else if (entry == "GROUP")
				srcgroup = AddGroup(value.String());
			else if (entry == "EXPANDGROUP")
			{
				if (srcgroup)
					srcgroup->expanded = value == "yes" ? true : false;
			}
			else if (entry == "TARGETNAME")
				fTargetName = value;
			else if (entry == "CCDEBUG")
				fDebug = value == "yes" ? true : false;
			else if (entry == "CCPROFILE")
				fProfile = value == "yes" ? true : false;
			else if (entry == "CCOPSIZE")
				fOpSize = value == "yes" ? true : false;
			else if (entry == "CCOPLEVEL")
				fOpLevel = atoi(value.String());
			else if (entry == "CCTARGETTYPE")
				fTargetType = atoi(value.String());
			else if (entry == "CCEXTRA")
				fExtraCompilerOptions = value;
			else if (entry == "LDEXTRA")
				fExtraLinkerOptions = value;
			else if (entry == "RUNARGS")
				fRunArgs = value;
			else if (entry == "SCM")
			{
				if (value.ICompare("hg") == 0)
					fSCMType = SCM_HG;
				else if (value.ICompare("git") == 0)
					fSCMType = SCM_GIT;
				else if (value.ICompare("svn") == 0)
					fSCMType = SCM_SVN;
				else
					fSCMType = SCM_NONE;
			}
			else if (entry == "PLATFORM")
			{
				if (value.ICompare("Haiku") == 0)
					fPlatform = PLATFORM_HAIKU;
				else if (value.ICompare("HaikuGCC4") == 0)
					fPlatform = PLATFORM_HAIKU_GCC4;
				else if (value.ICompare("Zeta") == 0)
					fPlatform = PLATFORM_ZETA;
				else
					fPlatform = PLATFORM_R5;
			}
				
		}
		
		line = file.ReadLine();
	}
	
	// Fix one of my pet peeves when changing platforms: having to add libsupc++.so whenever
	// I change to Haiku GCC4 or GCC4hybrid from any other platform
	if (actualPlatform == PLATFORM_HAIKU_GCC4 && actualPlatform != fPlatform)
	{
		BPath libpath;
		find_directory(B_USER_DEVELOP_DIRECTORY,&libpath);
		libpath.Append("lib/x86/libsupc++.so");
		AddLibrary(libpath.Path());
	}
	
	fObjectPath = fPath.GetFolder();
	
	BString objfolder("(Objects.");
	objfolder << GetName() << ")";
	fObjectPath.Append(objfolder.String());
	
	UpdateBuildInfo();
	
	// We now set the platform to whatever we're building on. fPlatform is only used
	// in the project loading code to be able to help cover over issues with changing platforms.
	// Most of the time this is just the differences in libraries, but there may be other
	// unforeseen issues that will come to light in the future.
	fPlatform = actualPlatform;
	
	return B_OK;
}
Beispiel #3
0
Project *
Project::CreateProject(const char *projname, const char *target, int32 type, const char *path,
						bool create_folder)
{
	BString name(projname), targetname(target);
	if (name.CountChars() < 1)
		name = "Untitled";
	
	if (targetname.CountChars() < 1)
		name = "BeApp";
	
	Project *newproj = new Project(name.String(),targetname.String());
	
	newproj->SetTargetType(type);
	
	newproj->AddLocalInclude(".");
	newproj->AddSystemInclude("/boot/develop/headers/be");
	newproj->AddSystemInclude("/boot/develop/headers/cpp");
	newproj->AddSystemInclude("/boot/develop/headers/posix");
	newproj->AddSystemInclude("/boot/home/config/include");
	
	newproj->AddLibrary("/boot/develop/lib/x86/libroot.so");
	
	newproj->AddGroup("Source Files");
	
	switch (type)
	{
		case PROJECT_GUI:
		{
			newproj->AddLibrary("/boot/develop/lib/x86/libbe.so");
			
			// Having to manually add this one is terribly annoying. :/
			if (DetectPlatform() == PLATFORM_HAIKU_GCC4)
				newproj->AddLibrary("/boot/develop/lib/x86/libsupc++.so");
			break;
		}
		case PROJECT_DRIVER:
		{
			newproj->AddLibrary("/boot/develop/lib/x86/_KERNEL_");
			break;
		}
		case PROJECT_CONSOLE:
		case PROJECT_SHARED_LIB:
		case PROJECT_STATIC_LIB:
		default:
			break;
	}
	
	BPath projpath(path);
	if (create_folder)
	{
		projpath.Append(name.String());
		if (!BEntry(projpath.Path()).Exists());
			create_directory(projpath.Path(),0777);
	}
	
	BString filename(newproj->GetName());
	filename << ".pld";
	projpath.Append(filename.String());
	newproj->Save(projpath.Path());
	
	return newproj;
}
Beispiel #4
0
void
InitGlobals(void)
{
	app_info ai;
	be_app->GetAppInfo(&ai);
	BPath path(&ai.ref);
	gAppPath = path.Path();
	
	DPath settingsPath(B_USER_SETTINGS_DIRECTORY);
	settingsPath << "Paladin_settings";
	
	gSettings.Load(settingsPath.GetFullPath());
	
	gDontManageHeaders = gSettings.GetBool("dontmanageheaders",true);
	gSingleThreadedBuild = gSettings.GetBool("singlethreaded",false);
	gShowFolderOnOpen = gSettings.GetBool("showfolderonopen",false);
	gAutoSyncModules = gSettings.GetBool("autosyncmodules",true);
	gUseCCache = gSettings.GetBool("ccache",false);
	gUseFastDep = gSettings.GetBool("fastdep",false);
	
	gDefaultSCM = (scm_t)gSettings.GetInt32("defaultSCM", SCM_HG);
	
	system_info sysinfo;
	get_system_info(&sysinfo);
	gCPUCount = sysinfo.cpu_count;
	
	gPlatform = DetectPlatform();
	
	// This will make sure that we can still build if ccache is borked and the user
	// wants to use it.
	if ((gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4 || gPlatform == PLATFORM_ZETA) &&
		system("ccache > /dev/null 2>&1") == 1)
	{
		gCCacheAvailable = true;
	}
		
	if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4)
	{
		if (system("fastdep > /dev/null 2>&1") == 0)
			gFastDepAvailable = true;
		
		if (system("hg > /dev/null 2>&1") == 0)
			gHgAvailable = true;
		
		#ifndef DISABLE_GIT_SUPPORT
		if (system("git > /dev/null 2>&1") == 1)
			gGitAvailable = true;
		#endif
		
		gUsePipeHack = true;
	}
	
	if (system("svn > /dev/null 2>&1") == 1)
		gSvnAvailable = true;
	
	if (system("lua -v > /dev/null 2>&1") == 0)
		gLuaAvailable = true;
	
	gProjectPath.SetTo(gSettings.GetString("projectpath",PROJECT_PATH));
	gLastProjectPath.SetTo(gSettings.GetString("lastprojectpath",PROJECT_PATH));
	
	DPath defaultBackupPath(B_DESKTOP_DIRECTORY);
	gBackupPath.SetTo(gSettings.GetString("backuppath", defaultBackupPath.GetFullPath()));
	
	DPath defaultRepoPath(B_USER_DIRECTORY);
	defaultRepoPath << "Paladin SVN Repos";
	gSVNRepoPath.SetTo(gSettings.GetString("svnrepopath", defaultRepoPath.GetFullPath()));
	
	
	gCodeLib.ScanFolders();
}