From d0029cb66998054d1a1c616b3873e1c1ac58afa7 Mon Sep 17 00:00:00 2001 From: DataM0del <183248792+DataM0del@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:56:55 -0600 Subject: [PATCH 1/4] add(.vscode): `c_cpp_properties.json` So you can edit this in VSCode. Assumes you have runluau located in the parent of where you cloned the repo, if not, skill issue, change the include paths. --- .gitignore | 1 + .vscode/c_cpp_properties.json | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.gitignore b/.gitignore index 8a30d25..bf02572 100644 --- a/.gitignore +++ b/.gitignore @@ -382,6 +382,7 @@ FodyWeavers.xsd !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json +!.vscode/c_cpp_properties.json *.code-workspace # Local History for Visual Studio Code diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..69e5112 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,21 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + // if it isn't here then skill issue L + ratio don't care change it yourself + "../runluau/shared/", + // shut up C++ + "../runluau/Luau/Compiler/include", + "../runluau/Luau/Ast/include", + "../runluau/Luau/Common/include", + "../runluau/Luau/CodeGen/include" + ], + "defines": [], + "cStandard": "c17", + "cppStandard": "c++20", + "intelliSenseMode": "linux-clang-x64" + } + ], + "version": 4 +} \ No newline at end of file From ea08523f73f0329123832f0c3314005845c5cf99 Mon Sep 17 00:00:00 2001 From: DataM0del <183248792+DataM0del@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:57:42 -0600 Subject: [PATCH 2/4] chore(runluau-template): don't include `Windows.h` if we're not on Windows --- runluau-template/pch.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/runluau-template/pch.h b/runluau-template/pch.h index 37cf671..0da6061 100644 --- a/runluau-template/pch.h +++ b/runluau-template/pch.h @@ -1,6 +1,8 @@ #pragma once #include +#ifdef _WIN32 #include +#endif #include "luau.h" \ No newline at end of file From c6db8165af02d741d24b3a74755e687a23a5b8dd Mon Sep 17 00:00:00 2001 From: DataM0del <183248792+DataM0del@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:49:35 -0600 Subject: [PATCH 3/4] feat(runluau-template): ChatGPT porting Inc. --- runluau-template/dllmain.cpp | 15 ++++++++++++++- runluau-template/lib.cpp | 21 ++++++++++++++------- runluau-template/pch.h | 5 ++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/runluau-template/dllmain.cpp b/runluau-template/dllmain.cpp index def0f3d..9c86ca5 100644 --- a/runluau-template/dllmain.cpp +++ b/runluau-template/dllmain.cpp @@ -1,5 +1,18 @@ #include "pch.h" +#ifdef _WIN32 +// Windows entry point BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { return TRUE; -} \ No newline at end of file +} + +#else +// Unix-like systems entry point +__attribute__((constructor)) void on_library_load() { + // Code to run when the shared library is loaded +} + +__attribute__((destructor)) void on_library_unload() { + // Code to run when the shared library is unloaded +} +#endif diff --git a/runluau-template/lib.cpp b/runluau-template/lib.cpp index 0f91cc8..38f1312 100644 --- a/runluau-template/lib.cpp +++ b/runluau-template/lib.cpp @@ -1,15 +1,22 @@ #include "pch.h" int test(lua_State* thread) { - printf("Working\n"); - return 0; + printf("Working\n"); + return 0; } #define reg(name) {#name, name} constexpr luaL_Reg library[] = { - reg(test), - {NULL, NULL} + reg(test), + {NULL, NULL} }; -extern "C" __declspec(dllexport) void register_library(lua_State* thread) { - luaL_register(thread, "template", library); -} \ No newline at end of file + +extern "C" +#ifdef _WIN32 +__declspec(dllexport) +#else +__attribute__((visibility("default"))) +#endif +void register_library(lua_State* thread) { + luaL_register(thread, "template", library); +} diff --git a/runluau-template/pch.h b/runluau-template/pch.h index 0da6061..92f33ae 100644 --- a/runluau-template/pch.h +++ b/runluau-template/pch.h @@ -1,8 +1,11 @@ #pragma once #include + #ifdef _WIN32 #include +#else +#include // For Unix-like systems #endif -#include "luau.h" \ No newline at end of file +#include "luau.h" From 90ea12aae9b5f15cc1d2418567193ec6d7335a7c Mon Sep 17 00:00:00 2001 From: DataM0del <183248792+DataM0del@users.noreply.github.com> Date: Tue, 12 Nov 2024 17:53:07 -0600 Subject: [PATCH 4/4] chore(lib.cpp): ChatGPT converted the indentation to spaces :skull: --- runluau-template/lib.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runluau-template/lib.cpp b/runluau-template/lib.cpp index 38f1312..c708ec3 100644 --- a/runluau-template/lib.cpp +++ b/runluau-template/lib.cpp @@ -1,14 +1,14 @@ #include "pch.h" int test(lua_State* thread) { - printf("Working\n"); - return 0; + printf("Working\n"); + return 0; } #define reg(name) {#name, name} constexpr luaL_Reg library[] = { - reg(test), - {NULL, NULL} + reg(test), + {NULL, NULL} }; extern "C" @@ -18,5 +18,5 @@ __declspec(dllexport) __attribute__((visibility("default"))) #endif void register_library(lua_State* thread) { - luaL_register(thread, "template", library); + luaL_register(thread, "template", library); }