⛏️ index : buildtools.git

author Maciej Bałuta <maciejbaluta0x539@gmail.com> 2021-10-29 10:25:20.0 +00:00:00
committer Jérôme Duval <jerome.duval@gmail.com> 2021-11-03 11:48:45.0 +00:00:00
commit
19aaa7936296ae7f71cd47f0d899c6543b2629b6 [patch]
tree
212203af05d68e3016f702e889b62eeb07d37797
parent
7f682463a1bb24b2a24d0d77a4089a7f39244d1e
download
19aaa7936296ae7f71cd47f0d899c6543b2629b6.tar.gz

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(-)

diff --git a/jam/jam.c b/jam/jam.c
index 8958c2b..6edf546 100644
--- a/jam/jam.c
+++ a/jam/jam.c
@@ -455,7 +455,7 @@
	/* close compilation database output file */
	if ( globs.comp_db )
	{
		fprintf(globs.comp_db, "]\n");
		fprintf(globs.comp_db, "\n]\n");
		fclose( globs.comp_db );
	}

diff --git a/jam/make1.c b/jam/make1.c
index 906b41a..7b8ed24 100644
--- a/jam/make1.c
+++ a/jam/make1.c
@@ -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);
     }

}
diff --git a/jam/patchlevel.h b/jam/patchlevel.h
index 14e6453..1ffed6b 100644
--- a/jam/patchlevel.h
+++ a/jam/patchlevel.h
@@ -1,5 +1,5 @@
/* Keep JAMVERSYM in sync with VERSION. */
/* It can be accessed as $(JAMVERSION) in the Jamfile. */

#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"