Skip to content

Commit

Permalink
Refactor unix/mac detection to be more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetricek committed Nov 14, 2013
1 parent 307965d commit a63f191
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* 1.0.3 - Fixed NuGet package
* 1.0.4 - Improve stability (refactor initialization), add documentation
* 1.0.5 - Update load script in the NuGet package
* 1.0.5 - Update load script in the NuGet package, improve cross-platform support
16 changes: 9 additions & 7 deletions src/RProvider/RInit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,23 @@ let private setupPathVariable () =
match getRLocation() with
| RInitError error -> RInitError error
| RInitResult location ->
let islinux =
let p=int Environment.OSVersion.Platform
p=4||p=6||p=128 //from www.mono-project.com/FAQ:_Technical
let isLinux =
let platform = Environment.OSVersion.Platform
// The guide at www.mono-project.com/FAQ:_Technical says to also check for the
// value 128, but that is only relevant to old versions of Mono without F# support
platform = PlatformID.MacOSX || platform = PlatformID.Unix
let binPath =
if islinux then
if isLinux then
Path.Combine(location, "lib")
else
Path.Combine(location, "bin", if Environment.Is64BitProcess then "x64" else "i386")
Path.Combine(location, "bin", if Environment.Is64BitProcess then "x64" else "i386")
// Set the path
if not ((Path.Combine(binPath, "libR.so") |> File.Exists) || (Path.Combine(binPath,"R.dll") |> File.Exists)) then
RInitError (sprintf "No R engine at %s" binPath)
else
// Set the path
let pathsepchar = if islinux then ":" else ";"
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + pathsepchar + binPath)
let pathSepChar = if isLinux then ":" else ";"
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + pathSepChar + binPath)
Logging.logf "setupPathVariable completed"
RInitResult ()
with e ->
Expand Down

0 comments on commit a63f191

Please sign in to comment.