Merge pull request #3553 from Aire-One/feat/lua54

Supports Lua 5.4
This commit is contained in:
Emmanuel Lepage Vallée 2022-02-02 14:08:50 -08:00 committed by GitHub
commit a1f58ab97c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 10 deletions

View File

@ -28,6 +28,13 @@ jobs:
fail-fast: false
matrix:
include:
- test_name: "lua5.4"
lua_version: "5.4"
lua_name: "lua5.4"
lua_library: "/usr/local/lib/liblua.a"
lua_include: "/usr/local/include"
manual_screens: true
- test_name: "codecov-lua5.3"
lua_version: "5.3"
lua_name: "lua5.3"
@ -136,24 +143,36 @@ jobs:
run: sudo dpkg -i /var/cache/apt/archives/*.deb
- name: Install Lua packages
if: matrix.lua_version != '5.4'
run: |
if [ "${{ matrix.lua_name }}" = "luajit" ]; then
sudo apt-get install libluajit-5.1-dev luajit
fi
sudo apt-get install liblua${{ matrix.lua_version }}-dev lua${{ matrix.lua_version }}
# Ubuntu 20.04 hasn't a package for Lua 5.4, we need to build it from source.
- name: Build and Install Lua 5.4
if: matrix.lua_version == '5.4'
run: |
wget -O /tmp/lua-5.4.3.tar.gz http://www.lua.org/ftp/lua-5.4.3.tar.gz
tar -xf /tmp/lua-5.4.3.tar.gz -C /tmp
cd /tmp/lua-5.4.3
make all
make test
sudo make install
- name: Cache luarocks
id: cache-luarocks
uses: actions/cache@v2
with:
path: /tmp/luarocks
# The build input for luarocks changes per test, so we need separate caches
key: ${{ github.workflow }}-${{ runner.os }}-${{ matrix.test_name }}-luarocks-3.5.0
key: ${{ github.workflow }}-${{ runner.os }}-${{ matrix.test_name }}-luarocks-3.8.0
- name: Install fresh Luarocks
if: steps.cache-luarocks.outputs.cache-hit != 'true'
run: |
wget -O /tmp/luarocks.tar.gz https://github.com/luarocks/luarocks/archive/v3.5.0.tar.gz
wget -O /tmp/luarocks.tar.gz https://github.com/luarocks/luarocks/archive/v3.8.0.tar.gz
mkdir /tmp/luarocks
tar -xf /tmp/luarocks.tar.gz -C /tmp/luarocks --strip-components=1
cd /tmp/luarocks
@ -189,9 +208,22 @@ jobs:
cd /tmp/xcb-errors
sudo make install
# Only LGI git master supports Lua 5.4. We need to build it from source.
- name: Build and Install LGI
if: matrix.lua_version == '5.4'
run: |
wget -O /tmp/lgi.zip https://github.com/pavouk/lgi/archive/refs/heads/master.zip
unzip /tmp/lgi.zip -d /tmp
cd /tmp/lgi-master
sed -i 's/5.1/5.4/' lgi/Makefile
make all
sudo make install
- name: Install rocks
run: |
sudo -H luarocks install lgi ${{ matrix.lgi_version }}
if [ "${{ matrix.lua_name }}" != "lua5.4" ]; then
sudo -H luarocks install lgi ${{ matrix.lgi_version }}
fi
sudo -H luarocks install ldoc
sudo -H luarocks install busted

View File

@ -84,10 +84,16 @@ init_rng(void)
lua_getfield(L, -1, "randomseed");
/* Push a seed */
lua_pushnumber(L, g_random_int() + g_random_double());
lua_pushnumber(L, g_random_int());
/* Call math.randomseed */
lua_call(L, 1, 0);
if(lua_pcall(L, 1, 0, 0))
{
warn("Random number generator initialization failed: %s", lua_tostring(L, -1));
/* Remove error function and error string */
lua_pop(L, 2);
return;
}
/* Remove "math" global */
lua_pop(L, 1);

View File

@ -73,9 +73,9 @@ if (NOT LUA_FOUND)
endif()
set(LUA_FULL_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}")
# 5.1 <= LUA_VERSION < 5.4
if(NOT ((LUA_FULL_VERSION VERSION_EQUAL 5.1.0 OR LUA_FULL_VERSION VERSION_GREATER 5.1.0) AND LUA_FULL_VERSION VERSION_LESS 5.4.0))
message(FATAL_ERROR "Awesome only supports Lua versions 5.1-5.3, please refer to"
# 5.1 <= LUA_VERSION < 5.5
if(NOT ((LUA_FULL_VERSION VERSION_EQUAL 5.1.0 OR LUA_FULL_VERSION VERSION_GREATER 5.1.0) AND LUA_FULL_VERSION VERSION_LESS 5.5.0))
message(FATAL_ERROR "Awesome only supports Lua versions 5.1-5.4, please refer to"
"https://awesomewm.org/apidoc/documentation/10-building-and-testing.md.html#Building")
endif()

4
luaa.h
View File

@ -31,8 +31,8 @@
#include "common/lualib.h"
#include "common/luaclass.h"
#if !(501 <= LUA_VERSION_NUM && LUA_VERSION_NUM < 504)
#error "Awesome only supports Lua versions 5.1-5.3 and LuaJIT2, please refer to https://awesomewm.org/apidoc/documentation/10-building-and-testing.md.html#Building"
#if !(501 <= LUA_VERSION_NUM && LUA_VERSION_NUM < 505)
#error "Awesome only supports Lua versions 5.1-5.4 and LuaJIT2, please refer to https://awesomewm.org/apidoc/documentation/10-building-and-testing.md.html#Building"
#endif
#define luaA_deprecate(L, repl) \