Browse Source

Enable command line arguments when compiling with juliac

pull/57/head
Fredrik Ekre 1 year ago
parent
commit
8d1dde8238
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 19
      juliac/runicc.jl

19
juliac/runicc.jl

@ -2,10 +2,21 @@ module RunicC
using Runic: Runic using Runic: Runic
# TODO: Why do we need this shim? Wouldn't it be possible to just compile `src/Runic.jl`? # Compileable main function corresponding to `int main(int argc, char** argv)`
Base.@ccallable function main()::Cint Base.@ccallable function main(argc::Cint, argv::Ptr{Ptr{UInt8}})::Cint
argv = String[] # Load command line arguments. Note that the first argument is the
return Runic.main(argv) # executable name so we skip it.
args = Vector{String}(undef, argc - 1)
for i in 2:argc
argptr = unsafe_load(argv, i)
arg = unsafe_string(argptr)
args[i - 1] = arg
end
# Call Runic's main function
return Runic.main(args)
end end
# Tell juliac about the main entrypoint
Base.Experimental.entrypoint(main, (Cint, Ptr{Ptr{UInt8}}))
end end

Loading…
Cancel
Save