From 975ad5de516393a75426833d310eab18750292a9 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Mon, 14 Oct 2019 19:15:45 +0300 Subject: [PATCH] Add release and build info to version-alist env_release.h shall be updated on each release. --- .gitignore | 1 + c/env_release.c | 4 ++++ c/main.c | 17 +++++++++++++++-- c/scheme.h | 9 +++++++++ scripts/build.sh | 15 +++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 c/env_release.c diff --git a/.gitignore b/.gitignore index cebbcdf..7d11823 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /build-*/ +/c/env_build.c diff --git a/c/env_release.c b/c/env_release.c new file mode 100644 index 0000000..48c896d --- /dev/null +++ b/c/env_release.c @@ -0,0 +1,4 @@ +// Latest release on which this build is based. + +char env_release[] = "0.0.0"; +char env_release_date[] = "1970-01-01"; diff --git a/c/main.c b/c/main.c index 68ca2ea..4d9330b 100644 --- a/c/main.c +++ b/c/main.c @@ -185,11 +185,24 @@ static value_t get_version_alist(void) fl_cons(symbol("scheme"), fl_cons(symbol("r7rs"), FL_NIL))); accum_name_value(&acc, "features", get_features_list()); accum_name_value(&acc, "platform", get_platform()); + accum_name_value(&acc, "c-type-bits", get_c_type_bits_list()); accum_name_value( - &acc, "c-compiler", + &acc, "c-compiler-version", fl_list2(string_from_cstr(SCHEME_C_COMPILER_NAME), string_from_cstr(SCHEME_C_COMPILER_VERSION))); - accum_name_value(&acc, "c-type-bits", get_c_type_bits_list()); + accum_name_value1(&acc, "c-compiler-command", + string_from_cstr(env_build_cc)); + accum_name_value1(&acc, "c-compiler-flags", + string_from_cstr(env_build_cflags)); + accum_name_value1(&acc, "c-linker-flags", + string_from_cstr(env_build_lflags)); + accum_name_value1(&acc, "revision", + string_from_cstr(env_build_revision)); + accum_name_value1(&acc, "build-date", + string_from_cstr(env_build_date)); + accum_name_value1(&acc, "release", string_from_cstr(env_release)); + accum_name_value1(&acc, "release-date", + string_from_cstr(env_release_date)); } return acc.list; } diff --git a/c/scheme.h b/c/scheme.h index 1b10bfa..aa477d9 100644 --- a/c/scheme.h +++ b/c/scheme.h @@ -1005,6 +1005,15 @@ const char *env_get_os_name(void); value_t builtin_environment_stack(value_t *args, uint32_t nargs); +extern char env_build_cc[]; +extern char env_build_cflags[]; +extern char env_build_lflags[]; +extern char env_build_revision[]; +extern char env_build_date[]; + +extern char env_release[]; +extern char env_release_date[]; + //// #include "libraries.h" value_t builtin_import(value_t *args, uint32_t nargs); diff --git a/scripts/build.sh b/scripts/build.sh index 8f73ca3..2b40890 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -16,6 +16,8 @@ o_files="$o_files buf.o" o_files="$o_files builtins.o" o_files="$o_files char.o" o_files="$o_files dump.o" +o_files="$o_files env_build.o" +o_files="$o_files env_release.o" o_files="$o_files env_unix.o" o_files="$o_files equalhash.o" o_files="$o_files flisp.o" @@ -81,11 +83,22 @@ esac CC="${CC:-$default_cc}" CFLAGS="${CFLAGS:-$default_cflags}" LFLAGS="${LFLAGS:-$default_lflags}" +revision="$(git describe --dirty --always 2>/dev/null || echo unknown)" +builddate="$(date -u '+%Y-%m-%d')" builddir="build-$os-$(uname -m | tr A-Z- a-z_)-$(basename "$CC")" cd "$(dirname "$0")"/.. echo "Entering directory '$PWD'" set -x +cat >c/env_build.c <