jam: make compile_commands.json valid JSON
There was a comma in compile_commands.json after the last entry what
prevented from using file directly in some tools.
Test plan:
verified new compile_commands.json with "python3 -m json.tool compile_commands.json"
Change-Id: I6c2582f7285a3409d95081a93f3c05b5cc9322b9
Reviewed-on: https://review.haiku-os.org/c/buildtools/+/4671
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Diff
jam/jam.c | 2 +-
jam/make1.c | 9 +++++++++
jam/patchlevel.h | 4 ++--
3 files changed, 11 insertions(+), 4 deletions(-)
@@ -455,7 +455,7 @@
if ( globs.comp_db )
{
fprintf(globs.comp_db, "]\n");
fprintf(globs.comp_db, "\n]\n");
fclose( globs.comp_db );
}
@@ -735,6 +735,9 @@
}
static int written_compile_database_objects = 0;
void out_compile_database
(
char const * const action,
@@ -750,13 +753,17 @@
&& (strstr(action, "Cc") != NULL || strstr(action, "C++") != NULL))
{
char buffer[PATH_MAX];
if( written_compile_database_objects++ > 0 )
{
fputs(",\n", globs.comp_db);
}
fputs("{ \"directory\": \"", globs.comp_db);
out_json(getcwd(buffer, sizeof(buffer)), globs.comp_db);
fputs("\", \"command\": \"", globs.comp_db);
out_json(command, globs.comp_db);
fputs("\", \"file\": \"", globs.comp_db);
out_json(source, globs.comp_db);
fputs("\" },\n", globs.comp_db);
fputs("\" }", globs.comp_db);
}
}
@@ -1,5 +1,5 @@
#define VERSION "2.5-haiku-20211020"
#define JAMVERSYM "JAMVERSION=2.5-haiku-20211020"
#define VERSION "2.5-haiku-20211029"
#define JAMVERSYM "JAMVERSION=2.5-haiku-20211029"