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 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..c708ec3 100644 --- a/runluau-template/lib.cpp +++ b/runluau-template/lib.cpp @@ -10,6 +10,13 @@ constexpr luaL_Reg library[] = { reg(test), {NULL, NULL} }; -extern "C" __declspec(dllexport) void register_library(lua_State* thread) { + +extern "C" +#ifdef _WIN32 +__declspec(dllexport) +#else +__attribute__((visibility("default"))) +#endif +void register_library(lua_State* thread) { luaL_register(thread, "template", library); -} \ No newline at end of file +} diff --git a/runluau-template/pch.h b/runluau-template/pch.h index 37cf671..92f33ae 100644 --- a/runluau-template/pch.h +++ b/runluau-template/pch.h @@ -1,6 +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"