Mercurial > hg > openttd
annotate projects/determineversion.vbs @ 15643:74f115a76c7c draft
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Mon, 02 Aug 2010 16:38:26 +0000 |
parents | 785511c4dacf |
children | ebcd705d7a0c |
rev | line source |
---|---|
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 Option Explicit |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
3 ' $Id$ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
4 ' |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
5 ' This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
6 ' OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
7 ' OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
8 ' See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
11916
diff
changeset
|
9 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 Dim FSO |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 Set FSO = CreateObject("Scripting.FileSystemObject") |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 Sub FindReplaceInFile(filename, to_find, replacement) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 Dim file, data |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 Set file = FSO.OpenTextFile(filename, 1, 0, 0) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 data = file.ReadAll |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 data = Replace(data, to_find, replacement) |
9783
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
19 Set file = FSO.CreateTextFile(filename, -1, 0) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 file.Write data |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 End Sub |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
23 |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
8702
diff
changeset
|
24 Sub UpdateFile(modified, revision, version, cur_date, filename) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
25 FSO.CopyFile filename & ".in", filename |
11916
1be572ca9966
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
rubidium <rubidium@openttd.org>
parents:
10523
diff
changeset
|
26 FindReplaceInFile filename, "!!MODIFIED!!", modified |
1be572ca9966
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
rubidium <rubidium@openttd.org>
parents:
10523
diff
changeset
|
27 FindReplaceInFile filename, "!!REVISION!!", revision |
1be572ca9966
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
rubidium <rubidium@openttd.org>
parents:
10523
diff
changeset
|
28 FindReplaceInFile filename, "!!VERSION!!", version |
1be572ca9966
(svn r16318) -Change: use !! instead of @@ in src/*.in too.
rubidium <rubidium@openttd.org>
parents:
10523
diff
changeset
|
29 FindReplaceInFile filename, "!!DATE!!", cur_date |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
30 End Sub |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
31 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 Sub UpdateFiles(version) |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
33 Dim modified, revision, cur_date |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 cur_date = DatePart("D", Date) & "." & DatePart("M", Date) & "." & DatePart("YYYY", Date) |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
35 |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
36 If InStr(version, Chr(9)) Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
37 revision = Mid(version, InStr(version, Chr(9)) + 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
38 revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
39 modified = Mid(version, InStrRev(version, Chr(9)) + 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
40 version = Mid(version, 1, InStr(version, Chr(9)) - 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
41 Else |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
42 revision = 0 |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
43 modified = 1 |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
44 End If |
7780
4301f74086b2
(svn r11330) -Add: OTTD version checking for NewGRFs. This allows NewGRFs to do something different for different versions of OpenTTD, like disabling it for too low versions or loading different graphics.
rubidium <rubidium@openttd.org>
parents:
7565
diff
changeset
|
45 |
9457
267a95510fdf
(svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz <smatz@openttd.org>
parents:
8702
diff
changeset
|
46 UpdateFile modified, revision, version, cur_date, "../src/rev.cpp" |
12846
62f969bd7ff4
(svn r17336) -Codechange: move some os specific files into src/os/
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
47 UpdateFile modified, revision, version, cur_date, "../src/os/windows/ottdres.rc" |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
48 End Sub |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
49 |
8702
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
50 Function ReadRegistryKey(shive, subkey, valuename, architecture) |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
51 Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
52 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
53 ' First, get the Registry Provider for the requested architecture |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
54 Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet") |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
55 objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
56 Set objLocator = CreateObject("Wbemscripting.SWbemLocator") |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
57 Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
58 Set objReg = objServices.Get("StdRegProv") |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
59 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
60 ' Check the hive and give it the right value |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
61 Select Case shive |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
62 Case "HKCR", "HKEY_CLASSES_ROOT" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
63 hiveKey = &h80000000 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
64 Case "HKCU", "HKEY_CURRENT_USER" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
65 hiveKey = &H80000001 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
66 Case "HKLM", "HKEY_LOCAL_MACHINE" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
67 hiveKey = &h80000002 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
68 Case "HKU", "HKEY_USERS" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
69 hiveKey = &h80000003 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
70 Case "HKCC", "HKEY_CURRENT_CONFIG" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
71 hiveKey = &h80000005 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
72 Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
73 hiveKey = &h80000006 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
74 Case Else |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
75 MsgBox "Hive not valid (ReadRegistryKey)" |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
76 End Select |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
77 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
78 Set Inparams = objReg.Methods_("GetStringValue").Inparameters |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
79 Inparams.Hdefkey = hiveKey |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
80 Inparams.Ssubkeyname = subkey |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
81 Inparams.Svaluename = valuename |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
82 Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx) |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
83 |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
84 ReadRegistryKey = Outparams.SValue |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
85 End Function |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
86 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 Function DetermineSVNVersion() |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
88 Dim WshShell, version, branch, modified, revision, url, oExec, line, hash |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 Set WshShell = CreateObject("WScript.Shell") |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
90 On Error Resume Next |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
91 |
10431
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
92 revision = 0 |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
93 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
94 ' Try TortoiseSVN |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 ' Get the directory where TortoiseSVN (should) reside(s) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 Dim sTortoise |
8702
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
97 ' First, try with 32-bit architecture |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
98 sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 32) |
15386
8d109d40da29
(svn r20029) -Fix: the 64 bits TortoiseSVN wasn't always properly detected
rubidium <rubidium@openttd.org>
parents:
15260
diff
changeset
|
99 If sTortoise = "" Or IsNull(sTortoise) Then |
8702
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
100 ' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored) |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
101 sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 64) |
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
102 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
103 |
8702
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
104 ' If TortoiseSVN is installed, try to get the revision number |
10431
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
105 If sTortoise <> "" Then |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
106 Dim SubWCRev |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
107 Set SubWCRev = WScript.CreateObject("SubWCRev.object") |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
108 SubWCRev.GetWCInfo FSO.GetAbsolutePathName("../"), 0, 0 |
10431
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
109 revision = SubWCRev.Revision |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
110 version = "r" & revision |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
111 modified = 0 |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
112 if SubWCRev.HasModifications then modified = 2 |
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
113 url = SubWCRev.Url |
8702
41702207d7c7
(svn r12375) -Fix [FS#1847]: revision detection failed to detect 64bit TortoiseSVN when ran from a 32bit MSVC on win64 system (Jafinto)
glx <glx@openttd.org>
parents:
7975
diff
changeset
|
114 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 ' Looks like there is no TortoiseSVN installed either. Then we don't know it. |
10431
c37ea0b252f0
(svn r14684) -Codechange: use SubWCRev object to get version info instead SubWCRev.exe for tortoiseSVN (Darkvater)
glx <glx@openttd.org>
parents:
10293
diff
changeset
|
117 If revision = 0 Then |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
118 ' Reset error and version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 Err.Clear |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 version = "norev000" |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
121 modified = 0 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
122 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
123 ' Set the environment to english |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
124 WshShell.Environment("PROCESS")("LANG") = "en" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
125 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 ' Do we have subversion installed? Check immediatelly whether we've got a modified WC. |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
127 Set oExec = WshShell.Exec("svnversion ../") |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 If Err.Number = 0 Then |
9783
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
129 ' Wait till the application is finished ... |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
130 Do While oExec.Status = 0 |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
131 Loop |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
133 line = OExec.StdOut.ReadLine() |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
134 If line <> "exported" Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
135 If InStr(line, "M") Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
136 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
137 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
139 ' And use svn info to get the correct revision and branch information. |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
140 Set oExec = WshShell.Exec("svn info ../") |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
141 If Err.Number = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
142 Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
143 line = OExec.StdOut.ReadLine() |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
144 If InStr(line, "URL") Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
145 url = line |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
146 End If |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
147 If InStr(line, "Last Changed Rev") Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
148 revision = Mid(line, 19) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
149 version = "r" & revision |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
150 End If |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
151 Loop While Not OExec.StdOut.atEndOfStream |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
152 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
153 End If ' line <> "exported" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
154 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
155 End If ' InStr(version, "$") |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 If version <> "norev000" Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 If InStr(url, "branches") Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
159 url = Mid(url, InStr(url, "branches/") + 9) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
160 branch = Mid(url, 1, InStr(2, url, "/") - 1) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 End If |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
162 Else ' version <> "norev000" |
7917
99d9c1a6f690
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
glx <glx@openttd.org>
parents:
7784
diff
changeset
|
163 ' svn detection failed, reset error and try git |
7784
84407cb523b6
(svn r11334) -Codechange: add hg detection to MSVC
glx <glx@openttd.org>
parents:
7780
diff
changeset
|
164 Err.Clear |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
165 Set oExec = WshShell.Exec("git rev-parse --verify HEAD") |
7975
7248d747d33b
(svn r11531) -Fix [FS#1459]: version determination did stall (read: never finish) when both svn and git were not installed.
rubidium <rubidium@openttd.org>
parents:
7917
diff
changeset
|
166 If Err.Number = 0 Then |
9783
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
167 ' Wait till the application is finished ... |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
168 Do While oExec.Status = 0 |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
169 Loop |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
170 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
171 If oExec.ExitCode = 0 Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
172 hash = oExec.StdOut.ReadLine() |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
173 version = "g" & Mid(hash, 1, 8) |
15260
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
174 ' Make sure index is in sync with disk |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
175 Set oExec = WshShell.Exec("git update-index --refresh") |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
176 If Err.Number = 0 Then |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
177 ' Wait till the application is finished ... |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
178 Do While oExec.Status = 0 |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
179 WScript.Sleep 10 |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
180 Loop |
012e08dc46ae
(svn r19895) -Fix [FS#3836]: Git version detection would sometimes mistakenly identify a checkout as modified.
michi_cc <michi_cc@openttd.org>
parents:
12846
diff
changeset
|
181 End If |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
182 Set oExec = WshShell.Exec("git diff-index --exit-code --quiet HEAD ../") |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
183 If Err.Number = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
184 ' Wait till the application is finished ... |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
185 Do While oExec.Status = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
186 Loop |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
187 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
188 If oExec.ExitCode = 1 Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
189 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
190 End If ' oExec.ExitCode = 1 |
7917
99d9c1a6f690
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
glx <glx@openttd.org>
parents:
7784
diff
changeset
|
191 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
192 Set oExec = WshShell.Exec("git symbolic-ref HEAD") |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
193 If Err.Number = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
194 line = oExec.StdOut.ReadLine() |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
195 line = Mid(line, InStrRev(line, "/") + 1) |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
196 If line <> "master" Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
197 branch = line |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
198 End If ' line <> "master" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
199 End If ' Err.Number = 0 |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
200 |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
201 Set oExec = WshShell.Exec("git log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 ../") |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
202 if Err.Number = 0 Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
203 revision = Mid(oExec.StdOut.ReadLine(), 7) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
204 revision = Mid(revision, 1, InStr(revision, ")") - 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
205 End If ' Err.Number = 0 |
15407
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
206 If revision = "" Then |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
207 ' No revision? Maybe it is a custom git-svn clone |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
208 ' Reset error number as WshShell.Exec will not do that on success |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
209 Err.Clear |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
210 Set oExec = WshShell.Exec("git log --pretty=format:%b --grep=" & Chr(34) & "git-svn-id:.*@[0-9]*" & Chr(34) & " -1 ../") |
15407
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
211 If Err.Number = 0 Then |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
212 revision = oExec.StdOut.ReadLine() |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
213 revision = Mid(revision, InStr(revision, "@") + 1) |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
214 revision = Mid(revision, 1, InStr(revision, " ") - 1) |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
215 End If ' Err.Number = 0 |
785511c4dacf
(svn r20050) -Add: git revision detection for custom git-svn clones.
michi_cc <michi_cc@openttd.org>
parents:
15386
diff
changeset
|
216 End If ' revision = "" |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
217 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
218 End If ' oExec.ExitCode = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
219 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
220 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
221 If version = "norev000" Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
222 ' git detection failed, reset error and try mercurial (hg) |
7917
99d9c1a6f690
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
glx <glx@openttd.org>
parents:
7784
diff
changeset
|
223 Err.Clear |
10163
2e31e1ef6346
(svn r14354) -Fix (r14253): also fix hg revision detection for MSVC
glx <glx@openttd.org>
parents:
10074
diff
changeset
|
224 Set oExec = WshShell.Exec("hg parents") |
7784
84407cb523b6
(svn r11334) -Codechange: add hg detection to MSVC
glx <glx@openttd.org>
parents:
7780
diff
changeset
|
225 If Err.Number = 0 Then |
9783
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
226 ' Wait till the application is finished ... |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
227 Do While oExec.Status = 0 |
f681ca68fb1e
(svn r13924) -Fix (r11531): determineversion.vbs could fail to find the right version with hg
glx <glx@openttd.org>
parents:
9457
diff
changeset
|
228 Loop |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
229 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
230 If oExec.ExitCode = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
231 line = OExec.StdOut.ReadLine() |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
232 hash = Mid(line, InStrRev(line, ":") + 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
233 version = "h" & Mid(hash, 1, 8) |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
234 Set oExec = WshShell.Exec("hg status ../") |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
235 If Err.Number = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
236 Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
237 line = OExec.StdOut.ReadLine() |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
238 If Len(line) > 0 And Mid(line, 1, 1) <> "?" Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
239 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
240 Exit Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
241 End If ' Len(line) > 0 And Mid(line, 1, 1) <> "?" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
242 Loop While Not OExec.StdOut.atEndOfStream |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
243 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
244 Set oExec = WshShell.Exec("hg branch") |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
245 If Err.Number = 0 Then |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
246 line = OExec.StdOut.ReadLine() |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
247 If line <> "default" Then |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
248 branch = line |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
249 End If ' line <> "default" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
250 End If ' Err.Number = 0 |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
251 |
15643
74f115a76c7c
(svn r20308) -Change: don't only look at only the src directory for the revision, but at the parent of the src directory.
rubidium <rubidium@openttd.org>
parents:
15407
diff
changeset
|
252 Set oExec = WshShell.Exec("hg log -r " & hash & ":0 -k " & Chr(34) & "svn" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc}\n" & Chr(34) & " ../") |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
253 If Err.Number = 0 Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
254 revision = Mid(OExec.StdOut.ReadLine(), 7) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
255 revision = Mid(revision, 1, InStr(revision, ")") - 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
256 End If ' Err.Number = 0 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
257 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
258 End If ' oExec.ExitCode = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
259 End If ' Err.Number = 0 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
260 End If ' version = "norev000" |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
261 End If ' version <> "norev000" |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
262 |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
263 If modified = 2 Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
264 version = version & "M" |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
265 End If |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
266 |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
267 If branch <> "" Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
268 version = version & "-" & branch |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
269 End If |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
270 |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
271 If version <> "norev000" Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
272 DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
273 Else |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
274 DetermineSVNVersion = version |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
275 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
276 End Function |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
277 |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
278 Function IsCachedVersion(ByVal version) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
279 Dim cache_file, cached_version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
280 cached_version = "" |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
281 Set cache_file = FSO.OpenTextFile("../config.cache.version", 1, True, 0) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
282 If Not cache_file.atEndOfStream Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
283 cached_version = cache_file.ReadLine() |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
284 End If |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
285 cache_file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
286 |
10283
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
287 If InStr(version, Chr(9)) Then |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
288 version = Mid(version, 1, Instr(version, Chr(9)) - 1) |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
289 End If |
1aae3419bad2
(svn r14522) -Fix: apply r14519 to determineversion.vbs. Also properly set 'modified' for hg and git (was always 1).
glx <glx@openttd.org>
parents:
10164
diff
changeset
|
290 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
291 If version <> cached_version Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
292 Set cache_file = fso.CreateTextFile("../config.cache.version", True) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
293 cache_file.WriteLine(version) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
294 cache_file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
295 IsCachedVersion = False |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
296 Else |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
297 IsCachedVersion = True |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
298 End If |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
299 End Function |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
300 |
10520
ae1d0f095774
(svn r14777) -Fix: be sure to update ottdres.rc and rev.cpp when their .in changes (MSVC)
glx <glx@openttd.org>
parents:
10431
diff
changeset
|
301 Function CheckFile(filename) |
10523
b3da8b28fbe1
(svn r14780) -Fix (r14777): of course VBS evaluates all parts of a boolean expression
glx <glx@openttd.org>
parents:
10520
diff
changeset
|
302 CheckFile = FSO.FileExists(filename) |
b3da8b28fbe1
(svn r14780) -Fix (r14777): of course VBS evaluates all parts of a boolean expression
glx <glx@openttd.org>
parents:
10520
diff
changeset
|
303 If CheckFile Then CheckFile = (FSO.GetFile(filename).DateLastModified >= FSO.GetFile(filename & ".in").DateLastModified) |
10520
ae1d0f095774
(svn r14777) -Fix: be sure to update ottdres.rc and rev.cpp when their .in changes (MSVC)
glx <glx@openttd.org>
parents:
10431
diff
changeset
|
304 End Function |
ae1d0f095774
(svn r14777) -Fix: be sure to update ottdres.rc and rev.cpp when their .in changes (MSVC)
glx <glx@openttd.org>
parents:
10431
diff
changeset
|
305 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
306 Dim version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
307 version = DetermineSVNVersion |
12846
62f969bd7ff4
(svn r17336) -Codechange: move some os specific files into src/os/
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
308 If Not (IsCachedVersion(version) And CheckFile("../src/rev.cpp") And CheckFile("../src/os/windows/ottdres.rc")) Then |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 UpdateFiles version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
310 End If |