diff --git a/uppsrc/ide/Builders/CCJ.cpp b/uppsrc/ide/Builders/CCJ.cpp index 57efbd3e3..22bb5cc39 100644 --- a/uppsrc/ide/Builders/CCJ.cpp +++ b/uppsrc/ide/Builders/CCJ.cpp @@ -346,7 +346,7 @@ Array MakeBuild::GetCompileCommands() b->include << m; } - incs << ' ' << "-I" << b->GetPathQ(UnixPath(GetUppOut())); + incs << ' ' << "-I" << GetPathQ(UnixPath(GetUppOut())); b->cc_inc = incs; diff --git a/uppsrc/ide/ClangTidy.cpp b/uppsrc/ide/ClangTidy.cpp index 39354c728..38b45d356 100644 --- a/uppsrc/ide/ClangTidy.cpp +++ b/uppsrc/ide/ClangTidy.cpp @@ -158,29 +158,45 @@ void Ide::ClangTidy() dlg.Save(); - MakeBuild *mb = dynamic_cast(TheIdeContext()); + MakeBuild *mb = dynamic_cast(TheIdeContext()); // TODO: Move to Builders/umk if(!mb) return; Array commands = mb->GetCompileCommands(); + + String cmdline; JsonArray ccj; String outdir; for(const auto& m : commands) { - String dir = GetFileFolder(m.file); if(IsNull(outdir)) - outdir = dir; // this is as good place as any - ccj << Upp::Json("directory", dir)("command", m.command)("file", GetFileName(m.file)); + outdir = GetFileFolder(m.ofile); + ccj << Upp::Json("directory", GetFileFolder(m.file))("command", m.command)("file", GetFileName(m.file)); + cmdline << ' ' << GetPathQ(m.file); } String cc_path = outdir + "/compile_commands.json"; + RealizePath(cc_path); Upp::SaveFile(cc_path, ccj.ToString()); DDUMP(cc_path); DDUMP(ccj.ToString()); + + cmdline << " -checks=" << Join(ClangTidyDlg::active_checks.GetKeys(), ",") + << " -p " << cc_path; -/* + + String rf_path = outdir + "/clang_tidy_parameters_file"; + Upp::SaveFile(rf_path, cmdline); + + BeginBuilding(true); + Host host; + CreateHost(host, darkmode, disable_uhd); + host.Execute(ClangTidyDlg::path + " @" + rf_path); + EndBuilding(true); + SetErrorEditor(); +/* String files; for(const String& f : ResolveFiles(sc, ccjpath, paths)) path << "\"" << f << "\" "; diff --git a/uppsrc/ide/Core/Builder.cpp b/uppsrc/ide/Core/Builder.cpp index d59db7cad..27597ebd2 100644 --- a/uppsrc/ide/Core/Builder.cpp +++ b/uppsrc/ide/Core/Builder.cpp @@ -12,7 +12,7 @@ String TrimSlash(String s) return s; } -String Builder::GetPathQ(const String& path) const +String GetPathQ(const String& path) { return '\"' + TrimSlash(path) + '\"'; } diff --git a/uppsrc/ide/Core/Core.h b/uppsrc/ide/Core/Core.h index 21cd9ca34..01b82f726 100644 --- a/uppsrc/ide/Core/Core.h +++ b/uppsrc/ide/Core/Core.h @@ -607,7 +607,6 @@ struct Builder { virtual ~Builder() {} void ChDir(const String& path); - 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; @@ -616,6 +615,9 @@ struct Builder { bool HasFlag(const char *f) const { return config.Find(f) >= 0; } }; +String TrimSlash(String s); +String GetPathQ(const String& path); + VectorMap& BuilderMap(); void RegisterBuilder(const char *name, Builder *(*create)());