Skip to content

Commit

Permalink
implemented PSL environment variable #51
Browse files Browse the repository at this point in the history
  • Loading branch information
chakravala committed Jun 14, 2021
1 parent 8a84fa8 commit 74f70e1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Reduce"
uuid = "93e0c654-6965-5f22-aba9-9c1ae6b3c259"
authors = ["Michael Reed"]
version = "1.2.10"
version = "1.2.11"

[deps]
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down
29 changes: 10 additions & 19 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,10 @@ end
if !Sys.iswindows()
try
try
process = _spawn(`$rpsl`)
process = _spawn(red())
kill(process)
catch
if Sys.islinux()
cmd = `$(joinpath(wdir,"usr","bin"))/$rpsl`
elseif Sys.isapple()
cmd = `$(joinpath(wdir,"psl"))/$rpsl`
else
cmd = `$(joinpath(wdir,"Reduce-svn$(rsvn[ρ])-src","bin"))/$rpsl`
end
process = _spawn(cmd)
process = _spawn(redsys(wdir))
kill(process)
!isfile("ver") && writever(0)
end
Expand All @@ -49,9 +42,9 @@ if !Sys.iswindows()
rtg = "reduce.tar.gz"
dl = "/download"
cd(wdir)
println("Building Reduce.jl with CSL binaries ... ")
println("Building Reduce.jl with $(ispsl() ? "PSL" : "CSL") binaries ... ")
if Sys.islinux()
src = "/reduce-csl_"
src = "/reduce-$(redsl())_"
if occursin("64",read(`uname -m`,String))
download(http*date[ρ]*"/linux64"*src*rsvn[ρ]*"_amd64.tgz"*dl,joinpath(wdir,rtg))
else
Expand All @@ -65,8 +58,8 @@ if !Sys.iswindows()
snap = "Reduce-snapshot"
download(http*date[ρ]*"/macintosh/"*snap*"_"*rsvn[ρ]*".dmg"*dl,joinpath(wdir,"$(snap)_$(date[ρ]).dmg"))
run(`hdiutil attach $(wdir)/$(snap)_$(date[ρ]).dmg`)
run(`rm -rf $(joinpath(wdir,"csl"))`)
run(`cp -r /Volumes/$(snap)/csl $(wdir)/csl`)
run(`rm -rf $(joinpath(wdir,redsl()))`)
run(`cp -r /Volumes/$(snap)/csl $(wdir)/$(redsl())`)
run(`hdiutil unmount /Volumes/$(snap)`)
run(`rm $(snap)_$(date[ρ]).dmg`)
writever(ρ)
Expand All @@ -83,16 +76,14 @@ if !Sys.iswindows()
end
else
try
#cmd = `"$(wdir)\psl\bpsl.exe" -td 16000000 -f "$(wdir)\red\reduce.img"`
cmd = `"$(wdir)\reduce.exe" --nogui`
process = _spawn(cmd)
process = _spawn(redsys(wdir))
kill(process)
catch
cd(wdir)
println("Building Reduce.jl with CSL binaries ...")
cab = "wincsl.cab"
println("Building Reduce.jl with $(ispsl() ? "PSL" : "CSL") binaries ...")
cab,winsl = "winred.cab",ispsl() ? "winpsl64" : "wincsl"
http = "https://master.dl.sourceforge.net/project/reduce-algebra/snapshot_"
download(http*date[ρ]*"/windows/wincsl_$(rsvn[ρ]).cab",joinpath(wdir,cab))
download(http*date[ρ]*"/windows/$(winsl)_$(rsvn[ρ]).cab",joinpath(wdir,cab))
open("redextract.bat","w") do f
write(f,"expand $cab \"$(wdir)\" -F:*\n")
#write(f,"reg Query \"HKLM\\Hardware\\Description\\System\\CentralProcessor\\0\" | find /i \"x86\" > NUL && set OSQ=32BIT || set OSQ=64BIT\n")
Expand Down
23 changes: 22 additions & 1 deletion deps/svn.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# This file is part of Reduce.jl. It is licensed under the MIT license
# Copyright (C) 2017 Michael Reed

rpsl = "redcsl"
ispsl() = haskey(ENV,"PSL")
red() = ispsl() ? `redpsl` : `redcsl -w`
red(path) = ispsl() ? `$path/redpsl` : `$path/redcsl -w`
redsl() = ispsl() ? "psl" : "csl"

ρ = 7

Expand All @@ -25,6 +28,24 @@ rsvn = Dict(
6 => "5377",
7 => "5424")

function redsys(dir)
if !(Sys.iswindows())
if Sys.islinux()
red(joinpath(dir,"usr","bin"))
elseif Sys.isapple()
red(joinpath(dir,ispsl() ? "psl" : "csl"))
else
rsl = red(joinpath(dir,"Reduce-svn$(rsvn[ρ])-src","bin"))
end
else
if ispsl()
`"$(dir)\psl\bpsl.exe" -td 16000000 -f "$(dir)\red\reduce.img"`
else
`"$(dir)\reduce.exe" --nogui`
end
end
end

function _spawn(cmd, input=devnull, output=devnull)
run(pipeline(cmd, stdin=input, stdout=output, stderr=stderr), wait=false)
end
20 changes: 5 additions & 15 deletions src/Reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,16 @@ struct PSL <: Base.AbstractPipe
# Setup pipes and reduce process
input = Pipe()
output = Pipe()
rsl = `$(split(rpsl))`
dirf = @__DIR__
rsl = red()
dirf = joinpath(@__DIR__,"..","deps")
if !Sys.iswindows()
try
process = _spawn(rsl, input, output)
process = _spawn(red(), input, output)
catch
if Sys.islinux()
rsl = `$(joinpath(dirf,"..","deps","usr","bin"))/$rpsl`
elseif Sys.isapple()
rsl = `$(joinpath(dirf,"..","deps","csl"))/$rpsl -w`
else
rsl = `$(joinpath(dirf,"..","Reduce-svn$(rsvn[ρ])-src","bin"))/$rpsl`
end
process = _spawn(rsl, input, output)
process = _spawn(redsys(dirf), input, output)
end
else
dirf = joinpath(dirf,"..","deps")
#rsl = `"$(dirf)\psl\bpsl.exe" -td 16000000 -f "$(dirf)\red\reduce.img"`
rsl = `"$(dirf)\reduce.exe" --nogui`
process = _spawn(rsl, input, output)
process = _spawn(redsys(dirf), input, output)
end
# Close the unneeded ends of Pipes
close(input.out)
Expand Down

2 comments on commit 74f70e1

@chakravala
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/38970

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.11 -m "<description of version>" 74f70e1c2b13875dfce720a736cc47b9b0ef084d
git push origin v1.2.11

Please sign in to comment.