context FEATURE use explicit compilation for context creation
Because recompilation would be needed otherwise
if LY_CTX_ALL_IMPLEMENTED is used.
diff --git a/src/context.c b/src/context.c
index e93db25..7ed97c7 100644
--- a/src/context.c
+++ b/src/context.c
@@ -269,6 +269,11 @@
}
ctx->change_count = 1;
+ if (!(options & LY_CTX_EXPLICIT_COMPILE)) {
+ /* use it for creating the initial context */
+ ctx->flags |= LY_CTX_EXPLICIT_COMPILE;
+ }
+
/* create dummy in */
rc = ly_in_new_memory(internal_modules[0].data, &in);
LY_CHECK_GOTO(rc, error);
@@ -283,6 +288,12 @@
/* resolve global unres */
LY_CHECK_GOTO(rc = lys_compile_unres_glob(ctx, &unres), error);
+ if (!(options & LY_CTX_EXPLICIT_COMPILE)) {
+ /* compile now */
+ LY_CHECK_GOTO(rc = ly_ctx_compile(ctx), error);
+ ctx->flags &= ~LY_CTX_EXPLICIT_COMPILE;
+ }
+
ly_in_free(in, 0);
lys_compile_unres_glob_erase(ctx, &unres);
*new_ctx = ctx;