forked from CelestialCartographers/Ahorn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathahorn.bat
127 lines (91 loc) · 4.1 KB
/
ahorn.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
@echo off
setlocal EnableDelayedExpansion
set minimum_version="v\"1.3.0\""
set julia_url_64bit=https://julialang-s3.julialang.org/bin/winnt/x64/1.4/julia-1.4.1-win64.exe
set julia_url_32bit=https://julialang-s3.julialang.org/bin/winnt/x86/1.4/julia-1.4.1-win32.exe
set julia_filename=julia-1.4.1-installed.exe
set install_url=https://raw.githubusercontent.com/CelestialCartographers/Ahorn/master/install_ahorn.jl
set install_filename=install_ahorn.jl
:start
where julia >nul 2>nul
if %ERRORLEVEL% equ 0 (
echo Using Julia from PATH environmental variable.
echo Make sure this version is meeting the requirements for Ahorn.
where julia
julia -e "exit(Int(VERSION < %minimum_version%))"
if !ERRORLEVEL! neq 0 (
echo The Path Julia version is too old to run Ahorn. Attempting to use auto detected version.
goto :autodetect
)
goto :run
)
:autodetect
rem New default directory, used for Julia 1.4
for /F " tokens=*" %%i IN ('dir /b /ad-h /o-d "%LocalAppData%\Programs\Julia"') do (
set fn=%%i
if "!fn:~0,6!" == "Julia-" (
set JULIA_PATH="%LocalAppData%\Programs\Julia\%%i\bin"
goto :foundJulia
)
)
rem Old default directory, Julia 1.3 is a valid target
for /F " tokens=*" %%i IN ('dir /b /ad-h /o-d "%LocalAppData%"') do (
set fn=%%i
if "!fn:~0,6!" == "Julia-" (
set JULIA_PATH="%LocalAppData%\%%i\bin"
goto :foundJulia
)
)
echo Julia installation not found in default install directory "%LocalAppData%\Programs\Julia\".
echo Please install to the default directory or add Julia manually to the PATH environmental variable.
goto :installPrompt
:foundJulia
set PATH=%JULIA_PATH%;%PATH%
echo Using Julia from: %JULIA_PATH%
julia -e "exit(Int(VERSION < %minimum_version%))"
if %ERRORLEVEL% neq 0 (
echo The Julia version is too old to run Ahorn. Please make sure the right version is used. You need at least Julia 1.3.0.
:installPrompt
set /p "confirmJuliaInstall=Do you want to install a compatible version of Julia? [y/N]: "
IF /I "!confirmJuliaInstall!" equ "y" (
echo Downloading compatible Julia version and starting the installer.
echo Install it into the default directory unless you want to manually add julia to the PATH environmental variable.
echo Make sure to restart the script after adding julia to the PATH if you are using a custom location.
echo Downloading installer
if "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (
powershell -Command "(New-Object Net.WebClient).DownloadFile('%julia_url_64bit%', '%julia_filename%')"
) else (
powershell -Command "(New-Object Net.WebClient).DownloadFile('%julia_url_32bit%', '%julia_filename%')"
)
echo Running installer
start /wait "" "%~dp0%julia_filename%"
del "%~dp0%julia_filename%"
goto :start
)
goto :end
)
:run
set AHORN_PATH=%LocalAppData%\Ahorn
set "AHORN_PATH=%AHORN_PATH:\=/%"
set AHORN_ENV=\"%AHORN_PATH%/env/\"
julia -e "using Pkg; Pkg.activate(%AHORN_ENV%); exit(length(Pkg.installed()))" > NUL 2>&1
if %ERRORLEVEL% equ 0 (
echo Installing Ahorn, this might take a while.
echo Please make sure not to put the command line into select mode, that means do not click inside the window.
powershell -Command "(New-Object Net.WebClient).DownloadFile('%install_url%', '%install_filename%')"
julia "%~dp0%install_filename%"
del "%~dp0%install_filename%"
julia -e "using Pkg; Pkg.activate(%AHORN_ENV%); exit(length(Pkg.installed()))" > NUL 2>&1
if !ERRORLEVEL! equ 0 (
goto end
)
goto :run
)
echo If this is the first time running Ahorn, this might take a while.
echo The window might stay blank for a long time, this is normal as packages are precompiling in the background.
echo Be patient, the program is still running until the terminal says "Press any key to continue" (or equivalent in your language).
echo The error log is located at "%AHORN_PATH%/error.log", should any problems occur.
julia -e "using Pkg; Pkg.activate(%AHORN_ENV%); using Ahorn; Ahorn.displayMainWindow()" 2> "%AHORN_PATH%/error.log"
:end
endlocal
pause