From 46cfc0fad8d4d88bec030451d86b94a47ed3bcbc Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 12 Dec 2020 19:27:04 +0000 Subject: [PATCH] ide: LocalHost/Host, urepo refactored git-svn-id: svn://ultimatepp.org/upp/trunk@15586 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Build.cpp | 17 +-- uppsrc/ide/Builders/Blitz.cpp | 10 +- uppsrc/ide/Builders/Build.cpp | 116 ++++++---------- uppsrc/ide/Builders/Build.h | 5 +- uppsrc/ide/Builders/Builders.h | 1 - uppsrc/ide/Builders/CppBuilder.cpp | 23 ++-- uppsrc/ide/Builders/GccBuilder.cpp | 70 +++++----- uppsrc/ide/Builders/JavaBuilder.cpp | 14 +- uppsrc/ide/Builders/MakeFile.cpp | 27 ++-- uppsrc/ide/Builders/MscBuilder.cpp | 58 ++++---- uppsrc/ide/Builders/ScriptBuilder.cpp | 22 ++-- uppsrc/ide/Common/Common.h | 3 + uppsrc/ide/Common/Util.cpp | 25 ++++ uppsrc/ide/Core/Builder.cpp | 39 +----- uppsrc/ide/Core/Core.h | 9 +- uppsrc/ide/Core/Host.cpp | 108 +++++---------- uppsrc/ide/Core/Host.h | 124 ++++-------------- uppsrc/{urepo => ide}/Credentials.cpp | 6 +- uppsrc/ide/Debug.cpp | 66 +++++----- uppsrc/ide/Debuggers/Gdb.cpp | 31 ++--- uppsrc/ide/Debuggers/Gdb.h | 8 +- uppsrc/ide/Debuggers/GdbCmd.cpp | 26 ++-- uppsrc/ide/Debuggers/Pdb.cpp | 10 +- uppsrc/ide/Debuggers/Pdb.h | 2 +- uppsrc/{urepo => ide}/Diff.cpp | 6 +- uppsrc/ide/Errors.cpp | 3 +- uppsrc/ide/Macro.cpp | 14 +- uppsrc/ide/Methods.cpp | 2 +- uppsrc/ide/OutputMode.cpp | 7 +- .../Console.cpp => ide/RepoConsole.cpp} | 39 +++--- uppsrc/{urepo => ide}/RepoSync.cpp | 6 +- uppsrc/ide/UppHub.cpp | 8 +- uppsrc/ide/Valgrind.cpp | 9 +- uppsrc/ide/ide.cpp | 4 +- uppsrc/ide/ide.h | 11 +- uppsrc/ide/ide.lay | 2 +- uppsrc/ide/ide.upp | 9 +- uppsrc/ide/idebar.cpp | 2 +- uppsrc/ide/idetool.cpp | 15 ++- uppsrc/{urepo => ide}/urepo.h | 14 +- uppsrc/{urepo => ide}/urepo.iml | 0 uppsrc/{urepo => ide}/urepo.lay | 0 uppsrc/urepo/Copying | 22 ---- uppsrc/urepo/main.cpp | 24 ---- uppsrc/urepo/urepo.upp | 20 --- uppsrc/urepo/usvn.iml | 9 -- uppsrc/urepo/usvn.lay | 22 ---- 47 files changed, 392 insertions(+), 676 deletions(-) rename uppsrc/{urepo => ide}/Credentials.cpp (93%) rename uppsrc/{urepo => ide}/Diff.cpp (93%) rename uppsrc/{urepo/Console.cpp => ide/RepoConsole.cpp} (79%) rename uppsrc/{urepo => ide}/RepoSync.cpp (95%) rename uppsrc/{urepo => ide}/urepo.h (87%) rename uppsrc/{urepo => ide}/urepo.iml (100%) rename uppsrc/{urepo => ide}/urepo.lay (100%) delete mode 100644 uppsrc/urepo/Copying delete mode 100644 uppsrc/urepo/main.cpp delete mode 100644 uppsrc/urepo/urepo.upp delete mode 100644 uppsrc/urepo/usvn.iml delete mode 100644 uppsrc/urepo/usvn.lay diff --git a/uppsrc/ide/Build.cpp b/uppsrc/ide/Build.cpp index afd531733..6f7605a99 100644 --- a/uppsrc/ide/Build.cpp +++ b/uppsrc/ide/Build.cpp @@ -31,7 +31,7 @@ String Ide::GetMain() return main; } -void Ide::BeginBuilding(bool sync_files, bool clear_console) +void Ide::BeginBuilding(bool clear_console) { SetupDefaultMethod(); HdependTimeDirty(); @@ -47,7 +47,6 @@ void Ide::BeginBuilding(bool sync_files, bool clear_console) if(clear_console) console.Clear(); build_time = msecs(); - CreateHost(sync_files, disable_uhd); cmdout.Clear(); } @@ -56,7 +55,8 @@ void Ide::EndBuilding(bool ok) console.EndGroup(); console.Wait(); Vector errors = console.PickErrors(); - CreateHost(false, disable_uhd)->DeleteFile(errors); + for(String p : errors) + DeleteFile(p); if(!errors.IsEmpty()) ok = false; PutConsole(""); @@ -79,7 +79,7 @@ void Ide::DoBuild() void Ide::PackageBuild() { InitBlitz(); - BeginBuilding(true, true); + BeginBuilding(true); const Workspace& wspc = IdeWorkspace(); int pi = GetPackageIndex(); if(pi >= 0 && pi <= wspc.GetCount()) { @@ -138,7 +138,7 @@ void Ide::FileCompile() return; ClearErrorEditor(editfile); SwitchHeader(); - BeginBuilding(true, true); + BeginBuilding(true); const Workspace& wspc = IdeWorkspace(); bool ok = true; onefile = editfile; @@ -180,11 +180,12 @@ void Ide::Preprocess(bool asmout) { const Workspace& wspc = IdeWorkspace(); if(pi >= wspc.GetCount()) return; - One host = CreateHost(darkmode, disable_uhd); - One b = CreateBuilder(~host); + Host host; + CreateHost(host, darkmode, disable_uhd); + One b = CreateBuilder(&host); Vector linkfile; String linkopt; - b->config = PackageConfig(wspc, pi, GetMethodVars(method), mainconfigparam, *host, *b); + b->config = PackageConfig(wspc, pi, GetMethodVars(method), mainconfigparam, host, *b); console.Clear(); PutConsole((asmout ? "Compiling " : "Preprocessing ") + editfile); b->Preprocess(wspc[pi], editfile, pfn, asmout); diff --git a/uppsrc/ide/Builders/Blitz.cpp b/uppsrc/ide/Builders/Blitz.cpp index 2c31e1c4c..13143f82f 100644 --- a/uppsrc/ide/Builders/Blitz.cpp +++ b/uppsrc/ide/Builders/Blitz.cpp @@ -77,7 +77,7 @@ Blitz BlitzBuilderComponent::MakeBlitzStep( b.build = true; blitz << "\r\n" << "#define BLITZ_INDEX__ F" << i << "\r\n" - << "#include \"" << builder->GetHostPath(sourceFile) << "\"\r\n"; + << "#include \"" << sourceFile << "\"\r\n"; b.info << ' ' << GetFileName(sourceFile); const Vector& d = HdependGetDefines(sourceFile); for(int i = 0; i < d.GetCount(); i++) @@ -97,16 +97,16 @@ Blitz BlitzBuilderComponent::MakeBlitzStep( if(b.count > 1) { sourceFiles = pick(excluded); soptions = pick(excludedoptions); - if(builder->LoadFile(b.path) != blitz) { - builder->RealizeDir(GetFileDirectory(b.path)); - builder->SaveFile(b.path, blitz); + if(LoadFile(b.path) != blitz) { + RealizeDirectory(GetFileDirectory(b.path)); + SaveFile(b.path, blitz); b.build = true; } obj.Add(b.object); immfile.Add(b.object); } else { - builder->DeleteFile(b.path); + DeleteFile(b.path); b.build = false; } return b; diff --git a/uppsrc/ide/Builders/Build.cpp b/uppsrc/ide/Builders/Build.cpp index 75bc4531d..4a9688db1 100644 --- a/uppsrc/ide/Builders/Build.cpp +++ b/uppsrc/ide/Builders/Build.cpp @@ -93,13 +93,11 @@ String NoCr(const char *s) return out; } -One MakeBuild::CreateHost(bool darkmode, bool disable_uhd) +void MakeBuild::CreateHost(Host& host, bool darkmode, bool disable_uhd, const VectorMap& add_to_env) { SetupDefaultMethod(); VectorMap bm = GetMethodVars(method); - One outhost; { - auto& host = outhost.Create(); VectorMap env = clone(Environment()); host.exedirs = SplitDirs(bm.Get("PATH", "") + ';' + env.Get("PATH", "")); #ifdef PLATFORM_WIN32 @@ -127,10 +125,14 @@ One MakeBuild::CreateHost(bool darkmode, bool disable_uhd) LDUMP(env[i]); host.environment << env.GetKey(i) << '=' << env[i] << '\0'; } + for(int i = 0; i < add_to_env.GetCount(); i++) { + LDUMP(add_to_env.GetKey(i)); + LDUMP(add_to_env[i]); + host.environment << add_to_env.GetKey(i) << '=' << add_to_env[i] << '\0'; + } host.environment.Cat(0); host.cmdout = &cmdout; } - return outhost; } One MakeBuild::CreateBuilder(Host *host) @@ -219,7 +221,7 @@ String MakeBuild::OutDir(const Index& cfg, const String& package, const Index excl; excl.Add(bm.Get("BUILDER", "GCC")); excl.Add("MSC"); - LocalHost().AddFlags(excl); + Host().AddFlags(excl); Vector x; bool dbg = cfg.Find("DEBUG_FULL") >= 0 || cfg.Find("DEBUG_MINIMAL") >= 0; if(cfg.Find("DEBUG") >= 0) { @@ -248,46 +250,6 @@ String MakeBuild::OutDir(const Index& cfg, const String& package, const return outdir; } -struct OneFileHost : Host { - One host; - String onefile; - - virtual String GetEnvironment() { return host->GetEnvironment(); } - virtual String GetHostPath(const String& path) { return host->GetHostPath(path); } - virtual String GetLocalPath(const String& path) { return host->GetLocalPath(path); } - virtual String NormalizePath(const String& path) { return host->NormalizePath(path); } - virtual String NormalizeExecutablePath(const String& path) { return host->NormalizeExecutablePath(path); } - virtual void DeleteFile(const Vector& path) { host->DeleteFile(path); } - virtual void DeleteFolderDeep(const String& folder) { host->DeleteFolderDeep(folder); } - virtual void ChDir(const String& path) { host->ChDir(path); } - virtual bool RealizeDir(const String& path) { return host->RealizeDir(path); } - virtual bool SaveFile(const String& path, const String& data) { return host->SaveFile(path, data); } - virtual String LoadFile(const String& path) { return host->LoadFile(path); } - virtual int Execute(const char *c) { return host->Execute(c); } - virtual int ExecuteWithInput(const char *c, bool noconvert) { return host->ExecuteWithInput(c, noconvert); } - virtual int Execute(const char *c, Stream& o, bool noconvert) { return host->Execute(c, o, noconvert); } - virtual int AllocSlot() { return host->AllocSlot(); } - virtual bool Run(const char *cmdline, int slot, String key, int blitz_count) { return host->Run(cmdline, slot, key, blitz_count); } - virtual bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count) { return host->Run(cmdline, out, slot, key, blitz_count); } - virtual bool Wait() { return host->Wait(); } - virtual bool Wait(int slot) { return host->Wait(slot); } - virtual void OnFinish(Event<> cb) { return host->OnFinish(cb); } - virtual One StartProcess(const char *c) { return host->StartProcess(c); } - virtual void Launch(const char *cmdline, bool) { host->Launch(cmdline); } - virtual void AddFlags(Index& cfg) { host->AddFlags(cfg); } - virtual const Vector& GetExecutablesDirs() const { return host->GetExecutablesDirs(); } - - virtual Vector GetFileInfo(const Vector& path) { - Vector fi = host->GetFileInfo(path); - for(int i = 0; i < path.GetCount(); i++) - if(path[i] == onefile) - (Time &)fi[i] = GetSysTime(); - else - (Time &)fi[i] = Time::Low(); - return fi; - } -}; - void MakeBuild::PkgConfig(const Workspace& wspc, const Index& config, Index& pkg_config) { for(int i = 0; i < wspc.GetCount(); i++) @@ -308,25 +270,21 @@ bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, i ConsoleShow(); return false; } - One host = CreateHost(false, false); - if(!IsNull(onefile)) { - OneFileHost *h = new OneFileHost; - h->host = pick(host); - h->onefile = onefile; - host = h; - } - One b = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + host.onefile = onefile; + One b = CreateBuilder(&host); if(!b) return false; - b->config = PackageConfig(wspc, pkindex, bm, mainparam, *host, *b); + b->config = PackageConfig(wspc, pkindex, bm, mainparam, host, *b); PkgConfig(wspc, b->config, b->pkg_config); const TargetMode& m = targetmode == 0 ? debug : release; b->version = m.version; b->method = method; b->outdir = OutDir(b->config, package, bm); - host->RealizeDir(b->outdir); + host.RealizeDir(b->outdir); String mainfn = Null; - Index mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, &mainfn); + Index mcfg = PackageConfig(wspc, 0, bm, mainparam, host, *b, &mainfn); HdependClearDependencies(); for(int i = 0; i < pkg.GetCount(); i++) { const Array& f = pkg[i].depends; @@ -335,7 +293,7 @@ bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, i HdependAddDependency(SourcePath(package, pkg[i]), SourcePath(package, f[j].text)); } String tout = OutDir(mcfg, mainpackage, bm, use_target); - host->RealizeDir(tout); + host.RealizeDir(tout); if(IsNull(mainfn)) mainfn = GetFileTitle(mainpackage) + b->GetTargetExt(); if(!IsNull(outfile)) @@ -348,18 +306,18 @@ bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, i else #endif if(m.target_override && !IsNull(m.target) && IsFolder(m.target)) - target = host->NormalizePath(AppendFileName(m.target, mainfn)); + target = NormalizePath(AppendFileName(m.target, mainfn)); else if(m.target_override && (IsFullPath(m.target) || *m.target == '/' || *m.target == '\\')) target = m.target; else if(m.target_override && !IsNull(m.target)) - target = host->NormalizePath(AppendFileName(tout, m.target)); + target = NormalizePath(AppendFileName(tout, m.target)); else if(IsFullPath(mainfn)) target = mainfn; else - target = host->NormalizePath(AppendFileName(tout, mainfn)); + target = NormalizePath(AppendFileName(tout, mainfn)); } b->target = target; b->mainpackage = mainpackage; @@ -373,19 +331,21 @@ bool MakeBuild::BuildPackage(const Workspace& wspc, int pkindex, int pknumber, i else b->config.FindAdd("NOLIB"); bool ok = b->BuildPackage(package, linkfile, immfile, linkopt, - GetAllUses(wspc, pkindex, bm, mainparam, *host, *b), - GetAllLibraries(wspc, pkindex, bm, mainparam, *host, *b), + GetAllUses(wspc, pkindex, bm, mainparam, host, *b), + GetAllLibraries(wspc, pkindex, bm, mainparam, host, *b), targetmode - 1); target = b->target; // apple app bundle can change target Vector errors = PickErrors(); - host->DeleteFile(errors); + for(String p : errors) + DeleteFile(p); if(!ok || !errors.IsEmpty()) return false; if(link) { ok = b->Link(linkfile, linkopt, GetTargetMode().createmap); PutLinkingEnd(ok); errors = PickErrors(); - host->DeleteFile(errors); + for(String p : errors) + DeleteFile(p); if(!ok || !errors.IsEmpty()) return false; } @@ -470,7 +430,7 @@ bool MakeBuild::Build(const Workspace& wspc, String mainparam, String outfile, b DeleteFile(hfile); ClearErrorEditor(); - BeginBuilding(true, clear_console); + BeginBuilding(clear_console); bool ok = true; main_conf.Clear(); if(wspc.GetCount()) { @@ -487,10 +447,11 @@ bool MakeBuild::Build(const Workspace& wspc, String mainparam, String outfile, b if(main_conf.GetCount()) { VectorMap bm = GetMethodVars(method); - One host = CreateHost(false, false); - One b = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + One b = CreateBuilder(&host); if(b) { - Index mcfg = PackageConfig(wspc, 0, bm, mainparam, *host, *b, NULL); + Index 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); @@ -567,12 +528,13 @@ bool MakeBuild::Build() ConsoleShow(); return false; } - One host = CreateHost(false, false); - One builder = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + One builder = CreateBuilder(&host); if(!builder) return false; Index p = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam, - *host, *builder); + host, *builder); Workspace wspc; wspc.Scan(GetMain(), p.GetKeys()); return Build(wspc, mainconfigparam, Null); @@ -581,12 +543,13 @@ bool MakeBuild::Build() void MakeBuild::CleanPackage(const Workspace& wspc, int package) { PutConsole(Format("Cleaning %s", wspc[package])); - One host = CreateHost(false, false); - One builder = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + One builder = CreateBuilder(&host); if(!builder) return; String outdir = OutDir(PackageConfig(wspc, package, GetMethodVars(method), mainconfigparam, - *host, *builder), wspc[package], GetMethodVars(method)); + host, *builder), wspc[package], GetMethodVars(method)); // TODO: almost perfect, but target will be detected after build. if build does not occur the target is empty :( // How to make sure we know target? Target directory is where android project sandbox is. builder->target = target; @@ -597,8 +560,9 @@ void MakeBuild::Clean() { ConsoleClear(); - One host = CreateHost(false, false); - One builder = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + One builder = CreateBuilder(&host); if(!builder) return; builder->target = target; diff --git a/uppsrc/ide/Builders/Build.h b/uppsrc/ide/Builders/Build.h index b4138f43e..c1d66a965 100644 --- a/uppsrc/ide/Builders/Build.h +++ b/uppsrc/ide/Builders/Build.h @@ -34,7 +34,7 @@ public: virtual void ConsoleClear() = 0; virtual void SetupDefaultMethod() = 0; virtual Vector PickErrors() = 0; //console.PickErrors() - virtual void BeginBuilding(bool sync_files, bool clear_console) = 0; + virtual void BeginBuilding(bool clear_console) = 0; virtual void EndBuilding(bool ok) = 0; virtual void ClearErrorEditor() = 0; virtual void DoProcessEvents() = 0; @@ -67,10 +67,11 @@ public: bool makefile_svn_revision = true; + void CreateHost(Host& host, bool darkmode = false, bool disable_uhd = false, const VectorMap& add_to_env = VectorMap()); + const TargetMode& GetTargetMode(); Index PackageConfig(const Workspace& wspc, int package, const VectorMap& bm, String mainparam, Host& host, Builder& b, String *target = NULL); - One CreateHost(bool darkmode, bool disable_uhd); One CreateBuilder(Host *host); String OutDir(const Index& cfg, const String& package, const VectorMap& bm, bool use_target = false); diff --git a/uppsrc/ide/Builders/Builders.h b/uppsrc/ide/Builders/Builders.h index 1d58bf94a..fe927693d 100644 --- a/uppsrc/ide/Builders/Builders.h +++ b/uppsrc/ide/Builders/Builders.h @@ -22,7 +22,6 @@ struct CppBuilder : Builder { Time targettime; String GetSharedLibPath(const String& package) const; - String GetLocalPath(const String& path) const; int AllocSlot(); bool Run(const char *cmdline, int slot, String key, int blitz_count); bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count); diff --git a/uppsrc/ide/Builders/CppBuilder.cpp b/uppsrc/ide/Builders/CppBuilder.cpp index a75f2d644..9bcfc2912 100644 --- a/uppsrc/ide/Builders/CppBuilder.cpp +++ b/uppsrc/ide/Builders/CppBuilder.cpp @@ -94,11 +94,6 @@ String CppBuilder::GetSharedLibPath(const String& package) const return CatAnyPath(GetFileFolder(target), outfn); } -String CppBuilder::GetLocalPath(const String& path) const -{ - return host->GetLocalPath(path); -} - int CppBuilder::AllocSlot() { return host->AllocSlot(); @@ -268,7 +263,7 @@ Vector CppBuilder::CustomStep(const String& pf, const String& package_, { String package = Nvl(package_, mainpackage); String path = (*pf == '.' && pf[1] != '.') ? target : SourcePath(package, pf); - String file = GetHostPath(path); + String file = path; String ext = ToLower(GetFileExt(pf)); if(ext == ".ext") { Vector files; @@ -355,15 +350,15 @@ Vector CppBuilder::CustomStep(const String& pf, const String& package_, AddPath(mac, "PACKAGE", package); mac.Add("FILE", GetFileName(file)); mac.Add("TITLE", GetFileTitle(file)); - AddPath(mac, "EXEPATH", GetHostPath(target)); - AddPath(mac, "EXEDIR", GetHostPath(GetFileFolder(target))); + AddPath(mac, "EXEPATH", target); + AddPath(mac, "EXEDIR", GetFileFolder(target)); mac.Add("EXEFILE", GetFileName(target)); mac.Add("EXETITLE", GetFileTitle(target)); - AddPath(mac, "OUTDIR", GetHostPath(outdir)); + AddPath(mac, "OUTDIR", outdir); //BW - AddPath(mac, "OUTDIR", GetHostPath(GetFileFolder(target))); - AddPath(mac, "OUTFILE", GetHostPath(GetFileName(target))); - AddPath(mac, "OUTTITLE", GetHostPath(GetFileTitle(target))); + AddPath(mac, "OUTDIR", GetFileFolder(target)); + AddPath(mac, "OUTFILE", GetFileName(target)); + AddPath(mac, "OUTTITLE", GetFileTitle(target)); mac.Add("INCLUDE", Join(include, ";")); @@ -406,8 +401,8 @@ String CppBuilder::Includes(const char *sep, const String& package, const Packag { String cc; for(int i = 0; i < include.GetCount(); i++) - cc << sep << GetHostPathQ(include[i]); - cc << sep << GetHostPathQ(outdir); + cc << sep << GetPathQ(include[i]); + cc << sep << GetPathQ(outdir); return cc; } diff --git a/uppsrc/ide/Builders/GccBuilder.cpp b/uppsrc/ide/Builders/GccBuilder.cpp index 4cd06eccd..528a9615f 100644 --- a/uppsrc/ide/Builders/GccBuilder.cpp +++ b/uppsrc/ide/Builders/GccBuilder.cpp @@ -28,7 +28,7 @@ void GccBuilder::BinaryToObject(String objfile, CParser& binscript, String based String tmpfile = ForceExt(objfile, ".c"); SaveFile(tmpfile, fo); String cc = CmdLine(package, pkg); - cc << " -c -o " << GetHostPathQ(objfile) << " -x c " << GetHostPathQ(tmpfile); + cc << " -c -o " << GetPathQ(objfile) << " -x c " << GetPathQ(tmpfile); int slot = AllocSlot(); if(slot < 0 || !Run(cc, slot, objfile, 1)) throw Exc(Format("Error compiling binary object '%s'.", objfile)); @@ -202,22 +202,22 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V int pch_slot = AllocSlot(); StringBuffer sb; - sb << Join(cc, cpp_options) << " -x c++-header " << GetHostPathQ(pch_header) << " -o " << GetHostPathQ(pch_file); + sb << Join(cc, cpp_options) << " -x c++-header " << GetPathQ(pch_header) << " -o " << GetPathQ(pch_file); PutConsole("Precompiling header: " + GetFileName(pch_header)); - if(pch_slot < 0 || !Run(~sb, pch_slot, GetHostPath(pch_file), 1)) + if(pch_slot < 0 || !Run(~sb, pch_slot, pch_file, 1)) error = true; Wait(); - pch_use = " -I" + GetHostPathQ(outdir) + " -include " + GetFileName(pch_header2) + " -Winvalid-pch "; + pch_use = " -I" + GetPathQ(outdir) + " -include " + GetFileName(pch_header2) + " -Winvalid-pch "; } if(blitz && b.build) { PutConsole("BLITZ:" + b.info); int slot = AllocSlot(); if(slot < 0 || !Run(String().Cat() << Join(cc, cpp_options) << ' ' - << GetHostPathQ(b.path) - << " -o " << GetHostPathQ(b.object), slot, GetHostPath(b.object), b.count)) + << GetPathQ(b.path) + << " -o " << GetPathQ(b.object), slot, b.object, b.count)) error = true; } @@ -237,7 +237,7 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V String objfile = CatAnyPath(outdir, GetFileTitle(fn) + (rc ? "$rc.o" : brc ? "$brc.o" : ".o")); if(GetFileName(fn) == "Info.plist") Info_plist = LoadFile(fn); - if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { + if(HdependFileTime(fn) > GetFileTime(objfile)) { PutConsole(GetFileName(fn)); int time = msecs(); bool execerr = false; @@ -247,14 +247,14 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V int q = compiler.ReverseFind('-'); // clang32 windres name is i686-w64-mingw32-windres.exe if(q > 0) windres = compiler.Mid(0, q + 1) + windres; - exec << GetHostPath(FindInDirs(host->GetExecutablesDirs(), windres)) << " -i " << GetHostPathQ(fn); + exec << FindInDirs(host->GetExecutablesDirs(), windres) << " -i " << GetPathQ(fn); if(cc.Find(" -m32 ") >= 0) exec << " --target=pe-i386 "; - exec << " -o " << GetHostPathQ(objfile) << Includes(" --include-dir=", package, pkg) + exec << " -o " << GetPathQ(objfile) << Includes(" --include-dir=", package, pkg) << DefinesTargetTime(" -D", package, pkg) + (HasFlag("DEBUG")?" -D_DEBUG":""); PutVerbose(exec); int slot = AllocSlot(); - execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); + execerr = (slot < 0 || !Run(exec, slot, objfile, 1)); } else if(brc) { try { @@ -262,7 +262,7 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V if(brcdata.IsVoid()) throw Exc(Format("error reading file '%s'", fn)); CParser parser(brcdata, fn); - BinaryToObject(GetHostPath(objfile), parser, GetFileDirectory(fn), package, pkg); + BinaryToObject(objfile, parser, GetFileDirectory(fn), package, pkg); } catch(Exc e) { PutConsole(e); @@ -285,10 +285,10 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V exec << fuse_cxa_atexit << Join(" -x c++", cpp_options) << ' '; exec << pch_use; } - exec << GetHostPathQ(fn) << " " << soptions[i] << " -o " << GetHostPathQ(objfile); + exec << GetPathQ(fn) << " " << soptions[i] << " -o " << GetPathQ(objfile); PutVerbose(exec); int slot = AllocSlot(); - execerr = (slot < 0 || !Run(exec, slot, GetHostPath(objfile), 1)); + execerr = (slot < 0 || !Run(exec, slot, objfile, 1)); } if(execerr) DeleteFile(objfile); @@ -340,11 +340,11 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V product = GetSharedLibPath(package); else product = CatAnyPath(outdir, GetAnyFileName(package) + ".a"); - String hproduct = GetHostPath(product); + String hproduct = product; Time producttime = GetFileTime(hproduct); if(obj.GetCount()) { - linkfile.Add(GetHostPath(product)); - immfile.Add(GetHostPath(product)); + linkfile.Add(product); + immfile.Add(product); } for(int i = 0; i < obj.GetCount(); i++) if(GetFileTime(obj[i]) > producttime) @@ -363,7 +363,7 @@ bool GccBuilder::CreateLib(const String& product, const Vector& obj, const String& link_options) { int libtime = msecs(); - String hproduct = GetHostPath(product); + String hproduct = product; String lib; bool is_shared = HasFlag("SO"); if(is_shared) { @@ -382,20 +382,20 @@ bool GccBuilder::CreateLib(const String& product, const Vector& obj, } else lib = "ar -sr "; - lib << GetHostPathQ(product); + lib << GetPathQ(product); String llib; for(int i = 0; i < obj.GetCount(); i++) - llib << ' ' << GetHostPathQ(obj[i]); + llib << ' ' << GetPathQ(obj[i]); PutConsole("Creating library..."); DeleteFile(hproduct); if(is_shared) { for(int i = 0; i < libpath.GetCount(); i++) - llib << " -L" << GetHostPathQ(libpath[i]); + llib << " -L" << GetPathQ(libpath[i]); for(int i = 0; i < all_uses.GetCount(); i++) - llib << ' ' << GetHostPathQ(GetSharedLibPath(all_uses[i])); + llib << ' ' << GetPathQ(GetSharedLibPath(all_uses[i])); for(int i = 0; i < all_libraries.GetCount(); i++) - llib << " -l" << GetHostPathQ(all_libraries[i]); + llib << " -l" << GetPathQ(all_libraries[i]); if(HasFlag("POSIX")) llib << " -Wl,-soname," << GetSoname(product); @@ -522,15 +522,15 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, lnk << " -mconsole"; } } - lnk << " -o " << GetHostPathQ(target); + lnk << " -o " << GetPathQ(target); if(createmap) - lnk << " -Wl,-Map," << GetHostPathQ(GetFileDirectory(target) + GetFileTitle(target) + ".map"); + lnk << " -Wl,-Map," << GetPathQ(GetFileDirectory(target) + GetFileTitle(target) + ".map"); if(HasFlag("DEBUG_MINIMAL") || HasFlag("DEBUG_FULL")) lnk << (HasFlag("CLANG") && HasFlag("WIN32") ? " -Wl,-pdb=" : " -ggdb"); else lnk << (!HasFlag("OSX") ? " -Wl,-s" : ""); for(i = 0; i < libpath.GetCount(); i++) - lnk << " -L" << GetHostPathQ(libpath[i]); + lnk << " -L" << GetPathQ(libpath[i]); MergeWith(lnk, " ", linkoptions); String lfilename; if(HasFlag("OBJC")) { @@ -538,23 +538,23 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, String linklist; for(i = 0; i < linkfile.GetCount(); i++) if(ToLower(GetFileExt(linkfile[i])) == ".o" || ToLower(GetFileExt(linkfile[i])) == ".a") - linklist << GetHostPath(linkfile[i]) << '\n'; + linklist << linkfile[i] << '\n'; String linklistM = "Producing link file list ...\n"; String odir = GetFileDirectory(linkfile[0]); - lfilename << GetHostPath(GetFileFolder(linkfile[0])) << ".LinkFileList"; + lfilename << GetFileFolder(linkfile[0]) << ".LinkFileList"; linklistM << lfilename; UPP::SaveFile(lfilename, linklist); - lnk << " -L" << GetHostPathQ(odir) - << " -F" << GetHostPathQ(odir) + lnk << " -L" << GetPathQ(odir) + << " -F" << GetPathQ(odir) << " -filelist " << lfilename << " "; PutConsole( linklistM ); } else for(i = 0; i < linkfile.GetCount(); i++) { if(ToLower(GetFileExt(linkfile[i])) == ".o") - lnk << ' ' << GetHostPathQ(linkfile[i]); + lnk << ' ' << GetPathQ(linkfile[i]); else lib.Add(linkfile[i]); } @@ -582,12 +582,12 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, if(pass == 0) { if(ext == ".a") - lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); + lnk << ' ' << GetPathQ(FindInDirs(libpath, lib[i])); } else if(ext != ".a") { if(ext == ".so" || ext == ".dll" || ext == ".lib") - lnk << ' ' << GetHostPathQ(FindInDirs(libpath, lib[i])); + lnk << ' ' << GetPathQ(FindInDirs(libpath, lib[i])); else lnk << " -l" << ln; } @@ -600,7 +600,7 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, CustomStep(".pre-link", Null, error); if(!error && Execute(lnk) == 0) { CustomStep(".post-link", Null, error); - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) linked in " << GetPrintTime(time)); return !error; } @@ -610,7 +610,7 @@ bool GccBuilder::Link(const Vector& linkfile, const String& linkoptions, } } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) is up to date."); return true; } @@ -627,7 +627,7 @@ bool GccBuilder::Preprocess(const String& package, const String& file, const Str String cmd = CmdLine(package, pkg); cmd << " " << Gather(pkg.option, config.GetKeys()); cmd << " -o " << target; - cmd << (asmout ? " -S " : " -E ") << GetHostPathQ(file); + cmd << (asmout ? " -S " : " -E ") << GetPathQ(file); if(BuilderUtils::IsCFile(file)) cmd << " " << c_options; else diff --git a/uppsrc/ide/Builders/JavaBuilder.cpp b/uppsrc/ide/Builders/JavaBuilder.cpp index e460a0c54..9e920d0e8 100644 --- a/uppsrc/ide/Builders/JavaBuilder.cpp +++ b/uppsrc/ide/Builders/JavaBuilder.cpp @@ -104,8 +104,8 @@ bool JavaBuilder::BuildPackage(const String& package, Vector& linkfile, ismf = true; if(manifest >= 0) { - PutConsole(Format("%s(1): duplicate manifest file", GetHostPath(fn))); - PutConsole(Format("%s(1): (previous manifest file)", GetHostPath(sfile[manifest]))); + PutConsole(Format("%s(1): duplicate manifest file", fn)); + PutConsole(Format("%s(1): (previous manifest file)", sfile[manifest])); } manifest = sfile.GetCount(); } @@ -199,12 +199,12 @@ bool JavaBuilder::PreprocessJava(String file, String target, String options, { prepfile = ForceExt(file, ".i"); host->ChDir(GetFileFolder(prepfile)); - execpath << GetHostPath(file); + execpath << file; } else { PutConsole(file); - execpath << GetHostPath(file) << " " << GetHostPath(target); + execpath << file << " " << target; prepfile = target; } if(Execute(execpath) != 0) @@ -268,9 +268,9 @@ bool JavaBuilder::Link(const Vector& linkfile, const String& linkoptions cmdline << "cf"; if(!manifest.IsEmpty()) cmdline << 'm'; - cmdline << ' ' << GetHostPath(target); + cmdline << ' ' << target; if(!manifest.IsEmpty()) - cmdline << ' ' << GetHostPath(manifest); + cmdline << ' ' << manifest; Time tm = Time::Low(); for(int i = ITEMCOUNT; i < linkfile.GetCount(); i++) tm = max(tm, AddClassDeep(cmdline, linkfile[i], Null)); @@ -301,7 +301,7 @@ bool JavaBuilder::Link(const Vector& linkfile, const String& linkoptions << " B) archived in " << GetPrintTime(time)); } else - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) is up to date."); return true; } diff --git a/uppsrc/ide/Builders/MakeFile.cpp b/uppsrc/ide/Builders/MakeFile.cpp index 32d1e0f15..c39959e10 100644 --- a/uppsrc/ide/Builders/MakeFile.cpp +++ b/uppsrc/ide/Builders/MakeFile.cpp @@ -92,7 +92,7 @@ void CppBuilder::AddMakeFile(MakeFile& makefile, String package, << " $(LINKOPTIONS)\n" "LIBPATH ="; for(int i = 0; i < libpath.GetCount(); i++) - makefile.config << " -L" << GetMakePath(AdjustMakePath(GetHostPathQ(libpath[i]))); + makefile.config << " -L" << GetMakePath(AdjustMakePath(GetPathQ(libpath[i]))); makefile.config << "\n" "AR = ar -sr\n\n"; Vector lib; @@ -149,7 +149,7 @@ void CppBuilder::AddMakeFile(MakeFile& makefile, String package, String ln = libs[i]; String ext = ToLower(GetFileExt(ln)); if(ext == ".a" || ext == ".so" || ext == ".dll") - makefile.linkfileend << " \\\n\t\t\t" << GetHostPathQ(FindInDirs(libpath, ln)); + makefile.linkfileend << " \\\n\t\t\t" << GetPathQ(FindInDirs(libpath, ln)); else makefile.linkfileend << " \\\n\t\t\t-l" << ln; } @@ -257,11 +257,12 @@ void CppBuilder::ShowTime(int count, int start_time) void MakeBuild::SaveMakeFile(const String& fn, bool exporting) { - BeginBuilding(false, true); + BeginBuilding(true); VectorMap bm = GetMethodVars(method); - One host = CreateHost(false, false); - One b = CreateBuilder(~host); + Host host; + CreateHost(host, false, false); + One b = CreateBuilder(&host); if(!b) return; @@ -271,10 +272,10 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) String makefile; Vector uppdirs = GetUppDirs(); - String uppout = exporting ? host->GetHostPath(GetVar("OUTPUT")) : ".cache/upp.out"; + String uppout = exporting ? GetVar("OUTPUT") : ".cache/upp.out"; String inclist; - Index allconfig = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam, *host, *b); + Index allconfig = PackageConfig(GetIdeWorkspace(), 0, bm, mainconfigparam, host, *b); bool win32 = allconfig.Find("WIN32") >= 0; Workspace wspc; @@ -282,7 +283,7 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) Index pkg_config; for(int i = 0; i < wspc.GetCount(); i++) { - Index modconfig = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b); + Index modconfig = PackageConfig(wspc, i, bm, mainconfigparam, host, *b); PkgConfig(wspc, modconfig, pkg_config); if(i) for(int a = allconfig.GetCount(); --a >= 0;) @@ -292,7 +293,7 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) if(!exporting) for(int i = 0; i < uppdirs.GetCount(); i++) { - String srcdir = GetMakePath(AdjustMakePath(host->GetHostPath(AppendFileName(uppdirs[i], ""))), win32); + String srcdir = GetMakePath(AdjustMakePath(AppendFileName(uppdirs[i], "")), win32); makefile << "UPPDIR" << (i + 1) << " = " << srcdir << "\n"; inclist << " -I$(UPPDIR" << (i + 1) << ")"; } @@ -308,7 +309,7 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) inclist << " -I$(UPPOUT)"; // build_info.h is created there makefile << "\n" - "UPPOUT = " << (exporting ? "_out/" : GetMakePath(AdjustMakePath(host->GetHostPath(AppendFileName(uppout, ""))), win32)) << "\n" + "UPPOUT = " << (exporting ? "_out/" : GetMakePath(AdjustMakePath(AppendFileName(uppout, "")), win32)) << "\n" "CINC = " << inclist << "\n" "Macro = "; @@ -322,12 +323,12 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) linkfileend << " \\\n\t\t\t`pkg-config --libs " << s << "`"; for(int i = 0; i < wspc.GetCount(); i++) { - b->config = PackageConfig(wspc, i, bm, mainconfigparam, *host, *b); + 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, bm, mainconfigparam, *host, *b), - GetAllLibraries(wspc, i, bm, mainconfigparam, *host, *b), allconfig, + b->AddMakeFile(mf, wspc[i], GetAllUses(wspc, i, bm, mainconfigparam, host, *b), + GetAllLibraries(wspc, i, bm, mainconfigparam, host, *b), allconfig, exporting); if(i == 0) { // main package String tdir = mf.outdir; diff --git a/uppsrc/ide/Builders/MscBuilder.cpp b/uppsrc/ide/Builders/MscBuilder.cpp index b4c9f6b9a..554f17906 100644 --- a/uppsrc/ide/Builders/MscBuilder.cpp +++ b/uppsrc/ide/Builders/MscBuilder.cpp @@ -161,7 +161,7 @@ String MscBuilder::Pdb(String package, int slot, bool separate_pdb) const String pdb_name = GetAnyFileName(package); if(separate_pdb) pdb_name << '-' << (slot + 1); - return " -Gy -Fd" + GetHostPathQ(CatAnyPath(outdir, pdb_name + ".pdb")); + return " -Gy -Fd" + GetPathQ(CatAnyPath(outdir, pdb_name + ".pdb")); } void DeletePCHFile(const String& pch_file) @@ -265,10 +265,10 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V cc << " -EHsc"; else cc << " -GX"; -// String pdb = GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pdb")); +// String pdb = GetPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pdb")); // String pch; // if(!HasFlag("MSC8")) // MSC8 does not support automatic precompiled headers... -// pch << " -YX -Fp" << GetHostPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pch")) << ' '; +// pch << " -YX -Fp" << GetPathQ(CatAnyPath(outdir, GetAnyFileName(package) + ".pch")) << ' '; // cc << " -Gy -Fd" << pdb; // if(HasFlag("SSE2") && !IsMsc64()) // cc << " /arch:SSE2"; @@ -309,7 +309,7 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V String pch_obj = CatAnyPath(outdir, GetFileTitle(pch_header) + "$pch.obj"); pch_file = CatAnyPath(outdir, GetFileTitle(pch_header) + ".pch"); RegisterPCHFile(pch_file); - String pch_common = GetHostPathQ(pch_header) + " -Fp" + GetHostPathQ(pch_file) + " -FI" + GetHostPathQ(pch_header); + String pch_common = GetPathQ(pch_header) + " -Fp" + GetPathQ(pch_file) + " -FI" + GetPathQ(pch_header); if(blitz) // enable MK__s macros pch_common.Cat(" -DBLITZ_INDEX__=FPCH"); @@ -318,9 +318,9 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V int pch_slot = AllocSlot(); StringBuffer sb; sb << Join(cc, cpp_options) << Pdb(package, pch_slot, false) << " -Yc" << pch_common - << " -Tp " << GetHostPathQ(pch_header) << " -Fo" + GetHostPathQ(pch_obj); + << " -Tp " << GetPathQ(pch_header) << " -Fo" + GetPathQ(pch_obj); PutConsole("Precompiling header: " + GetFileName(pch_header)); - if(pch_slot < 0 || !Run(~sb, pch_slot, GetHostPath(pch_obj), 1)) + if(pch_slot < 0 || !Run(~sb, pch_slot, pch_obj, 1)) error = true; Wait(); } @@ -336,8 +336,8 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V if(HasAnyDebug()) c << Pdb(package, slot, false); if(slot < 0 || - !Run(c + " -Tp " + GetHostPathQ(b.path) + " -Fo" + GetHostPathQ(b.object), - slot, GetHostPath(b.object), b.count)) + !Run(c + " -Tp " + GetPathQ(b.path) + " -Fo" + GetPathQ(b.object), + slot, b.object, b.count)) error = true; } @@ -362,9 +362,9 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V if(rc) { PutConsole(GetFileNamePos(fn)); int slot = AllocSlot(); - if(slot < 0 || !Run("rc /fo" + GetHostPathQ(objfile) + Includes(" /i", package, pkg) + if(slot < 0 || !Run("rc /fo" + GetPathQ(objfile) + Includes(" /i", package, pkg) + DefinesTargetTime(" /d", package, pkg) + (HasFlag("DEBUG")?" /d_DEBUG":"") - + ' ' + GetHostPathQ(fn), slot, GetHostPath(objfile), 1)) + + ' ' + GetPathQ(fn), slot, objfile, 1)) execerr = true; } else @@ -381,8 +381,8 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V int slot = AllocSlot(); StringBuffer cmdline; cmdline << cc << Pdb(package, slot, false) - << " -Tc " << GetHostPathQ(tmpfile) << " -Fo" << GetHostPathQ(objfile); - if(slot < 0 || !Run(String(cmdline), slot, GetHostPath(objfile), 1)) + << " -Tc " << GetPathQ(tmpfile) << " -Fo" << GetPathQ(objfile); + if(slot < 0 || !Run(String(cmdline), slot, objfile, 1)) throw Exc(Format("Error compiling binary object '%s'.", objfile)); } catch(Exc e) { @@ -396,10 +396,10 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V if(HasAnyDebug()) c << Pdb(package, slot, !sContainsPchOptions(cc) && !sContainsPchOptions(soptions[i])); c << " " + soptions[i] + (ext == ".c" ? Join(c_options, " -Tc") : Join(cpp_options, " -Tp")) + ' ' - + GetHostPathQ(fn) + " -Fo" + GetHostPathQ(objfile); + + GetPathQ(fn) + " -Fo" + GetPathQ(objfile); if(nopch.Find(fn) < 0) c << pch_use; - if(slot < 0 || !Run(c, slot, GetHostPath(objfile), 1)) + if(slot < 0 || !Run(c, slot, objfile, 1)) execerr = true; } if(execerr) @@ -495,8 +495,8 @@ bool MscBuilder::CreateLib(const String& product, const Vector& obj, if(is_shared) { linker << LinkerName() << " -dll -nologo "; lib << "-machine:" << MachineName() - << " -pdb:" << GetHostPathQ(ForceExt(product, ".pdb")) - << " -out:" << GetHostPathQ(product); + << " -pdb:" << GetPathQ(ForceExt(product, ".pdb")) + << " -out:" << GetPathQ(product); if(!isgemsc10) lib << " -incremental:no"; if(HasAnyDebug()) @@ -525,12 +525,12 @@ bool MscBuilder::CreateLib(const String& product, const Vector& obj, PutConsole(Format("%s: error saving file", deffile)); return false; } - lib << " -def:" << GetHostPathQ(deffile); + lib << " -def:" << GetPathQ(deffile); for(int i = 0; i < libpath.GetCount(); i++) - lib << " -LIBPATH:" << GetHostPathQ(libpath[i]); + lib << " -LIBPATH:" << GetPathQ(libpath[i]); lib << ' ' << link_options; for(int i = 0; i < all_uses.GetCount(); i++) - lib << ' ' << GetHostPathQ(ForceExt(GetSharedLibPath(all_uses[i]), ".lib")); + lib << ' ' << GetPathQ(ForceExt(GetSharedLibPath(all_uses[i]), ".lib")); for(int i = 0; i < all_libraries.GetCount(); i++) { String libfile = AppendExt(all_libraries[i], ".lib"); if(!IsFullPath(libfile)) { @@ -542,15 +542,15 @@ bool MscBuilder::CreateLib(const String& product, const Vector& obj, } } } - lib << ' ' << GetHostPathQ(libfile); + lib << ' ' << GetPathQ(libfile); } } else{ linker << (HasFlag("INTEL") ? "xilib" : "link /lib") << " -nologo "; - lib << " -out:" << GetHostPathQ(product) << ' ' << link_options; + lib << " -out:" << GetPathQ(product) << ' ' << link_options; } for(int i = 0; i < obj.GetCount(); i++) - lib << ' ' << GetHostPathQ(obj[i]); + lib << ' ' << GetPathQ(obj[i]); PutConsole("Creating library..."); IdeConsoleEndGroup(); DeleteFile(product); @@ -595,7 +595,7 @@ bool MscBuilder::CreateLib(const String& product, const Vector& obj, else if((IsMsc86() || IsMsc64()) && is_shared) { String mt("mt -nologo -manifest "); - mt << GetHostPathQ(product) << ".manifest -outputresource:" << GetHostPathQ(product) << ";2"; + mt << GetPathQ(product) << ".manifest -outputresource:" << GetPathQ(product) << ";2"; Execute(mt); } PutConsole(String().Cat() << product << " (" << GetFileInfo(product).length @@ -626,8 +626,8 @@ bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, if(GetFileTime(linkfile[i]) > targettime) { String link, lib; link << LinkerName() << " -nologo -machine:" << MachineName() - << " -pdb:" << GetHostPathQ(ForceExt(target, ".pdb")) - << " -out:" << GetHostPathQ(target); + << " -pdb:" << GetPathQ(ForceExt(target, ".pdb")) + << " -out:" << GetPathQ(target); if(!isgemsc10) if(HasAnyDebug()) link << " -incremental:yes -debug -OPT:NOREF"; @@ -656,7 +656,7 @@ bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, link << " -LIBPATH:\"" << libpath[i] << '\"'; link << ' ' << linkoptions << ' '; for(i = 0; i < linkfile.GetCount(); i++) - lib << ' ' << GetHostPathQ(AppendExt(linkfile[i], ".lib")); + lib << ' ' << GetPathQ(AppendExt(linkfile[i], ".lib")); PutConsole("Linking..."); bool error = false; @@ -697,11 +697,11 @@ bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, CustomStep(".post-link", Null, error); if((IsMsc86() || IsMsc64()) && HasFlag("SHARED")) { String mt("mt -nologo -manifest "); - mt << GetHostPathQ(target) << ".manifest -outputresource:" << GetHostPathQ(target) + mt << GetPathQ(target) << ".manifest -outputresource:" << GetPathQ(target) << (HasFlag("DLL") ? ";2" : ";1"); Execute(mt); } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) linked in " << GetPrintTime(time)); } else { @@ -712,7 +712,7 @@ bool MscBuilder::Link(const Vector& linkfile, const String& linkoptions, FileDelete(tmpFileName); return !error; } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) is up to date."); return true; } diff --git a/uppsrc/ide/Builders/ScriptBuilder.cpp b/uppsrc/ide/Builders/ScriptBuilder.cpp index 5235cb1cd..dc4b3947a 100644 --- a/uppsrc/ide/Builders/ScriptBuilder.cpp +++ b/uppsrc/ide/Builders/ScriptBuilder.cpp @@ -79,12 +79,12 @@ void ScriptBuilder::CheckParse() EscValue inclist; inclist.SetEmptyArray(); for(int i = 0; i < include.GetCount(); i++) - inclist.ArrayAdd(GetHostPathQ(include[i])); + inclist.ArrayAdd(GetPathQ(include[i])); globals.GetAdd("INCLUDE") = inclist; EscValue liblist; liblist.SetEmptyArray(); for(int i = 0; i < libpath.GetCount(); i++) - liblist.ArrayAdd(GetHostPathQ(libpath[i])); + liblist.ArrayAdd(GetPathQ(libpath[i])); globals.GetAdd("LIBPATH") = liblist; try @@ -156,7 +156,7 @@ bool ScriptBuilder::BuildPackage(const String& package, Vector& linkfile if(b.build) { PutConsole("BLITZ:" + b.info); int time = msecs(); - if(Execute(cc + " " + GetHostPathQ(b.path) + " -o " + GetHostPathQ(b.object)) == 0) + if(Execute(cc + " " + GetPathQ(b.path) + " -o " + GetPathQ(b.object)) == 0) PutCompileTime(time, b.count); else error = true; @@ -176,10 +176,10 @@ bool ScriptBuilder::BuildPackage(const String& package, Vector& linkfile return false; if(IsNull(objfile)) objfile = CatAnyPath(outdir, GetFileTitle(fn) + ".o"); - if(HdependFileTime(fn) > GetFileTime(GetHostPath(objfile))) { + if(HdependFileTime(fn) > GetFileTime(objfile)) { PutConsole(GetFileName(fn)); int time = msecs(); - if(!ExecuteIf("compile", GetHostPathQ(fn), GetHostPathQ(objfile), soptions[i]).GetNumber()) { + if(!ExecuteIf("compile", GetPathQ(fn), GetPathQ(objfile), soptions[i]).GetNumber()) { DeleteFile(objfile); error = true; } @@ -218,7 +218,7 @@ bool ScriptBuilder::BuildPackage(const String& package, Vector& linkfile EscValue objlist; objlist.SetEmptyArray(); for(int i = 0; i < obj.GetCount(); i++) - objlist.ArrayAdd(GetHostPathQ(obj[i])); + objlist.ArrayAdd(GetPathQ(obj[i])); if(!ExecuteIf("library", objlist, product).GetNumber()) { DeleteFile(product); error = true; @@ -248,13 +248,13 @@ bool ScriptBuilder::Link(const Vector& linkfile, const String& linkoptio liblist.SetEmptyArray(); for(i = 0; i < linkfile.GetCount(); i++) if(*linkfile[i] == '*') - liblist.ArrayAdd(GetHostPathQ(linkfile[i].Mid(1))); + liblist.ArrayAdd(GetPathQ(linkfile[i].Mid(1))); else - objlist.ArrayAdd(GetHostPathQ(linkfile[i])); + objlist.ArrayAdd(GetPathQ(linkfile[i])); Vector linkargs; linkargs.Add(objlist); linkargs.Add(liblist); - linkargs.Add(GetHostPathQ(target)); + linkargs.Add(GetPathQ(target)); linkargs.Add(linkoptions); PutConsole("Linking..."); bool error = false; @@ -264,11 +264,11 @@ bool ScriptBuilder::Link(const Vector& linkfile, const String& linkoptio return false; } CustomStep(".post-link", Null, error); - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) linked in " << GetPrintTime(time)); return !error; } - PutConsole(String().Cat() << GetHostPath(target) << " (" << GetFileInfo(target).length + PutConsole(String().Cat() << target << " (" << GetFileInfo(target).length << " B) is up to date."); return true; } diff --git a/uppsrc/ide/Common/Common.h b/uppsrc/ide/Common/Common.h index 152426f21..47f2026a6 100644 --- a/uppsrc/ide/Common/Common.h +++ b/uppsrc/ide/Common/Common.h @@ -104,6 +104,9 @@ bool CopyFolder(const char *dst, const char *src, Progress *pi = NULL); bool HasSvn(); bool HasGit(); +#ifdef PLATFORM_WIN32 +String GetInternalGitPath(); +#endif int MaxAscent(Font f); diff --git a/uppsrc/ide/Common/Util.cpp b/uppsrc/ide/Common/Util.cpp index dabff0f7b..927683d15 100644 --- a/uppsrc/ide/Common/Util.cpp +++ b/uppsrc/ide/Common/Util.cpp @@ -252,6 +252,31 @@ bool HasSvn() return b; } +#ifdef PLATFORM_WIN32 + +String GetInternalGitPath() +{ + return GetExeDirFile("bin/mingit/cmd/git.exe"); +} + +bool HasGit() +{ + String dummy; + static bool b = FileExists(GetInternalGitPath()) || Sys("svn", dummy) >= 0; + return b; +} + +#else + +bool HasGit() +{ + String dummy; + static bool b = Sys("svn", dummy) >= 0; + return b; +} + +#endif + int MaxAscent(Font f) { return max(f.GetAscent(), f().Bold().GetAscent(), diff --git a/uppsrc/ide/Core/Builder.cpp b/uppsrc/ide/Core/Builder.cpp index 02e436d0d..9cb89c446 100644 --- a/uppsrc/ide/Core/Builder.cpp +++ b/uppsrc/ide/Core/Builder.cpp @@ -5,11 +5,6 @@ void Builder::ChDir(const String& path) host->ChDir(path); } -String Builder::GetHostPath(const String& path) const -{ - return host->GetHostPath(path); -} - String TrimSlash(String s) { while(findarg(*s.Last(), '/', '\\') >= 0) @@ -17,9 +12,9 @@ String TrimSlash(String s) return s; } -String Builder::GetHostPathQ(const String& path) const +String Builder::GetPathQ(const String& path) const { - return '\"' + TrimSlash(GetHostPath(path)) + '\"'; + return '\"' + TrimSlash(path) + '\"'; } Vector Builder::GetFileInfo(const Vector& path) const @@ -72,33 +67,3 @@ int Builder::Execute(const char *cl, Stream& out) { return host->Execute(CmdX(cl), out); } - -void Builder::DeleteFile(const Vector& path) -{ - host->DeleteFile(path); -} - -void Builder::DeleteFile(const String& path) -{ - host->DeleteFile(Vector() << path); -} - -bool Builder::RealizeDir(const String& path) -{ - return host->RealizeDir(path); -} - -bool Builder::SaveFile(const String& path, const String& data) -{ - return host->SaveFile(path, data); -} - -String Builder::LoadFile(const String& path) -{ - return host->LoadFile(path); -} - -bool Builder::FileExists(const String& path) const -{ - return !IsNull(GetFileInfo(path).length); -} diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index 3fe985f7f..3ef6c0d6b 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -476,19 +476,12 @@ struct Builder { // TODO: move other methods if needed void ChDir(const String& path); - String GetHostPath(const String& path) const; - String GetHostPathQ(const String& path) const; + String GetPathQ(const String& path) const; Vector GetFileInfo(const Vector& path) const; Host::FileInfo GetFileInfo(const String& path) const; Time GetFileTime(const String& path) const; int Execute(const char *cmdline); int Execute(const char *cl, Stream& out); - void DeleteFile(const Vector& path); - void DeleteFile(const String& path); - bool FileExists(const String& path) const; - bool RealizeDir(const String& path); - bool SaveFile(const String& path, const String& data); - String LoadFile(const String& path); bool HasFlag(const char *f) const { return config.Find(f) >= 0; } }; diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index 8de0d0f4d..c675d7602 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -4,40 +4,21 @@ #include -LocalHost::LocalHost() +Host::Host() { } -String LocalHost::GetEnvironment() +String Host::GetEnvironment() { return environment; } -String LocalHost::GetHostPath(const String& path) -{ - return path; -} - -String LocalHost::GetLocalPath(const String& path) -{ - return path; -} - -String LocalHost::NormalizePath(const String& path) -{ - return ::NormalizePath(path); -} - -String LocalHost::NormalizeExecutablePath(const String& path) -{ - return NormalizeExePath(path); -} - -Vector LocalHost::GetFileInfo(const Vector& path) +Vector Host::GetFileInfo(const Vector& path) { Vector fi; for(int i = 0; i < path.GetCount(); i++) { FindFile ff(path[i]); + FileInfo& f = fi.Add(); if(ff) { (Time&)f = ff.GetLastWriteTime(); @@ -47,22 +28,18 @@ Vector LocalHost::GetFileInfo(const Vector& path) (Time&)f = Time::Low(); f.length = Null; } + + if(onefile.GetCount()) { + if(path[i] == onefile) + (Time &)f = GetSysTime(); + else + (Time &)f = Time::Low(); + } } return fi; } -void LocalHost::DeleteFile(const Vector& path) -{ - for(int i = 0; i < path.GetCount(); i++) - ::DeleteFile(path[i]); -} - -void LocalHost::DeleteFolderDeep(const String& folder) -{ - ::DeleteFolderDeep(folder); -} - -void LocalHost::ChDir(const String& path) +void Host::ChDir(const String& path) { #ifdef PLATFORM_WIN32 SetCurrentDirectory(path); @@ -71,10 +48,10 @@ void LocalHost::ChDir(const String& path) IGNORE_RESULT( chdir(path) ); #endif if(cmdout) - *cmdout << "cd \"" << GetHostPath(path) << "\"\n"; + *cmdout << "cd \"" << path << "\"\n"; } -void LocalHost::DoDir(const String& dir) +void Host::DoDir(const String& dir) { if(dir.GetLength() > 3) { DoDir(GetFileFolder(dir)); @@ -82,7 +59,7 @@ void LocalHost::DoDir(const String& dir) } } -bool LocalHost::RealizeDir(const String& path) +bool Host::RealizeDir(const String& path) { bool realized = RealizeDirectory(path); if(cmdout) @@ -90,17 +67,7 @@ bool LocalHost::RealizeDir(const String& path) return realized; } -bool LocalHost::SaveFile(const String& path, const String& data) -{ - return ::SaveFile(path, data); -} - -String LocalHost::LoadFile(const String& path) -{ - return ::LoadFile(path); -} - -int LocalHost::Execute(const char *cmdline) +int Host::Execute(const char *cmdline) { if(cmdout) *cmdout << cmdline << '\n'; @@ -110,7 +77,7 @@ int LocalHost::Execute(const char *cmdline) return q; } -int LocalHost::ExecuteWithInput(const char *cmdline, bool noconvert) +int Host::ExecuteWithInput(const char *cmdline, bool noconvert) { if(cmdout) *cmdout << cmdline << '\n'; @@ -120,7 +87,7 @@ int LocalHost::ExecuteWithInput(const char *cmdline, bool noconvert) return q; } -int LocalHost::Execute(const char *cmdline, Stream& out, bool noconvert) +int Host::Execute(const char *cmdline, Stream& out, bool noconvert) { PutVerbose(cmdline); int q = IdeConsoleExecute(FindCommand(exedirs, cmdline), &out, environment, true, noconvert); @@ -128,47 +95,46 @@ int LocalHost::Execute(const char *cmdline, Stream& out, bool noconvert) return q; } -int LocalHost::AllocSlot() +int Host::AllocSlot() { return IdeConsoleAllocSlot(); } -bool LocalHost::Run(const char *cmdline, int slot, String key, int blitz_count) +bool Host::Run(const char *cmdline, int slot, String key, int blitz_count) { return IdeConsoleRun(FindCommand(exedirs, cmdline), NULL, environment, false, slot, key, blitz_count); } -bool LocalHost::Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count) +bool Host::Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count) { return IdeConsoleRun(FindCommand(exedirs, cmdline), &out, environment, true, slot, key, blitz_count); } -bool LocalHost::Wait() +bool Host::Wait() { return IdeConsoleWait(); } -bool LocalHost::Wait(int slot) +bool Host::Wait(int slot) { return IdeConsoleWait(slot); } -void LocalHost::OnFinish(Event<> cb) +void Host::OnFinish(Event<> cb) { IdeConsoleOnFinish(cb); } -One LocalHost::StartProcess(const char *cmdline) +bool Host::StartProcess(LocalProcess& p, const char *cmdline) { try { PutVerbose(cmdline); - One p; - if(p.Create().Start(FindCommand(exedirs, cmdline), environment)) - return p; + if(p.Start(FindCommand(exedirs, cmdline), environment)) + return true; } catch(...) { } - return NULL; + return false; } #ifdef PLATFORM_POSIX @@ -201,7 +167,7 @@ String HostConsole = "powershell.exe"; String HostConsole = "/usr/bin/xterm -e"; #endif -void LocalHost::Launch(const char *_cmdline, bool console) +void Host::Launch(const char *_cmdline, bool console) { String cmdline = FindCommand(exedirs, _cmdline); PutVerbose(cmdline); @@ -319,7 +285,7 @@ void LocalHost::Launch(const char *_cmdline, bool console) #endif } -void LocalHost::AddFlags(Index& cfg) +void Host::AddFlags(Index& cfg) { if(HasPlatformFlag(cfg)) return; @@ -373,12 +339,12 @@ void LocalHost::AddFlags(Index& cfg) #endif } -const Vector& LocalHost::GetExecutablesDirs() const +const Vector& Host::GetExecutablesDirs() const { return exedirs; } -bool LocalHost::HasPlatformFlag(const Index& cfg) +bool Host::HasPlatformFlag(const Index& cfg) { static const Index platformFlags = { "WIN32", "POSIX", "LINUX", "ANDROID", @@ -392,13 +358,3 @@ bool LocalHost::HasPlatformFlag(const Index& cfg) return false; } - -#if 0 -static bool IsSamePath(const char *a, const char *b, int count) { - for(; --count >= 0; a++, b++) - if(a != b && ToLower(*a) != ToLower(*b) && !((*a == '\\' || *a == '/') && (*b == '\\' || *b == '/'))) - return false; - return true; -} - -#endif diff --git a/uppsrc/ide/Core/Host.h b/uppsrc/ide/Core/Host.h index a583fd30a..8abf63cf4 100644 --- a/uppsrc/ide/Core/Host.h +++ b/uppsrc/ide/Core/Host.h @@ -2,119 +2,43 @@ enum { REMOTE_TIMEOUT = 2000 }; extern String HostConsole; -class Host { -public: - virtual ~Host() {} - +struct Host : LocalProcess { struct FileInfo : Time, Moveable { int length; }; - - virtual String GetEnvironment() = 0; - virtual String GetHostPath(const String& path) = 0; - virtual String GetLocalPath(const String& path) = 0; - virtual String NormalizePath(const String& path) = 0; - virtual String NormalizeExecutablePath(const String& path) = 0; - virtual Vector GetFileInfo(const Vector& path) = 0; - virtual void DeleteFile(const Vector& path) = 0; - virtual void DeleteFolderDeep(const String& dir) = 0; - virtual void ChDir(const String& path) = 0; - virtual bool RealizeDir(const String& path) = 0; - virtual bool SaveFile(const String& path, const String& data) = 0; - virtual String LoadFile(const String& path) = 0; - virtual int Execute(const char *cmdline) = 0; - virtual int ExecuteWithInput(const char *cmdline, bool noconvert) = 0; - virtual int Execute(const char *cmdline, Stream& out, bool noconvert = false) = 0; - virtual int AllocSlot() = 0; - virtual bool Run(const char *cmdline, int slot, String key, int blitz_count) = 0; - virtual bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count) = 0; - virtual bool Wait() = 0; - virtual bool Wait(int slot) = 0; - virtual void OnFinish(Event<> cb) = 0; - virtual One StartProcess(const char *cmdline) = 0; - virtual void Launch(const char *cmdline, bool console = false) = 0; - virtual void AddFlags(Index& cfg) = 0; - - virtual const Vector& GetExecutablesDirs() const = 0; -}; -class LocalHost : public Host { -public: Vector exedirs; String environment; String *cmdout; + + String onefile; // support for Ctrl+F7 - build single file + void DoDir(const String& s); -public: /* Host */ - LocalHost(); + Host(); - String GetEnvironment() override; - String GetHostPath(const String& path) override; - String GetLocalPath(const String& path) override; - String NormalizePath(const String& path) override; - String NormalizeExecutablePath(const String& path) override; - Vector GetFileInfo(const Vector& path) override; - void DeleteFile(const Vector& path) override; - void DeleteFolderDeep(const String& dir) override; - void ChDir(const String& path) override; - bool RealizeDir(const String& path) override; - bool SaveFile(const String& path, const String& data) override; - String LoadFile(const String& path) override; - int Execute(const char *cmdline) override; - int ExecuteWithInput(const char *cmdline, bool noconvert) override; - int Execute(const char *cmdline, Stream& out, bool noconvert = false) override; - int AllocSlot() override; - bool Run(const char *cmdline, int slot, String key, int blitz_count) override; - bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count) override; - bool Wait() override; - bool Wait(int slot) override; - void OnFinish(Event<> cb) override; - One StartProcess(const char *cmdline) override; - void Launch(const char *cmdline, bool console) override; - void AddFlags(Index& cfg) override; + String GetEnvironment(); + Vector GetFileInfo(const Vector& path); + + void ChDir(const String& path); + bool RealizeDir(const String& path); + + int Execute(const char *cmdline); + int ExecuteWithInput(const char *cmdline, bool noconvert); + int Execute(const char *cmdline, Stream& out, bool noconvert = false); + int AllocSlot(); + bool Run(const char *cmdline, int slot, String key, int blitz_count); + bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count); + bool Wait(); + bool Wait(int slot); + void OnFinish(Event<> cb); + bool StartProcess(LocalProcess& p, const char *cmdline); + void Launch(const char *cmdline, bool console = false); + void AddFlags(Index& cfg); - const Vector& GetExecutablesDirs() const override; + const Vector& GetExecutablesDirs() const; private: bool HasPlatformFlag(const Index& cfg); }; - -/* -struct RemoteHost : Host { - String host; - int port; - String os_type; -// bool transfer_files; - Vector path_map_local; - Vector path_map_remote; - String chdir_path; - String environment; - - static Time TimeBase() { return Time(2000, 1, 1); } - - virtual String GetEnvironment(); - virtual String GetHostPath(const String& path); - virtual String GetLocalPath(const String& path); - virtual String NormalizePath(const String& path); - virtual Vector GetFileInfo(const Vector& path); - virtual void DeleteFile(const Vector& path); - virtual void DeleteFolderDeep(const String& dir); - virtual void ChDir(const String& path); - virtual void RealizeDir(const String& path); - virtual void SaveFile(const String& path, const String& data); - virtual String LoadFile(const String& path); - virtual int Execute(const char *cmdline); - virtual int ExecuteWithInput(const char *cmdline); - virtual int Execute(const char *cmdline, Stream& out); - virtual int AllocSlot(); - virtual bool Run(const char *cmdline, int slot, String key, int blitz_count); - virtual bool Run(const char *cmdline, Stream& out, int slot, String key, int blitz_count); - virtual bool Wait(); - virtual One StartProcess(const char *cmdline); - virtual void Launch(const char *cmdline, bool console); - virtual void AddFlags(Index& cfg); - - String RemoteExec(String cmd); -}; -*/ \ No newline at end of file diff --git a/uppsrc/urepo/Credentials.cpp b/uppsrc/ide/Credentials.cpp similarity index 93% rename from uppsrc/urepo/Credentials.cpp rename to uppsrc/ide/Credentials.cpp index 824a38ebe..983296bb6 100644 --- a/uppsrc/urepo/Credentials.cpp +++ b/uppsrc/ide/Credentials.cpp @@ -1,6 +1,4 @@ -#include "urepo.h" - -namespace Upp { +#include "ide.h" String GetSvnDir(const String& p) { @@ -81,5 +79,3 @@ void EditCredentials(RepoSync& rs) dlg.GetResults(); } } - -}; \ No newline at end of file diff --git a/uppsrc/ide/Debug.cpp b/uppsrc/ide/Debug.cpp index 0e63db996..4172a0ae0 100644 --- a/uppsrc/ide/Debug.cpp +++ b/uppsrc/ide/Debug.cpp @@ -105,14 +105,13 @@ void Ide::RunArgs() { } } -One Ide::CreateHostRunDir() +void Ide::CreateHostRunDir(Host& h) { - One h = CreateHost(darkmode, disable_uhd); + CreateHost(h, darkmode, disable_uhd); if(IsNull(rundir)) - h->ChDir(GetFileFolder(target)); + h.ChDir(GetFileFolder(target)); else - h->ChDir(rundir); - return h; + h.ChDir(rundir); } bool Ide::ShouldHaveConsole() @@ -135,24 +134,25 @@ void Ide::BuildAndExecute() void Ide::ExecuteBinary() { int time = msecs(); - One h = CreateHostRunDir(); - h->ChDir(Nvl(rundir, GetFileFolder(target))); + Host h; + CreateHostRunDir(h); + h.ChDir(Nvl(rundir, GetFileFolder(target))); String cmdline; if(!runexternal) - cmdline << '\"' << h->GetHostPath(target) << "\" "; + cmdline << '\"' << target << "\" "; cmdline << ToSystemCharset(runarg); int exitcode; switch(runmode) { case RUN_WINDOW: HideBottom(); - h->Launch(cmdline, ShouldHaveConsole()); + h.Launch(cmdline, ShouldHaveConsole()); break; case RUN_CONSOLE: ShowConsole(); PutConsole(String().Cat() << "Executing: " << cmdline); console.Sync(); - exitcode = h->ExecuteWithInput(cmdline, console_utf8); + exitcode = h.ExecuteWithInput(cmdline, console_utf8); PutConsole("Finished in " + GetPrintTime(time) + ", exit code: " + AsString(exitcode)); break; case RUN_FILE: { @@ -167,7 +167,7 @@ void Ide::ExecuteBinary() PromptOK("Unable to open output file [* " + DeQtf(stdout_file) + "] !"); return; } - if(h->Execute(cmdline, out, console_utf8) >= 0) { + if(h.Execute(cmdline, out, console_utf8) >= 0) { out.Close(); EditFile(fn); } @@ -177,16 +177,17 @@ void Ide::ExecuteBinary() void Ide::LaunchTerminal(const char *dir) { - One h = CreateHost(false, false); - h->ChDir(dir); + Host h; + CreateHost(h, false, false); + h.ChDir(dir); #ifdef PLATFORM_WIN32 - h->Launch(Nvl(HostConsole, "powershell.exe"), false); + h.Launch(Nvl(HostConsole, "powershell.exe"), false); #else String c = HostConsole; int q = c.Find(' '); if(q >= 0) c.Trim(q); - h->Launch(Nvl(c, "/usr/bin/xterm"), false); + h.Launch(Nvl(c, "/usr/bin/xterm"), false); #endif } @@ -260,27 +261,29 @@ void Ide::ExecuteApk() if(!select.GetDeviceCount()) return; - One host = CreateHost(darkmode, disable_uhd); + Host host; + CreateHost(host, darkmode, disable_uhd); Apk apk(target, sdk); String packageName = apk.FindPackageName(); String activityName = apk.FindLaunchableActivity(); Adb adb = sdk.MakeAdb(); adb.SetSerial(select.GetSelectedSerial()); - host->Execute(adb.MakeInstallCmd(target)); + host.Execute(adb.MakeInstallCmd(target)); if(!packageName.IsEmpty() && !activityName.IsEmpty()) - host->Execute(adb.MakeLaunchOnDeviceCmd(packageName, activityName)); + host.Execute(adb.MakeLaunchOnDeviceCmd(packageName, activityName)); } void Ide::BuildAndDebug0(const String& srcfile) { if(Build()) { - One h = CreateHostRunDir(); - h->ChDir(GetFileFolder(target)); + Host h; + CreateHostRunDir(h); + h.ChDir(GetFileFolder(target)); VectorMap bm = GetMethodVars(method); String dbg = Nvl(bm.Get("DEBUGGER", Null), "gdb"); - h->Launch('\"' + dbg + "\" \"" + h->GetHostPath(target) + "\"", true); + h.Launch('\"' + dbg + "\" \"" + target + "\"", true); } } @@ -294,10 +297,10 @@ void Ide::BuildAndExtDebugFile() BuildAndDebug0(editfile); } -One GdbCreate(One&& host, const String& exefile, const String& cmdline, bool console); +One GdbCreate(Host& host, const String& exefile, const String& cmdline, bool console); #ifdef PLATFORM_WIN32 -One PdbCreate(One&& host, const String& exefile, const String& cmdline, bool clang); +One PdbCreate(Host& host, const String& exefile, const String& cmdline, bool clang); #endif void Ide::BuildAndDebug(bool runto) @@ -317,8 +320,9 @@ void Ide::BuildAndDebug(bool runto) return; if(designer && !editfile_isfolder) EditAsText(); - One host = CreateHostRunDir(); - host->ChDir(Nvl(rundir, GetFileFolder(target))); + Host host; + CreateHostRunDir(host); + host.ChDir(Nvl(rundir, GetFileFolder(target))); HideBottom(); editor.Disable(); @@ -326,10 +330,10 @@ void Ide::BuildAndDebug(bool runto) #ifdef PLATFORM_WIN32 if(findarg(builder, "GCC") < 0) // llvm-mingw can generate pdb symbolic info - debugger = PdbCreate(pick(host), target, runarg, builder == "CLANG"); + debugger = PdbCreate(host, target, runarg, builder == "CLANG"); else #endif - debugger = GdbCreate(pick(host), target, runarg, console); + debugger = GdbCreate(host, target, runarg, console); if(!debugger) { IdeEndDebug(); @@ -426,9 +430,11 @@ void Ide::ConditionalBreak() String brk = editor.GetBreakpoint(ln); if(brk == "\xe") brk = "1"; - - Index cfg = PackageConfig(IdeWorkspace(), 0, GetMethodVars(method), mainconfigparam, - *CreateHost(darkmode, disable_uhd), *CreateBuilder(~CreateHostRunDir())); + + Host h; + CreateHost(h, darkmode, disable_uhd); + Index cfg = PackageConfig(IdeWorkspace(), 0, GetMethodVars(method), mainconfigparam, h, + *CreateBuilder(&h)); #ifdef PLATFORM_WIN32 if(cfg.Find("MSC") >= 0) { if(EditPDBExpression("Conditional breakpoint", brk, NULL)) diff --git a/uppsrc/ide/Debuggers/Gdb.cpp b/uppsrc/ide/Debuggers/Gdb.cpp index c03388779..d92a6ddcc 100644 --- a/uppsrc/ide/Debuggers/Gdb.cpp +++ b/uppsrc/ide/Debuggers/Gdb.cpp @@ -136,9 +136,9 @@ int CharFilterReSlash(int c) return c == '\\' ? '/' : c; } -String Bpoint(Host& host, const String& file, int line) +String Bpoint(const String& file, int line) { - return String().Cat() << Filter(host.GetHostPath(NormalizePath(file)), CharFilterReSlash) << ":" << line + 1; + return String().Cat() << Filter(NormalizePath(file), CharFilterReSlash) << ":" << line + 1; } bool Gdb::TryBreak(const char *text) @@ -156,7 +156,7 @@ bool Gdb::SetBreakpoint(const String& filename, int line, const String& bp) return true; } - String bi = Bpoint(*host, filename, line); + String bi = Bpoint(filename, line); String command; if(bp.IsEmpty()) @@ -230,7 +230,7 @@ bool ParsePos(const String& s, String& fn, int& line, adr_t & adr) void Gdb::CheckEnd(const char *s) { - if(!dbg) { + if(!dbg.IsRunning()) { Stop(); return; } @@ -270,9 +270,9 @@ String Gdb::Cmdp(const char *cmdline, bool fr, bool setframe) } if(ParsePos(s, file, line, addr)) { - IdeSetDebugPos(GetLocalPath(file), line - 1, fr ? DbgImg::FrameLinePtr() - : DbgImg::IpLinePtr(), 0); - IdeSetDebugPos(GetLocalPath(file), line - 1, + IdeSetDebugPos(file, line - 1, fr ? DbgImg::FrameLinePtr() + : DbgImg::IpLinePtr(), 0); + IdeSetDebugPos(file, line - 1, disas.HasFocus() ? fr ? DbgImg::FrameLinePtr() : DbgImg::IpLinePtr() : Image(), 1); SyncDisas(fr); @@ -303,7 +303,7 @@ String Gdb::Cmdp(const char *cmdline, bool fr, bool setframe) SyncFrameButtons(); } - if (dbg->IsRunning()) { + if (dbg.IsRunning()) { if (IsProcessExitedNormally(s)) Stop(); else { @@ -430,7 +430,7 @@ bool Gdb::RunTo() bi = Sprintf("*0x%X", disas.GetCursor()); } else - bi = Bpoint(*host, IdeGetFileName(), IdeGetFileLine()); + bi = Bpoint(IdeGetFileName(), IdeGetFileLine()); if(!TryBreak("b " + bi)) { Exclamation("No code at chosen location!"); return false; @@ -593,14 +593,11 @@ bool Gdb::Key(dword key, int count) return Ctrl::Key(key, count); } -bool Gdb::Create(One&& _host, const String& exefile, const String& cmdline, bool console) +bool Gdb::Create(Host& host, const String& exefile, const String& cmdline, bool console) { - host = pick(_host); - - String gdb_command = GdbCommand(console) + host->NormalizeExecutablePath(exefile); - dbg = host->StartProcess(gdb_command); + String gdb_command = GdbCommand(console) + NormalizeExePath(exefile); - if (!dbg) { + if(!host.StartProcess(dbg, gdb_command)) { Loge() << METHOD_NAME << "Failed to launch gdb (\"" << gdb_command << "\")."; ErrorOK("Error while invoking gdb! For details check TheIDE logs."); @@ -780,10 +777,10 @@ Gdb::Gdb() pane.Add(nodebuginfo_bg); } -One GdbCreate(One&& host, const String& exefile, const String& cmdline, bool console) +One GdbCreate(Host& host, const String& exefile, const String& cmdline, bool console) { auto dbg = MakeOne(); - if(!dbg->Create(pick(host), exefile, cmdline, console)) + if(!dbg->Create(host, exefile, cmdline, console)) return nullptr; return pick(dbg); // CLANG does not like this without pick } diff --git a/uppsrc/ide/Debuggers/Gdb.h b/uppsrc/ide/Debuggers/Gdb.h index 34d763a8e..f6d53e35c 100644 --- a/uppsrc/ide/Debuggers/Gdb.h +++ b/uppsrc/ide/Debuggers/Gdb.h @@ -23,9 +23,6 @@ public: void AddReg(const char *reg, Label *lbl) { regname.Add(reg); reglbl.Add(lbl); } - String GetHostPath(const String& path) { return host->GetHostPath(path); } - String GetLocalPath(const String& path) { return host->GetLocalPath(path); } - void Lock(); void Unlock(); @@ -94,7 +91,7 @@ public: void BreakRunning(); - bool Create(One&& host, const String& exefile, const String& cmdline, bool console); + bool Create(Host& host, const String& exefile, const String& cmdline, bool console); TimeCallback periodic; // Period check for killed console void Periodic(); @@ -105,8 +102,7 @@ public: Gdb(); protected: - One host; - One dbg; + LocalProcess dbg; Vector regname; Vector