diff --git a/.travis.yml b/.travis.yml index 82bdb8b7..bf9fad6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,8 +54,10 @@ install: if [[ "$LUA" == "5.3" ]]; then wget http://www.lua.org/ftp/lua-5.3.3.tar.gz -O lua.tar.gz tar -xvzf lua.tar.gz + (echo '#!/bin/sh' ; echo 'set -x' ; echo 'gcc -shared -Wl,--no-undefined -o "$@" -ldl -lm') > /tmp/myar + chmod a+x /tmp/myar (cd lua-5.3.3/src \ - && make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="gcc -shared -ldl -o" liblua.so \ + && make SYSCFLAGS="-DLUA_USE_LINUX -ULUA_COMPAT_5_2 -DLUA_USE_APICHECK" SYSLIBS="-Wl,-E -ldl -lreadline" LUA_A=liblua.so MYCFLAGS="-fPIC" RANLIB=: AR="/tmp/myar" liblua.so \ && cd .. \ && sudo make INSTALL_TOP=/usr/ INSTALL_INC=${LUAINCLUDE} TO_LIB=liblua.so linux install) elif [[ "$LUANAME" == "luajit-2.0" ]]; then diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fb5711f..558b282e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,10 +148,6 @@ target_link_libraries(${PROJECT_AWE_NAME} ${AWESOME_REQUIRED_LDFLAGS} ${AWESOME_OPTIONAL_LDFLAGS}) -# check for lgi and the needed gobject introspection files -add_custom_target(lgi-check ALL - COMMAND ${SOURCE_DIR}/build-utils/lgi-check.sh) - # {{{ Generated sources # atoms file(MAKE_DIRECTORY ${BUILD_DIR}/common) diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 55448a0b..b039a88c 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -343,6 +343,16 @@ endif() #}}} +# {{{ Check for LGI +add_executable(lgi-check build-utils/lgi-check.c) +target_link_libraries(lgi-check ${LUA_LIBRARIES}) +target_include_directories(lgi-check PRIVATE ${LUA_INCLUDE_DIR}) +add_custom_target(lgi-check-run ALL + COMMAND lgi-check + DEPENDS lgi-check + COMMENT "Checking for LGI...") +# }}} + # {{{ Generate some aggregated documentation from lua script file(MAKE_DIRECTORY ${BUILD_DIR}/script_files/) @@ -351,7 +361,7 @@ add_custom_command( OUTPUT ${BUILD_DIR}/docs/06-appearance.md COMMAND lua ${SOURCE_DIR}/docs/06-appearance.md.lua ${BUILD_DIR}/docs/06-appearance.md - DEPENDS lgi-check + DEPENDS lgi-check-run ) add_custom_command( diff --git a/build-utils/lgi-check.c b/build-utils/lgi-check.c new file mode 100644 index 00000000..9d7a2261 --- /dev/null +++ b/build-utils/lgi-check.c @@ -0,0 +1,63 @@ +/* + * lgi-check.c - Check that LGI is available + * + * Copyright © 2017 Uli Schlachter + * + * 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 +#include +#include +#include +#include + +const char commands[] = +"print(string.format('Building for %s.', jit and jit.version or _VERSION))\n" +"local lgi_version = require('lgi.version')\n" +"print(string.format('Found lgi %s.', lgi_version))\n" +"_, _, major_minor, patch = string.find(lgi_version, '^(%d%.%d)%.(%d)')\n" +"if tonumber(major_minor) < 0.8 or (tonumber(major_minor) == 0.8 and tonumber(patch) < 0) then\n" +" error(string.format('lgi is too old, need at least version %s, got %s.',\n" +" '0.8.0', require('lgi.version')))\n" +"end\n" +"lgi = require('lgi')\n" +"assert(lgi.cairo, lgi.Pango, lgi.PangoCairo, lgi.GLib, lgi.Gio)\n" +; + +int main() +{ + int result = 0; + const char *env = "AWESOME_IGNORE_LGI"; + lua_State *L = luaL_newstate(); + luaL_openlibs(L); + if (luaL_dostring(L, commands)) + { + fprintf(stderr, "Error: %s\n", + lua_tostring(L, -1)); + fprintf(stderr, "\n\n WARNING\n =======\n\n" + " The lgi check failed.\n" + " Awesome needs lgi to run.\n" + " Add %s=1 to your environment to continue.\n\n\n", + env); + if (getenv(env) == NULL) + result = 1; + } + lua_close(L); + return result; +} + +// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/build-utils/lgi-check.sh b/build-utils/lgi-check.sh deleted file mode 100755 index cbc7ec2a..00000000 --- a/build-utils/lgi-check.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -die() -{ - exec >&2 - echo - echo - echo " WARNING" - echo " =======" - echo - echo " The lgi check failed." - echo " The Lua GObject introspection package is just a runtime dependency, so it is not" - echo " necessary for building awesome. However, awesome needs it to run." - echo " Add AWESOME_IGNORE_LGI=1 to your environment to continue." - echo - echo - if [ "x$AWESOME_IGNORE_LGI" = "x1" ] - then - exit 0 - fi - exit 1 -} - -# Check if we have lgi -lua -e 'require("lgi")' || die - -# Check the version number. -# Keep this in sync with lib/gears/surface.lua and .travis.yml (LGIVER)! -lua -e '_, _, major_minor, patch = string.find(require("lgi.version"), "^(%d%.%d)%.(%d)"); - if tonumber(major_minor) < 0.8 or (tonumber(major_minor) == 0.8 and tonumber(patch) < 0) then - error(string.format("lgi is too old, need at least version %s, got %s.", - "0.8.0", require("lgi.version"))) end' || die - -# Check for the needed gi files -lua -e 'l = require("lgi") assert(l.cairo, l.Pango, l.PangoCairo, l.GLib, l.Gio)' || die - -# vim: filetype=sh:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/lib/gears/surface.lua b/lib/gears/surface.lua index 3bdd460c..3e506b9b 100644 --- a/lib/gears/surface.lua +++ b/lib/gears/surface.lua @@ -12,7 +12,7 @@ local color = nil local gdebug = require("gears.debug") local hierarchy = require("wibox.hierarchy") --- Keep this in sync with build-utils/lgi-check.sh! +-- Keep this in sync with build-utils/lgi-check.c! local ver_major, ver_minor, ver_patch = string.match(require('lgi.version'), '(%d)%.(%d)%.(%d)') if tonumber(ver_major) <= 0 and (tonumber(ver_minor) < 8 or (tonumber(ver_minor) == 8 and tonumber(ver_patch) < 0)) then error("lgi too old, need at least version 0.8.0")