Skip to content

Commit 945715f

Browse files
authored
Support the nmakeobj path and the standard intermediate output path for compile_commands.json on Windows. (#322)
1 parent f20d4dc commit 945715f

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/jit-format/jit-format.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,22 @@ private void validate()
231231
// If the user didn't specify a compile_commands.json, we need to see if one exists, and if not, create it.
232232
if (!_untidy && _compileCommands == null)
233233
{
234-
string[] compileCommandsPath = { _rootPath, "..", "..", "artifacts", "nmakeobj", _os + "." + _arch + "." + _build, "compile_commands.json" };
235-
_compileCommands = Path.Combine(compileCommandsPath);
234+
// Check both the nmakeobj and obj paths for back-compat with the old Ninja/NMake output dir.
235+
string[] nmakeObjCompileCommandsPathSegments = { _rootPath, "..", "..", "artifacts", "nmakeobj", _os + "." + _arch + "." + _build, "compile_commands.json" };
236+
string[] compileCommandsPathSegments = { _rootPath, "..", "..", "artifacts", "obj", "coreclr", _os + "." + _arch + "." + _build, "compile_commands.json" };
237+
string nmakeObjCompileCommands = Path.Combine(nmakeObjCompileCommandsPathSegments);
238+
string compileCommandsPath = Path.Combine(compileCommandsPathSegments);
236239
_rewriteCompileCommands = true;
237240

238-
if (!File.Exists(_compileCommands))
241+
if (File.Exists(compileCommandsPath))
242+
{
243+
_compileCommands = compileCommandsPath;
244+
}
245+
else if (File.Exists(nmakeObjCompileCommands))
246+
{
247+
_compileCommands = nmakeObjCompileCommands;
248+
}
249+
else
239250
{
240251
// We haven't done a build, so we need to do one.
241252
if (_verbose)
@@ -258,6 +269,20 @@ private void validate()
258269
Console.WriteLine("There was an error running CMake to generate compile_commands.json. Please do a full build to generate a build log.");
259270
Environment.Exit(-1);
260271
}
272+
273+
if (File.Exists(compileCommandsPath))
274+
{
275+
_compileCommands = compileCommandsPath;
276+
}
277+
else if (File.Exists(nmakeObjCompileCommands))
278+
{
279+
_compileCommands = nmakeObjCompileCommands;
280+
}
281+
else
282+
{
283+
Console.WriteLine("CMake ran successfully, but no compile_commmands.json was generated.");
284+
Environment.Exit(-1);
285+
}
261286
}
262287
}
263288
}

0 commit comments

Comments
 (0)