mirror of
https://gitcode.com/JianFeeeee/LuaCangjia_api.git
synced 2026-09-19 16:42:48 +00:00
尝试修复库引用
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@ -32,4 +32,9 @@
|
||||
*.app
|
||||
.vscode
|
||||
.cache
|
||||
build
|
||||
build
|
||||
cjpm.lock
|
||||
.script-hash
|
||||
build-script-cache
|
||||
liboutput
|
||||
target
|
||||
19
cjpm.toml
19
cjpm.toml
@ -1,21 +1,16 @@
|
||||
[package]
|
||||
name = "LuaCangjia_api"
|
||||
version = "0.0.0"
|
||||
name = "LuaCangjie_api"
|
||||
version = "0.0.1"
|
||||
description = "Lua C API bindings for Cangjie"
|
||||
license = "GPLv3"
|
||||
|
||||
cjc-version = "0.49.1" # 必需:指定所需 cjc 最低版本
|
||||
license = "GPLv3" # 可选:许可证信息
|
||||
output-type ="executable"
|
||||
[dependencies]
|
||||
|
||||
[ffi.c]
|
||||
# C 库头文件路径
|
||||
include = ["lib/lua"]
|
||||
# 编译好的库文件路径
|
||||
library = ["liboutput"]
|
||||
# 链接的库名(去掉 lib 前缀和 .so/.a 后缀)
|
||||
link = ["my_clib"]
|
||||
luacjapi.so.path = "./lib/build/luacjapi"
|
||||
|
||||
[scripts]
|
||||
# 构建钩子,指向你的 build.cj
|
||||
pre-build = "cjpm run build.cj pre-build"
|
||||
post-build = "cjpm run build.cj post-build"
|
||||
pre-clean = "cjpm run build.cj pre-clean"
|
||||
pre-clean = "cjpm run build.cj pre-clm ean"
|
||||
@ -16,10 +16,6 @@ include_directories(${NATIVERENDER_ROOT_PATH}
|
||||
# 添加lua子目录
|
||||
add_subdirectory(lua)
|
||||
|
||||
# 创建共享库,使用标准的entry命名
|
||||
add_library(runner SHARED
|
||||
script_run.c
|
||||
json/cJSON.c)
|
||||
add_library(luarunner STATIC
|
||||
lua_runner.cpp)
|
||||
|
||||
@ -31,17 +27,4 @@ target_link_libraries(luarunner
|
||||
)
|
||||
target_link_libraries(luacjapi
|
||||
luarunner
|
||||
)
|
||||
|
||||
# 链接库
|
||||
#target_link_libraries(runner
|
||||
# lua # 链接到lua库
|
||||
# m)
|
||||
#add_executable(test test.c)
|
||||
#target_link_libraries(test runner)
|
||||
|
||||
#add_executable(testcpp test.cpp)
|
||||
#target_link_libraries(testcpp luarunner)
|
||||
|
||||
add_executable(test1 test1.c)
|
||||
target_link_libraries(test1 luacjapi)
|
||||
)
|
||||
@ -72,6 +72,7 @@ lua_State *Lua_runner::get_lua_State()
|
||||
|
||||
int Lua_runner::load_lib(const char *path,const char *name)
|
||||
{
|
||||
//如果引入哈希表会导致删除包时的多次哈希查询,污染缓存。同时性能仅与数组实现相当
|
||||
if(!this->check_luastatue())
|
||||
{
|
||||
return -1;
|
||||
|
||||
16
src/main.cj
16
src/main.cj
@ -1,17 +1,17 @@
|
||||
@FFI("LuaCangjie_api")
|
||||
package LuaCangjie_api
|
||||
|
||||
@C
|
||||
struct lua_runner {
|
||||
|
||||
|
||||
}
|
||||
|
||||
foreign func init_lua_runner(self:CPointer<lua_runner>,pathio:CString,pkgpath:CString,io_input:CFunc<() -> Int32>,io_output:CFunc<() -> Int32>):Int32
|
||||
foreign func get_errno():Int32
|
||||
foreign func getresult(runner:CPointer<lua_runner>):CString
|
||||
foreign func run(self:CPointer<lua_runner>,path:CString,arg:CString):Int32
|
||||
|
||||
foreign{
|
||||
func init_lua_runner(self:CPointer<lua_runner>,pathio:CString,pkgpath:CString,io_input:CFunc<() -> Int32>,io_output:CFunc<() -> Int32>):Int32
|
||||
func get_errno():Int32
|
||||
func getresult(runner:CPointer<lua_runner>):CString
|
||||
func run(self:CPointer<lua_runner>,path:CString,arg:CString):Int32
|
||||
}
|
||||
main(): Int64 {
|
||||
var runnr = lua_runner
|
||||
println("hello world")
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user