schema compilation CHANGE basic support for global augments

Including the process of making dependent module implemented (compiling
it) and reverting the process in case of failure.
diff --git a/src/context.c b/src/context.c
index ad3abb2..10542c0 100644
--- a/src/context.c
+++ b/src/context.c
@@ -484,8 +484,8 @@
     }
 }
 
-API LY_ERR
-ly_ctx_module_implement(struct ly_ctx *ctx, struct lys_module *mod)
+LY_ERR
+ly_ctx_module_implement_internal(struct ly_ctx *ctx, struct lys_module *mod, uint8_t value)
 {
     struct lys_module *m;
 
@@ -510,14 +510,20 @@
     }
 
     /* mark the module implemented, check for collision was already done */
-    mod->implemented = 1;
+    mod->implemented = value;
 
     /* compile the schema */
-    LY_CHECK_RET(lys_compile(mod, 0));
+    LY_CHECK_RET(lys_compile(mod, LYSC_OPT_INTERNAL));
 
     return LY_SUCCESS;
 }
 
+API LY_ERR
+ly_ctx_module_implement(struct ly_ctx *ctx, struct lys_module *mod)
+{
+    return ly_ctx_module_implement_internal(ctx, mod, 1);
+}
+
 API void
 ly_ctx_destroy(struct ly_ctx *ctx, void (*private_destructor)(const struct lysc_node *node, void *priv))
 {