diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fec54e0..7c361126 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,9 +53,6 @@ set(qjs_sources list(APPEND qjs_defines _GNU_SOURCE) -file(STRINGS "VERSION" QJS_VERSION_STR) -list(APPEND qjs_defines CONFIG_VERSION="${QJS_VERSION_STR}") - add_library(qjs STATIC ${qjs_sources}) target_compile_definitions(qjs PUBLIC QJS_VERSION_STR="${QJS_VERSION_STR}" diff --git a/Makefile b/Makefile index c2673a5c..64ebb277 100644 --- a/Makefile +++ b/Makefile @@ -112,7 +112,7 @@ STRIP=$(CROSS_PREFIX)strip ifdef CONFIG_WERROR CFLAGS+=-Werror endif -DEFINES:=-D_GNU_SOURCE -DCONFIG_VERSION=\"$(shell cat VERSION)\" +DEFINES:=-D_GNU_SOURCE ifdef CONFIG_WIN32 DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior endif diff --git a/VERSION b/VERSION deleted file mode 100644 index 22ffec18..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -2021-03-27 diff --git a/qjs.c b/qjs.c index ee6f8b58..66ff4c66 100644 --- a/qjs.c +++ b/qjs.c @@ -269,7 +269,7 @@ static const JSMallocFunctions trace_mf = { void help(void) { - printf("QuickJS version " CONFIG_VERSION "\n" + printf("QuickJS version %s\n" "usage: " PROG_NAME " [options] [file [args]]\n" "-h --help list options\n" "-e --eval EXPR evaluate EXPR\n" @@ -283,7 +283,7 @@ void help(void) " --memory-limit n limit the memory usage to 'n' bytes\n" " --stack-size n limit the stack size to 'n' bytes\n" " --unhandled-rejection dump unhandled promise rejections\n" - "-q --quit just instantiate the interpreter and quit\n"); + "-q --quit just instantiate the interpreter and quit\n", JS_GetVersion()); exit(1); } diff --git a/qjsc.c b/qjsc.c index 381c8edc..19cbc2be 100644 --- a/qjsc.c +++ b/qjsc.c @@ -339,7 +339,7 @@ static const char main_c_template2[] = void help(void) { - printf("QuickJS Compiler version " CONFIG_VERSION "\n" + printf("QuickJS Compiler version %s\n" "usage: " PROG_NAME " [options] [files]\n" "\n" "options are:\n" @@ -353,6 +353,7 @@ void help(void) "-x byte swapped output\n" "-p prefix set the prefix of the generated C names\n" "-S n set the maximum stack size to 'n' bytes (default=%d)\n", + JS_GetVersion(), JS_DEFAULT_STACK_SIZE); #ifdef CONFIG_LTO { diff --git a/quickjs.c b/quickjs.c index da7f60ab..88eff066 100644 --- a/quickjs.c +++ b/quickjs.c @@ -107,6 +107,19 @@ #include #endif +#define STRINGIFY_(x) #x +#define STRINGIFY(x) STRINGIFY_(x) + +#define QJS_VERSION_STRING \ + STRINGIFY(QJS_VERSION_MAJOR) "." STRINGIFY(QJS_VERSION_MINOR) "." STRINGIFY(QJS_VERSION_PATCH) QJS_VERSION_SUFFIX + +const char* JS_GetVersion(void) { + return QJS_VERSION_STRING; +} + +#undef STRINFIGY_ +#undef STRINGIFY + enum { /* classid tag */ /* union usage | properties */ JS_CLASS_OBJECT = 1, /* must be first */ @@ -5920,9 +5933,8 @@ void JS_ComputeMemoryUsage(JSRuntime *rt, JSMemoryUsage *s) void JS_DumpMemoryUsage(FILE *fp, const JSMemoryUsage *s, JSRuntime *rt) { - fprintf(fp, "QuickJS memory usage -- " - CONFIG_VERSION " version, %d-bit, malloc limit: %"PRId64"\n\n", - (int)sizeof(void *) * 8, (int64_t)(ssize_t)s->malloc_limit); + fprintf(fp, "QuickJS memory usage -- %s version, %d-bit, malloc limit: %"PRId64"\n\n", + JS_GetVersion(), (int)sizeof(void *) * 8, (int64_t)(ssize_t)s->malloc_limit); #if 1 if (rt) { static const struct { diff --git a/quickjs.h b/quickjs.h index 1617f8b9..86f2f958 100644 --- a/quickjs.h +++ b/quickjs.h @@ -1009,6 +1009,16 @@ typedef enum JSPromiseStateEnum { JSPromiseStateEnum JS_PromiseState(JSContext *ctx, JSValue promise); JSValue JS_PromiseResult(JSContext *ctx, JSValue promise); +/* Version */ + +#define QJS_VERSION_MAJOR 0 +#define QJS_VERSION_MINOR 1 +#define QJS_VERSION_PATCH 0 +#define QJS_VERSION_SUFFIX "" + +const char* JS_GetVersion(void); + + #undef js_unlikely #undef js_force_inline diff --git a/run-test262.c b/run-test262.c index 40613763..cbac5945 100644 --- a/run-test262.c +++ b/run-test262.c @@ -1945,7 +1945,7 @@ void run_test_dir_list(namelist_t *lp, int start_index, int stop_index) void help(void) { - printf("run-test262 version " CONFIG_VERSION "\n" + printf("run-test262 version %s\n" "usage: run-test262 [options] {-f file ... | [dir_list] [index range]}\n" "-h help\n" "-a run tests in strict and nostrict modes\n" @@ -1962,7 +1962,8 @@ void help(void) "-e file load the known errors from 'file'\n" "-f file execute single test from 'file'\n" "-r file set the report file name (default=none)\n" - "-x file exclude tests listed in 'file'\n"); + "-x file exclude tests listed in 'file'\n", + JS_GetVersion()); exit(1); }