From 06fd6f1b3a2525c3e8cfb7382965296c5885774f Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Tue, 16 Mar 2021 11:29:55 -0700 Subject: [PATCH 1/2] Support the nmakeobj path and the standard intermediate output path for compile_commands.json on Windows. --- src/jit-format/jit-format.cs | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/jit-format/jit-format.cs b/src/jit-format/jit-format.cs index 3fa2b548..6af571be 100644 --- a/src/jit-format/jit-format.cs +++ b/src/jit-format/jit-format.cs @@ -231,11 +231,21 @@ 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); + 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 +268,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); + } } } } From 40e214c96d25f4b23b3a59067fa37ede7771e45b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 17 Mar 2021 09:23:25 -0700 Subject: [PATCH 2/2] Update src/jit-format/jit-format.cs --- src/jit-format/jit-format.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jit-format/jit-format.cs b/src/jit-format/jit-format.cs index 6af571be..f7e736d5 100644 --- a/src/jit-format/jit-format.cs +++ b/src/jit-format/jit-format.cs @@ -231,6 +231,7 @@ 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) { + // 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);