Add JS_GetVersion
This commit is contained in:
parent
38f88c0898
commit
55e845c5dd
8 changed files with 33 additions and 13 deletions
|
@ -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}"
|
||||
|
|
2
Makefile
2
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
|
||||
|
|
1
VERSION
1
VERSION
|
@ -1 +0,0 @@
|
|||
2021-03-27
|
4
qjs.c
4
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);
|
||||
}
|
||||
|
||||
|
|
3
qjsc.c
3
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
|
||||
{
|
||||
|
|
18
quickjs.c
18
quickjs.c
|
@ -107,6 +107,19 @@
|
|||
#include <errno.h>
|
||||
#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 {
|
||||
|
|
10
quickjs.h
10
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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue