Esempio n. 1
0
One<Builder> MakeBuild::CreateBuilder(Host *host)
{
	SetupDefaultMethod();
	VectorMap<String, String> bm = GetMethodVars(method);
	String builder = bm.Get("BUILDER", "GCC");
	int q = BuilderMap().Find(builder);
	if(q < 0) {
		PutConsole("Invalid builder " + builder);
		ConsoleShow();
		return NULL;
	}
	One<Builder> b = (*BuilderMap().Get(builder))();
	b->host = host;
	b->compiler = bm.Get("COMPILER", "");
	b->include = SplitDirs(GetVar("UPP") + ';' + bm.Get("INCLUDE", "") + ';' + add_includes);
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pkg = wspc.GetPackage(i);
		for(int j = 0; j < pkg.include.GetCount(); j++)
			b->include.Add(SourcePath(wspc[i], pkg.include[j].text));
	}	
	b->libpath = SplitDirs(bm.Get("LIB", ""));
	b->debug_options = bm.Get("DEBUG_OPTIONS", "");
	b->release_options = bm.Get("RELEASE_OPTIONS", "");
	b->release_size_options = bm.Get("RELEASE_SIZE_OPTIONS", "");
	b->debug_link = bm.Get("DEBUG_LINK", "");
	b->release_link = bm.Get("RELEASE_LINK", "");
	b->script = bm.Get("SCRIPT", "");
	b->main_conf = !!main_conf.GetCount();
	return b;
}
Esempio n. 2
0
void MakeBuild::Clean()
{
	ConsoleClear();
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++)
		CleanPackage(wspc, i);
	PutConsole("...done");
}
Esempio n. 3
0
void CodeBrowser::Load()
{
	String find = ToUpper((String)~search);
	String match = ToUpper((String)~search_scope);
	String pm = GetPm();
	Vector<String> txt;
	Vector<Value>  ndx;
	Index<int>     fi;
	Index<String>  fs;
	for(int i = 0; i < CodeBase().GetCount(); i++) {
		String s = CodeBase().GetKey(i);
		const Array<CppItem>& n = CodeBase()[i];
		if(s.GetCount())
			if(MatchCib(s, match) && (MatchCib(s, find) || HasItem(n, find)) && MatchPm(n, pm)) {
				txt.Add(s);
				ndx.Add(s);
			}
		for(int i = 0; i < n.GetCount(); i++) {
			int f = n[i].file;
			if(fi.Find(f) < 0) {
				String s = GetFileText(GetSourceFilePath(f));
				if(s.StartsWith(pm) && MatchCib(s, match) &&
				   (IsNull(find) || MatchCib(s, find) || n[i].uname.StartsWith(find))) {
					txt.Add(s);
					ndx.Add(f);
					fs.Add(s);
					fi.Add(f);
				}
			}
		}
	}
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		String pn = wspc[i];
		const Package& p = wspc.GetPackage(i);
		String pp = PackageDirectory(pn);
		for(int j = 0; j < p.GetCount(); j++)
			if(!p[j].separator) {
				String fn = AppendFileName(pp, p[j]);
				String s = GetFileText(AppendFileName(pn, p[j]));
				if(fs.Find(s) < 0 && (IsNull(find) || MatchCib(s, find)) && MatchCib(s, match) && MatchPm(fn, pm)) {
					int f = GetSourceFileIndex(SourcePath(pn, p[j]));
					txt.Add(s);
					ndx.Add(f);
					fs.Add(s);
				}
			}
	}
	IndexSort(txt, ndx, ScopeLess());
	Value key = scope.GetKey();
	int sc = scope.GetCursorSc();
	scope.Clear();
	for(int i = 0; i < txt.GetCount(); i++)
		scope.Add(IsString(ndx[i]) ? ndx[i] : Null, txt[i], ndx[i]);
	if(scope.FindSetCursor(key))
		scope.ScCursor(sc);
