Update version output to match SRFI 176 draft 2

This commit is contained in:
Lassi Kortela 2020-02-13 23:54:05 +02:00
parent 02852627da
commit 9e76fdb005
3 changed files with 74 additions and 35 deletions

74
c/env.c
View File

@ -85,9 +85,8 @@ static value_t build_stable_specs_list(void)
return acc.list;
}
static value_t build_platform_list(void)
static const char *get_build_platform(void)
{
struct accum acc;
const char *kernel;
const char *userland;
const char *computer;
@ -194,11 +193,31 @@ static value_t build_platform_list(void)
endian = "little";
#endif
accum_init(&acc);
accum_name_value1(&acc, "kernel", symbol(kernel));
accum_name_value1(&acc, "userland", symbol(userland));
accum_name_value1(&acc, "computer", symbol(computer));
accum_name_value1(&acc, "endian", symbol(endian));
return kernel;
}
static value_t build_srfi_list(void)
{
struct accum acc = ACCUM_EMPTY;
accum_elt(&acc, fixnum(0));
accum_elt(&acc, fixnum(1));
accum_elt(&acc, fixnum(6));
accum_elt(&acc, fixnum(22));
accum_elt(&acc, fixnum(27));
accum_elt(&acc, fixnum(174));
accum_elt(&acc, fixnum(175));
accum_elt(&acc, fixnum(176));
return acc.list;
}
static value_t list_from_cstrv(const char **sv)
{
struct accum acc = ACCUM_EMPTY;
for (; *sv; sv++) {
accum_elt(&acc, string_from_cstr(*sv));
}
return acc.list;
}
@ -211,29 +230,32 @@ value_t get_version_alist(void)
initialized = 1;
accum_init(&acc);
accum_name_value1(&acc, "command", string_from_cstr("upscheme"));
accum_name_value1(&acc, "scheme-id", symbol("upscheme"));
accum_name_value1(&acc, "release", string_from_cstr(env_release));
accum_name_value1(&acc, "release/date",
string_from_cstr(env_release_date));
accum_name_value(
&acc, "language",
&acc, "languages",
fl_cons(symbol("scheme"), fl_cons(symbol("r7rs"), FL_NIL)));
accum_name_value(&acc, "features", get_features_list());
accum_name_value(&acc, "platform", build_platform_list());
accum_name_value(&acc, "c-type-bits", build_c_type_bits_list());
accum_name_value1(&acc, "c-compiler-version",
accum_name_value1(&acc, "scheme/id", symbol("upscheme"));
accum_name_value(&acc, "scheme/srfi", build_srfi_list());
accum_name_value(&acc, "scheme/features", get_features_list());
accum_name_value1(&acc, "build/platform",
string_from_cstr(get_build_platform()));
accum_name_value1(&acc, "build/date",
string_from_cstr(env_build_date));
accum_name_value1(&acc, "build/git/branch",
string_from_cstr(env_build_git_branch));
accum_name_value1(&acc, "build/git/commit",
string_from_cstr(env_build_git_commit));
accum_name_value(&acc, "build/git/modified",
list_from_cstrv(env_build_git_modified));
accum_name_value(&acc, "c/type-bits", build_c_type_bits_list());
accum_name_value1(&acc, "c/version",
string_from_cstr(SCHEME_C_COMPILER_NAME
" " SCHEME_C_COMPILER_VERSION));
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));
accum_name_value(&acc, "c/compile",
list_from_cstrv(env_build_c_compile));
accum_name_value(&acc, "c/link", list_from_cstrv(env_build_c_link));
accum_name_value(&acc, "upscheme/stable-specs",
build_stable_specs_list());
accum_name_value1(&acc, "upscheme/unstable-spec",

View File

@ -1015,11 +1015,12 @@ value_t builtin_version_alist(value_t *args, uint32_t nargs);
value_t builtin_environment_stack(value_t *args, uint32_t nargs);
extern const char env_build_cc[];
extern const char env_build_cflags[];
extern const char env_build_lflags[];
extern const char env_build_revision[];
extern const char *env_build_c_compile[];
extern const char *env_build_c_link[];
extern const char env_build_date[];
extern const char env_build_git_branch[];
extern const char env_build_git_commit[];
extern const char *env_build_git_modified[];
extern const char env_release[];
extern const char env_release_date[];

View File

@ -84,20 +84,36 @@ 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
pre_cflags="$(echo "$CC" "$CFLAGS" | tr ' ' '\n' | sed -e 's/^/"/' -e 's/$/",/')"
pre_lflags="$(echo "$CC" "$LFLAGS" | tr ' ' '\n' | sed -e 's/^/"/' -e 's/$/",/')"
git_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
git_commit="$(git rev-parse --short HEAD 2>/dev/null || true)"
git_modified="$(git diff-files --name-only 2>/dev/null | head | xargs -n 1 printf '"%s",\n')"
cat >c/env_build.c <<EOF
// Generated from scratch at each build.
const char env_build_cc[] = "$CC";
const char env_build_cflags[] = "$CFLAGS";
const char env_build_lflags[] = "$LFLAGS";
const char env_build_revision[] = "$revision";
const char *env_build_c_compile[] = {
$pre_cflags
0
};
const char *env_build_c_link[] = {
$pre_lflags
0
};
const char env_build_date[] = "$builddate";
const char env_build_git_branch[] = "$git_branch";
const char env_build_git_commit[] = "$git_commit";
const char *env_build_git_modified[] = {
$git_modified
0
};
EOF
mkdir -p "$builddir"