Sun, 12 Apr 2015 23:02:26 +0300
- fix spacing in cmakelists
933
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | # |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | # Copyright 2015 Teemu Piippo |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | # All rights reserved. |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | # |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | # Redistribution and use in source and binary forms, with or without |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | # modification, are permitted provided that the following conditions |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | # are met: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | # |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | # 1. Redistributions of source code must retain the above copyright |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | # notice, this list of conditions and the following disclaimer. |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | # 2. Redistributions in binary form must reproduce the above copyright |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | # notice, this list of conditions and the following disclaimer in the |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | # documentation and/or other materials provided with the distribution. |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | # 3. Neither the name of the copyright holder nor the names of its |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | # contributors may be used to endorse or promote products derived from |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | # this software without specific prior written permission. |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | # |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | # |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | import md5 |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | import re |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | import sys |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | import os |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | class OutputFile: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | def __init__(self, filename): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | self.filename = filename |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | try: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | with open (self.filename, "r") as fp: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | self.oldsum = fp.readline().replace ('\n', '').replace ('// ', '') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | except IOError: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | self.oldsum = '' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | self.body = '' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | def write(self, a): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | self.body += a |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | def save(self): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | checksum = md5.new (self.body).hexdigest() |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | if checksum == self.oldsum: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | print '%s is up to date' % self.filename |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | return False |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | with open (self.filename, "w") as fp: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | fp.write ('// %s\n' % checksum) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | fp.write (self.body) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | return True |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | def prog_configaux(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | class CfgEntry: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | def __init__(self, type, name, defvalue): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | self.type = type |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | self.name = name |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | self.defvalue = defvalue |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | if len (sys.argv) < 3: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | print 'Usage: %s <output> <input1> [input2] [input3] ... [input-n]' % sys.argv[0] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | quit(1) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | f = OutputFile (sys.argv[1]) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | f.write ('#pragma once\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | entries = [] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | for inputname in sys.argv[2:]: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | fp = open (inputname, 'r') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | for line in fp.readlines(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | match = re.match (r'CFGENTRY\s*\(([^,]+),\s*([^,]+),\s*([^)]+)\)', line) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | if match: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | entries.append (CfgEntry (match.group (1), match.group (2), match.group (3))) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | for e in entries: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | f.write ('EXTERN_CFGENTRY (%s, %s)\n' % (e.type, e.name)) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | f.write ('\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | f.write ('static void InitConfigurationEntry (class AbstractConfigEntry* entry);\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | f.write ('static void SetupConfigurationLists()\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | f.write ('{\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | for e in entries: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | f.write ('\tInitConfigurationEntry (new %sConfigEntry (&cfg::%s, \"%s\", %s));\n' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | % (e.type, e.name, e.name, e.defvalue)) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | f.write ('}\n') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | if f.save(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | print 'Wrote configuration aux code to %s' % f.filename |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | def prog_hginfo(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | import subprocess |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | from datetime import datetime |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | if len (sys.argv) != 2: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | print 'usage: %s <output>' % sys.argv[0] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | quit (1) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | f = OutputFile (sys.argv[1]) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | data = subprocess.check_output (['hg', 'log', '-r.', '--template', |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | '{node|short} {branch} {date|hgdate}']).replace ('\n', '').split (' ') |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | rev = data[0] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | branch = data[1] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | timestamp = int (data[2]) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | date = datetime.utcfromtimestamp (timestamp) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | datestring = date.strftime ('%y%m%d-%H%M') if date.year >= 2000 else '000000-0000' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | if len(rev) > 7: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | rev = rev[0:7] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | if subprocess.check_output (['hg', 'id', '-n']).replace ('\n', '')[-1] == '+': |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | rev += '+' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | f.write ('#define HG_NODE "%s"\n' % rev) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | f.write ('#define HG_BRANCH "%s"\n' % branch) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | f.write ('#define HG_DATE_VERSION "%s"\n' % datestring) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | f.write ('#define HG_DATE_STRING "%s"\n' % date.strftime ('%d %b %Y')) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | f.write ('#define HG_DATE_TIME %d\n' % int (timestamp)) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
132 | if f.save(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | print '%s updated to %s' % (f.filename, rev) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
134 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | def main(): |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | if len(sys.argv) < 2: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | print 'You must give a program name' |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | quit(1) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
139 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | progname = sys.argv[1] |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | sys.argv[0] = '%s %s' % (sys.argv[0], sys.argv[1]) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | sys.argv.pop (1) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | impl = globals().copy() |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | impl.update (locals()) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | method = impl.get ('prog_' + progname) |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | if method: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | method() |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | else: |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | print 'no such program %s' % progname |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
152 | |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
153 | if __name__ == '__main__': |
f4c80d92e71e
- rewrote codegen in python and merged updaterevision into it
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
154 | main() |