diff --git a/uppsrc/ide/Builders/Build.cpp b/uppsrc/ide/Builders/Build.cpp index 225b1e35d..d6cccd3f4 100644 --- a/uppsrc/ide/Builders/Build.cpp +++ b/uppsrc/ide/Builders/Build.cpp @@ -267,6 +267,7 @@ struct OneFileHost : Host { 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); diff --git a/uppsrc/ide/Builders/GccBuilder.cpp b/uppsrc/ide/Builders/GccBuilder.cpp index b2b82480f..725554375 100644 --- a/uppsrc/ide/Builders/GccBuilder.cpp +++ b/uppsrc/ide/Builders/GccBuilder.cpp @@ -215,7 +215,7 @@ bool GccBuilder::BuildPackage(const String& package, Vector& linkfile, V bool execerr = false; if(rc) { String exec; - exec << "windres -i " << GetHostPathQ(fn); + exec << GetHostPathShort(FindInDirs(host->GetExecutablesDirs(), "windres.exe")) << " -i " << GetHostPathQ(fn); if(cc.Find(" -m32 ") >= 0) exec << " --target=pe-i386 "; exec << " -o " << GetHostPathQ(objfile) << IncludesShort(" --include-dir=", package, pkg) diff --git a/uppsrc/ide/Core/Builder.cpp b/uppsrc/ide/Core/Builder.cpp index b7f65bf95..af10f4924 100644 --- a/uppsrc/ide/Core/Builder.cpp +++ b/uppsrc/ide/Core/Builder.cpp @@ -13,11 +13,14 @@ String Builder::GetHostPath(const String& path) const String Builder::GetHostPathShort(const String& path) const { #ifdef PLATFORM_WIN32 - const dword SHORT_PATH_LENGTH = 2048; - char short_path[SHORT_PATH_LENGTH]; - dword length = ::GetShortPathName((LPCTSTR) path, (LPTSTR) short_path, SHORT_PATH_LENGTH); + dword length = ::GetShortPathName(static_cast(path), nullptr, 0); + if(length == 0) + return path; + Buffer shortPathBuffer(length); + length = ::GetShortPathName( + static_cast(path), static_cast(~shortPathBuffer), length); if(length > 0) - return String(short_path, length); + return String(shortPathBuffer, length); #endif return path; } diff --git a/uppsrc/ide/Core/Host.cpp b/uppsrc/ide/Core/Host.cpp index 4bfaa59a5..2388833f4 100644 --- a/uppsrc/ide/Core/Host.cpp +++ b/uppsrc/ide/Core/Host.cpp @@ -364,6 +364,11 @@ void LocalHost::AddFlags(Index& cfg) #endif } +const Vector& LocalHost::GetExecutablesDirs() const +{ + return exedirs; +} + bool LocalHost::HasPlatformFlag(const Index& cfg) { static const Index platformFlags = { diff --git a/uppsrc/ide/Core/Host.h b/uppsrc/ide/Core/Host.h index 316868041..09ce2b71d 100644 --- a/uppsrc/ide/Core/Host.h +++ b/uppsrc/ide/Core/Host.h @@ -2,35 +2,38 @@ enum { REMOTE_TIMEOUT = 2000 }; extern String LinuxHostConsole; -struct Host { +class Host { +public: + virtual ~Host() {} + 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 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 ~Host() {} + + 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 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 { @@ -41,29 +44,31 @@ public: String *cmdout; void DoDir(const String& s); - 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 bool RealizeDir(const String& path); - virtual bool 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, bool noconvert); - virtual int Execute(const char *cmdline, Stream& out, bool noconvert = false); - 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 bool Wait(int slot); - virtual void OnFinish(Event<> cb); - virtual One StartProcess(const char *cmdline); - virtual void Launch(const char *cmdline, bool console); - virtual void AddFlags(Index& cfg); +public: /* Host */ + String GetEnvironment() override; + String GetHostPath(const String& path) override; + String GetLocalPath(const String& path) override; + String NormalizePath(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; + const Vector& GetExecutablesDirs() const override; private: bool HasPlatformFlag(const Index& cfg); diff --git a/uppsrc/ide/Debuggers/Gdb.cpp b/uppsrc/ide/Debuggers/Gdb.cpp index 2edd373b2..26d938495 100644 --- a/uppsrc/ide/Debuggers/Gdb.cpp +++ b/uppsrc/ide/Debuggers/Gdb.cpp @@ -335,6 +335,8 @@ bool Gdb::Key(dword key, int count) bool Gdb::Create(One&& _host, const String& exefile, const String& cmdline, bool console) { host = pick(_host); + + // TODO: Normalize exe path should be part of the host. What about remote GDB? dbg = host->StartProcess(GdbCommand(console) + NormalizeExePath(GetHostPath(exefile))); if(!dbg) { ErrorOK("Error while invoking gdb!");