Skip to content

Commit a43737a

Browse files
committed
chore(binding/lua): fix code
Signed-off-by: owl <ouyangjun1999@gmail.com>
1 parent 0b4be2e commit a43737a

8 files changed

Lines changed: 25 additions & 43 deletions

File tree

.github/workflows/bindings_lua.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ jobs:
4646
- name: Setup lua toolchain
4747
run: |
4848
sudo apt-get update
49-
sudo apt-get install -y lua-busted
49+
sudo apt-get install -y lua-busted luarocks liblua5.2-dev
5050
- name: Setup Rust toolchain
5151
uses: ./.github/actions/setup
5252
- name: Build & Test
5353
working-directory: "bindings/lua"
5454
run: |
55-
cargo build
56-
mv ../../target/debug/libopendal_lua.so opendal.so
55+
sudo "PATH=$PATH" luarocks make
5756
busted test/opendal_test.lua

Cargo.lock

Lines changed: 4 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/lua/Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ rust-version.workspace = true
3131

3232

3333
[features]
34-
default = ["mlua/lua54"]
35-
lua54 = ["mlua", "mlua/lua54"]
36-
lua53 = ["mlua", "mlua/lua53"]
34+
default = ["mlua/lua52"]
3735
lua52 = ["mlua", "mlua/lua52"]
38-
lua51 = ["mlua", "mlua/lua51"]
39-
luajit = ["mlua", "mlua/luajit"]
40-
vendored = ["mlua", "mlua/vendored"]
36+
37+
# todo: fix mlua multi-version in `cargo build --all-features` error
38+
# https://github.com/apache/incubator-opendal/pull/2558#issuecomment-1613570958
39+
40+
#lua54 = ["mlua", "mlua/lua54"]
41+
#lua53 = ["mlua", "mlua/lua53"]
42+
#lua52 = ["mlua", "mlua/lua52"]
43+
#lua51 = ["mlua", "mlua/lua51"]
44+
#luajit = ["mlua", "mlua/luajit"]
45+
#vendored = ["mlua", "mlua/vendored"]
4146

4247
# for disable default features
4348
[dependencies.mlua]
@@ -49,7 +54,6 @@ optional = true
4954

5055
[lib]
5156
crate-type = ["cdylib"]
52-
name = "lopendal"
5357

5458
[dependencies]
5559
opendal.workspace = true

bindings/lua/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Example
66

77
```lua
8-
local opendal = require("lopendal")
8+
local opendal = require("opendal")
99

1010
local op, err = opendal.operator.new("fs",{root="/tmp"})
1111
if err ~= nil then

bindings/lua/example/fs.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
2020
]]
2121

22-
local opendal = require("lopendal")
22+
local opendal = require("opendal")
2323

2424
local op, err = opendal.operator.new("fs",{root="/tmp"})
2525
if err ~= nil then
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package = "lopendal"
1+
package = "opendal"
22
version = "0.1.0-1"
33

44
source = {
@@ -22,6 +22,7 @@ dependencies = {
2222
build = {
2323
type = "rust-mlua",
2424
modules = {
25-
"lopendal"
25+
["opendal"] = "opendal_lua",
2626
},
27+
target_path = "../../target",
2728
}

bindings/lua/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn operator_stat<'a>(
194194
}
195195

196196
#[mlua::lua_module]
197-
fn lopendal(lua: &Lua) -> LuaResult<LuaTable> {
197+
fn opendal(lua: &Lua) -> LuaResult<LuaTable> {
198198
let exports = lua.create_table()?;
199199
let operator = lua.create_table()?;
200200
operator.set("new", lua.create_function(operator_new)?)?;

bindings/lua/test/opendal_test.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
2020
]]
2121

22+
local opendal = require("opendal")
23+
2224
describe("opendal unit test", function()
2325
describe("opendal fs schema", function()
2426
it("operator function in fs schema", function()
25-
local opendal = require("opendal")
2627
local op, err = opendal.operator.new("fs",{root="/tmp"})
2728
assert.is_nil(err)
2829
assert.is_nil(op:write("test.txt","hello world"))
@@ -34,7 +35,6 @@ describe("opendal unit test", function()
3435
assert.equal(op:is_exist("test.txt"), false)
3536
end)
3637
it("meta function in fs schema", function()
37-
local opendal = require("opendal")
3838
local op, err = opendal.operator.new("fs",{root="/tmp"})
3939
assert.is_nil(err)
4040
assert.is_nil(op:write("test.txt","hello world"))
@@ -53,7 +53,6 @@ describe("opendal unit test", function()
5353
end)
5454
describe("opendal memory schema", function()
5555
it("operator function in memory schema", function()
56-
local opendal = require("opendal")
5756
local op, err = opendal.operator.new("memory",{root="/tmp"})
5857
assert.is_nil(err)
5958
assert.is_nil(op:write("test.txt","hello world"))
@@ -65,7 +64,6 @@ describe("opendal unit test", function()
6564
assert.equal(op:is_exist("test.txt"), false)
6665
end)
6766
it("meta function in memory schema", function()
68-
local opendal = require("opendal")
6967
local op, err = opendal.operator.new("memory",{root="/tmp"})
7068
assert.is_nil(err)
7169
assert.is_nil(op:write("test.txt","hello world"))

0 commit comments

Comments
 (0)