Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optionally building without plugin-host #540

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --features plugin-cranelift

build:
name: Cargo build & test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
features: ["", "--features plugin-cranelift"]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
Expand Down Expand Up @@ -136,4 +138,4 @@ jobs:
with:
use-cross: ${{ matrix.use-cross }}
command: build
args: --target=${{ matrix.target }}
args: --target=${{ matrix.target }} ${{ matrix.features }}
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
default-members = ["feather/server"]
members = [
# libcraft
"libcraft/core",
Expand Down
10 changes: 5 additions & 5 deletions feather/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ num-bigint = "0.4"
num-traits = "0.2"
once_cell = "1"
parking_lot = "0.11"
plugin-host = { path = "../plugin-host", package = "feather-plugin-host" }
plugin-host = { path = "../plugin-host", package = "feather-plugin-host", optional = true }
protocol = { path = "../protocol", package = "feather-protocol" }
quill-common = { path = "../../quill/common" }

Expand All @@ -58,15 +58,15 @@ libcraft-items = { path = "../../libcraft/items" }
worldgen = { path = "../worldgen", package = "feather-worldgen" }

[features]
default = [ "plugin-cranelift" ]
default = []

# Use zlib-ng for faster compression. Requires CMake.
zlib-ng = [ "flate2/zlib-ng-compat" ]

plugins = ["plugin-host"]
# Use Cranelift to JIT-compile plugins. Pure Rust
# but produces slower code than LLVM.
plugin-cranelift = [ "plugin-host/cranelift" ]
plugin-cranelift = [ "plugins", "plugin-host/cranelift" ]
# Use LLVM to JIT-compile plugins. Produces
# very fast code, but requires LLVM to be installed
# on the build system. May impact startup times.
plugin-llvm = [ "plugin-host/llvm" ]
plugin-llvm = [ "plugins", "plugin-host/llvm" ]
5 changes: 4 additions & 1 deletion feather/server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ use base::anvil::level::SuperflatGeneratorOptions;
use common::{Game, TickLoop, World};
use ecs::SystemExecutor;
use feather_server::{config::Config, Server};
#[cfg(feature = "plugins")]
use plugin_host::PluginManager;
use worldgen::{ComposableGenerator, SuperflatWorldGenerator, VoidWorldGenerator, WorldGenerator};

mod logging;

#[cfg(feature = "plugins")]
const PLUGINS_DIRECTORY: &str = "plugins";
const CONFIG_PATH: &str = "config.toml";

Expand Down Expand Up @@ -40,6 +42,7 @@ fn init_game(server: Server, config: &Config) -> anyhow::Result<Game> {
let mut game = Game::new();
init_systems(&mut game, server);
init_world_source(&mut game, config);
#[cfg(feature = "plugins")]
init_plugin_manager(&mut game)?;
Ok(game)
}
Expand Down Expand Up @@ -75,7 +78,7 @@ fn init_world_source(game: &mut Game, config: &Config) {
};
game.world = World::with_gen_and_path(generator, config.world.name.clone());
}

#[cfg(feature = "plugins")]
fn init_plugin_manager(game: &mut Game) -> anyhow::Result<()> {
let mut plugin_manager = PluginManager::new();
plugin_manager.load_dir(game, PLUGINS_DIRECTORY)?;
Expand Down