awesome/common/version.c
Uli Schlachter 896eee8b1f Print LuaJIT version in --version (#996)
When called with "--version", awesome prints the Lua version that it was
compiled against and the one that it is running against. This commit makes the
code detect LuaJIT and makes it print the LuaJIT version instead of an
unspecific "Lua 5.1".

Signed-off-by: Uli Schlachter <psychon@znc.in>
2016-07-09 19:05:44 +02:00

83 lines
2.1 KiB
C

/*
* version.c - version message utility functions
*
* Copyright © 2008 Julien Danjou <julien@danjou.info>
* Copyright © 2008 Hans Ulrich Niedermann <hun@n-dimensional.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "common/version.h"
#include "awesome-version-internal.h"
#include <stdlib.h>
#include <stdio.h>
#include <lualib.h>
#include <lauxlib.h>
/** \brief Print version message and quit program.
* \param executable program name
*/
void
eprint_version(void)
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
lua_getglobal(L, "_VERSION");
lua_getglobal(L, "jit");
if (lua_istable(L, 2))
lua_getfield(L, 2, "version");
else
lua_pop(L, 1);
#ifdef WITH_DBUS
const char *has_dbus = "";
#else
const char *has_dbus = "";
#endif
printf("awesome %s (%s)\n"
" • Compiled against %s (running with %s)\n"
" • D-Bus support: %s\n",
AWESOME_VERSION, AWESOME_RELEASE,
LUA_RELEASE, lua_tostring(L, -1),
has_dbus);
lua_close(L);
exit(EXIT_SUCCESS);
}
/** Get version string.
* \return A string describing the current version.
*/
const char *
awesome_version_string(void)
{
return AWESOME_VERSION;
}
/** Get release string.
* \return A string describing the code name of the relase.
*/
const char *
awesome_release_string(void)
{
return AWESOME_RELEASE;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80