Skip to content

Commit 6246d95

Browse files
committed
try build
1 parent 38a41cd commit 6246d95

File tree

6 files changed

+49
-6
lines changed

6 files changed

+49
-6
lines changed

.github/workflows/build.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
matrix:
1818
include:
1919
- { os: ubuntu-20.04, target: x86_64-unknown-linux-gnu, platform: linux-x64, cross: general }
20-
# - { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, platform: linux-arm64, cross: aarch64 }
20+
- { os: ubuntu-22.04, target: aarch64-unknown-linux-gnu, platform: linux-arm64, cross: no_format }
2121
- { os: ubuntu-20.04, target: x86_64-unknown-linux-musl, platform: linux-musl, cross: cross }
22-
# - { os: ubuntu-22.04, target: x86_64-unknown-freebsd, platform: linux-bsd, cross: bsd }
22+
- { os: ubuntu-22.04, target: x86_64-unknown-freebsd, platform: linux-bsd, cross: no_format }
2323
- { os: macos-latest, target: x86_64-apple-darwin, platform: darwin-x64, cross: general }
2424
- { os: macos-latest, target: aarch64-apple-darwin, platform: darwin-arm64, cross: general }
2525
- { os: windows-latest, target: x86_64-pc-windows-msvc, platform: win32-x64, cross: general }
@@ -41,6 +41,12 @@ jobs:
4141
run: |
4242
cargo install cross
4343
cross build --release --target ${{ matrix.target }}
44+
- name: Build - no_format
45+
if: ${{ matrix.cross == 'no_format' }}
46+
run: |
47+
cargo install cross
48+
cross build --release --target ${{ matrix.target }} --features no_format
49+
4450
- name: package-unix
4551
if: ${{ matrix.os != 'windows-latest' }}
4652
run: |

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ glob = "0.3.0"
2121
[[bin]]
2222
name = "lua-language-server"
2323
path = "src/main.rs"
24+
25+
[features]
26+
no_format = []

build.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ fn main() {
44
build_lua_seri();
55
build_lpeglabel();
66
cfg!(windows).then(|| build_setfilemode());
7-
build_emmyluacodestyle();
7+
cfg!(not(feature = "no_format")).then(|| build_emmyluacodestyle());
88
}
99

10-
1110
fn build_lua() {
1211
cc::Build::new()
1312
.include("3rd/lua")

src/codestyle/mod.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use mlua::Lua;
2+
3+
fn not_implement(_: &Lua, _: mlua::MultiValue) -> mlua::Result<(bool, String)> {
4+
Ok((false, "not implement".to_string()))
5+
}
6+
7+
pub fn fake_code_style(lua: &Lua) -> mlua::Result<mlua::Table> {
8+
let table = lua.create_table()?;
9+
table.set("format", lua.create_function(not_implement)?)?;
10+
table.set("range_format", lua.create_function(not_implement)?)?;
11+
table.set("type_format", lua.create_function(not_implement)?)?;
12+
table.set("update_config", lua.create_function(not_implement)?)?;
13+
table.set("diagnose_file", lua.create_function(not_implement)?)?;
14+
table.set("set_default_config", lua.create_function(not_implement)?)?;
15+
table.set("spell_load_dictionary_from_path", lua.create_function(not_implement)?)?;
16+
table.set("spell_load_dictionary_from_buffer", lua.create_function(not_implement)?)?;
17+
table.set("spell_analysis", lua.create_function(not_implement)?)?;
18+
table.set("spell_suggest", lua.create_function(not_implement)?)?;
19+
table.set("set_nonstandard_symbol", lua.create_function(not_implement)?)?;
20+
table.set("set_clike_comments_symbol", lua.create_function(not_implement)?)?;
21+
table.set("name_style_analysis", lua.create_function(not_implement)?)?;
22+
table.set("update_name_style_config", lua.create_function(not_implement)?)?;
23+
Ok(table)
24+
}

src/lua_preload.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use crate::bee;
2+
use crate::codestyle::fake_code_style;
23
use crate::lua_seri;
34
use crate::override_lua;
45
use mlua::{lua_State, prelude::*};
56

67
extern "C-unwind" {
78
fn luaopen_lpeglabel(lua: *mut lua_State) -> i32;
89

10+
#[cfg(not(feature = "no_format"))]
911
fn luaopen_code_format(lua: *mut lua_State) -> i32;
1012
}
1113

@@ -14,8 +16,16 @@ pub fn lua_preload(lua: &Lua) -> LuaResult<()> {
1416
let lpeglabel_loader = unsafe { lua.create_c_function(luaopen_lpeglabel) }.unwrap();
1517
add_preload_module(&lua, "lpeglabel", lpeglabel_loader)?;
1618
// code_format
17-
let code_format_loader = unsafe { lua.create_c_function(luaopen_code_format) }.unwrap();
18-
add_preload_module(&lua, "code_format", code_format_loader)?;
19+
#[cfg(feature = "no_format")]
20+
{
21+
let code_format_loader = lua.create_function(|lua: &Lua, ()| Ok(fake_code_style(lua)))?;
22+
add_preload_module(&lua, "code_format", code_format_loader)?;
23+
}
24+
#[cfg(not(feature = "no_format"))]
25+
{
26+
let code_format_loader = unsafe { lua.create_c_function(luaopen_code_format) }?;
27+
add_preload_module(&lua, "code_format", code_format_loader)?;
28+
}
1929

2030
// bee.platform
2131
let bee_platform_loader =

src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ mod bee;
22
mod lua_preload;
33
mod lua_seri;
44
mod override_lua;
5+
mod codestyle;
56

67

78
#[macro_use]

0 commit comments

Comments
 (0)