Hash :
1cfd44ea
Author :
Thomas de Grivel
Date :
2025-10-11T19:48:20
Fix build on MacOS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
/* kc3
* Copyright from 2022 to 2025 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#include "../libkc3/kc3.h"
#include "config.h"
const char *g_env_argv0_default = PROG;
const char *g_env_argv0_dir_default = PREFIX;
int main (int argc, char **argv)
{
bool b;
s_call call = {0};
s_env *env;
const s_sym *module = NULL;
sw r = 1;
s_tag tmp = {0};
kc3_init(NULL, &argc, &argv);
env = env_global();
assert(env);
module = sym_1("Kpkg.Main");
call_init(&call);
call.ident.module = module;
call.ident.sym = sym_1("main");
if (! env_module_has_ident(env, module, &call.ident, &b)) {
err_puts("kpkg: env_module_has_ident");
goto clean;
}
if (! b &&
! env_module_load(env, module)) {
err_puts("kpkg: env_module_load");
goto clean;
}
if (! env_eval_call(env, &call, &tmp)) {
err_puts("kpkg: eval_call");
goto clean;
}
switch (tmp.type) {
case TAG_U8:
r = tmp.data.u8;
break;
default:
err_write_1("invalid return type from main: ");
err_inspect_tag(&tmp);
err_write_1("\n");
}
clean:
tag_clean(&tmp);
call_clean(&call);
kc3_clean(NULL);
return r;
}