Allow "project.json5" to be used.

This commit is contained in:
Christoffer Lerno
2024-08-25 00:19:08 +02:00
parent 1ed3eab010
commit a870881fff
7 changed files with 106 additions and 95 deletions

View File

@@ -22,6 +22,7 @@
#define MAX_ARRAY_SIZE INT64_MAX
#define MAX_SOURCE_LOCATION_LEN 255
#define PROJECT_JSON "project.json"
#define PROJECT_JSON5 "project.json5"
#if defined( _WIN32 ) || defined( __WIN32__ ) || defined( _WIN64 )
#define PLATFORM_WINDOWS 1

View File

@@ -421,12 +421,13 @@ void file_find_top_dir()
while (1)
{
struct stat info;
int err = stat(PROJECT_JSON, &info);
const char *filename = file_exists(PROJECT_JSON5) ? PROJECT_JSON5 : PROJECT_JSON;
int err = stat(filename, &info);
// Error and the it's not a "missing file"?
if (err && errno != ENOENT)
{
error_exit("Can't open %s: %s.", PROJECT_JSON, strerror(errno));
error_exit("Can't open %s: %s.", filename, strerror(errno));
}
// Everything worked and it's a regular file? We're done!