From b2cbb9adcaffa96c608274fd7512e8069721f657 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 28 Aug 2026 02:58:49 +0300 Subject: [PATCH] tolua: Make generated code deterministic Port patch from freeciv tree. This is necessary for any project that uses tolua to build reproducibly. Signed-off-by: Marko Lindqvist --- .../tolua/08-gen-code-deterministic.patch | 38 +++++++++++++++++++ dependencies/tolua/tolua_5.2.4.bb | 1 + 2 files changed, 39 insertions(+) create mode 100644 dependencies/tolua/tolua/08-gen-code-deterministic.patch diff --git a/dependencies/tolua/tolua/08-gen-code-deterministic.patch b/dependencies/tolua/tolua/08-gen-code-deterministic.patch new file mode 100644 index 0000000..639e79b --- /dev/null +++ b/dependencies/tolua/tolua/08-gen-code-deterministic.patch @@ -0,0 +1,38 @@ +Upstream-Status: Inactive-Upstream + +diff -Nurd tolua-5.2/src/bin/lua/package.lua tolua-5.2/src/bin/lua/package.lua +--- tolua-5.2/src/bin/lua/package.lua 2026-08-06 05:52:07.651394122 +0200 ++++ tolua-5.2/src/bin/lua/package.lua 2026-08-06 05:49:00.012771828 +0200 +@@ -125,7 +125,11 @@ + output('\n') + output('/* function to release collected object via destructor */') + output('#ifdef __cplusplus\n') +- for i,v in pairs(_collect) do ++ local sorted = {} ++ for i in pairs(_collect) do tinsert(sorted,i) end ++ sort(sorted) ++ for _,i in ipairs(sorted) do ++ local v = _collect[i] + output('\nstatic int '..v..' (lua_State* tolua_S)') + output('{') + output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);') +@@ -141,7 +145,10 @@ + output('/* function to register type */') + output('static void tolua_reg_types (lua_State* tolua_S)') + output('{') +- foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end) ++ local sorted = {} ++ foreach(_usertype,function(n,v) tinsert(sorted,v) end) ++ sort(sorted) ++ foreachi(sorted,function(i,v) output(' tolua_usertype(tolua_S,"',v,'");') end) + output('}') + output('\n') + end +@@ -182,7 +189,6 @@ + -- write header file + function classPackage:header () + output('/*\n') output('** Lua binding: '..self.name..'\n') +- output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n') + output('*/\n\n') + + if not flags.h then diff --git a/dependencies/tolua/tolua_5.2.4.bb b/dependencies/tolua/tolua_5.2.4.bb index f2bd9a7..1d1940d 100644 --- a/dependencies/tolua/tolua_5.2.4.bb +++ b/dependencies/tolua/tolua_5.2.4.bb @@ -24,6 +24,7 @@ SRC_URI = "\ file://04-include-tolua_event.patch \ file://05-gen-code-fix-null-dereferences.patch \ file://06-gen-code-no-trailing-spaces.patch \ + file://08-gen-code-deterministic.patch \ " B = "${S}"