diff --git a/src/jit-format/jit-format.cs b/src/jit-format/jit-format.cs index 3fa2b548..f7e736d5 100644 --- a/src/jit-format/jit-format.cs +++ b/src/jit-format/jit-format.cs @@ -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) @@ -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); + } } } }