build.jl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # This file is part of Reduce.jl. It is licensed under the MIT license
  2. # Copyright (C) 2017 Michael Reed
  3. oldwdir = pwd()
  4. wdir = @__DIR__
  5. include("svn.jl")
  6. if isfile("ver")
  7. global ver = NaN
  8. open("ver","r") do f
  9. global ver = readstring(f) |> parse
  10. end
  11. if ver ≠ ρ
  12. if is_linux()
  13. run(`rm -rf $(joinpath(wdir,"usr"))`)
  14. elseif is_apple()
  15. run(`rm -rf $(joinpath(wdir,"psl"))`)
  16. end
  17. run(`rm ver`)
  18. end
  19. end
  20. function writever(rv)
  21. open("ver","w") do f
  22. write(f,"$rv")
  23. end
  24. end
  25. if !is_windows()
  26. try
  27. try
  28. process = _spawn(`$rpsl`)
  29. kill(process)
  30. catch
  31. if is_linux()
  32. cmd = `$(joinpath(wdir,"usr","bin"))/$rpsl`
  33. elseif is_apple()
  34. cmd = `$(joinpath(wdir,"psl"))/$rpsl`
  35. else
  36. cmd = `$(joinpath(wdir,rsvn[ρ],"bin"))/$rpsl`
  37. end
  38. process = _spawn(cmd)
  39. kill(process)
  40. !isfile("ver") && writever(0)
  41. end
  42. catch
  43. http = "https://sourceforge.net/projects/reduce-algebra/files/snapshot_"
  44. rtg = "reduce.tar.gz"
  45. dl = "/download"
  46. cd(wdir)
  47. println("Building redpsl ... ")
  48. if is_linux()
  49. src = "/linux-tar/reduce-psl_"
  50. if contains(readstring(`uname -m`),"64")
  51. download(http*date[ρ]*src*date[ρ]*"_amd64.tgz"*dl,joinpath(wdir,rtg))
  52. else
  53. download(http*date[ρ]*src*date[ρ]*"_i386.tgz"*dl,joinpath(wdir,rtg))
  54. end
  55. run(`rm -rf $(joinpath(wdir,"usr"))`)
  56. run(`tar -xvf $(rtg)`)
  57. run(`rm $(rtg)`)
  58. writever(ρ)
  59. elseif is_apple()
  60. snap = "Reduce-snapshot"
  61. download(http*date[ρ]*"/"*snap*"_"*date[ρ]*".dmg"*dl,joinpath(wdir,"$(snap)_$(date[ρ]).dmg"))
  62. run(`hdiutil attach $(wdir)/$(snap)_$(date[ρ]).dmg`)
  63. run(`rm -rf $(joinpath(wdir,"psl"))`)
  64. run(`cp -r /Volumes/$(snap)/psl $(wdir)/psl`)
  65. run(`hdiutil unmount /Volumes/$(snap)`)
  66. run(`rm $(snap)_$(date[ρ]).dmg`)
  67. writever(ρ)
  68. else
  69. download(http*date[ρ]*"/"*rsvn[ρ]*".tar.gz"*dl,joinpath(wdir,rtg))
  70. run(`tar -xvf $(rtg)`)
  71. run(`rm $(rtg)`)
  72. cd(joinpath("$wdir",rsvn[ρ]))
  73. run(`./configure --with-psl`)
  74. run(`make`)
  75. end
  76. println("DONE")
  77. end
  78. else
  79. try
  80. folder = joinpath(wdir," ..","deps","install","lib","psl")
  81. cmd = `"$(folder)\psl\bpsl.exe" -td 16000000 -f "$(folder)\red\reduce.img"`
  82. process = _spawn(cmd)
  83. kill(process)
  84. catch
  85. cd(wdir)
  86. http = "https://ayera.dl.sourceforge.net/project/reduce-algebra/snapshot_"
  87. setup = "Reduce-Setup"
  88. if contains(wdir,"appveyor")
  89. println("Building redpsl...")
  90. download("https://github.com/chakravala/Reduce.jl/wiki/redpsl.cab",joinpath(wdir,"redpsl.cab"))
  91. #download("http://codemist.dynu.com/red/winpsl.cab",joinpath(wdir,"winpsl.cab"))
  92. open("redpsl.bat","w") do f
  93. #write(f,"expand redpsl.cab \"$(wdir)\" -F:*"); end
  94. write(f,"expand winpsl.cab \"$(wdir)\" -F:*\n")
  95. write(f,"reg Query \"HKLM\\Hardware\\Description\\System\\CentralProcessor\\0\" | find /i \"x86\" > NUL && set OSQ=32BIT || set OSQ=64BIT\n")
  96. write(f,"echo %OSQ% > osbit.txt")
  97. end
  98. run(`$(wdir)\\redpsl.bat`)
  99. else
  100. println("Downloading reduce binaries...")
  101. download(http*date[ρ]*"/"*setup*"_"*date[ρ]*".exe",joinpath(wdir,"$(setup)_$(date[ρ]).exe"))
  102. println("Installing reduce binaries...")
  103. run(`$(setup)_$(date[ρ]).exe /SILENT /DIR=$(joinpath(wdir,"install"))`)
  104. end
  105. println("DONE")
  106. end
  107. end
  108. cd(oldwdir)