Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/jit-format/jit-format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,22 @@ private void validate()
// If the user didn't specify a compile_commands.json, we need to see if one exists, and if not, create it.
if (!_untidy && _compileCommands == null)
{
string[] compileCommandsPath = { _rootPath, "..", "..", "artifacts", "nmakeobj", _os + "." + _arch + "." + _build, "compile_commands.json" };
_compileCommands = Path.Combine(compileCommandsPath);
// Check both the nmakeobj and obj paths for back-compat with the old Ninja/NMake output dir.
string[] nmakeObjCompileCommandsPathSegments = { _rootPath, "..", "..", "artifacts", "nmakeobj", _os + "." + _arch + "." + _build, "compile_commands.json" };
string[] compileCommandsPathSegments = { _rootPath, "..", "..", "artifacts", "obj", "coreclr", _os + "." + _arch + "." + _build, "compile_commands.json" };
string nmakeObjCompileCommands = Path.Combine(nmakeObjCompileCommandsPathSegments);
string compileCommandsPath = Path.Combine(compileCommandsPathSegments);
_rewriteCompileCommands = true;

if (!File.Exists(_compileCommands))
if (File.Exists(compileCommandsPath))
{
_compileCommands = compileCommandsPath;
}
else if (File.Exists(nmakeObjCompileCommands))
{
_compileCommands = nmakeObjCompileCommands;
}
else
{
// We haven't done a build, so we need to do one.
if (_verbose)
Expand All @@ -258,6 +269,20 @@ private void validate()
Console.WriteLine("There was an error running CMake to generate compile_commands.json. Please do a full build to generate a build log.");
Environment.Exit(-1);
}

if (File.Exists(compileCommandsPath))
{
_compileCommands = compileCommandsPath;
}
else if (File.Exists(nmakeObjCompileCommands))
{
_compileCommands = nmakeObjCompileCommands;
}
else
{
Console.WriteLine("CMake ran successfully, but no compile_commmands.json was generated.");
Environment.Exit(-1);
}
}
}
}
Expand Down