Skip to content

Commit 7c2219f

Browse files
author
Patrick Häcker
committed
Revert PROGRAM_FILE logic for Julia < 1.12
The reason for using the C API is described in [#649](#649). But for the moment use the Julia logic for Julia >= 1.12 as it is still better than not being able to compile an app at all.
1 parent 50a32d3 commit 7c2219f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/embedding_wrapper.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,28 @@ int main(int argc, char *argv[]) {
140140

141141
// Update ARGS and PROGRAM_FILE
142142
checked_eval_string("append!(empty!(Base.ARGS), Core.ARGS)");
143+
144+
#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR >= 12
143145
checked_eval_string("Core.eval(Base, :(global PROGRAM_FILE))");
144146
checked_eval_string("Base.PROGRAM_FILE = popfirst!(ARGS)");
147+
#else
148+
jl_value_t *firstarg = checked_eval_string("popfirst!(ARGS)");
149+
JL_GC_PUSH1(&firstarg);
150+
jl_sym_t *var = jl_symbol("PROGRAM_FILE");
151+
#if JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR >= 11
152+
jl_binding_t *bp = jl_get_binding_wr(jl_base_module, var, /* alloc */ 1);
153+
jl_checked_assignment(bp, jl_base_module, var, firstarg);
154+
#elif JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR >= 10
155+
jl_binding_t *bp = jl_get_binding_wr(jl_base_module, var);
156+
jl_checked_assignment(bp, jl_base_module, var, firstarg);
157+
#elif JULIA_VERSION_MAJOR == 1 && JULIA_VERSION_MINOR >= 9
158+
jl_binding_t *bp = jl_get_binding_wr(jl_base_module, var, 1);
159+
jl_checked_assignment(bp, firstarg);
160+
#else
161+
jl_set_global(jl_base_module, jl_symbol("PROGRAM_FILE"), firstarg);
162+
#endif
163+
JL_GC_POP();
164+
#endif
145165

146166
// call the work function, and get back a value
147167
jl_value_t *jl_retcode = checked_eval_string(JULIA_MAIN "()");

0 commit comments

Comments
 (0)