Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 14 additions & 1 deletion runluau-template/dllmain.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
}

#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
11 changes: 9 additions & 2 deletions runluau-template/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 6 additions & 1 deletion runluau-template/pch.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#pragma once

#include <stdio.h>

#ifdef _WIN32
#include <Windows.h>
#else
#include <dlfcn.h> // For Unix-like systems
#endif

#include "luau.h"
#include "luau.h"