From: fennecdjay Date: Fri, 31 Mar 2023 12:37:17 +0000 (+0200) Subject: :wrench: Update embed system X-Git-Tag: nightly~172 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=c51b425ca18c6430dcf1c8b20431d2b68a72398b;p=gwion.git :wrench: Update embed system --- diff --git a/Makefile b/Makefile index ddd34d11..d861d88c 100644 --- a/Makefile +++ b/Makefile @@ -89,9 +89,9 @@ options-show: with_config: bash scripts/embed.bash gwion.config.json - touch src/main.c + touch src/main.c touch src/arg.c ${MAKE} USE_CONFIG=1 - touch src/main.c + touch src/main.c touch src/arg.c almost_gwion: ${almost_obj} ${ALMOST_LIBS} diff --git a/scripts/embed.bash b/scripts/embed.bash index e744543a..817a8eac 100644 --- a/scripts/embed.bash +++ b/scripts/embed.bash @@ -153,7 +153,6 @@ handle_scripts() { done } - embed() { array_is_ok "$scripts" || array_is_ok "$libraries" || return echo "ANN void gwion_embed(const Gwion gwion) {" >> embed/embed_foot @@ -193,25 +192,24 @@ args=$(jq -rc '.args' <<< "$json") echo "static const int config_argc = $count;" cat << EOF ANN const char** config_args(int *argc, char **const argv) { +#ifdef GWION_NO_UARGS + *argc = 0; +#endif const int nargs = config_argc + *argc; const char ** args = malloc(nargs * SZ_INT); for(int i = 0; i < config_argc; i++) { args[i] = config_argv[i]; } -#ifndef GWION_STANDALONE for(int i = 0; i < *argc; i++) { args[i + config_argc] = argv[i]; } - *argc = nargs; -#else *argc = config_argc; -#endif return args; } EOF } >> embed/embed.c -[ "$libraries" != "null" ] || [ "$scripts" != "null" ] && +not_null "$libraries" || not_null "$scripts" && config "CFLAGS += -DGWION_EMBED" cflags=$(jq -rc '.cflags' <<< "$json") @@ -229,9 +227,9 @@ array_is_ok "$ldflags" && { done } -standalone=$(jq -rc '.standalone' <<< "$json") -[ "$standalone" = "true" ] && { - array_is_ok "$args" || config "CFLAGS += -DGWION_CONFIG_ARGS" - config "CFLAGS += -DGWION_STANDALONE" -} -: +rc=$(jq -rc '.urc' <<< "$json") +[ "$rc" = "false" ] && config "CFLAGS += -DGWION_NO_URC" +ulib=$(jq -rc '.ulib' <<< "$json") +[ "$ulib" = "false" ] && config "CFLAGS += -DGWION_NO_ULIB" +uargs=$(jq -rc '.uargs' <<< "$json") +[ "$uargs" = "false" ] && config "CFLAGS += -DGWION_NO_UARGS" diff --git a/src/arg.c b/src/arg.c index d090e700..1997cf73 100644 --- a/src/arg.c +++ b/src/arg.c @@ -46,7 +46,7 @@ ANN static inline void config_end(const Vector config) { } } -#ifndef GWION_STANDALONE +#ifndef GWION_NO_ULIB ANN static m_str plug_dir(void) { const m_str home = getenv("HOME"); const size_t sz = strlen(home); @@ -75,7 +75,7 @@ ANN static void arg_init(CliArg *arg) { vector_init(&arg->add); vector_init(&arg->lib); vector_init(&arg->config); -#ifndef GWION_STANDALONE +#ifndef GWION_NO_ULIB vector_add(&arg->lib, (vtype)plug_dir()); #endif arg->color = COLOR_AUTO; @@ -377,7 +377,7 @@ ANN m_bool _arg_parse(struct ArgInternal *arg) { return GW_OK; } -#ifndef GWION_STANDALONE +#ifndef GWION_NO_URC ANN static void config_default(struct ArgInternal *arg) { char *home = getenv("HOME"); char c[strlen(home) + strlen(GWIONRC) + 2]; @@ -392,7 +392,7 @@ ANN m_bool arg_parse(const Gwion gwion, CliArg *a) { #ifdef __FUZZING return; #endif -#ifndef GWION_STANDALONE +#ifndef GWION_NO_URC config_default(&arg); #endif return _arg_parse(&arg); diff --git a/src/main.c b/src/main.c index dd4139f7..e64b6c6c 100644 --- a/src/main.c +++ b/src/main.c @@ -52,10 +52,10 @@ ANN void gwion_embed(const Gwion); int main(int argc, char **argv) { #ifndef GWION_CONFIG_ARGS - CliArg arg = {.arg = {.argc = argc, .argv = argv}, .loop = false}; + CliArg arg = {.arg = {.argc = argc, .argv = argv} }; #else char **config_argv = config_args(&argc, argv); - CliArg arg = {.arg = {.argc = argc, .argv = config_argv}, .loop = false}; + CliArg arg = {.arg = {.argc = argc, .argv = config_argv} }; #endif signal(SIGINT, sig); signal(SIGTERM, sig);