build.jl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.windows() ? `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(`$rpsl`)
  31. kill(process)
  32. catch
  33. if Sys.islinux()
  34. cmd = `$(joinpath(wdir,"usr","bin"))/$rpsl`
  35. elseif Sys.isapple()
  36. cmd = `$(joinpath(wdir,"psl"))/$rpsl`
  37. else
  38. cmd = `$(joinpath(wdir,"Reduce-svn$(rsvn[ρ])-src","bin"))/$rpsl`
  39. end
  40. process = _spawn(cmd)
  41. kill(process)
  42. !isfile("ver") && writever(0)
  43. end
  44. catch
  45. http = "https://sourceforge.net/projects/reduce-algebra/files/snapshot_"
  46. rtg = "reduce.tar.gz"
  47. dl = "/download"
  48. cd(wdir)
  49. println("Building Reduce.jl with CSL binaries ... ")
  50. if Sys.islinux()
  51. src = "/reduce-csl_"
  52. if occursin("64",read(`uname -m`,String))
  53. download(http*date[ρ]*"/linux64"*src*rsvn[ρ]*"_amd64.tgz"*dl,joinpath(wdir,rtg))
  54. else
  55. download(http*date[ρ]*"/linux32"*src*rsvn[ρ]*"_i386.tgz"*dl,joinpath(wdir,rtg))
  56. end
  57. run(`rm -rf $(joinpath(wdir,"usr"))`)
  58. run(`tar -xvf $(rtg)`)
  59. run(`rm $(rtg)`)
  60. writever(ρ)
  61. elseif Sys.isapple()
  62. snap = "Reduce-snapshot"
  63. download(http*date[ρ]*"/macintosh/"*snap*"_"*rsvn[ρ]*".dmg"*dl,joinpath(wdir,"$(snap)_$(date[ρ]).dmg"))
  64. run(`hdiutil attach $(wdir)/$(snap)_$(date[ρ]).dmg`)
  65. run(`rm -rf $(joinpath(wdir,"csl"))`)
  66. run(`cp -r /Volumes/$(snap)/csl $(wdir)/csl`)
  67. run(`hdiutil unmount /Volumes/$(snap)`)
  68. run(`rm $(snap)_$(date[ρ]).dmg`)
  69. writever(ρ)
  70. else
  71. download(http*date[ρ]*"/Reduce-svn$(rsvn[ρ])-src.tar.gz"*dl,joinpath(wdir,rtg))
  72. run(`tar -xvf $(rtg)`)
  73. run(`rm $(rtg)`)
  74. cd(joinpath("$wdir","Reduce-svn$(rsvn[ρ])-src"))
  75. run(`./configure --with-psl`)
  76. run(`make`)
  77. writever(ρ)
  78. end
  79. println("DONE")
  80. end
  81. else
  82. try
  83. #cmd = `"$(wdir)\psl\bpsl.exe" -td 16000000 -f "$(wdir)\red\reduce.img"`
  84. cmd = `"$(wdir)\reduce.exe" --nogui`
  85. process = _spawn(cmd)
  86. kill(process)
  87. catch
  88. cd(wdir)
  89. println("Building Reduce.jl with CSL binaries ...")
  90. cab = "wincsl.cab"
  91. http = "https://ayera.dl.sourceforge.net/project/reduce-algebra/snapshot_"
  92. download(http*date[ρ]*"/windows/wincsl_$(rsvn[ρ]).cab",joinpath(wdir,cab))
  93. open("redextract.bat","w") do f
  94. write(f,"expand $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)\\redextract.bat`)
  99. writever(ρ)
  100. println("DONE")
  101. end
  102. end
  103. cd(oldwdir)