Skip to content

Commit d3b895d

Browse files
committed
refactor to workspace mode
1 parent e08fb73 commit d3b895d

28 files changed

+101
-64
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
1-
[package]
2-
name = "luals-rust"
3-
version = "0.1.0"
4-
edition = "2021"
5-
license-file = "LICENSE"
6-
include = ["resources/**/*"]
1+
[workspace]
2+
resolver = "2"
3+
members = [
4+
"crates/*",
5+
]
76

8-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9-
10-
[dependencies]
7+
[workspace.dependencies]
118
mlua = { version = "0.10.0-beta.2", features = [ "lua54", "vendored", "async"] }
129
lazy_static = "1.4.0"
1310
encoding_rs = "0.8"
1411
tokio = { version = "1.40.0", features = ["full"] }
1512
notify = { version = "6.1.1", features = ["serde"] }
16-
17-
[build-dependencies]
18-
cc = "1.0"
19-
glob = "0.3.0"
20-
21-
[[bin]]
22-
name = "lua-language-server"
23-
path = "src/main.rs"
24-
25-
[features]
26-
no_format = []
27-

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To build the project, run:
2323

2424
```bash
2525
git submodule update --init --recursive
26-
cargo build
26+
cargo build --release -p luals
2727
```
2828

2929
# Publish

crates/basic/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "luals-basic"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
mlua.workspace = true
8+
lazy_static.workspace = true
9+
encoding_rs.workspace = true
10+
tokio.workspace = true
11+
notify.workspace = true
12+
13+
14+
[build-dependencies]
15+
cc = "1.0"
16+
glob = "0.3.0"
17+
18+
[features]
19+
no_format = []

build.rs renamed to crates/basic/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fn main() {
22
std::env::set_var("CC_LOG", "1");
3+
std::env::set_current_dir("../..").unwrap();
34
// build_lua();
45
build_lua_seri();
56
build_lpeglabel();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/bee/lua_thread.rs renamed to crates/basic/src/bee/lua_thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::lua_preload;
21
use lazy_static::lazy_static;
32
use mlua::prelude::LuaResult;
43
use mlua::{prelude::*, Lua, UserData};
@@ -143,7 +142,7 @@ fn bee_thread_thread(_: &Lua, script: String) -> LuaResult<()> {
143142
let rt = Builder::new_current_thread().enable_all().build().unwrap();
144143
rt.block_on(async move {
145144
let lua = unsafe { Lua::unsafe_new() };
146-
if let Err(e) = lua_preload::lua_preload(&lua) {
145+
if let Err(e) = crate::lua_preload(&lua) {
147146
eprintln!("Error during lua_preload: {:?}", e);
148147
return;
149148
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lua_preload.rs renamed to crates/basic/src/lib.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
use crate::bee;
1+
pub mod bee;
2+
pub mod codestyle;
3+
pub mod lua_seri;
4+
pub mod override_lua;
5+
6+
#[macro_use]
7+
extern crate lazy_static;
28
#[allow(unused)]
39
use crate::codestyle::fake_code_style;
4-
use crate::lua_seri;
5-
#[allow(unused)]
6-
use crate::override_lua;
710
use mlua::{lua_State, prelude::*};
811

912
extern "C-unwind" {
File renamed without changes.
File renamed without changes.

crates/luals/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "luals"
3+
version = "0.1.0"
4+
edition = "2021"
5+
license-file = "LICENSE"
6+
include = ["resources/**/*"]
7+
8+
[[bin]]
9+
name = "lua-language-server"
10+
path = "src/main.rs"
11+
12+
[dependencies]
13+
luals-basic = { path = "../basic" }
14+
mlua.workspace = true
15+
tokio.workspace = true

src/main.rs renamed to crates/luals/src/main.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
mod bee;
2-
mod codestyle;
3-
mod lua_preload;
4-
mod lua_seri;
5-
mod override_lua;
6-
7-
#[macro_use]
8-
extern crate lazy_static;
91
use mlua::prelude::*;
102
use std::{env, path};
113

124
#[tokio::main(flavor = "current_thread")]
135
async fn main() -> LuaResult<()> {
146
let lua = unsafe { Lua::unsafe_new() };
15-
lua_preload::lua_preload(&lua)?;
7+
luals_basic::lua_preload(&lua)?;
168

179
#[cfg(not(debug_assertions))]
1810
{
@@ -48,7 +40,7 @@ mod tests {
4840
let rt = Builder::new_current_thread().enable_all().build().unwrap();
4941
rt.block_on(async move {
5042
let lua = unsafe { Lua::unsafe_new() };
51-
if let Err(e) = lua_preload::lua_preload(&lua) {
43+
if let Err(e) = luals_basic::lua_preload(&lua) {
5244
eprintln!("Error during lua_preload: {:?}", e);
5345
return;
5446
}

crates/luals_wasm/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "luals-wasm"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
luals-basic = { path = "../basic" }

crates/luals_wasm/src/lib.rs

Whitespace-only changes.

publish/UnixPublish.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
cargo build --release
3+
cargo build --release -p luals
44

55
if [ -d "dist" ]; then
66
rm -rf dist

0 commit comments

Comments
 (0)