From a1db87ca82c141ac6170ccb6978c02408bb84b24 Mon Sep 17 00:00:00 2001 From: cxl Date: Tue, 13 Jan 2015 14:32:48 +0000 Subject: [PATCH] PCH can now be set from local menu, just like Optimize for speed git-svn-id: svn://ultimatepp.org/upp/trunk@8036 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/ide/Builders/MscBuilder.icpp | 2 +- uppsrc/ide/Core/Core.cpp | 5 +++++ uppsrc/ide/Core/Core.h | 2 ++ uppsrc/ide/UppDlg.cpp | 2 +- uppsrc/ide/UppDlg.h | 1 + uppsrc/ide/UppWspc.cpp | 17 +++++++++++++++-- uppsrc/ide/ide.upp | 3 +-- 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/uppsrc/ide/Builders/MscBuilder.icpp b/uppsrc/ide/Builders/MscBuilder.icpp index 2174aa554..6404b2d95 100644 --- a/uppsrc/ide/Builders/MscBuilder.icpp +++ b/uppsrc/ide/Builders/MscBuilder.icpp @@ -310,7 +310,7 @@ bool MscBuilder::BuildPackage(const String& package, Vector& linkfile, V if(ext == ".lib") linkfile.Add(fn); else - if(findarg(ext, ".h", ".hpp", ".hh", ".hxx") >= 0 && pkg[i].pch && allow_pch && IsMsc89() && release && !HasAnyDebug() && !blitz) { + if(IsHeaderExt(ext) >= 0 && pkg[i].pch && allow_pch && IsMsc89() && release && !HasAnyDebug() && !blitz) { if(pch_header.GetCount()) PutConsole(GetFileName(fn) + ": multiple PCH is not allowed. Check your package configuration"); else diff --git a/uppsrc/ide/Core/Core.cpp b/uppsrc/ide/Core/Core.cpp index 83870f822..41ef3e6c0 100644 --- a/uppsrc/ide/Core/Core.cpp +++ b/uppsrc/ide/Core/Core.cpp @@ -91,6 +91,11 @@ void PutVerbose(const char *s) { if(the_ide) the_ide->PutVerbose(s); } void PutLinking() { if(the_ide) the_ide->PutLinking(); } void PutLinkingEnd(bool ok) { if(the_ide) the_ide->PutLinkingEnd(ok); } +bool IsHeaderExt(const String& ext) +{ + return findarg(ext, ".h", ".hpp", ".hh", ".hxx") >= 0; +} + const Workspace& GetIdeWorkspace() { if(the_ide) diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index d76182632..2db390151 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -431,6 +431,8 @@ bool HdependBlitzApproved(const String& path); const Vector& HdependGetDefines(const String& path); const Vector& HdependGetAllFiles(); +bool IsHeaderExt(const String& ext); + class BinObjInfo { public: BinObjInfo(); diff --git a/uppsrc/ide/UppDlg.cpp b/uppsrc/ide/UppDlg.cpp index 3f53a8d5c..f0a4e5b66 100644 --- a/uppsrc/ide/UppDlg.cpp +++ b/uppsrc/ide/UppDlg.cpp @@ -373,7 +373,7 @@ void PackageEditor::FileCursor() String p = GetActiveFilePath(); String ext = ToLower(GetFileExt(p)); bool tpp = ext == ".tpp" && IsFolder(p); - bool hdr = findarg(ext, ".h", ".hpp", ".hh", ".hxx") >= 0 && !tpp; + bool hdr = IsHeaderExt(ext) && !tpp; optimize_speed_file.Enable(!tpp); optimize_speed_file <<= f.optimize_speed; pch_file.Enable(hdr); diff --git a/uppsrc/ide/UppDlg.h b/uppsrc/ide/UppDlg.h index c562d4a83..e9fa7528a 100644 --- a/uppsrc/ide/UppDlg.h +++ b/uppsrc/ide/UppDlg.h @@ -348,6 +348,7 @@ struct WorkspaceWork { void DelFile(); void RenameFile(); void ToggleFileSpeed(); + void TogglePCH(); void ToggleIncludeable(); void AddNormalUses(); diff --git a/uppsrc/ide/UppWspc.cpp b/uppsrc/ide/UppWspc.cpp index 87bd13b3c..f7adeb132 100644 --- a/uppsrc/ide/UppWspc.cpp +++ b/uppsrc/ide/UppWspc.cpp @@ -927,15 +927,20 @@ void WorkspaceWork::FileMenu(Bar& menu) if(IsActiveFile()) { menu.Separator(); String p = GetActiveFilePath(); - if(GetFileExt(p) == ".tpp" && IsFolder(p)) { + String ext = GetFileExt(p); + if(ext == ".tpp" && IsFolder(p)) { menu.Add("Includeable topic group", THISBACK(ToggleIncludeable)) .Check(FileExists(AppendFileName(p, "all.i"))); if(IsSvnDir(p)) menu.Add("Svn Synchronize " + p, THISBACK1(SyncSvnDir, p)); } - else + else { menu.Add("Optimize for speed", THISBACK(ToggleFileSpeed)) .Check(ActiveFile().optimize_speed); + if(IsHeaderExt(ext)) + menu.Add("Precompile header", THISBACK(TogglePCH)) + .Check(ActiveFile().pch); + } } FilePropertiesMenu(menu); } @@ -948,6 +953,14 @@ void WorkspaceWork::ToggleFileSpeed() } } +void WorkspaceWork::TogglePCH() +{ + if(IsActiveFile()) { + ActiveFile().pch = !ActiveFile().pch; + SaveLoadPackageNS(); + } +} + void WorkspaceWork::ToggleIncludeable() { if(IsActiveFile()) { diff --git a/uppsrc/ide/ide.upp b/uppsrc/ide/ide.upp index f2ee0ac86..81f43f59e 100644 --- a/uppsrc/ide/ide.upp +++ b/uppsrc/ide/ide.upp @@ -25,8 +25,7 @@ link(WIN32 MSC) /MAP; file IDE readonly separator, - ide.h - options() PCH, + ide.h options PCH, version.h, UppDlg.h, BaseDlg.cpp,