474 lines
15 KiB
Diff
474 lines
15 KiB
Diff
https://git.alpinelinux.org/aports/plain/community/gpick/revert-cpp-lua.patch?id=3c7a8d560f9c2700d6a5ea52d0f451411f4b183d
|
|
From 0a724b1ac6036f316b3e84c41908f2269cdfc907 Mon Sep 17 00:00:00 2001
|
|
From: knuxify <knuxify@gmail.com>
|
|
Date: Sun, 8 May 2022 19:20:06 +0200
|
|
Subject: [PATCH] Revert "Use C++ Lua variant."
|
|
|
|
The C++ variant seems to be Ubuntu-specific from my brief research;
|
|
most sources say not to compile Lua as C++, so it probably makes no
|
|
sense to modify the lua package to support it.
|
|
---
|
|
.azure-pipelines/ubuntu-latest.yml | 22 ++----------------
|
|
CMakeLists.txt | 21 ++++++++---------
|
|
README.md | 2 ++
|
|
SConscript | 4 +++-
|
|
source/ColorSpaceType.cpp | 2 ++
|
|
source/Converter.cpp | 4 +++-
|
|
source/GlobalState.cpp | 2 ++
|
|
source/layout/Layout.cpp | 2 ++
|
|
source/lua/Color.cpp | 2 ++
|
|
source/lua/ColorObject.cpp | 2 ++
|
|
source/lua/DynvSystem.cpp | 2 ++
|
|
source/lua/Extensions.cpp | 2 ++
|
|
source/lua/GlobalState.cpp | 2 ++
|
|
source/lua/I18N.cpp | 2 ++
|
|
source/lua/Layout.cpp | 2 ++
|
|
source/lua/Ref.cpp | 2 ++
|
|
source/lua/Script.cpp | 2 ++
|
|
source/test/Script.cpp | 36 ++----------------------------
|
|
source/uiDialogOptions.cpp | 5 ++++-
|
|
19 files changed, 51 insertions(+), 67 deletions(-)
|
|
|
|
diff --git a/.azure-pipelines/ubuntu-latest.yml b/.azure-pipelines/ubuntu-latest.yml
|
|
index a9d5a09..1e76696 100644
|
|
--- a/.azure-pipelines/ubuntu-latest.yml
|
|
+++ b/.azure-pipelines/ubuntu-latest.yml
|
|
@@ -9,34 +9,16 @@ jobs:
|
|
gcc_gtk3_lua52:
|
|
publish_prefix: gcc-gtk3-lua52
|
|
lua_package: liblua5.2-dev
|
|
- compiler: g++
|
|
- CC: gcc
|
|
- CXX: g++
|
|
gcc_gtk3_lua53:
|
|
publish_prefix: gcc-gtk3-lua53
|
|
lua_package: liblua5.3-dev
|
|
- compiler: g++
|
|
- CC: gcc
|
|
- CXX: g++
|
|
- clang_gtk3_lua52:
|
|
- publish_prefix: clang-gtk3-lua52
|
|
- lua_package: liblua5.2-dev
|
|
- compiler: clang
|
|
- CC: clang
|
|
- CXX: clang++
|
|
- clang_gtk3_lua53:
|
|
- publish_prefix: clang-gtk3-lua53
|
|
- lua_package: liblua5.3-dev
|
|
- compiler: clang
|
|
- CC: clang
|
|
- CXX: clang++
|
|
pool:
|
|
vmImage: ubuntu-latest
|
|
steps:
|
|
- script: >
|
|
sudo apt-get update && sudo apt-get install
|
|
- $(compiler) $(lua_package) git ragel gettext libgtk-3-dev libexpat1-dev
|
|
- libboost-test-dev
|
|
+ git ragel g++ gcc gettext libgtk-3-dev $(lua_package) libexpat1-dev
|
|
+ libboost-filesystem-dev libboost-system-dev libboost-test-dev
|
|
- task: CMake@1
|
|
inputs:
|
|
workingDirectory: 'build'
|
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index bb6c670..f433c95 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -16,12 +16,11 @@ file(GLOB SOURCES
|
|
source/transformation/*.cpp source/transformation/*.h
|
|
source/version/*.cpp source/version/*.h
|
|
)
|
|
-list(REMOVE_ITEM SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/source/Color.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/Color.h ${CMAKE_CURRENT_SOURCE_DIR}/source/lua/Script.cpp ${CMAKE_CURRENT_SOURCE_DIR}/source/lua/Script.h)
|
|
-
|
|
+list(REMOVE_ITEM SOURCES source/Color.cpp source/Color.h source/lua/Script.cpp source/lua/Script.h)
|
|
include(Version)
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/source/version/Version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Version.cpp" @ONLY)
|
|
list(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/Version.cpp")
|
|
-find_package(Boost 1.58 COMPONENTS unit_test_framework REQUIRED)
|
|
+find_package(Boost 1.58 COMPONENTS filesystem system unit_test_framework REQUIRED)
|
|
find_package(PkgConfig)
|
|
if (PkgConfig_FOUND)
|
|
if (USE_GTK3)
|
|
@@ -30,7 +29,7 @@ if (PkgConfig_FOUND)
|
|
pkg_check_modules(GTK2 gtk+-2.0>=2.24)
|
|
pkg_check_modules(GioUnix gio-unix-2.0>=2.24)
|
|
endif()
|
|
- pkg_search_module(Lua lua5.4-c++>=5.4 lua5-c++>=5.4 lua5.3-c++>=5.3 lua5-c++>=5.3 lua-c++>=5.3 lua5.2-c++>=5.2 lua-c++>=5.2)
|
|
+ pkg_search_module(Lua lua5.4>=5.4 lua5>=5.4 lua5.3>=5.3 lua5>=5.3 lua>=5.3 lua5.2>=5.2 lua>=5.2)
|
|
pkg_check_modules(Expat expat>=1.0)
|
|
endif()
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
@@ -81,7 +80,7 @@ function(add_gtk_options target)
|
|
endfunction()
|
|
|
|
file(GLOB MATH_SOURCES source/math/Empty.cpp)
|
|
-add_library(gpick-math OBJECT ${MATH_SOURCES})
|
|
+add_library(gpick-math STATIC ${MATH_SOURCES})
|
|
set_compile_options(gpick-math)
|
|
target_include_directories(gpick-math PRIVATE
|
|
source
|
|
@@ -89,7 +88,7 @@ target_include_directories(gpick-math PRIVATE
|
|
)
|
|
|
|
file(GLOB COLOR_SOURCES source/Color.cpp source/Color.h)
|
|
-add_library(gpick-color OBJECT ${COLOR_SOURCES})
|
|
+add_library(gpick-color STATIC ${COLOR_SOURCES})
|
|
set_compile_options(gpick-color)
|
|
target_link_libraries(gpick-color PRIVATE gpick-math)
|
|
target_include_directories(gpick-color PRIVATE
|
|
@@ -98,7 +97,7 @@ target_include_directories(gpick-color PRIVATE
|
|
)
|
|
|
|
file(GLOB COMMON_SOURCES source/common/*.cpp source/common/*.h)
|
|
-add_library(gpick-common OBJECT ${COMMON_SOURCES})
|
|
+add_library(gpick-common STATIC ${COMMON_SOURCES})
|
|
set_compile_options(gpick-common)
|
|
target_include_directories(gpick-common PRIVATE
|
|
source
|
|
@@ -106,7 +105,7 @@ target_include_directories(gpick-common PRIVATE
|
|
)
|
|
|
|
file(GLOB DYNV_SOURCES source/dynv/*.cpp source/dynv/*.h)
|
|
-add_library(gpick-dynv OBJECT ${DYNV_SOURCES})
|
|
+add_library(gpick-dynv STATIC ${DYNV_SOURCES})
|
|
set_compile_options(gpick-dynv)
|
|
target_link_libraries(gpick-dynv PRIVATE gpick-color)
|
|
target_include_directories(gpick-dynv PRIVATE
|
|
@@ -116,7 +115,7 @@ target_include_directories(gpick-dynv PRIVATE
|
|
)
|
|
|
|
file(GLOB LUA_SOURCES source/lua/Script.cpp source/lua/Script.h)
|
|
-add_library(gpick-lua OBJECT ${LUA_SOURCES})
|
|
+add_library(gpick-lua STATIC ${LUA_SOURCES})
|
|
set_compile_options(gpick-lua)
|
|
target_link_libraries(gpick-lua PRIVATE
|
|
${Lua_LIBRARIES}
|
|
@@ -130,7 +129,7 @@ target_include_directories(gpick-lua PRIVATE
|
|
file(GLOB PARSER_SOURCES source/parser/*.cpp source/parser/*.h)
|
|
ragel_target(text_file_parser source/parser/TextFileParser.rl ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TextFileParser.cpp)
|
|
list(APPEND PARSER_SOURCES ${RAGEL_text_file_parser_OUTPUTS})
|
|
-add_library(gpick-parser OBJECT ${PARSER_SOURCES})
|
|
+add_library(gpick-parser STATIC ${PARSER_SOURCES})
|
|
set_compile_options(gpick-parser)
|
|
target_include_directories(gpick-parser PRIVATE
|
|
source
|
|
@@ -168,6 +167,8 @@ target_link_libraries(gpick PRIVATE
|
|
gpick-lua
|
|
gpick-parser
|
|
gpick-common
|
|
+ ${Boost_FILESYSTEM_LIBRARY}
|
|
+ ${Boost_SYSTEM_LIBRARY}
|
|
${Lua_LIBRARIES}
|
|
${Expat_LIBRARIES}
|
|
Threads::Threads
|
|
diff --git a/README.md b/README.md
|
|
index ac87f64..d3fdd73 100644
|
|
--- a/README.md
|
|
+++ b/README.md
|
|
@@ -45,6 +45,8 @@ Expat ([http://expat.sourceforge.net](http://expat.sourceforge.net)).
|
|
Boost 1.71 or newer ([http://www.boost.org](http://www.boost.org)).
|
|
Used libraries:
|
|
|
|
+ * Filesystem.
|
|
+ * System.
|
|
* Interprocess.
|
|
* Test (only when building/running tests).
|
|
|
|
diff --git a/SConscript b/SConscript
|
|
index 79b3b30..0bb9783 100644
|
|
--- a/SConscript
|
|
+++ b/SConscript
|
|
@@ -77,7 +77,7 @@ if not env.GetOption('clean'):
|
|
libs['GIO_PC'] = {'checks':{'gio-unix-2.0': '>= 2.26.0', 'gio-2.0': '>= 2.26.0'}}
|
|
else:
|
|
libs['GTK_PC'] = {'checks':{'gtk+-3.0': '>= 3.0.0'}}
|
|
- libs['LUA_PC'] = {'checks':{'lua5.4-c++': '>= 5.4', 'lua5.3-c++': '>= 5.3', 'lua-c++': '>= 5.2', 'lua5.2-c++': '>= 5.2'}}
|
|
+ libs['LUA_PC'] = {'checks':{'lua5.4': '>= 5.4', 'lua5.3': '>= 5.3', 'lua': '>= 5.2', 'lua5.2': '>= 5.2'}}
|
|
env.ConfirmLibs(conf, libs)
|
|
env.ConfirmBoost(conf, '1.71')
|
|
env = conf.Finish()
|
|
@@ -292,6 +292,8 @@ def buildGpick(env):
|
|
gpick_env.Append(LIBS = ['glib-2.0', 'gtk-win32-2.0', 'gobject-2.0', 'gdk-win32-2.0', 'cairo', 'gdk_pixbuf-2.0', 'lua5.2', 'expat2.1', 'pango-1.0', 'pangocairo-1.0', 'intl'])
|
|
gpick_env.Append(LINKFLAGS = ['/SUBSYSTEM:WINDOWS', '/ENTRY:mainCRTStartup'], CPPDEFINES = ['XML_STATIC'])
|
|
objects += buildWindowsResources(env)
|
|
+ else:
|
|
+ gpick_env.Append(LIBS = ['boost_filesystem', 'boost_system'])
|
|
|
|
if not gpick_env['BUILD_TARGET'] == 'win32':
|
|
gpick_env.Append(LIBS = ['expat'])
|
|
diff --git a/source/ColorSpaceType.cpp b/source/ColorSpaceType.cpp
|
|
index 8f5d124..69e8fab 100644
|
|
--- a/source/ColorSpaceType.cpp
|
|
+++ b/source/ColorSpaceType.cpp
|
|
@@ -22,7 +22,9 @@
|
|
#include "lua/Color.h"
|
|
#include "lua/Script.h"
|
|
#include "lua/Callbacks.h"
|
|
+extern "C"{
|
|
#include <lua.h>
|
|
+}
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
diff --git a/source/Converter.cpp b/source/Converter.cpp
|
|
index ee9d7d7..6847b87 100644
|
|
--- a/source/Converter.cpp
|
|
+++ b/source/Converter.cpp
|
|
@@ -33,9 +33,11 @@
|
|
#include <vector>
|
|
#include <iostream>
|
|
#include <functional>
|
|
+using namespace std;
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
-using namespace std;
|
|
+}
|
|
Converter::Converter(const char *name, const char *label, lua::Ref &&serialize, lua::Ref &&deserialize):
|
|
m_name(name),
|
|
m_label(label),
|
|
diff --git a/source/GlobalState.cpp b/source/GlobalState.cpp
|
|
index ca6542b..c848141 100644
|
|
--- a/source/GlobalState.cpp
|
|
+++ b/source/GlobalState.cpp
|
|
@@ -37,8 +37,10 @@
|
|
#include <filesystem>
|
|
#include <stdlib.h>
|
|
#include <glib/gstdio.h>
|
|
+extern "C" {
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
#include <fstream>
|
|
#include <iostream>
|
|
struct GlobalState::Impl {
|
|
diff --git a/source/layout/Layout.cpp b/source/layout/Layout.cpp
|
|
index c81a927..c513244 100644
|
|
--- a/source/layout/Layout.cpp
|
|
+++ b/source/layout/Layout.cpp
|
|
@@ -20,8 +20,10 @@
|
|
#include "System.h"
|
|
#include "../lua/Layout.h"
|
|
#include <iostream>
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
using namespace std;
|
|
namespace layout
|
|
{
|
|
diff --git a/source/lua/Color.cpp b/source/lua/Color.cpp
|
|
index 724831a..55475dc 100644
|
|
--- a/source/lua/Color.cpp
|
|
+++ b/source/lua/Color.cpp
|
|
@@ -18,8 +18,10 @@
|
|
|
|
#include "Color.h"
|
|
#include "../Color.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
static int newColor(lua_State *L)
|
|
diff --git a/source/lua/ColorObject.cpp b/source/lua/ColorObject.cpp
|
|
index a1971b5..2a13e26 100644
|
|
--- a/source/lua/ColorObject.cpp
|
|
+++ b/source/lua/ColorObject.cpp
|
|
@@ -20,8 +20,10 @@
|
|
#include "Color.h"
|
|
#include "Script.h"
|
|
#include "../ColorObject.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
static int newColorObject(lua_State *L)
|
|
diff --git a/source/lua/DynvSystem.cpp b/source/lua/DynvSystem.cpp
|
|
index ff3508c..b7b56e5 100644
|
|
--- a/source/lua/DynvSystem.cpp
|
|
+++ b/source/lua/DynvSystem.cpp
|
|
@@ -17,8 +17,10 @@
|
|
*/
|
|
|
|
#include "DynvSystem.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua {
|
|
dynv::Ref checkDynvSystem(lua_State *L, int index) {
|
|
void *ud = luaL_checkudata(L, index, "dynvSystem");
|
|
diff --git a/source/lua/Extensions.cpp b/source/lua/Extensions.cpp
|
|
index 62c6c1b..e17d05e 100644
|
|
--- a/source/lua/Extensions.cpp
|
|
+++ b/source/lua/Extensions.cpp
|
|
@@ -31,8 +31,10 @@
|
|
#include "../Converters.h"
|
|
#include "../Converter.h"
|
|
#include "version/Version.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
static void checkArgumentIsFunctionOrNil(lua_State *L, int index)
|
|
diff --git a/source/lua/GlobalState.cpp b/source/lua/GlobalState.cpp
|
|
index 8908538..d125f68 100644
|
|
--- a/source/lua/GlobalState.cpp
|
|
+++ b/source/lua/GlobalState.cpp
|
|
@@ -18,8 +18,10 @@
|
|
|
|
#include "GlobalState.h"
|
|
#include "../GlobalState.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
void setGlobalState(lua_State *L, GlobalState &global_state)
|
|
diff --git a/source/lua/I18N.cpp b/source/lua/I18N.cpp
|
|
index 6791c97..d59ce3f 100644
|
|
--- a/source/lua/I18N.cpp
|
|
+++ b/source/lua/I18N.cpp
|
|
@@ -18,8 +18,10 @@
|
|
|
|
#include "I18N.h"
|
|
#include "../I18N.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
int getText(lua_State *L)
|
|
diff --git a/source/lua/Layout.cpp b/source/lua/Layout.cpp
|
|
index be83686..b9dfc8d 100644
|
|
--- a/source/lua/Layout.cpp
|
|
+++ b/source/lua/Layout.cpp
|
|
@@ -23,8 +23,10 @@
|
|
#include "../layout/Box.h"
|
|
#include "../layout/System.h"
|
|
#include "../layout/Layout.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
#include <typeinfo>
|
|
#include <iostream>
|
|
using namespace std;
|
|
diff --git a/source/lua/Ref.cpp b/source/lua/Ref.cpp
|
|
index 9b1acc7..fced0cc 100644
|
|
--- a/source/lua/Ref.cpp
|
|
+++ b/source/lua/Ref.cpp
|
|
@@ -17,8 +17,10 @@
|
|
*/
|
|
|
|
#include "Ref.h"
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
namespace lua
|
|
{
|
|
Ref::Ref():
|
|
diff --git a/source/lua/Script.cpp b/source/lua/Script.cpp
|
|
index a39e3eb..50f31d2 100644
|
|
--- a/source/lua/Script.cpp
|
|
+++ b/source/lua/Script.cpp
|
|
@@ -18,8 +18,10 @@
|
|
|
|
#include "Script.h"
|
|
#include <sstream>
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
#include <iostream>
|
|
using namespace std;
|
|
namespace lua
|
|
diff --git a/source/test/Script.cpp b/source/test/Script.cpp
|
|
index 8fdeaa9..498a9eb 100644
|
|
--- a/source/test/Script.cpp
|
|
+++ b/source/test/Script.cpp
|
|
@@ -18,25 +18,15 @@
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
#include "lua/Script.h"
|
|
-#include "common/Scoped.h"
|
|
+extern "C" {
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
+}
|
|
using namespace lua;
|
|
static int test(lua_State *L) {
|
|
lua_pushstring(L, "ok");
|
|
return 1;
|
|
}
|
|
-static int error(lua_State *L) {
|
|
- lua_getglobal(L, "cleanupOnError");
|
|
- auto &cleanupOnError = *reinterpret_cast<bool *>(lua_touserdata(L, -1));
|
|
- lua_pop(L, 1);
|
|
- common::Scoped<std::function<void()>> callOnScopeEnd([&cleanupOnError]() {
|
|
- cleanupOnError = true;
|
|
- });
|
|
- luaL_error(L, "error");
|
|
- return 0;
|
|
-}
|
|
-BOOST_AUTO_TEST_SUITE(script)
|
|
BOOST_AUTO_TEST_CASE(register_extension) {
|
|
Script script;
|
|
bool status = script.registerExtension("test", [](Script &script) {
|
|
@@ -72,25 +62,3 @@ BOOST_AUTO_TEST_CASE(register_nullptr_extension) {
|
|
std::string returnValue = script.getString(-1);
|
|
BOOST_CHECK(returnValue == "ok");
|
|
}
|
|
-BOOST_AUTO_TEST_CASE(error_handling) {
|
|
- Script script;
|
|
- lua_State *L = script;
|
|
- bool cleanupOnError = false;
|
|
- lua_pushlightuserdata(L, &cleanupOnError);
|
|
- lua_setglobal(L, "cleanupOnError");
|
|
- bool status = script.registerExtension("test", [](Script &script) {
|
|
- static const struct luaL_Reg functions[] = {
|
|
- { "error", error },
|
|
- { nullptr, nullptr }
|
|
- };
|
|
- luaL_newlib(script, functions);
|
|
- return 1;
|
|
- });
|
|
- BOOST_CHECK(status == true);
|
|
- status = script.loadCode("test = require(\"gpick/test\")\nreturn test.error()");
|
|
- BOOST_CHECK(status == true);
|
|
- status = script.run(0, 0);
|
|
- BOOST_CHECK(status == false);
|
|
- BOOST_CHECK(cleanupOnError == true);
|
|
-}
|
|
-BOOST_AUTO_TEST_SUITE_END()
|
|
diff --git a/source/uiDialogOptions.cpp b/source/uiDialogOptions.cpp
|
|
index e70debb..7a2e53c 100644
|
|
--- a/source/uiDialogOptions.cpp
|
|
+++ b/source/uiDialogOptions.cpp
|
|
@@ -28,9 +28,12 @@
|
|
#include "lua/Callbacks.h"
|
|
#include <string>
|
|
#include <iostream>
|
|
+using namespace std;
|
|
+extern "C"{
|
|
#include <lualib.h>
|
|
#include <lauxlib.h>
|
|
-using namespace std;
|
|
+}
|
|
+
|
|
static const struct{
|
|
const char *label;
|
|
const char *setting;
|
|
--
|
|
2.36.0
|
|
|