Skip to content
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

workaround Rf_initialize_R in Windows #372

Merged
merged 1 commit into from
May 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/setup.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const Rembedded = Ref{Bool}(false)

@static if Sys.iswindows()
import WinReg

const libRgraphapp = joinpath(dirname(libR), "Rgraphapp.dll")

function ask_yes_no_cancel(prompt::Ptr{Cchar})
println(String(prompt))
query = readline(STDIN)
Expand Down Expand Up @@ -78,8 +79,7 @@ function initEmbeddedR()
ccall(:_wputenv,Cint,(Cwstring,),"HOME="*homedir())
end

argv = ["REmbeddedJulia","--slave","--silent","--no-save", "--no-restore"]
ccall((:Rf_initialize_R,libR),Cint,(Cint,Ptr{Ptr{Cchar}}),length(argv),argv)
argv = ["REmbeddedJulia","--silent","--no-save", "--no-restore"]

SA_NORESTORE = 0
SA_RESTORE = 1
Expand Down Expand Up @@ -115,6 +115,11 @@ function initEmbeddedR()

ccall((:R_SetParams,libR),Nothing,(Ptr{RStart},), Ref(rs))

# Rf_initialize_R sets signal handler for SIGINT
# we need to work around it
ccall((:R_set_command_line_arguments,libR),Cint,(Cint,Ptr{Ptr{Cchar}}),length(argv),argv)
ccall((:GA_initapp,libRgraphapp),Cint,(Cint,Ptr{Nothing}),0,C_NULL)

# fix an unicode issue
# cf https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17677
try unsafe_store!(cglobal((:EmitEmbeddedUTF8, RCall.libR),Cint), 1) catch end
Expand Down