From 3f7c21165352ac81b74d8ab451301dddeafdd6cc Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 18:58:57 +0100 Subject: [PATCH 01/56] Initial commit for macos CI --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5743351..1d761a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,3 +79,40 @@ jobs: - name: Test working-directory: ${{runner.workspace}}/build run: ctest -V -C ${{matrix.build_type}} --timeout 60 + macos: + strategy: + matrix: + os: + - { name: macos-12 } + build_type: [Debug, Release] + toolchain: ["gcc-32bit", "gcc-64bit"] + + name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" + runs-on: ${{matrix.os.distro}} + + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Create build environment + working-directory: ${{runner.workspace}} + run: mkdir build + + - name: Initialize CMake + env: + CC: /usr/bin/gcc + CXX: /usr/bin/g++ + working-directory: ${{runner.workspace}}/build + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake + + - name: Build + shell: bash + working-directory: ${{runner.workspace}}/build + run: make + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + run: ctest -V -C ${{matrix.build_type}} + From 1c28a3baca69ff9cd1a43e40e368f2765872bbd3 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:03:18 +0100 Subject: [PATCH 02/56] Update name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d761a3..ce644a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,7 +83,7 @@ jobs: strategy: matrix: os: - - { name: macos-12 } + - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] toolchain: ["gcc-32bit", "gcc-64bit"] From 2c8ed97a5266fa8951cb2248c4d35a8e3890842c Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:17:40 +0100 Subject: [PATCH 03/56] Link libSystem.dylib --- toolchains/gcc-32bit.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index c2a9674..b019513 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -2,3 +2,5 @@ set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_EXE_LINKER_FLAGS "-m32") + +target_link_libraries(gluasteal System) From 1446c4f3e05d4f1c40a9e2b5323866a47a27d6ec Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:19:43 +0100 Subject: [PATCH 04/56] Temp link System --- src/CMakeLists.txt | 2 +- toolchains/gcc-32bit.cmake | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f981ba8..46022f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,4 +24,4 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) -target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library) +target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library System) diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index b019513..c2a9674 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -2,5 +2,3 @@ set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_EXE_LINKER_FLAGS "-m32") - -target_link_libraries(gluasteal System) From db84949384dc946b3bca30fad6791c9c02d1f722 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:21:31 +0100 Subject: [PATCH 05/56] lib prefix? --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46022f9..7896892 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,4 +24,4 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) -target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library System) +target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library libSystem) From da34cdca4a42700297bd1381bb993d62ed281412 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:24:42 +0100 Subject: [PATCH 06/56] Find libSystem --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7896892..f4de7aa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,4 +24,6 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) +find_library(libSystem "libSystem") + target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library libSystem) From b4a13b8b4c622673a41102b636f92703f127e8f5 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:27:07 +0100 Subject: [PATCH 07/56] Add more names --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f4de7aa..bc91c98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,6 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) -find_library(libSystem "libSystem") +find_library(libSystem "libSystem" "System" "system" "libSystem.dylib") target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library libSystem) From 5e16a48cfd4de960406a3a16f036fd7d1c8fca11 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:34:57 +0100 Subject: [PATCH 08/56] Update flags --- src/CMakeLists.txt | 4 +--- toolchains/gcc-32bit.cmake | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc91c98..f981ba8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,6 +24,4 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) -find_library(libSystem "libSystem" "System" "system" "libSystem.dylib") - -target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library libSystem) +target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library) diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index c2a9674..454d2a3 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -lSystem") +set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -lSystem") -set(CMAKE_EXE_LINKER_FLAGS "-m32") +set(CMAKE_EXE_LINKER_FLAGS "-m32 -lSystem") From 04d2788b81fe8d941d9be4b9e353cbe1271dcf58 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:39:20 +0100 Subject: [PATCH 09/56] Add prefix --- toolchains/gcc-32bit.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index 454d2a3..7124481 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -lSystem") -set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -lSystem") +set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -llibSystem") +set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -llibSystem") -set(CMAKE_EXE_LINKER_FLAGS "-m32 -lSystem") +set(CMAKE_EXE_LINKER_FLAGS "-m32 -llibSystem") From 7c641ced6c7b4d3de73a2fb23618ca9257187dd8 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:41:48 +0100 Subject: [PATCH 10/56] Change order --- toolchains/gcc-32bit.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index 7124481..717b672 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -llibSystem") -set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -llibSystem") +set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_EXE_LINKER_FLAGS "-m32 -llibSystem") +set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32") From 3b3a3ba78cddd8fe5cdd35798b8d8ea52f33b45f Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:56:44 +0100 Subject: [PATCH 11/56] Link --- src/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f981ba8..d571d8a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,4 +24,8 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) +find_library(libSystem "system" "System" "libsystem" "libSystem") + +message(STATUS "libSystem: ${libSystem}") + target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library) From 63a2ed11013442f16208f36773eed0c58ce10370 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 19:59:58 +0100 Subject: [PATCH 12/56] Move stuff --- CMakeLists.txt | 4 ++++ src/CMakeLists.txt | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f39ffa..fd0cd30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.10) project(gluasteal LANGUAGES CXX VERSION 2.0) +find_library(libSystem "system" "System" "libsystem" "libSystem") + +message(STATUS "libSystem: ${libSystem}") + enable_testing() # set PIC diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d571d8a..f981ba8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,8 +24,4 @@ add_subdirectory(tests) add_library(gluasteal SHARED main.cpp init.cpp logger.cpp config.cpp) -find_library(libSystem "system" "System" "libsystem" "libSystem") - -message(STATUS "libSystem: ${libSystem}") - target_link_libraries(gluasteal PRIVATE ${CMAKE_THREADS_LIBS_INIT} file lua hook gamesdk library) From 5c545257bc15bd1882610bf21c036ca25f8060ea Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 20:09:52 +0100 Subject: [PATCH 13/56] Debug output --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce644a9..d0f3b08 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: CC: /usr/bin/gcc CXX: /usr/bin/g++ working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake + run: cmake --debug-output $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake - name: Build shell: bash From d9295e68386245b16db5b7328a49f42d47d644cb Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 20:11:18 +0100 Subject: [PATCH 14/56] Debug output --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0f3b08..cf85729 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: CC: /usr/bin/gcc CXX: /usr/bin/g++ working-directory: ${{runner.workspace}}/build - run: cmake --debug-output $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake - name: Build shell: bash @@ -104,7 +104,7 @@ jobs: CC: /usr/bin/gcc CXX: /usr/bin/g++ working-directory: ${{runner.workspace}}/build - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake + run: cmake --debug-output $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DCMAKE_TOOLCHAIN_FILE=toolchains/${{matrix.toolchain}}.cmake - name: Build shell: bash From b9d61d4af030cb705a4e31baed4655d5f4108ef4 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 21:52:15 +0100 Subject: [PATCH 15/56] Reverse gcc-32bit toolchain --- .github/workflows/ci.yml | 2 +- toolchains/gcc-32bit.cmake | 6 +++--- toolchains/gcc-macos-32bit.cmake | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 toolchains/gcc-macos-32bit.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf85729..9d269ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -85,7 +85,7 @@ jobs: os: - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] - toolchain: ["gcc-32bit", "gcc-64bit"] + toolchain: ["gcc-macos-32bit", "gcc-64bit"] name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" runs-on: ${{matrix.os.distro}} diff --git a/toolchains/gcc-32bit.cmake b/toolchains/gcc-32bit.cmake index 717b672..c2a9674 100644 --- a/toolchains/gcc-32bit.cmake +++ b/toolchains/gcc-32bit.cmake @@ -1,4 +1,4 @@ -set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32") +set(CMAKE_EXE_LINKER_FLAGS "-m32") diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake new file mode 100644 index 0000000..717b672 --- /dev/null +++ b/toolchains/gcc-macos-32bit.cmake @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") + +set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32") From c43b6b4fb6c7a89776666e1ca9649f16b5563df1 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 22:12:17 +0100 Subject: [PATCH 16/56] Link options --- toolchains/gcc-macos-32bit.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 717b672..ca2922b 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -2,3 +2,5 @@ set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable" set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32") + +add_link_options("-lSystem") From 5cf31d3bed6ade4e02416bd5bc707cec8c660779 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 22:24:24 +0100 Subject: [PATCH 17/56] CMAKE_TRY_COMPILE_TARGET_TYPE --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd0cd30..b2de4ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 3.10) + +set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + project(gluasteal LANGUAGES CXX VERSION 2.0) find_library(libSystem "system" "System" "libsystem" "libSystem") From b31629f1535e758ae876d922679e431bd1c1b215 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 22:29:01 +0100 Subject: [PATCH 18/56] Add macOS 11 to CI matrix --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d269ef..f498b71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,6 +83,7 @@ jobs: strategy: matrix: os: + - { name: "macOS Big Sur 11", distro: macos-11 } - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] toolchain: ["gcc-macos-32bit", "gcc-64bit"] From 74c906215da9fed850c3f2c2bcfef093919ab19e Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Thu, 27 Oct 2022 22:50:26 +0100 Subject: [PATCH 19/56] Remove link.h include for macos --- src/library/library.cpp | 6 +++--- src/library/library.hpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index 310e5e1..16e2e8c 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -34,7 +34,7 @@ static const std::map extension_mapping = { #endif }; -#if (defined(OS_LINUX) || defined(OS_MAC)) +#if (defined(OS_LINUX)) struct library_entry { const char* name; void* lib; @@ -57,7 +57,7 @@ glt::lib::Library::Library(const std::string& pathname) : std::string pathnamext(pathname + GetExtension(pathname)); -#if (defined(OS_LINUX) || defined(OS_MAC)) +#if (defined(OS_LINUX)) library_entry entry; entry.name = pathnamext.c_str(); entry.lib = nullptr; @@ -92,7 +92,7 @@ glt::lib::Library::Library(const std::string& pathname) : } glt::lib::Library::~Library() { -#if (defined(OS_LINUX) || defined(OS_MAC)) +#if (defined(OS_LINUX)) if (m_handle) { dlclose(m_handle); } diff --git a/src/library/library.hpp b/src/library/library.hpp index 868d102..e360486 100644 --- a/src/library/library.hpp +++ b/src/library/library.hpp @@ -25,12 +25,14 @@ along with this program. If not, see . */ #include "os.hpp" -#if (defined(OS_LINUX) || defined(OS_MAC)) +#if (defined(OS_LINUX)) #include #include #elif (defined(OS_WINDOWS)) #include #include +#elif (defined(OS_MAC)) +#include #endif namespace glt::lib { From df2f5af0a7a2ec68454f69311da56daf73613b21 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Fri, 28 Oct 2022 08:36:47 +0100 Subject: [PATCH 20/56] Include dyld.h --- src/library/library.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/library.hpp b/src/library/library.hpp index e360486..24784c0 100644 --- a/src/library/library.hpp +++ b/src/library/library.hpp @@ -33,6 +33,7 @@ along with this program. If not, see . */ #include #elif (defined(OS_MAC)) #include +#include #endif namespace glt::lib { From 437818284ff0f362a9e38dd15f3840f7f8a42d45 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 17:41:24 +0100 Subject: [PATCH 21/56] Set arch to i386 --- toolchains/gcc-macos-32bit.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index ca2922b..8cdd94b 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,6 +1,6 @@ -set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") +set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") -set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32") +set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32 -arch i386") add_link_options("-lSystem") From fcab91e2c8bd06a82418af145c2eee4f2162dd81 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 17:50:31 +0100 Subject: [PATCH 22/56] Set sysroot --- toolchains/gcc-macos-32bit.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 8cdd94b..2b6722d 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,5 +1,5 @@ -set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") -set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") +set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") +set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32 -arch i386") From bd4d4edf75d3fb4c349b631f1cdfa0eff6d186f3 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 17:54:43 +0100 Subject: [PATCH 23/56] Set CMake sysroot and deployment target --- toolchains/gcc-macos-32bit.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 2b6722d..7593903 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -3,4 +3,8 @@ set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -a set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32 -arch i386") +set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.15/) + +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") + add_link_options("-lSystem") From b7006ee87eb948575377c4012a2ba6fb0f9dcfc3 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 17:57:36 +0100 Subject: [PATCH 24/56] Remove -lSystem flag --- toolchains/gcc-macos-32bit.cmake | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 7593903..950c329 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,10 +1,8 @@ -set(CMAKE_CXX_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") -set(CMAKE_C_FLAGS "-lSystem -m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") +set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") +set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") -set(CMAKE_EXE_LINKER_FLAGS "-lSystem -m32 -arch i386") +set(CMAKE_EXE_LINKER_FLAGS "-m32 -arch i386") set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.15/) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") - -add_link_options("-lSystem") From d26d467fae946afc482ec40363a0066c05f11b3d Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:05:58 +0100 Subject: [PATCH 25/56] Set up xcode version --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f498b71..4112db1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,8 @@ jobs: strategy: matrix: os: - - { name: "macOS Big Sur 11", distro: macos-11 } - - { name: "macOS Monterey 12", distro: macos-12 } + - { name: "macOS Big Sur 11", distro: macos-11, xcode_version: 10.7 } + - { name: "macOS Monterey 12", distro: macos-12, xcode_version: latest-stable } build_type: [Debug, Release] toolchain: ["gcc-macos-32bit", "gcc-64bit"] @@ -92,6 +92,10 @@ jobs: runs-on: ${{matrix.os.distro}} steps: + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: ${{matrix.os.xcode_version}} + - uses: actions/checkout@v2 with: submodules: recursive From eaabfbb70b77ae733548e6b1f80c2456a3d024e0 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:07:03 +0100 Subject: [PATCH 26/56] Fix indentation --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4112db1..2e10faf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,8 +93,8 @@ jobs: steps: - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{matrix.os.xcode_version}} + with: + xcode-version: ${{matrix.os.xcode_version}} - uses: actions/checkout@v2 with: From cec6257348b0ecbd2e4bb9feaa3ed958bac07bb9 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:11:47 +0100 Subject: [PATCH 27/56] Revert "Fix indentation" This reverts commit eaabfbb70b77ae733548e6b1f80c2456a3d024e0. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e10faf..4112db1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,8 +93,8 @@ jobs: steps: - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{matrix.os.xcode_version}} + with: + xcode-version: ${{matrix.os.xcode_version}} - uses: actions/checkout@v2 with: From 2b216c0006b7d0535a342a02b4a4d3a2f49bd424 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:11:51 +0100 Subject: [PATCH 28/56] Revert "Set up xcode version" This reverts commit d26d467fae946afc482ec40363a0066c05f11b3d. --- .github/workflows/ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4112db1..f498b71 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,8 @@ jobs: strategy: matrix: os: - - { name: "macOS Big Sur 11", distro: macos-11, xcode_version: 10.7 } - - { name: "macOS Monterey 12", distro: macos-12, xcode_version: latest-stable } + - { name: "macOS Big Sur 11", distro: macos-11 } + - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] toolchain: ["gcc-macos-32bit", "gcc-64bit"] @@ -92,10 +92,6 @@ jobs: runs-on: ${{matrix.os.distro}} steps: - - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: ${{matrix.os.xcode_version}} - - uses: actions/checkout@v2 with: submodules: recursive From 6aba6e4fca097802af560902fa81f010914a822e Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:12:59 +0100 Subject: [PATCH 29/56] CMAKE_OSX_ARCHITECTURES --- toolchains/gcc-macos-32bit.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 950c329..5f0645e 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,8 +1,9 @@ -set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") -set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386 --sysroot /Developer/SDKs/MacOSX10.15.sdk/") +set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") +set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") set(CMAKE_EXE_LINKER_FLAGS "-m32 -arch i386") set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.15/) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") + +set(CMAKE_OSX_ARCHITECTURES i386) From 258242f69ae218b52ad7a4bb344f576de3eb066c Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:17:06 +0100 Subject: [PATCH 30/56] Clean up --- toolchains/gcc-macos-32bit.cmake | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 5f0645e..40b1d57 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,9 +1,8 @@ -set(CMAKE_CXX_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") -set(CMAKE_C_FLAGS "-m32 -Wall -Wextra -pedantic -Wno-unused-variable -arch i386") +set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_EXE_LINKER_FLAGS "-m32 -arch i386") +#set(CMAKE_EXE_LINKER_FLAGS "-m32 -arch i386") -set(CMAKE_OSX_SYSROOT /Developer/SDKs/MacOSX10.15/) +set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.15/") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") - -set(CMAKE_OSX_ARCHITECTURES i386) +set(CMAKE_OSX_ARCHITECTURES "i386") From f8a43596921c6532bb308c9891f4c94569a39fce Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:22:59 +0100 Subject: [PATCH 31/56] Remove sysroot and deployment target flags --- toolchains/gcc-macos-32bit.cmake | 4 ---- 1 file changed, 4 deletions(-) diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-32bit.cmake index 40b1d57..32fef36 100644 --- a/toolchains/gcc-macos-32bit.cmake +++ b/toolchains/gcc-macos-32bit.cmake @@ -1,8 +1,4 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") -#set(CMAKE_EXE_LINKER_FLAGS "-m32 -arch i386") - -set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.15/") -set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15") set(CMAKE_OSX_ARCHITECTURES "i386") From 4af6af1858056fb04be23454bfa2658b064d63b8 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 18:27:01 +0100 Subject: [PATCH 32/56] macOS build instructions --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f03d318..8683480 100644 --- a/README.md +++ b/README.md @@ -154,11 +154,22 @@ git clone https://github.com/lewisclark/glua-steal cd glua-steal git submodule update --init --recursive mkdir build && cd build -choose the 32bit or 64bit toolchain below (toolchains are in toolchains/ folder) +choose the gcc-32bit or gcc-64bit toolchain below (toolchains are in toolchains/ folder) cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-<32bit/64bit>.cmake make ``` +##### macOS +``` +git clone https://github.com/lewisclark/glua-steal +cd glua-steal +git submodule update --init --recursive +mkdir build && cd build +choose the gcc-macos-32bit or gcc-64bit toolchain below (toolchains are in toolchains/ folder) +cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-.cmake +make +``` + --- ### License From a054e3d208935b6abd8b91a3ad87f2b87f0a9c4f Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 19:15:59 +0100 Subject: [PATCH 33/56] Initial implementation of loaded library fetching --- src/library/library.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/library/library.cpp b/src/library/library.cpp index 16e2e8c..c22b733 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -84,6 +84,23 @@ glt::lib::Library::Library(const std::string& pathname) : } } while (Module32Next(module_snap, &module_entry)); +#elif (defined(OS_MAC)) + // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dyld.3.html + + // FIXME: It isn't thread safe to iterate using this count - find an alternative + uint32_t num_images = _dyld_image_count(); + + for (uint32_t i = 0; i < num_images; ++i) { + std::string library_name = _dyld_get_image_name(i); + + if (library_name.find(pathnamext) != std::string::npos) { + m_handle = reinterpret_cast( + _dyld_get_image_vmaddr_slide(i) + ); + + break; + } + } #endif if (!m_handle) { From a9dd2df2bbddd3ccd45f12b6f9c9aec0acea6591 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 19:36:36 +0100 Subject: [PATCH 34/56] Add logging --- src/library/library.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index c22b733..653f135 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -90,13 +90,25 @@ glt::lib::Library::Library(const std::string& pathname) : // FIXME: It isn't thread safe to iterate using this count - find an alternative uint32_t num_images = _dyld_image_count(); + const auto& logger = glt::GetLogger(); + logger->debug("{} images to enumerate"); + for (uint32_t i = 0; i < num_images; ++i) { - std::string library_name = _dyld_get_image_name(i); + const char* c_name = _dyld_get_image_name(i); + + if (!c_name) + continue; + + std::string name = c_name; + + logger->debug("image \"{}\"", name); + + if (name.find(pathnamext) != std::string::npos) { + auto p = _dyld_get_image_vmaddr_slide(i); + + logger->debug("found image \"{}\" at {:x}", name, p); - if (library_name.find(pathnamext) != std::string::npos) { - m_handle = reinterpret_cast( - _dyld_get_image_vmaddr_slide(i) - ); + m_handle = reinterpret_cast(p); break; } From b56f6eb9c103f3da11abbab91df474bb1607634d Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 19:38:08 +0100 Subject: [PATCH 35/56] Include logger.hpp --- src/library/library.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/library.hpp b/src/library/library.hpp index 24784c0..50815d7 100644 --- a/src/library/library.hpp +++ b/src/library/library.hpp @@ -24,6 +24,7 @@ along with this program. If not, see . */ #include #include "os.hpp" +#include "logger.hpp" #if (defined(OS_LINUX)) #include From ff0e99ad66e3ca5b1c6fb2451e711f628dc95c72 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 19:43:57 +0100 Subject: [PATCH 36/56] Use dlopen instead of _dyld_get_image_vmaddr_slide --- src/library/library.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index 653f135..7d0c6e1 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -104,9 +104,9 @@ glt::lib::Library::Library(const std::string& pathname) : logger->debug("image \"{}\"", name); if (name.find(pathnamext) != std::string::npos) { - auto p = _dyld_get_image_vmaddr_slide(i); + auto p = dlopen(c_name, RTLD_NOLOAD | RTLD_NOW); - logger->debug("found image \"{}\" at {:x}", name, p); + logger->debug("found image \"{}\" at {:x}", name, (uintptr_t)p); m_handle = reinterpret_cast(p); @@ -121,7 +121,7 @@ glt::lib::Library::Library(const std::string& pathname) : } glt::lib::Library::~Library() { -#if (defined(OS_LINUX)) +#if (defined(OS_LINUX) || defined(OS_MAC)) if (m_handle) { dlclose(m_handle); } From a447f0efebc215caf038f6b2a984b4a756f04bdd Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 20:02:56 +0100 Subject: [PATCH 37/56] Add num_images as arg to debug log --- src/library/library.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/library/library.cpp b/src/library/library.cpp index 7d0c6e1..59e9fe7 100644 --- a/src/library/library.cpp +++ b/src/library/library.cpp @@ -91,7 +91,7 @@ glt::lib::Library::Library(const std::string& pathname) : uint32_t num_images = _dyld_image_count(); const auto& logger = glt::GetLogger(); - logger->debug("{} images to enumerate"); + logger->debug("{} images to enumerate", num_images); for (uint32_t i = 0; i < num_images; ++i) { const char* c_name = _dyld_get_image_name(i); From 53fcd26cca3f59f222216c791907b71f6f346982 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 20:28:33 +0100 Subject: [PATCH 38/56] Remove old debug stuff --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2de4ee..ac9d126 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,6 @@ set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") project(gluasteal LANGUAGES CXX VERSION 2.0) -find_library(libSystem "system" "System" "libsystem" "libSystem") - -message(STATUS "libSystem: ${libSystem}") - enable_testing() # set PIC From 90d9449b92182f3097eabb9f3b870aa287539642 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sat, 29 Oct 2022 21:17:34 +0100 Subject: [PATCH 39/56] Update actions/checkout to v3 for macOS CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f347db..40b580f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: runs-on: ${{matrix.os.distro}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive From 56474f6dfb2a6a289d7d900e05dc3f23292afb53 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Sun, 30 Oct 2022 22:34:14 +0000 Subject: [PATCH 40/56] Force trace debug level --- src/config.cpp | 2 +- src/logger.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/config.cpp b/src/config.cpp index 2545a5e..ad072fd 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -92,7 +92,7 @@ void glt::config::LoadConfig() { } } - spdlog::set_level(cfg.logger_level); + //spdlog::set_level(cfg.logger_level); logger->debug("Config loaded"); diff --git a/src/logger.cpp b/src/logger.cpp index 8266064..253741f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -21,10 +21,13 @@ static std::shared_ptr logger = nullptr; void glt::InitLogger() { spdlog::flush_every(std::chrono::seconds(1)); spdlog::set_pattern("[%d-%m-%C - %T.%e] [%l] %v"); + spdlog::set_level(spdlog::level::trace); const auto& logpath = file::GetLogFilePath(); logger = spdlog::basic_logger_mt("gluasteal", logpath.string()); + + logger.get()->debug("Logger initialised"); } spdlog::logger* glt::GetLogger() { From 34f05cb24c8120b828b22c213d052db7df49dda0 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 08:49:48 +0000 Subject: [PATCH 41/56] Add x86_64 arch macOS toolchain --- toolchains/gcc-macos-x86_64.cmake | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 toolchains/gcc-macos-x86_64.cmake diff --git a/toolchains/gcc-macos-x86_64.cmake b/toolchains/gcc-macos-x86_64.cmake new file mode 100644 index 0000000..d164055 --- /dev/null +++ b/toolchains/gcc-macos-x86_64.cmake @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") + +set(CMAKE_OSX_ARCHITECTURES "x86_64") From 7ac3285751d51e8823080107b4ad7b4660423bab Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 08:50:59 +0000 Subject: [PATCH 42/56] Rename toolchain gcc-macos-32bit to gcc-macos-i386 --- .github/workflows/ci.yml | 2 +- toolchains/{gcc-macos-32bit.cmake => gcc-macos-i386.cmake} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename toolchains/{gcc-macos-32bit.cmake => gcc-macos-i386.cmake} (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40b580f..2cb07ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: - { name: "macOS Big Sur 11", distro: macos-11 } - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] - toolchain: ["gcc-macos-32bit", "gcc-64bit"] + toolchain: ["gcc-macos-i386", "gcc-64bit"] name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" runs-on: ${{matrix.os.distro}} diff --git a/toolchains/gcc-macos-32bit.cmake b/toolchains/gcc-macos-i386.cmake similarity index 100% rename from toolchains/gcc-macos-32bit.cmake rename to toolchains/gcc-macos-i386.cmake From 9ab35d59935e436c0d313e6c212a35ca50134a1a Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 08:51:54 +0000 Subject: [PATCH 43/56] Change macOS 64bit ci to x86_64 toolchain --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cb07ef..196a2fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: - { name: "macOS Big Sur 11", distro: macos-11 } - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] - toolchain: ["gcc-macos-i386", "gcc-64bit"] + toolchain: ["gcc-macos-i386", "gcc-macos-x86_64"] name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" runs-on: ${{matrix.os.distro}} From febdc48cf966db74a7bada99b70c8f2296f56dad Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:00:48 +0000 Subject: [PATCH 44/56] Add macOS fat toolchain and to CI --- .github/workflows/ci.yml | 2 +- toolchains/gcc-macos-fat.cmake | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 toolchains/gcc-macos-fat.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 196a2fc..6f7b3aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: - { name: "macOS Big Sur 11", distro: macos-11 } - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] - toolchain: ["gcc-macos-i386", "gcc-macos-x86_64"] + toolchain: ["gcc-macos-i386", "gcc-macos-x86_64", "gcc-macos-fat"] name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" runs-on: ${{matrix.os.distro}} diff --git a/toolchains/gcc-macos-fat.cmake b/toolchains/gcc-macos-fat.cmake new file mode 100644 index 0000000..dbcfe76 --- /dev/null +++ b/toolchains/gcc-macos-fat.cmake @@ -0,0 +1,4 @@ +set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") +set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") + +set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") From adaadaeacc99ab5f6106bca2535a6dcea844ab86 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:14:13 +0000 Subject: [PATCH 45/56] Correctly set cache variable CMAKE_OSX_ARCHITECTURES --- toolchains/gcc-macos-fat.cmake | 2 +- toolchains/gcc-macos-i386.cmake | 2 +- toolchains/gcc-macos-x86_64.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/toolchains/gcc-macos-fat.cmake b/toolchains/gcc-macos-fat.cmake index dbcfe76..efe04b8 100644 --- a/toolchains/gcc-macos-fat.cmake +++ b/toolchains/gcc-macos-fat.cmake @@ -1,4 +1,4 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_OSX_ARCHITECTURES "i386;x86_64") +set(CMAKE_OSX_ARCHITECTURES "i386;x86_64" CACHE STRING "" FORCE) diff --git a/toolchains/gcc-macos-i386.cmake b/toolchains/gcc-macos-i386.cmake index 32fef36..e088850 100644 --- a/toolchains/gcc-macos-i386.cmake +++ b/toolchains/gcc-macos-i386.cmake @@ -1,4 +1,4 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_OSX_ARCHITECTURES "i386") +set(CMAKE_OSX_ARCHITECTURES "i386" CACHE STRING "" FORCE) diff --git a/toolchains/gcc-macos-x86_64.cmake b/toolchains/gcc-macos-x86_64.cmake index d164055..8a612e8 100644 --- a/toolchains/gcc-macos-x86_64.cmake +++ b/toolchains/gcc-macos-x86_64.cmake @@ -1,4 +1,4 @@ set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") set(CMAKE_C_FLAGS "-Wall -Wextra -pedantic -Wno-unused-variable") -set(CMAKE_OSX_ARCHITECTURES "x86_64") +set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "" FORCE) From b54eb95f1412f36d0609ebc59a0af23608d6ea75 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:23:59 +0000 Subject: [PATCH 46/56] Remove 32-bit/i386 macOS build from CI https://developer.apple.com/documentation/xcode-release-notes/xcode-10-release-notes The macOS 10.14 SDK no longer contains support for compiling 32-bit applications. If developers need to compile for i386, Xcode 9.4 or earlier is required. (39858111) No stable GitHub Actions macOS image includes that old of an Xcode version. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f7b3aa..c579dd1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,7 +86,7 @@ jobs: - { name: "macOS Big Sur 11", distro: macos-11 } - { name: "macOS Monterey 12", distro: macos-12 } build_type: [Debug, Release] - toolchain: ["gcc-macos-i386", "gcc-macos-x86_64", "gcc-macos-fat"] + toolchain: ["gcc-macos-x86_64"] name: "${{matrix.os.name}} ${{matrix.build_type}} ${{matrix.toolchain}}" runs-on: ${{matrix.os.distro}} From da0ff0dd9f1fe657d1392b31835a62bc9bd39252 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:32:30 +0000 Subject: [PATCH 47/56] Update README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 733a4cc..306fffb 100644 --- a/README.md +++ b/README.md @@ -166,11 +166,12 @@ git clone https://github.com/lewisclark/glua-steal cd glua-steal git submodule update --init --recursive mkdir build && cd build -choose the gcc-macos-32bit or gcc-64bit toolchain below (toolchains are in toolchains/ folder) -cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-.cmake +cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-macos-x86_64.cmake make ``` +If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. + --- ### License From e0ae849950674e6bf4e9ac5fa944eb03a3ff8cf0 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:36:37 +0000 Subject: [PATCH 48/56] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 306fffb..40b4a31 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-macos-x86_64.cmake make ``` -If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. +If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](/commit/b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. --- From 21ef281a18ef1f73723e4067fcb49f7e916b9382 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:37:10 +0000 Subject: [PATCH 49/56] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40b4a31..882502e 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-macos-x86_64.cmake make ``` -If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](/commit/b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. +If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](../../commit/b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. --- From 682e05feea463726be35ac44889349f35c3ea44b Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Mon, 31 Oct 2022 09:48:35 +0000 Subject: [PATCH 50/56] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 882502e..23eb78d 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/gcc-macos-x86_64.cmake make ``` -If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been build or tested because [Xcode dropped support](../../commit/b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. +If needed, the library can be built in i386 (32-bit) using either the `gcc-macos-i386` or `gcc-macos-fat` toolchain. The 32-bit build of glua-steal has not been built or tested because Xcode [dropped support](../../commit/b54eb95f1412f36d0609ebc59a0af23608d6ea75) for building 32-bit applications. --- From 7a78d2d36480f42ee0ab8c093df18e305b432193 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 18:53:25 +0000 Subject: [PATCH 51/56] Revert "Force trace debug level" This reverts commit 56474f6dfb2a6a289d7d900e05dc3f23292afb53. --- src/config.cpp | 2 +- src/logger.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index ad072fd..2545a5e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -92,7 +92,7 @@ void glt::config::LoadConfig() { } } - //spdlog::set_level(cfg.logger_level); + spdlog::set_level(cfg.logger_level); logger->debug("Config loaded"); diff --git a/src/logger.cpp b/src/logger.cpp index 253741f..8266064 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -21,13 +21,10 @@ static std::shared_ptr logger = nullptr; void glt::InitLogger() { spdlog::flush_every(std::chrono::seconds(1)); spdlog::set_pattern("[%d-%m-%C - %T.%e] [%l] %v"); - spdlog::set_level(spdlog::level::trace); const auto& logpath = file::GetLogFilePath(); logger = spdlog::basic_logger_mt("gluasteal", logpath.string()); - - logger.get()->debug("Logger initialised"); } spdlog::logger* glt::GetLogger() { From c5eaf943cbf6b48284ac1d8c7b68b0a2ec48d118 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 18:55:14 +0000 Subject: [PATCH 52/56] Set cmake try compile back to executable --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac9d126..d9008f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.10) -set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") - project(gluasteal LANGUAGES CXX VERSION 2.0) enable_testing() From 6122910a5354cf584d0fed9a3d18ab620d8198a2 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 19:05:04 +0000 Subject: [PATCH 53/56] Update README.md --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 23eb78d..cfbdd61 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,14 @@ gluasteal is a better, cross-platform replacement for various Lua dumpers and lo ![Windows usage](https://i.imgur.com/j38AKQ7.png) ![Linux usage](https://i.imgur.com/N7reRXS.png) -Supports Windows & Linux (32-bit & 64-bit). Has not yet been tested on macOS. +Supported operating systems and architectures: +- Windows 32-bit +- Windows 64-bit +- Linux 32-bit +- Linux 64-bit +- macOS 64-bit + +Please submit an issue if glua-steal is not working on your system. --- @@ -61,7 +68,17 @@ Logs and Lua files will be written to the gluasteal folder, in your home directo #### macOS -Using DYLD\_INSERT\_LIBRARIES (see LD\_PRELOAD above) +Using LLDB. + +```bash +pid=1234 +lib_path="/full/path/to/libgluasteal.dylib" + +sudo lldb --attach-pid $pid --batch \ + -o "p (void*)dlopen(\"$lib_path\", 1)" \ + -o detach \ + -o quit +``` --- From f567b23f2377d1ada808dd5138dffeacccaf3c3e Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 19:08:08 +0000 Subject: [PATCH 54/56] Update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cfbdd61..138a463 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,11 @@ gluasteal is a better, cross-platform replacement for various Lua dumpers and lo ![Windows usage](https://i.imgur.com/j38AKQ7.png) ![Linux usage](https://i.imgur.com/N7reRXS.png) +| Operating System | Architecture | +| ------------- | ------------- | +| Content Cell | Content Cell | +| Content Cell | Content Cell | + Supported operating systems and architectures: - Windows 32-bit - Windows 64-bit @@ -32,7 +37,6 @@ Please submit an issue if glua-steal is not working on your system. * Concurrent IO - The Lua dumper does IO in its own thread to eliminate bottleneck and ensure maximum in-game performance * Robust protections against servers serving malicious file paths * Supports the 32-bit and 64-bit versions of the game -* Supports Windows and Linux * Easily [configurable](#configuration) --- From 8ec5dece4248083f5862a7ee3e36144331cf6ce2 Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 19:11:21 +0000 Subject: [PATCH 55/56] Update readme --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 138a463..a04659c 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,6 @@ gluasteal is a better, cross-platform replacement for various Lua dumpers and lo ![Windows usage](https://i.imgur.com/j38AKQ7.png) ![Linux usage](https://i.imgur.com/N7reRXS.png) -| Operating System | Architecture | -| ------------- | ------------- | -| Content Cell | Content Cell | -| Content Cell | Content Cell | - Supported operating systems and architectures: - Windows 32-bit - Windows 64-bit @@ -36,7 +31,6 @@ Please submit an issue if glua-steal is not working on your system. * Lua Blocker - Block Lua scripts of your choosing * Concurrent IO - The Lua dumper does IO in its own thread to eliminate bottleneck and ensure maximum in-game performance * Robust protections against servers serving malicious file paths -* Supports the 32-bit and 64-bit versions of the game * Easily [configurable](#configuration) --- From 786254b595721417ba8e631b8eae73cf8004b7ae Mon Sep 17 00:00:00 2001 From: Lewis Clark Date: Tue, 1 Nov 2022 19:30:09 +0000 Subject: [PATCH 56/56] Bump version to 2.1 --- CMakeLists.txt | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9008f6..b12c604 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.10) -project(gluasteal LANGUAGES CXX VERSION 2.0) +project(gluasteal LANGUAGES CXX VERSION 2.1) enable_testing() diff --git a/README.md b/README.md index a04659c..4edfcdd 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI Badge](https://github.com/lewisclark/glua-steal/workflows/CI/badge.svg)](https://github.com/lewisclark/glua-steal/actions?query=workflow%3Aci) ![Downloads Badge](https://img.shields.io/github/downloads/lewisclark/glua-steal/total) -![Version Badge](https://img.shields.io/badge/version-2.0-green) +![Version Badge](https://img.shields.io/badge/version-2.1-green) ![License Badge](https://img.shields.io/github/license/lewisclark/glua-steal) ![Issues Badge](https://img.shields.io/github/issues/lewisclark/glua-steal)