//	clear.Enable(IsSearch());
}
Esempio n. 4
0
TopicLinkDlg::TopicLinkDlg()
{
	CtrlLayoutOKCancel(*this, "Hyperlink");
	package.WhenKillCursor = package.WhenEnterItem = THISBACK(Package);
	group.WhenKillCursor = group.WhenEnterItem = THISBACK(Group);
	topic.WhenKillCursor = topic.WhenEnterItem = THISBACK(Topic);
	label.WhenKillCursor = label.WhenEnterItem = THISBACK(Label);
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++)
		package.Add(wspc[i]);
	insert <<= Breaker(IDYES);
}
Esempio n. 5
0
bool MakeBuild::Build()
{
	VectorMap<String, String> bm = GetMethodVars(method);
	if(bm.GetCount() == 0) {
		PutConsole("Invalid build method");
		ConsoleShow();
		return false;
	}
	One<Host> host = CreateHost(false);
	One<Builder> builder = CreateBuilder(~host);
	if(!builder)
		return false;
	Index<String> p = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam,
	                                *host, *builder);
	Workspace wspc;
	wspc.Scan(GetMain(), p.GetKeys());
	return Build(wspc, mainconfigparam, Null);
}
Esempio n. 6
0
Vector<String> IgnoreList()
{
	Vector<String> ignore;
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pk = wspc.GetPackage(i);
		for(int j = 0; j < pk.GetCount(); j++)
			if(!pk[j].separator && pk[j] == "ignorelist") {
				FileIn in(SourcePath(wspc[i], pk[j]));
				while(in && !in.IsEof()) {
					String s = in.GetLine();
					if(!s.IsEmpty())
						ignore.Add(s);
				}
			}
	}
	return ignore;
}
Esempio n. 7
0
void MakeBuild::SetHdependDirs()
{
	Vector<String> include = SplitDirs(GetVar("UPP") + ';'
		+ GetMethodVars(method).Get("INCLUDE", "") + ';'
		+ Environment().Get("INCLUDE", "")
#ifdef PLATFORM_POSIX
		+ ";/usr/include;/usr/local/include;"
#endif
		+ add_includes
		);
	// Also adding internal includes
	const Workspace& wspc = GetIdeWorkspace();
	for(int i = 0; i < wspc.GetCount(); i++) {
		const Package& pkg = wspc.GetPackage(i);
		for(int j = 0; j < pkg.include.GetCount(); j++)
			include.Add(SourcePath(wspc[i], pkg.include[j].text));
	}

	HdependSetDirs(include);
}
Esempio n. 8
0
void ModePane::Load(const TargetMode& m)
{
	target_override = m.target_override;
	target <<= m.target;
	map = m.createmap;
	linkmode = m.linkmode;
	version = m.version.ToWString();
	debug = m.def.debug;
	blitz = m.def.blitz;
	const Workspace& wspc = GetIdeWorkspace();
	package.Clear();
	for(int i = 0; i < wspc.GetCount(); i++) {
		int q;
		String p = wspc[i];
		q = m.package.Find(p);
		if(q >= 0) {
			const PackageMode& k = m.package[q];
			package.Add(p, k.debug, k.blitz);
		}
		else
			package.Add(p);
	}
}
Esempio n. 9
0
void MakeBuild::SaveMakeFile(const String& fn, bool exporting)
{
	BeginBuilding(false, true);

	VectorMap<String, String> bm = GetMethodVars(method);
	One<Host> host = CreateHost(false);
	One<Builder> b = CreateBuilder(~host);
	
	if(!b)
		return;
	
	const TargetMode& tm = GetTargetMode();

	String makefile;

	Vector<String> uppdirs = GetUppDirs();
	String uppout = exporting ? host->GetHostPath(GetVar("OUTPUT")) : "_out/";
	String inclist;

	Index<String> allconfig = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam, *host, *b);
	bool win32 = allconfig.Find("WIN32") >= 0;

	Workspace wspc;
	wspc.Scan(GetMain(), allconfig.GetKeys());

	for(int i = 1; i < wspc.GetCount(); i++) {
		Index<String> modconfig = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b);
		for(int a = allconfig.GetCount(); --a >= 0;)
			if(modconfig.Find(allconfig[a]) < 0)
				allconfig.Remove(a);
	}

	if(!exporting)
		for(int i = 0; i < uppdirs.GetCount(); i++) {
			String srcdir = GetMakePath(AdjustMakePath(host->GetHostPath(AppendFileName(uppdirs[i], ""))), win32);
			makefile << "UPPDIR" << (i + 1) << " = " << srcdir << "\n";
			inclist << " -I$(UPPDIR" << (i + 1) << ")";
		}
	else
		inclist << "-I./";
	Vector<String> includes = SplitDirs(bm.Get("INCLUDE",""));
	for(int i = 0; i < includes.GetCount(); i++)
		inclist << " -I" << includes[i];

	makefile << "\n"
		"UPPOUT = " << (exporting ? "_out/" : GetMakePath(AdjustMakePath(host->GetHostPath(AppendFileName(uppout, ""))), win32)) << "\n"
		"CINC = " << inclist << "\n"
		"Macro = ";

	for(int i = 0; i < allconfig.GetCount(); i++)
		makefile << " -Dflag" << allconfig[i];
	makefile << "\n";

	String output, config, install, rules, linkdep, linkfiles, linkfileend;

	for(int i = 0; i < wspc.GetCount(); i++) {
		b->config = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b);
		b->version = tm.version;
		b->method = method;
		MakeFile mf;
		b->AddMakeFile(mf, wspc[i], GetAllUses(wspc, i),
		               GetAllLibraries(wspc, i, bm, mainconfigparam, *host, *b), allconfig,
		               exporting);
		if(!i) {
			String tdir = mf.outdir;
			String trg;
			if(tm.target_override) {
				trg = GetMakePath(AdjustMakePath(tm.target), win32);
				if(!trg.IsEmpty() && *trg.Last() == (win32 ? '\\' : '/'))
					trg << mf.outfile;
				else if(trg.Find(win32 ? '\\' : '/') < 0)
					trg.Insert(0, "$(OutDir)");
			}
			output = Nvl(trg, mf.output);
			if(exporting)
				output = wspc[i] + ".out";
			install << "\n"
				"OutDir = " << tdir << "\n"
				"OutFile = " << output << "\n"
				"\n"
				".PHONY: all\n"
				"all: prepare $(OutFile)\n"
				"\n"
				".PHONY: prepare\n"
				"prepare:\n";
		}
		config << mf.config;
		install << mf.install;
		rules << mf.rules;
		linkdep << mf.linkdep;
		linkfiles << mf.linkfiles;
		linkfileend << mf.linkfileend;
	}

	makefile
		<< config
		<< install
		<< "\n"
		"$(OutFile): " << linkdep << "\n\t" << linkfiles << linkfileend << " -Wl,--end-group\n\n"
		<< rules
		<< ".PHONY: clean\n"
		<< "clean:\n"
		<< "\tif [ -d $(UPPOUT) ]; then rm -rf $(UPPOUT); fi;\n";

	bool sv = ::SaveFile(fn, makefile);
	if(!exporting)
		if(sv)
			PutConsole(NFormat("%s(1): makefile generation complete", fn));
		else
			PutConsole(NFormat("%s: error writing makefile", fn));

	EndBuilding(true);
}
Esempio n. 10
0
void Ide::FindInFiles(bool replace) {
	CodeEditor::FindReplaceData d = editor.GetFindReplaceData();
	CtrlRetriever rf;
	rf(ff.find, d.find)
	  (ff.replace, d.replace)
	  (ff.ignorecase, d.ignorecase)
	  (ff.samecase, d.samecase)
	  (ff.wholeword, d.wholeword)
	  (ff.wildcards, d.wildcards)
	  (ff.regexp, d.regexp)
	;
	WriteList(ff.find, d.find_list);
	WriteList(ff.replace, d.replace_list);
	ff.Sync();
	if(IsNull(~ff.folder))
		ff.folder <<= GetUppDir();
	ff.style <<= STYLE_NO_REPLACE;
	ff.Sync();
	ff.itext = editor.GetI();
	ff.Setup(replace);
	
	int c = ff.Execute();

	ff.find.AddHistory();
	ff.replace.AddHistory();

	rf.Retrieve();
	d.find_list = ReadList(ff.find);
	d.replace_list = ReadList(ff.replace);
	editor.SetFindReplaceData(d);
	
	if(c == IDOK) {
		ffound.HeaderTab(2).SetText("Source line");
		Renumber();
		ff.find.AddHistory();
		ff.files.AddHistory();
		ff.folder.AddHistory();
		ff.replace.AddHistory();
		Progress pi("Found %d files to search.");
		pi.AlignText(ALIGN_LEFT);
		Index<String> files;
		if(ff.workspace) {
			const Workspace& wspc = GetIdeWorkspace();
			for(int i = 0; i < wspc.GetCount(); i++)
				SearchForFiles(files, GetFileFolder(PackagePath(wspc[i])),
					           ~ff.files, ~ff.readonly, pi);
		}
		else
			SearchForFiles(files, NormalizePath(~~ff.folder, GetUppDir()), ~ff.files, ~ff.readonly, pi);
		if(!pi.Canceled()) {
			String pattern;
			RegExp rx, *regexp = NULL;
			if(ff.regexp) {
				rx.SetPattern(~ff.find);
				regexp = &rx;
				pattern = "dummy";
			}
			else
			if(ff.wildcards) {
				String q = ~ff.find;
				for(const char *s = q; *s; s++)
					if(*s == '\\') {
						s++;
						if(*s == '\0') break;
						pattern.Cat(*s);
					}
					else
					switch(*s) {
					case '*': pattern.Cat(WILDANY); break;
					case '?': pattern.Cat(WILDONE); break;
					case '%': pattern.Cat(WILDSPACE); break;
					case '#': pattern.Cat(WILDNUMBER); break;
					case '$': pattern.Cat(WILDID); break;
					default:  pattern.Cat(*s);
					}
			}
			else
				pattern = ~ff.find;
			pi.SetTotal(files.GetCount());
			ShowConsole2();
			ffound.Clear();
			pi.SetPos(0);
			int n = 0;
			for(int i = 0; i < files.GetCount(); i++) {
				pi.SetText(files[i]);
				if(pi.StepCanceled()) break;
				if(!IsNull(pattern)) {
					if(!SearchInFile(files[i], pattern, ff.wholeword, ff.ignorecase, n, regexp))
						break;
				}
				else {
					ErrorInfo f;
					f.file = files[i];
					f.lineno = 1;
					f.linepos = 0;
					f.kind = 0;
					f.message = files[i];
					ffound.Add(f.file, 1, f.message, RawToValue(f));
					ffound.Sync();
					n++;
				}
			}
			if(!IsNull(pattern))
				ffound.Add(Null, Null, AsString(n) + " occurrence(s) have been found.");
			else
				ffound.Add(Null, Null, AsString(n) + "  matching file(s) have been found.");
			ffound.HeaderTab(2).SetText(Format("Source line (%d)", ffound.GetCount()));
		}
	}
}