-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.bat
80 lines (61 loc) · 2.6 KB
/
configure.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
@ECHO OFF
REM project: Configure http://github.com/handcraftsman/Configure
REM author: Copyright (c) 2010 Clinton Sheppard <[email protected]>
REM license: MIT License http://creativecommons.org/licenses/MIT/
SETLOCAL
SET CONFIGURE_RAW_FILE_URL=http://github.com/handcraftsman/Configure/raw/master/
SET CONFIGURE_SCRIPT_FILE_NAME=configure.js
SET CONFIGURE_SCRIPT_URL="%CONFIGURE_RAW_FILE_URL%%CONFIGURE_SCRIPT_FILE_NAME%"
SET DOWNLOAD_SCRIPT_FILE_NAME=downloadFile.js
cscript > NUL
IF ERRORLEVEL 1 GOTO:CSCRIPT_FAILED
IF EXIST %CONFIGURE_SCRIPT_FILE_NAME% GOTO :CONFIGURE
IF EXIST %DOWNLOAD_SCRIPT_FILE_NAME% GOTO :DOWNLOAD_CONFIGURE_SCRIPT
(ECHO function downloadFile(url, fileName^)
ECHO {
ECHO var result;
ECHO try
ECHO {
ECHO var req = new ActiveXObject("WinHttp.WinHttpRequest.5.1"^);
ECHO req.Open("GET", url, false^);
ECHO req.Send(^);
ECHO var ForWriting= 2;
ECHO var AsAscii = 0;
ECHO var fso = new ActiveXObject("Scripting.FileSystemObject"^);
ECHO var file = fso.OpenTextFile(fileName, ForWriting, true, AsAscii^);
ECHO file.Write(req.ResponseText^);
ECHO file.Close(^);
ECHO result = "OK\n"+file.path;
ECHO }
ECHO catch (error^)
ECHO {
ECHO result = error + "\n"
ECHO result += "WinHTTP returned error: " +
ECHO (error.number ^& 0xFFFF^).toString(^) + "\n\n";
ECHO result += error.description;
ECHO }
ECHO return result;
ECHO }
ECHO downloadFile(WScript.Arguments.Item(0^),WScript.Arguments.Item(1^)^);) >> %DOWNLOAD_SCRIPT_FILE_NAME%
:DOWNLOAD_CONFIGURE_SCRIPT
IF EXIST %CONFIGURE_SCRIPT_FILE_NAME% GOTO :CONFIGURE
ECHO downloading %CONFIGURE_SCRIPT_URL% to %CONFIGURE_SCRIPT_FILE_NAME%
cscript //NoLogo %DOWNLOAD_SCRIPT_FILE_NAME% "%CONFIGURE_SCRIPT_URL%" "%CONFIGURE_SCRIPT_FILE_NAME%" > NUL
IF NOT EXIST %CONFIGURE_SCRIPT_FILE_NAME% GOTO:DOWNLOAD_CONFIGURE_SCRIPT_FAILED
:CONFIGURE
ECHO executing %CONFIGURE_SCRIPT_FILE_NAME%
cscript //NoLogo %CONFIGURE_SCRIPT_FILE_NAME%
IF ERRORLEVEL 1 GOTO:CONFIGURE_FAILED
ECHO configuration complete type Build.bat to build
IF EXIST %DOWNLOAD_SCRIPT_FILE_NAME% del %DOWNLOAD_SCRIPT_FILE_NAME%
IF EXIST %CONFIGURE_SCRIPT_FILE_NAME% del %CONFIGURE_SCRIPT_FILE_NAME%
GOTO :EOF
:DOWNLOAD_CONFIGURE_SCRIPT_FAILED
ECHO failed to download %CONFIGURE_SCRIPT_URL% to %CONFIGURE_SCRIPT_FILE_NAME% ... please download the file manually and rerun configure.bat
GOTO :EOF
:CONFIGURE_FAILED
ECHO CONFIGURE failed, see error message above... cannot continue.
GOTO :EOF
:CSCRIPT_FAILED
ECHO cscript engine disabled or missing... cannot continue.
GOTO :EOF