-
-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PROGRAM_FILE
not set when compiled through juliac.jl
#54
Comments
Here is an example: # examples/args.jl
foo() = println("ARGS: $ARGS") # Sometimes code accesses ARGS directly, as a global
# Create a temporary .html file, and open it to share the greetings.
Base.@ccallable function julia_main(args::Vector{String})::Cint
println("@__DIR__: $(@__DIR__)")
println("@__FILE__: $(@__FILE__)")
println("PROGRAM_FILE: $(PROGRAM_FILE)")
foo() # access global ARGS
return 0
end
julia_main(["a b c"]) $ julia examples/args.jl d e f
@__DIR__: /Users/daly/src/build-jl-app-bundle/examples
@__FILE__: /Users/daly/src/build-jl-app-bundle/examples/args.jl
PROGRAM_FILE: examples/args.jl
ARGS: String["d", "e", "f"] # NOTE: these are the command line args, not the inputs to `julia_main()`. $ julia ~/.julia/v0.6/PackageCompiler/juliac.jl -v -a -e examples/args.jl && ./builddir/args d e f
...
@__DIR__: /Users/daly/src/build-jl-app-bundle/examples # Note these are not a viable replacement (compile-time macros)
@__FILE__: /Users/daly/src/build-jl-app-bundle/examples/args.jl
PROGRAM_FILE:
ARGS: String[] |
I tried calling Also, I even tried setting Does anyone have suggestions? |
Ah, okay, I was using the wrong module. I fixed it by adding that line, but using Although this seems like kind of a hack, since If you all think it's reasonable, I'm happy to send a PR to add this to examples/program.c, but that doesn't feel like a complete solution to me... |
@lucatrv: I'm interested in your thoughts here as well. Do you have any idea how we could set global Does the method I used in my custom program.c, above seem like a hack, or should I send a PR to add it to this repo's I hope your travel was nice!! 😄 |
I think we can add the fix for Yes my travel to Japan was very nice, thanks!! |
Oh wowwwww i've always wanted to go to japan!!! That's excellent! :) (opened PR #57) |
Fixed in #57 |
* workaround julia#34076 * fix typo
Base.PROGRAM_FILE
is empty when compiled throughjuliac.jl
. (The globalARGS
is empty, which is wherePROGRAM_FILE
is set from.)PROGRAM_FILE
is set here, by popping the first value off ofARGS
, iffARGS
is not empty (checked here).Currently, the default
program.c
skips setting the globalARGS
, opting instead to pass an Array tojulia_main
. This means that there is no way to accessPROGRAM_FILE
from compiled code.The text was updated successfully, but these errors were encountered: