Exemplo n.º 1
0
void WorkspaceWork::PackageCursor()
{
	InvalidatePackageCache();
	filelist.WhenBar.Clear();
	actualpackage = GetActivePackage();
	svn_dirs = false;
	if(actualpackage.IsEmpty()) return;
	if(actualpackage == METAPACKAGE) {
		actual.file.Clear();
		actual.file.AddPick(Package::File(String(HELPNAME)));
		Vector<String> d = GetUppDirs();
		for(int i = 0; i < d.GetCount(); i++)
			actual.file.AddPick(Package::File(AppendFileName(d[i], "$.tpp")));
		actual.file.AddPick(Package::File(ConfigFile("global.defs")));
	}
	else {
		String pp = PackagePathA(actualpackage);
		RealizePath(pp);
		actual.Load(pp);
	}
	LoadActualPackage();
	filelist.Enable();
	if(actualpackage != METAPACKAGE)
		filelist.WhenBar = THISBACK(FileMenu);
	svn_dirs = SvnDirs(true).GetCount();
}
Exemplo n.º 2
0
// fetch the new app version from server
// and replaces older one
// if ver is not specified, fetches the maximum available
// one but which is less than or equal maxVersion
bool Updater::FetchApp(ProductVersion ver, bool devel)
{
	int err = 0;

	if(!ver)
		ver = FetchMaxValidVersion(acceptDevelVersions);
	if(!ver)
		return false;

	String appServerPath, destPath;
	#ifdef PLATFORM_POSIX
		appServerPath = GetPlatformRoot() + ver.ToString() + "/" + appName;
		destPath = AppendFileName(GetProgramsFolder(), appName);
	#else
		appServerPath = GetPlatformRoot() + ver.ToString() + "/" + appName + ".exe";
		destPath = AppendFileName(GetProgramsFolder(), appName + "\\" + appName + ".exe");
		RealizePath(destPath);
	#endif

	if(isWebServer)
	{
		http.Url(appServerPath);
		http.Timeout(1000*60*30);
		http.MaxContentSize(100000000);
		http.WhenDo = THISBACK(doProgress);

		// fetch version file from server
		appBuffer = http.Execute();
		err = http.GetStatusCode();
		if(err != 200 || http.IsAbort() || http.IsError())
		{
			appBuffer = "";
			return false;
		}
	
		// replaces/installs app
		if(!SaveFile(destPath, appBuffer))
			return false;
	}
	else
		FileCopy(appServerPath, destPath);
#ifdef PLATFORM_POSIX
	if(chmod(~destPath, 0755) != 0)
		return false;
#endif

	// stores current version inside system config path
	if(!SaveFile(AppendFileName(systemConfigPath, "version"), ver.ToString()))
		return false;

	installedVersion = ver;

	return true;
}
Exemplo n.º 3
0
bool CppBuilder::Cp(const String& cmd, const String& package, bool& error) {
	if(cmd.GetLength() > 2 && ToLower(cmd.Mid(0, 3)) == "cp ") {
		Vector<String> path = Split(cmd.Mid(3), ' ');
		if(path.GetCount() == 2) {
			String p = GetFileFolder(PackagePath(package));
			String p1 = NormalizePath(path[0], p);
			String p2 = NormalizePath(path[1], p);
			RealizePath(p2);
			if(!FileExists(p1)) {
				PutConsole("FAILED: " + cmd);
				error = true;
			}
			SaveFile(p2, LoadFile(p1));
		}
		return true;
	}
	return false;
}
Exemplo n.º 4
0
void CppBuilder::SaveBuildInfo(const String& package)
{
	String path = AppendFileName(outdir, "build_info.h");
	RealizePath(path);
	FileOut info(path);
	Time t = GetSysTime();
	info << "#define bmYEAR   " << (int)t.year << "\r\n";
	info << "#define bmMONTH  " << (int)t.month << "\r\n";
	info << "#define bmDAY    " << (int)t.day << "\r\n";
	info << "#define bmHOUR   " << (int)t.hour << "\r\n";
	info << "#define bmMINUTE " << (int)t.minute << "\r\n";
	info << "#define bmSECOND " << (int)t.second << "\r\n";
	info << Format("#define bmTIME   Time(%d, %d, %d, %d, %d, %d)\r\n",
	        (int)t.year, (int)t.month, (int)t.day, (int)t.hour, (int)t.minute, (int)t.second);
	info << "#define bmMACHINE " << AsCString(GetComputerName()) << "\r\n";
	info << "#define bmUSER    " << AsCString(GetUserName()) << "\r\n";

	if(package == mainpackage)
		info << Join(SvnInfo(package), "\r\n");
}
Exemplo n.º 5
0
void TemplateDlg::Create()
{
	const PackageTemplate& tp = ActualTemplate();
	ArrayMap<String, EscValue> var = MakeVars();
	for(int i = 0; i < tp.file.GetCount(); i++) {
		const FileTemplate& ft = tp.file[i];
		if(IsNull(ft.condition) || IsTrue(Evaluate(ft.condition, var))) {
			String fn = Expand(ft.filename, var);
			if(!IsNull(fn)) {
				fn = AppendFileName(AppendFileName(~nest, (String)~package), fn);
				RealizePath(fn);
				SaveFile(fn, Expand(ft.text, var));
			}
		}
	}
	Package p;
	String f = AppendFileName(AppendFileName(~nest, (String)~package), (String)~package + ".upp");
	p.Load(f);
	p.description = ~description;
	p.Save(f);
}
Exemplo n.º 6
0
void WorkspaceWork::SavePackage()
{
	if(IsNull(actualpackage) || actualpackage == METAPACKAGE)
		return;
	InvalidatePackageInfo(actualpackage);
	String pp = PackagePathA(actualpackage);
	RealizePath(pp);
	if(organizer && backup.Find(pp) < 0) {
		Backup& b = backup.Add(pp);
		FindFile ff(pp);
		if(ff) {
			b.time = ff.GetLastWriteTime();
			b.data = LoadFile(pp);
		}
		else
			b.data = String::GetVoid();
	}
	actual.Save(pp);
	String init;
	String mnm = Filter('_' + actualpackage + "_icpp_init_stub", CharFilterMacro);
	init << "#ifndef " << mnm << "\r\n";
	init << "#define " << mnm << "\r\n";
	Index<String> once;
	for(int i = 0; i < actual.uses.GetCount(); i++) {
		String u = actual.uses[i].text;
		if(once.Find(u) < 0) {
			once.Add(u);
			init << "#include \"" << actual.uses[i].text << "/init\"\r\n";
		}
	}
	for(int i = 0; i < actual.GetCount(); i++) {
		String f = actual[i];
		if(ToLower(GetFileExt(f)) == ".icpp")
			init << "#define BLITZ_INDEX__ " << "F" << MD5String(f) << "\r\n"
			     << "#include \"" << f << "\"\r\n"
			     << "#undef BLITZ_INDEX__\r\n";
	}
	init << "#endif\r\n";
	SaveChangedFile(SourcePath(actualpackage, "init"), init);
}
Exemplo n.º 7
0
void WorkspaceWork::PackageOp(String active, String from_package, String rename)
{
	active = UnixPath(active);
	from_package = UnixPath(from_package);
	rename = UnixPath(rename);
	for(int i = 0; i < package.GetCount(); i++)
		if(IsNull(from_package) || UnixPath(package[i].name) == from_package) {
			String pp = PackagePath(package[i].name);
			RealizePath(pp);
			Package prj;
			prj.Load(pp);
			for(int i = prj.uses.GetCount(); --i >= 0;)
				if(UnixPath(prj.uses[i].text) == active) {
					if(rename.GetCount())
						prj.uses[i].text = rename;
					else
						prj.uses.Remove(i);
				}
			prj.Save(pp);
		}
	ScanWorkspace();
	SyncWorkspace();
}
Exemplo n.º 8
0
void SelectPackageDlg::OnNew() {
	TemplateDlg dlg;
	LoadFromGlobal(dlg, "NewPackage");
	int f = ~filter;
	dlg.Load(GetUppDirs(), f & MAIN);
	while(dlg.Run() == IDOK) {
		String nest = ~dlg.nest;
		String name = NativePath(String(~dlg.package));
		String path = AppendFileName(nest, AppendFileName(name, GetFileName(name) + ".upp"));
		if(FileExists(path) && !PromptYesNo("Package [* \1" + path + "\1] already exists.&"
		                                    "Do you wish to recreate the files?"))
			continue;
		RealizePath(path);
		if(!SaveFile(path, Null)) {
			Exclamation("Error writing the file [* \1" + path + "\1].");
			continue;
		}
		dlg.Create();
		selected = name;
		Break(IDYES);
		break;
	}
	StoreToGlobal(dlg, "NewPackage");
}
Exemplo n.º 9
0
bool RenamePackageFs(const String& upp, const String& newname)
{
	if(IsNull(newname)) {
		Exclamation("Wrong name.");
		return false;
	}
	if(FileExists(PackagePath(newname))) {
		Exclamation("Package [* \1" + newname + "\1] already exists!");
		return false;
	}
	String pf = GetFileFolder(upp);
	String npf = GetPackagePathNest(pf) + "/" + newname;
	RealizePath(npf);
	if(!FileMove(pf, npf)) {
		Exclamation("Renaming package folder has failed.");
		return false;
	}
	if(!FileMove(npf + "/" + GetFileName(upp), npf + "/" + GetFileName(newname) + ".upp")) {
		FileMove(npf, pf);
		Exclamation("Renaming .upp file has failed.");
		return false;
	}
	return true;
}
Exemplo n.º 10
0
bool MakeBuild::Build(const Workspace& wspc, String mainparam, String outfile, bool clear_console)
{
	String hfile = outfile + ".xxx";
	SaveFile(hfile, "");
	FileTime start_time = GetFileTime(hfile); // Defensive way to get correct filetime of start
	DeleteFile(hfile);
	
	ClearErrorEditor();
	BeginBuilding(true, clear_console);
	bool ok = true;
	if(wspc.GetCount()) {
		for(int i = 0; i < wspc.GetCount(); i++) {
			const Package& pk = wspc.package[i];
			for(int j = 0; j < pk.GetCount(); j++)
				if(pk[j] == "main.conf") {
					String pn = wspc[i];
					String p = SourcePath(pn, "main.conf");
					main_conf << "// " << pn << "\r\n" << LoadFile(p) << "\r\n";
					PutConsole("Found " + p);
				}
		}

		if(main_conf.GetCount()) {
			VectorMap<String, String> bm = GetMethodVars(method);
			One<Host> host = CreateHost(false);
			One<Builder> b = CreateBuilder(~host);
			if(b) {
				Index<String> mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, NULL);
				String outdir = OutDir(mcfg, wspc[0], bm, false);
				String path = AppendFileName(outdir, "main.conf.h");
				RealizePath(path);
				SaveChangedFile(path, main_conf);
				PutConsole("Saving " + path);
				add_includes << outdir << ';';
			}
		}

		Vector<int> build_order;
		if(GetTargetMode().linkmode != 2) {
			for(int i = 1; i < wspc.GetCount(); i++)
				build_order.Add(i);
		}
		else {
			Index<int> remaining;
			for(int i = 1; i < wspc.GetCount(); i++)
				remaining.Add(i);
			while(!remaining.IsEmpty()) {
				int t;
				for(t = 0; t < remaining.GetCount(); t++) {
					const Package& pk = wspc.package[remaining[t]];
					bool delay = false;
					for(int u = 0; u < pk.uses.GetCount(); u++)
						if(remaining.Find(wspc.package.Find(pk.uses[u].text)) >= 0) {
							delay = true;
							break;
						}
					if(!delay)
						break;
				}
				if(t >= remaining.GetCount())
					t = 0;
				build_order.Add(remaining[t]);
				remaining.Remove(t);
			}
		}

		String mainpackage = wspc[0];
		Vector<String> linkfile;
		String linkopt = GetMethodVars(method).Get(targetmode ? "RELEASE_LINK" : "DEBUG_LINK", Null);
		if(linkopt.GetCount())
			linkopt << ' ';
		ok = true;
		int ms = msecs();
		for(int i = 0; i < build_order.GetCount() && (ok || !stoponerrors); i++) {
			int px = build_order[i];
			ok = BuildPackage(wspc, px, i, build_order.GetCount() + 1,
				              mainparam, Null, linkfile, linkopt) && ok;
			if(msecs() - ms >= 200) {
				DoProcessEvents();
				ms = msecs();
			}
		}
		if(ok || !stoponerrors) {
			ok = BuildPackage(wspc, 0, build_order.GetCount(), build_order.GetCount() + 1,
			                  mainparam, outfile, linkfile, linkopt, ok) && ok;
			// Set the time of target to start-time, so that if any file changes during
			// compilation, it is recompiled during next build
			SetFileTime(target, start_time); 
		}
	}
	EndBuilding(ok);
	ReQualifyCodeBase();
	SetErrorEditor();
	return ok;
}
Exemplo n.º 11
0
String HelpTopicSave(Vector<String>& saved_files, String text_folder, HelpTopicInfoMap& diff, String out_folder, bool skip_file_write)
{
	Vector<String> drls = HelpTopicListTextFolder(IsNull(out_folder) ? text_folder : String::GetVoid());
	Index<String> used_names;
	HelpTopicInfoMap& map = HelpTopicMap();
	String out;
	bool first = true;
	String dir_dph;
	for(int t = 0; t < drls.GetCount(); t++) {
		String drl = drls[t];
		const HelpTopicInfo& topicinfo = HelpTopicGet(drl);
		String space, nesting, topic;
		HelpParseDPP(drl, space, nesting, topic);
		String outdir = AppendFileName(Nvl(out_folder, text_folder), "doc.dpp");
		String title = HelpTopicTextModuleTitle(space, nesting, topic, used_names);
		for(int l = 0; l < topicinfo.language.GetCount(); l++)
			if(!IsNull(topicinfo.title[l]) || !IsNull(topicinfo.text[l])) {
				String file;
				file << title << '_' << LNGAsTextShort(topicinfo.language[l]) << ".dpx";
				String path = AppendFileName(outdir, file);
				dir_dph << "#include \"" << path << "\"\n";
				if(!skip_file_write) {
					String lng = LNGAsText(topicinfo.language[l]);
					String out;
					out << "HELP_TOPIC(" << AsCString(space)
						<< ", " << AsCString(nesting)
						<< ", " << AsCString(topic)
						<< ", " << AsCString(lng)
						<< ", " << AsCString(topicinfo.title[l]) << ")\n";
					String text = topicinfo.text[l];
					String ctext;
					const char *p = text;
					while(*p) {
						const char *b = p;
						enum { CHUNK = 100 };
						while(*p && *p++ != '\n' && p - b < CHUNK)
							;
						if(!IsNull(ctext))
							ctext << "\n\t";
						ctext << AsCString(String(b, p));
						if(ctext.GetLength() >= 5000)
						{
							out << "HELP_TEXT(\n\t" << ctext << ")\n";
							ctext = Null;
						}
					}
					if(!IsNull(ctext))
						out << "\tHELP_TEXT(\n\t" << ctext << ")\n";
					out << "HELP_END\n";
					if(first) {
						first = false;
						RealizePath(path);
					}
					if(!IsSameTextFile(LoadFile(path), out)) {
						if(!SaveFileBackup(path, out))
							throw Exc(NFormat("Nelze uložit soubor '%s'.", path));
						saved_files.Add(path);
					}
				}
				diff.GetAdd(drl) <<= topicinfo;
			}
	}
	return dir_dph;
}