POSIX conditional compilation:

* All features related to POSIX environments (env vars, shell stuff) gated by feature flags
* Dependencies optional per feature flags
* new CI target for non-POSIX build
* new CI target for release binary artifact

Signed-off-by: Ava Hahn [ava@sunnypup.io](mailto:ava@sunnypup.io)
This commit is contained in:
Ava Apples Affine 2023-05-26 06:41:18 +00:00
parent 5e15109b0c
commit 906cb16355
13 changed files with 330 additions and 319 deletions

View file

@ -23,7 +23,9 @@ use std::rc::Rc;
use std::cell::RefCell;
use std::env::vars;
#[cfg(feature = "posix")]
pub mod posix;
pub mod append;
pub mod boolean;
pub mod control;
@ -57,7 +59,7 @@ fn prompt_delimiter_default_callback(_: &Seg, _: &mut SymTable) -> Result<Ctr, T
/// static_stdlib
/// inserts all stdlib functions that can be inserted without
/// any kind of further configuration data into a symtable
pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> {
pub fn static_stdlib(syms: &mut SymTable) {
append::add_list_lib(syms);
strings::add_string_lib(syms);
decl::add_decl_lib_static(syms);
@ -76,24 +78,21 @@ pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> {
..Default::default()
}
);
Ok(())
}
/// dynamic_stdlib
/// takes configuration data and uses it to insert dynamic
/// callbacks with configuration into a symtable
pub fn dynamic_stdlib(syms: &mut SymTable, shell: Option<Rc<RefCell<posix::ShellState>>>) -> Result<(), String> {
//get CFG_RELISH_ENV from syms
#[cfg(feature="posix")]
pub fn dynamic_stdlib(syms: &mut SymTable, shell: Option<Rc<RefCell<posix::ShellState>>>) {
// get CFG_RELISH_ENV from syms
let env_cfg_user_form = syms
.call_symbol(&MODENV_CFG_VNAME.to_string(), &Seg::new(), true)
.unwrap_or_else(|_: Traceback| Box::new(Ctr::None))
.to_string()
.eq("true");
decl::add_decl_lib_dynamic(syms, env_cfg_user_form);
// This should be replaced by actual compiler conditionals in the future
if let Some(shell_state) = shell {
let posix_cfg_user_form = syms
.call_symbol(&POSIX_CFG_VNAME.to_string(), &Seg::new(), true)
@ -105,8 +104,11 @@ pub fn dynamic_stdlib(syms: &mut SymTable, shell: Option<Rc<RefCell<posix::Shell
posix::load_posix_shell(syms, shell_state);
}
}
}
Ok(())
#[cfg(not(feature="posix"))]
pub fn dynamic_stdlib(syms: &mut SymTable) {
decl::add_decl_lib_dynamic(syms, false);
}
pub fn load_environment(syms: &mut SymTable) {