fixed lua dependency
This commit is contained in:
parent
ebf2efdfc8
commit
a5213c552a
|
@ -1,6 +1,3 @@
|
||||||
[submodule "3rdlibs/glfw"]
|
[submodule "3rdlibs/glfw"]
|
||||||
path = 3rdlibs/glfw
|
path = 3rdlibs/glfw
|
||||||
url = https://github.com/glfw/glfw.git
|
url = https://github.com/glfw/glfw.git
|
||||||
[submodule "3rdlibs/lua"]
|
|
||||||
path = 3rdlibs/lua
|
|
||||||
url = https://github.com/lua/lua.git
|
|
|
@ -9,11 +9,8 @@ project(HazelLuaEngine
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HAZEL_CORE_NAME hazel_core)
|
set(HAZEL_CORE_NAME hazel_core)
|
||||||
set(HAZEL_EXECUTOR_NAME hazel)
|
set(HAZEL_EXECUTOR_NAME HazelRunner)
|
||||||
|
set(HAZEL_LUA_BRIDGE_NAME hazel)
|
||||||
# glfw
|
|
||||||
set(GLFW_BUILD_DOCS OFF)
|
|
||||||
set(GLFW_INSTALL OFF)
|
|
||||||
|
|
||||||
include(cmake/FindLua.cmake)
|
include(cmake/FindLua.cmake)
|
||||||
include(cmake/FindGLFW.cmake)
|
include(cmake/FindGLFW.cmake)
|
||||||
|
@ -31,4 +28,4 @@ if(WIN32)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
# sandbox
|
# sandbox
|
||||||
add_subdirectory(binding/lua/executor)
|
add_subdirectory(binding/lua)
|
|
@ -1 +1,3 @@
|
||||||
A tiny engine made with C and Lua for 1MGames
|
A tiny engine made with C and Lua for 1MGames
|
||||||
|
|
||||||
|
NOTE: **Under Windows, you must use MinGW to compile**
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
add_library(${HAZEL_LUA_BRIDGE_NAME} SHARED bridge.c)
|
||||||
|
target_link_libraries(${HAZEL_LUA_BRIDGE_NAME} PUBLIC ${HAZEL_CORE_NAME} lua)
|
||||||
|
|
||||||
|
add_executable(${HAZEL_EXECUTOR_NAME} executor.c)
|
||||||
|
target_link_libraries(${HAZEL_EXECUTOR_NAME} PUBLIC lua)
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include "lua.h"
|
||||||
|
#include "lauxlib.h"
|
||||||
|
#include "lualib.h"
|
||||||
|
#include "luaconf.h"
|
||||||
|
|
||||||
|
#include "hazel/hazel.h"
|
||||||
|
|
||||||
|
static int LuaBridge_RunExampleWindow(lua_State* L) {
|
||||||
|
Hazel_RunExampleWindow();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct luaL_Reg hazel[] = {
|
||||||
|
{"RunExampleWindow", LuaBridge_RunExampleWindow},
|
||||||
|
{NULL, NULL},
|
||||||
|
};
|
||||||
|
|
||||||
|
DLLEXPORT int luaopen_hazel(lua_State* L) {
|
||||||
|
luaL_newlib(L, hazel);
|
||||||
|
return 1;
|
||||||
|
}
|
|
@ -1,5 +1,3 @@
|
||||||
#include "hazel/hazel.h"
|
|
||||||
|
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "lualib.h"
|
#include "lualib.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
|
@ -10,7 +8,7 @@ int main() {
|
||||||
printf("lua init failed\n");
|
printf("lua init failed\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
if (luaL_loadfile(L, "main.lua") || lua_pcall(L, 0, 0, 0)) {
|
if (luaL_loadfile(L, "main.lua") || lua_pcall(L, 0, 0, 0)) {
|
||||||
printf("main.lua load and execute failed\n");
|
printf("main.lua load and execute failed\n");
|
|
@ -1,2 +0,0 @@
|
||||||
add_executable(${HAZEL_EXECUTOR_NAME} ./executor.c)
|
|
||||||
target_link_libraries(${HAZEL_EXECUTOR_NAME} PUBLIC ${HAZEL_CORE_NAME} lua)
|
|
|
@ -1 +1,5 @@
|
||||||
print("hello")
|
---@class hazel
|
||||||
|
---@field RunExampleWindow function
|
||||||
|
local hazel = require "hazel"
|
||||||
|
|
||||||
|
hazel.RunExampleWindow()
|
|
@ -1 +1,3 @@
|
||||||
|
set(GLFW_BUILD_DOCS OFF)
|
||||||
|
set(GLFW_INSTALL OFF)
|
||||||
add_subdirectory(3rdlibs/glfw)
|
add_subdirectory(3rdlibs/glfw)
|
|
@ -1,31 +1,40 @@
|
||||||
set(LUA_SRC
|
set(LUA_SRC
|
||||||
3rdlibs/lua/lapi.c
|
3rdlibs/lua/src/lapi.c
|
||||||
3rdlibs/lua/lcode.c
|
3rdlibs/lua/src/lcode.c
|
||||||
3rdlibs/lua/lctype.c
|
3rdlibs/lua/src/lctype.c
|
||||||
3rdlibs/lua/ldebug.c
|
3rdlibs/lua/src/ldebug.c
|
||||||
3rdlibs/lua/ldo.c
|
3rdlibs/lua/src/ldo.c
|
||||||
3rdlibs/lua/ldump.c
|
3rdlibs/lua/src/ldump.c
|
||||||
3rdlibs/lua/lfunc.c
|
3rdlibs/lua/src/lfunc.c
|
||||||
3rdlibs/lua/lgc.c
|
3rdlibs/lua/src/lgc.c
|
||||||
3rdlibs/lua/llex.c
|
3rdlibs/lua/src/llex.c
|
||||||
|
3rdlibs/lua/src/lmem.c
|
||||||
3rdlibs/lua/lmem.c
|
3rdlibs/lua/src/lobject.c
|
||||||
3rdlibs/lua/lobject.c
|
3rdlibs/lua/src/lopcodes.c
|
||||||
3rdlibs/lua/lopcodes.c
|
3rdlibs/lua/src/lparser.c
|
||||||
3rdlibs/lua/lparser.c
|
3rdlibs/lua/src/lstate.c
|
||||||
3rdlibs/lua/lstate.c
|
3rdlibs/lua/src/lstring.c
|
||||||
3rdlibs/lua/lstring.c
|
3rdlibs/lua/src/ltable.c
|
||||||
3rdlibs/lua/ltable.c
|
3rdlibs/lua/src/ltm.c
|
||||||
|
3rdlibs/lua/src/lundump.c
|
||||||
3rdlibs/lua/ltm.c
|
3rdlibs/lua/src/lvm.c
|
||||||
3rdlibs/lua/lundump.c
|
3rdlibs/lua/src/lzio.c
|
||||||
3rdlibs/lua/lvm.c
|
3rdlibs/lua/src/lauxlib.c
|
||||||
3rdlibs/lua/lzio.c
|
3rdlibs/lua/src/lbaselib.c
|
||||||
3rdlibs/lua/ltests.c
|
3rdlibs/lua/src/lcorolib.c
|
||||||
3rdlibs/lua/lauxlib.c
|
3rdlibs/lua/src/ldblib.c
|
||||||
|
3rdlibs/lua/src/liolib.c
|
||||||
|
3rdlibs/lua/src/lmathlib.c
|
||||||
|
3rdlibs/lua/src/loadlib.c
|
||||||
|
3rdlibs/lua/src/loslib.c
|
||||||
|
3rdlibs/lua/src/lstrlib.c
|
||||||
|
3rdlibs/lua/src/ltablib.c
|
||||||
|
3rdlibs/lua/src/lutf8lib.c
|
||||||
|
3rdlibs/lua/src/linit.c
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(lua STATIC ${LUA_SRC})
|
add_library(lua STATIC ${LUA_SRC})
|
||||||
target_include_directories(lua PUBLIC ./3rdlibs/lua)
|
target_include_directories(lua PUBLIC ./3rdlibs/lua/src)
|
||||||
target_compile_features(lua PRIVATE c_std_99)
|
target_compile_features(lua PRIVATE c_std_99)
|
||||||
|
|
||||||
# TODO if you use MinGW, maybe you need this
|
# TODO if you use MinGW, maybe you need this
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
DLLEXPORT void RunExampleWindow();
|
DLLEXPORT void Hazel_RunExampleWindow();
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -1,6 +1,6 @@
|
||||||
#include "hazel/hazel.h"
|
#include "hazel/hazel.h"
|
||||||
|
|
||||||
void RunExampleWindow() {
|
void Hazel_RunExampleWindow() {
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
|
|
||||||
/* Initialize the library */
|
/* Initialize the library */
|
||||||
|
|
Reference in New Issue