diff options
Diffstat (limited to '')
-rwxr-xr-x | linden/scripts/build_version.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/linden/scripts/build_version.py b/linden/scripts/build_version.py new file mode 100755 index 0000000..4bef290 --- /dev/null +++ b/linden/scripts/build_version.py | |||
@@ -0,0 +1,54 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # | ||
3 | # Print the build information embedded in a header file. | ||
4 | # | ||
5 | # Expects to be invoked from the command line with a file name and a | ||
6 | # list of directories to search. The file name will be one of the | ||
7 | # following: | ||
8 | # | ||
9 | # llversionserver.h | ||
10 | # llversionviewer.h | ||
11 | # | ||
12 | # The directory list that follows will include indra/llcommon, where | ||
13 | # these files live. | ||
14 | |||
15 | import errno, os, re | ||
16 | |||
17 | def get_version(filename): | ||
18 | fp = open(filename) | ||
19 | data = fp.read() | ||
20 | fp.close() | ||
21 | |||
22 | vals = {} | ||
23 | m = re.search('const S32 LL_VERSION_MAJOR = (\d+);', data) | ||
24 | vals['major'] = m.group(1) | ||
25 | m = re.search('const S32 LL_VERSION_MINOR = (\d+);', data) | ||
26 | vals['minor'] = m.group(1) | ||
27 | m = re.search('const S32 LL_VERSION_PATCH = (\d+);', data) | ||
28 | vals['patch'] = m.group(1) | ||
29 | m = re.search('const S32 LL_VERSION_BUILD = (\d+);', data) | ||
30 | vals['build'] = m.group(1) | ||
31 | |||
32 | return "%(major)s.%(minor)s.%(patch)s.%(build)s" % vals | ||
33 | |||
34 | if __name__ == '__main__': | ||
35 | import sys | ||
36 | |||
37 | try: | ||
38 | for path in sys.argv[2:]: | ||
39 | name = os.path.join(path, sys.argv[1]) | ||
40 | try: | ||
41 | print get_version(name) | ||
42 | break | ||
43 | except OSError, err: | ||
44 | if err.errno != errno.ENOENT: | ||
45 | raise | ||
46 | else: | ||
47 | print >> sys.stderr, 'File not found:', sys.argv[1] | ||
48 | sys.exit(1) | ||
49 | except AttributeError: | ||
50 | print >> sys.stderr, 'Error: malformatted file: ', name | ||
51 | sys.exit(1) | ||
52 | except IndexError: | ||
53 | print >> sys.stderr, ('Usage: %s llversion[...].h [directories]' % | ||
54 | sys.argv[0]) | ||