diff --git a/reference/build_info/build_info.cpp b/reference/build_info/build_info.cpp index 4d8e2b4cc..7598b4f1d 100644 --- a/reference/build_info/build_info.cpp +++ b/reference/build_info/build_info.cpp @@ -19,6 +19,9 @@ CONSOLE_APP_MAIN #ifdef bmSVN_REVISION LOG("Svn revision " << bmSVN_REVISION); #endif +#ifdef bmGIT_REVCOUNT + LOG("Git revcount " << bmGIT_REVCOUNT); +#endif #ifdef bmSVN_URL LOG("Svn url " << bmSVN_URL); #endif diff --git a/uppsrc/ide/About.cpp b/uppsrc/ide/About.cpp index 6774b7e9f..a7fea4a1f 100644 --- a/uppsrc/ide/About.cpp +++ b/uppsrc/ide/About.cpp @@ -57,9 +57,11 @@ String SplashCtrl::GenerateVersionNumber() { #ifdef bmSVN_REVISION return bmSVN_REVISION; -#else - return IDE_VERSION; #endif +#ifdef bmGIT_REVCOUNT + return AsString(atoi(bmGIT_REVCOUNT) + 2270); +#endif + return IDE_VERSION; } Size SplashCtrl::MakeLogo(Ctrl& parent, Array& ctrl) diff --git a/uppsrc/ide/Builders/Builders.h b/uppsrc/ide/Builders/Builders.h index dfbe23876..cc2dfebb6 100644 --- a/uppsrc/ide/Builders/Builders.h +++ b/uppsrc/ide/Builders/Builders.h @@ -12,7 +12,7 @@ void PutCompileTime(int time, int count); String BrcToC(CParser& binscript, String basedir); -Vector SvnInfo(const String& package); +Vector RepoInfo(const String& package); String MakeIdent(const char *name); diff --git a/uppsrc/ide/Builders/CppBuilder.cpp b/uppsrc/ide/Builders/CppBuilder.cpp index 8cf590460..3a3b3577f 100644 --- a/uppsrc/ide/Builders/CppBuilder.cpp +++ b/uppsrc/ide/Builders/CppBuilder.cpp @@ -476,28 +476,12 @@ String CppBuilder::Includes(const char *sep, const String& package, const Packag return cc; } -bool IsSvnDir2(const String& p) -{ // this is a cope of usvn/IsSvnDir to avoid modular issues - if(IsNull(p)) - return false; - if(DirectoryExists(AppendFileName(p, ".svn")) || DirectoryExists(AppendFileName(p, "_svn"))) - return true; - String path = p; - String path0; - while(path != path0) { - path0 = path; - path = GetFileFolder(path); - if(DirectoryExists(AppendFileName(path, ".svn"))) - return true; - } - return false; -} - -Vector SvnInfo(const String& package) +Vector RepoInfo(const String& package) { Vector info; String d = GetFileFolder(PackagePath(package)); - if(IsSvnDir2(d)) { + int repo = GetRepoKind(d); + if(repo == SVN_DIR) { String v = Sys("svnversion " + d); if(IsDigit(*v)) info.Add("#define bmSVN_REVISION " + AsCString(TrimBoth(v))); @@ -511,6 +495,11 @@ Vector SvnInfo(const String& package) } } } + if(repo == GIT_DIR) { + String v = Sys("git rev-list --count HEAD"); + if(IsDigit(*v)) + info.Add("#define bmGIT_REVCOUNT " + AsCString(TrimBoth(v))); + } return info; } @@ -532,7 +521,7 @@ void CppBuilder::SaveBuildInfo(const String& package) info << "#define bmUSER " << AsCString(GetUserName()) << "\r\n"; if(package == mainpackage) - info << Join(SvnInfo(package), "\r\n"); + info << Join(RepoInfo(package), "\r\n"); } String CppBuilder::DefinesTargetTime(const char *sep, const String& package, const Package& pkg) diff --git a/uppsrc/ide/Builders/MakeFile.cpp b/uppsrc/ide/Builders/MakeFile.cpp index 00020b102..c28d35838 100644 --- a/uppsrc/ide/Builders/MakeFile.cpp +++ b/uppsrc/ide/Builders/MakeFile.cpp @@ -363,7 +363,7 @@ void MakeBuild::SaveMakeFile(const String& fn, bool exporting) String svn_info; String build_info = "\"$(UPPOUT)/build_info.h\""; if(makefile_svn_revision) { - Vector bi = SvnInfo(wspc[i]); + Vector bi = RepoInfo(wspc[i]); for(int i = 0; i < bi.GetCount(); i++) svn_info << " echo '" << bi[i] << "' >> " << build_info << "\n"; } diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index f78ec5f18..4018a525d 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -560,4 +560,9 @@ void DeletePCHFiles(); String GetLineEndings(const String& data, const String& default_eol = "\r\n"); +enum { NOT_REPO_DIR = 0, SVN_DIR, GIT_DIR }; + +int GetRepoKind(const String& p); +int GetRepo(String& path); + #endif \ No newline at end of file diff --git a/uppsrc/ide/Core/Core.upp b/uppsrc/ide/Core/Core.upp index 9375a1efc..e66ad6de8 100644 --- a/uppsrc/ide/Core/Core.upp +++ b/uppsrc/ide/Core/Core.upp @@ -18,6 +18,7 @@ file Workspace.cpp, usc.cpp, BinObj.cpp, + Util.cpp, Host readonly separator, Host.h, Host.cpp, diff --git a/uppsrc/ide/Core/Util.cpp b/uppsrc/ide/Core/Util.cpp new file mode 100644 index 000000000..e6ea0d3ff --- /dev/null +++ b/uppsrc/ide/Core/Util.cpp @@ -0,0 +1,26 @@ +#include "Core.h" + +int GetRepo(String& path) +{ + if(IsNull(path)) + return NOT_REPO_DIR; + if(DirectoryExists(AppendFileName(path, ".svn")) || DirectoryExists(AppendFileName(path, "_svn"))) + return SVN_DIR; + for(;;) { + if(DirectoryExists(AppendFileName(path, ".git"))) + return GIT_DIR; + if(DirectoryExists(AppendFileName(path, ".svn"))) + return SVN_DIR; + String path0 = path; + path = GetFileFolder(path); + if(path == path0) + break; + } + return NOT_REPO_DIR; +} + +int GetRepoKind(const String& p) +{ + String pp = p; + return GetRepo(pp); +} diff --git a/uppsrc/ide/LayDes/laylib.cpp b/uppsrc/ide/LayDes/laylib.cpp index 43f4a5429..7b791fc3c 100644 --- a/uppsrc/ide/LayDes/laylib.cpp +++ b/uppsrc/ide/LayDes/laylib.cpp @@ -311,7 +311,8 @@ void LayLib() global.Add("SColorHighlight", EscColor(SColorHighlight)); global.Add("IntNull", (int)Null); - global.Add("DblNullLim", DOUBLE_NULL_LIM); + global.Add("DblNull", (double)Null); + global.Add("DblNullLim", -1e307); } void EscDraw::DrawRect(EscEscape& e) diff --git a/uppsrc/ide/RepoSync.cpp b/uppsrc/ide/RepoSync.cpp index fba0e2dcc..69476feb0 100644 --- a/uppsrc/ide/RepoSync.cpp +++ b/uppsrc/ide/RepoSync.cpp @@ -558,27 +558,3 @@ String RepoSync::GetMsgs() { return Garble(StoreAsString(*this)); } - -int GetRepo(String& path) -{ - if(IsNull(path)) - return NOT_REPO_DIR; - if(DirectoryExists(AppendFileName(path, ".svn")) || DirectoryExists(AppendFileName(path, "_svn"))) - return SVN_DIR; - String path0; - while(path != path0) { - path0 = path; - if(DirectoryExists(AppendFileName(path, ".git"))) - return GIT_DIR; - if(DirectoryExists(AppendFileName(path, ".svn"))) - return SVN_DIR; - DirectoryUp(path); - } - return NOT_REPO_DIR; -} - -int GetRepoKind(const String& p) -{ - String pp = p; - return GetRepo(pp); -} diff --git a/uppsrc/ide/urepo.h b/uppsrc/ide/urepo.h index 3b8482b7a..8726c98c5 100644 --- a/uppsrc/ide/urepo.h +++ b/uppsrc/ide/urepo.h @@ -26,10 +26,6 @@ String RepoSys(const char *cmd); String SvnCmd(const char *cmd); -enum { NOT_REPO_DIR = 0, SVN_DIR, GIT_DIR }; - -int GetRepoKind(const String& p); -int GetRepo(String& path); String GetSvnDir(const String& p); String GitCmd(const char *dir, const char *command);