#include "ide.h" struct FlagsDlg : WithConfLayout { VectorMap>> code_flags; Index recognized_flags; int standard_flags; enum { CC_SET, CC_FLAG, CC_PACKAGES, CC_COUNT }; void Options(); void Flags(); void Reload(); void Get(const Package::Config& cfg) { flags <<= cfg.param; name <<= cfg.name; Flags(); } void Set(Package::Config& cfg) { cfg.param = ~flags; cfg.name = ~name; } FlagsDlg(); ~FlagsDlg(); }; void FlagsDlg::Options() { Vector flg = SplitFlags0(~~flags); String f; if(gui) f << "GUI "; if(debugcode) f << "DEBUGCODE "; for(int i = 0; i < accepts.GetCount(); i++) if(accepts.Get(i, CC_SET)) f << accepts.Get(i, CC_FLAG) << ' '; for(String s : flg) if(recognized_flags.Find(s) < 0) f << s << ' '; f.TrimEnd(" "); flags <<= f; flags.SetSelection(flags.GetLength()); } void FlagsDlg::Flags() { Index flg(pick(SplitFlags0(~~flags))); gui <<= flg.Find("GUI") >= 0; debugcode <<= flg.Find("DEBUGCODE") >= 0; for(int i = 0; i < accepts.GetCount(); i++) accepts.Set(i, CC_SET, flg.Find(~~accepts.Get(i, CC_FLAG)) >= 0); } FlagsDlg::~FlagsDlg() { StoreToGlobal([&](Stream& s) { SerializePlacement(s); }, "FlagsDlgPlacement"); } FlagsDlg::FlagsDlg() { CtrlLayoutOKCancel(*this, "Configuration flags"); Sizeable().Zoomable(); LoadFromGlobal([&](Stream& s) { SerializePlacement(s); }, "FlagsDlgPlacement"); PPInfo pp; pp.SetIncludes(TheIde()->GetCurrentIncludePath() + ";" + GetClangInternalIncludes()); const Workspace& wspc = GetIdeWorkspace(); static Index ignore_flags = { "DEBUG", "WIN32", "GUI", "DEBUGCODE", "GCC", "GCC32", "CLANG", "ANDROID", "WIN32", "POSIX", "OSX", "SO", }; for(int i = 0; i < wspc.GetCount(); i++) { // find package of included file const Package& pk = wspc.GetPackage(i); String pk_name = wspc[i]; for(int i = 0; i < pk.file.GetCount(); i++) if(!pk.file[i].separator) for(auto m : ~pp.GetFileFlags(SourcePath(pk_name, pk.file[i]))) { String f = m.key; f.TrimStart("flag"); if(ignore_flags.Find(f) < 0) { auto& fl = code_flags.GetAdd(f); fl.b.FindAdd(pk_name); String comment = m.value; if(comment.GetCount() > fl.a.GetCount()) fl.a = comment; } } } SortByKey(code_flags); Sizeable().MaximizeBox(); enum { CC_SET, CC_NAME, CC_PACKAGES, CC_COUNT }; accepts.AddColumn("Set").With([=](One& ctrl) { ctrl.Create