Mercurial > hg > openttd
annotate projects/determineversion.vbs @ 20729:ea20edff1862 draft default tip master
(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author | planetmaker <planetmaker@openttd.org> |
---|---|
date | Wed, 31 Jul 2013 18:50:01 +0000 |
parents | 8ec8deb54cef |
children |
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) |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
38 modified = Mid(revision, InStr(revision, Chr(9)) + 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
|
39 revision = Mid(revision, 1, InStr(revision, Chr(9)) - 1) |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
40 modified = Mid(modified, 1, InStr(modified, Chr(9)) - 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
|
41 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
|
42 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
|
43 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
|
44 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
|
45 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
|
46 |
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
|
47 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
|
48 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
|
49 End Sub |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
50 |
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
|
51 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
|
52 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
|
53 |
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 ' 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 |
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 ' 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 |
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 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
|
80 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
|
81 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
|
82 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
|
83 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
|
84 |
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 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
|
86 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
|
87 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 Function DetermineSVNVersion() |
16626
26f234f699a1
(svn r21356) -Fix (r21351): sometimes versions wouldn't be correctly set for Windows builds
rubidium <rubidium@openttd.org>
parents:
16621
diff
changeset
|
89 Dim WshShell, version, branch, modified, revision, clean_rev, url, oExec, line, hash |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
90 Set WshShell = CreateObject("WScript.Shell") |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
91 On Error Resume Next |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
92 |
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
|
93 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
|
94 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 ' Try TortoiseSVN |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
96 ' Get the directory where TortoiseSVN (should) reside(s) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
97 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
|
98 ' 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
|
99 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
|
100 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
|
101 ' 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
|
102 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
|
103 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
104 |
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
|
105 ' 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
117 ' 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
|
118 If revision = 0 Then |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 ' Reset error and version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 Err.Clear |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
121 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
|
122 modified = 0 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
123 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
124 ' 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
|
125 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
|
126 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 ' 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
|
128 Set oExec = WshShell.Exec("svnversion ../") |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 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
|
130 ' 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
|
131 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
|
132 Loop |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
134 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
|
135 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
|
136 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
|
137 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
138 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
140 ' 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
|
141 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
|
142 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
|
143 Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
144 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
|
145 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
|
146 url = line |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
147 End If |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 End If |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 End If ' InStr(version, "$") |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 If version <> "norev000" Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 If InStr(url, "branches") Then |
16895
dd473f691ea9
(svn r21630) -Fix (r20308, r21615): version detection of subversion branches and tags got broken
rubidium <rubidium@openttd.org>
parents:
16626
diff
changeset
|
160 branch = Mid(url, InStr(url, "branches/") + 9) |
dd473f691ea9
(svn r21630) -Fix (r20308, r21615): version detection of subversion branches and tags got broken
rubidium <rubidium@openttd.org>
parents:
16626
diff
changeset
|
161 End If |
dd473f691ea9
(svn r21630) -Fix (r20308, r21615): version detection of subversion branches and tags got broken
rubidium <rubidium@openttd.org>
parents:
16626
diff
changeset
|
162 If InStr(url, "tags") Then |
dd473f691ea9
(svn r21630) -Fix (r20308, r21615): version detection of subversion branches and tags got broken
rubidium <rubidium@openttd.org>
parents:
16626
diff
changeset
|
163 version = Mid(url, InStr(url, "tags/") + 5) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 End If |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
165 Else ' version <> "norev000" |
7917
99d9c1a6f690
(svn r11470) -Codechange: add git detection to MSVC (michi_cc)
glx <glx@openttd.org>
parents:
7784
diff
changeset
|
166 ' 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
|
167 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
|
168 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
|
169 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
|
170 ' 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
|
171 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
|
172 Loop |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
173 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
174 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
|
175 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
|
176 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
|
177 ' 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
|
178 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
|
179 If Err.Number = 0 Then |
19893
8ec8deb54cef
(svn r24826) -Fix: determineversion.vbs could hang in a git checkout
glx <glx@openttd.org>
parents:
17663
diff
changeset
|
180 ' StdOut and StdErr share a 4kB buffer so prevent it from filling up as we don't care about the output |
8ec8deb54cef
(svn r24826) -Fix: determineversion.vbs could hang in a git checkout
glx <glx@openttd.org>
parents:
17663
diff
changeset
|
181 oExec.StdOut.Close |
8ec8deb54cef
(svn r24826) -Fix: determineversion.vbs could hang in a git checkout
glx <glx@openttd.org>
parents:
17663
diff
changeset
|
182 oExec.StdErr.Close |
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
|
183 ' 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
|
184 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 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
|
190 ' 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
|
191 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
|
192 Loop |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
193 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
194 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
|
195 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
196 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
|
197 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 branch = line |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
204 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
|
205 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
|
206 |
17102
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 ' 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
|
214 ' 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
|
215 Err.Clear |
17102
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 End If ' revision = "" |
17102
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
223 |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
224 ' Check if a tag is currently checked out |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
225 Err.Clear |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
226 Set oExec = WshShell.Exec("git name-rev --name-only --tags --no-undefined HEAD") |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
227 If Err.Number = 0 Then |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
228 ' Wait till the application is finished ... |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
229 Do While oExec.Status = 0 |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
230 Loop |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
231 If oExec.ExitCode = 0 Then |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
232 version = oExec.StdOut.ReadLine() |
17663
d6bd3e10d87f
(svn r22435) -Fix: Git revision detection would return too much when tags are involved.
michi_cc <michi_cc@openttd.org>
parents:
17120
diff
changeset
|
233 If Right(version, 2) = "^0" Then |
d6bd3e10d87f
(svn r22435) -Fix: Git revision detection would return too much when tags are involved.
michi_cc <michi_cc@openttd.org>
parents:
17120
diff
changeset
|
234 version = Left(version, Len(version) - 2) |
d6bd3e10d87f
(svn r22435) -Fix: Git revision detection would return too much when tags are involved.
michi_cc <michi_cc@openttd.org>
parents:
17120
diff
changeset
|
235 End If |
17102
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
236 branch = "" |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
237 End If ' oExec.ExitCode = 0 |
04d7d238167c
(svn r21839) -Change: Support tags created by git-svn for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
16895
diff
changeset
|
238 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
|
239 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
|
240 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
|
241 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
|
242 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
243 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
|
244 ' 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
|
245 Err.Clear |
17103
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
246 Set oExec = WshShell.Exec("hg id -i") |
7784
84407cb523b6
(svn r11334) -Codechange: add hg detection to MSVC
glx <glx@openttd.org>
parents:
7780
diff
changeset
|
247 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
|
248 ' 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
|
249 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
|
250 Loop |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
251 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
252 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
|
253 line = OExec.StdOut.ReadLine() |
17103
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
254 hash = Left(line, 12) |
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
|
255 version = "h" & Mid(hash, 1, 8) |
17103
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
256 |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
257 ' Check if a tag is currently checked out |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
258 Err.Clear |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
259 Set oExec = WshShell.Exec("hg id -t") |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
260 If Err.Number = 0 Then |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
261 line = oExec.StdOut.ReadLine() |
17119
342dacb475e6
(svn r21856) -Fix (r21840): Don't fail tag detection on hg repositories that use mercurial queues. Add some safety against tags and branches with spaces as well.
michi_cc <michi_cc@openttd.org>
parents:
17103
diff
changeset
|
262 If Len(line) > 0 And Right(line, 3) <> "tip" Then |
17103
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
263 version = line |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
264 branch = "" |
17119
342dacb475e6
(svn r21856) -Fix (r21840): Don't fail tag detection on hg repositories that use mercurial queues. Add some safety against tags and branches with spaces as well.
michi_cc <michi_cc@openttd.org>
parents:
17103
diff
changeset
|
265 End If ' Len(line) > 0 And Right(line, 3) <> "tip" |
17103
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
266 End If ' Err.Number = 0 |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
267 |
473b6165a404
(svn r21840) -Change: Support tags created by hgsubversion for the revision detection.
michi_cc <michi_cc@openttd.org>
parents:
17102
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
272 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
|
273 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
|
274 modified = 2 |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
275 Exit Do |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
276 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
|
277 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
|
278 |
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
279 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
|
280 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
|
281 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
|
282 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
|
283 branch = line |
10074
98c9d031670d
(svn r14242) -Fix: removed some possible infinite loop in version determination (again).
glx <glx@openttd.org>
parents:
10035
diff
changeset
|
284 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
|
285 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
|
286 |
17120
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
287 Set oExec = WshShell.Exec("hg log -f -k " & Chr(34) & "(svn r" & Chr(34) & " -l 1 --template " & Chr(34) & "{desc|firstline}\n" & Chr(34) & " --cwd ../") |
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
|
288 If Err.Number = 0 Then |
17120
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
289 line = oExec.StdOut.ReadLine() |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
290 If Left(line, 6) = "(svn r" Then |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
291 revision = Mid(line, 7) |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
292 revision = Mid(revision, 1, InStr(revision, ")") - 1) |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
293 End If 'Left(line, 6) = "(svn r" |
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
|
294 End If ' Err.Number = 0 |
17120
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
295 |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
296 If revision = "" Then |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
297 ' No rev? Maybe it is a custom hgsubversion clone |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
298 Err.Clear |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
299 Set oExec = WshShell.Exec("hg parent --template=" & Chr(34) & "{svnrev}" & Chr(34)) |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
300 If Err.Number = 0 Then |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
301 revision = oExec.StdOut.ReadLine() |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
302 End If ' Err.Number = 0 |
28b86b282635
(svn r21857) -Add: Revision detection for hgsubversion repositories.
michi_cc <michi_cc@openttd.org>
parents:
17119
diff
changeset
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 End If ' version <> "norev000" |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 |
16626
26f234f699a1
(svn r21356) -Fix (r21351): sometimes versions wouldn't be correctly set for Windows builds
rubidium <rubidium@openttd.org>
parents:
16621
diff
changeset
|
310 If version = "norev000" And FSO.FileExists("../.ottdrev") Then |
26f234f699a1
(svn r21356) -Fix (r21351): sometimes versions wouldn't be correctly set for Windows builds
rubidium <rubidium@openttd.org>
parents:
16621
diff
changeset
|
311 Dim rev_file |
26f234f699a1
(svn r21356) -Fix (r21351): sometimes versions wouldn't be correctly set for Windows builds
rubidium <rubidium@openttd.org>
parents:
16621
diff
changeset
|
312 Set rev_file = FSO.OpenTextFile("../.ottdrev", 1, True, 0) |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
313 DetermineSVNVersion = rev_file.ReadLine() |
16626
26f234f699a1
(svn r21356) -Fix (r21351): sometimes versions wouldn't be correctly set for Windows builds
rubidium <rubidium@openttd.org>
parents:
16621
diff
changeset
|
314 rev_file.Close() |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
315 Else |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
316 If modified = 2 Then |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
317 version = version & "M" |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
318 End If |
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
|
319 |
16621
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
320 clean_rev = version |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
321 If branch <> "" Then |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
322 version = version & "-" & branch |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
323 End If |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
324 |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
325 If version <> "norev000" Then |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
326 DetermineSVNVersion = version & Chr(9) & revision & Chr(9) & modified & Chr(9) & clean_rev |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
327 Else |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
328 DetermineSVNVersion = version |
0a728d98d51e
(svn r21351) -Change: read some metadata from (official) source tarballs so you'll more likely get the right version/revision out-of-the-box
rubidium <rubidium@openttd.org>
parents:
15813
diff
changeset
|
329 End If |
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
|
330 End If |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
331 End Function |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
332 |
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
|
333 Function IsCachedVersion(ByVal version) |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
334 Dim cache_file, cached_version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
335 cached_version = "" |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
336 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
|
337 If Not cache_file.atEndOfStream Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
338 cached_version = cache_file.ReadLine() |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
339 End If |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
340 cache_file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
341 |
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
|
342 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
|
343 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
|
344 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
|
345 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
346 If version <> cached_version Then |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
347 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
|
348 cache_file.WriteLine(version) |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
349 cache_file.Close |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
350 IsCachedVersion = False |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
351 Else |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
352 IsCachedVersion = True |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
353 End If |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
354 End Function |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
355 |
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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 |
7564
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
361 Dim version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
362 version = DetermineSVNVersion |
12846
62f969bd7ff4
(svn r17336) -Codechange: move some os specific files into src/os/
rubidium <rubidium@openttd.org>
parents:
12778
diff
changeset
|
363 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
|
364 UpdateFiles version |
0f45d5223c87
(svn r11089) -Codechange: add revision detection to MSVC.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
365 End If |