build.jl 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 = parse(Int,read(f,String))
  10. end
  11. if ver ≠ ρ
  12. if Sys.islinux()
  13. run(`rm -rf $(joinpath(wdir,"usr"))`)
  14. elseif Sys.isapple()
  15. run(`rm -rf $(joinpath(wdir,"csl"))`)
  16. elseif Sys.iswindows()
  17. run(`cmd /C DEL /F /S /Q /A "$(joinpath(wdir,"reduce.exe"))"`)
  18. end
  19. run(Sys.iswindows() ? `cmd /C DEL /F /S /Q /A "ver"` : `rm ver`)
  20. end
  21. end
  22. function writever(rv)
  23. open("ver","w") do f
  24. write(f,"$rv")
  25. end
  26. end
  27. if !Sys.iswindows()
  28. try
  29. try
  30. process = _spawn(red())
  31. kill(process)
  32. catch
  33. process = _spawn(redsys(wdir))
  34. kill(process)
  35. !isfile("ver") && writever(0)
  36. end
  37. catch
  38. http = "https://sourceforge.net/projects/reduce-algebra/files/snapshot_"
  39. rtg = "reduce.tar.gz"
  40. dl = "/download"
  41. cd(wdir)
  42. println("Building Reduce.jl with $(ispsl() ? "PSL" : "CSL") binaries ... ")
  43. if Sys.islinux()
  44. src = "/reduce-$(redsl())_"
  45. if occursin("64",read(`uname -m`,String))
  46. download(http*date[ρ]*"/linux64"*src*rsvn[ρ]*"_amd64.tgz"*dl,joinpath(wdir,rtg))
  47. else
  48. download(http*date[ρ]*"/linux32"*src*rsvn[ρ]*"_i386.tgz"*dl,joinpath(wdir,rtg))
  49. end
  50. run(`rm -rf $(joinpath(wdir,"usr"))`)
  51. run(`tar -xvf $(rtg)`)
  52. run(`rm $(rtg)`)
  53. writever(ρ)
  54. elseif Sys.isapple()
  55. snap = "Reduce-snapshot"
  56. download(http*date[ρ]*"/macintosh/"*snap*"_"*rsvn[ρ]*".dmg"*dl,joinpath(wdir,"$(snap)_$(date[ρ]).dmg"))
  57. run(`hdiutil attach $(wdir)/$(snap)_$(date[ρ]).dmg`)
  58. run(`rm -rf $(joinpath(wdir,redsl()))`)
  59. run(`cp -r /Volumes/$(snap)/csl $(wdir)/$(redsl())`)
  60. run(`hdiutil unmount /Volumes/$(snap)`)
  61. run(`rm $(snap)_$(date[ρ]).dmg`)
  62. writever(ρ)
  63. else
  64. download(http*date[ρ]*"/Reduce-svn$(rsvn[ρ])-src.tar.gz"*dl,joinpath(wdir,rtg))
  65. run(`tar -xvf $(rtg)`)
  66. run(`rm $(rtg)`)
  67. cd(joinpath("$wdir","Reduce-svn$(rsvn[ρ])-src"))
  68. run(`./configure --with-psl`)
  69. run(`make`)
  70. writever(ρ)
  71. end
  72. println("DONE")
  73. end
  74. else
  75. try
  76. process = _spawn(redsys(wdir))
  77. kill(process)
  78. catch
  79. cd(wdir)
  80. println("Building Reduce.jl with $(ispsl() ? "PSL" : "CSL") binaries ...")
  81. cab,winsl = "winred.cab",ispsl() ? "winpsl64" : "wincsl"
  82. http = "https://master.dl.sourceforge.net/project/reduce-algebra/snapshot_"
  83. download(http*date[ρ]*"/windows/$(winsl)_$(rsvn[ρ]).cab",joinpath(wdir,cab))
  84. open("redextract.bat","w") do f
  85. write(f,"expand $cab \"$(wdir)\" -F:*\n")
  86. #write(f,"reg Query \"HKLM\\Hardware\\Description\\System\\CentralProcessor\\0\" | find /i \"x86\" > NUL && set OSQ=32BIT || set OSQ=64BIT\n")
  87. #write(f,"echo %OSQ% > osbit.txt")
  88. end
  89. run(`$(wdir)\\redextract.bat`)
  90. writever(ρ)
  91. println("DONE")
  92. end
  93. end
  94. cd(oldwdir)