~ubuntu-branches/ubuntu/quantal/enigmail/quantal-security

« back to all changes in this revision

Viewing changes to config/make-stl-wrappers.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2013-09-13 16:02:15 UTC
  • mfrom: (0.12.16)
  • Revision ID: package-import@ubuntu.com-20130913160215-u3g8nmwa0pdwagwc
Tags: 2:1.5.2-0ubuntu0.12.10.1
* New upstream release v1.5.2 for Thunderbird 24

* Build enigmail using a stripped down Thunderbird 17 build system, as it's
  now quite difficult to build the way we were doing previously, with the
  latest Firefox build system
* Add debian/patches/no_libxpcom.patch - Don't link against libxpcom, as it
  doesn't exist anymore (but exists in the build system)
* Add debian/patches/use_sdk.patch - Use the SDK version of xpt.py and
  friends
* Drop debian/patches/ipc-pipe_rename.diff (not needed anymore)
* Drop debian/patches/makefile_depth.diff (not needed anymore)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This Source Code Form is subject to the terms of the Mozilla Public
2
 
# License, v. 2.0. If a copy of the MPL was not distributed with this
3
 
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
 
 
5
 
import os, re, string, sys
6
 
 
7
 
def find_in_path(file, searchpath):
8
 
    for dir in searchpath.split(os.pathsep):
9
 
        f = os.path.join(dir, file)
10
 
        if os.path.exists(f):
11
 
            return f
12
 
    return ''
13
 
 
14
 
def header_path(header, compiler):
15
 
    if compiler == 'gcc':
16
 
        # we use include_next on gcc
17
 
        return header
18
 
    elif compiler == 'msvc':
19
 
        return find_in_path(header, os.environ.get('INCLUDE', ''))
20
 
    else:
21
 
        # hope someone notices this ...
22
 
        raise NotImplementedError, compiler
23
 
 
24
 
def is_comment(line):
25
 
    return re.match(r'\s*#.*', line)
26
 
 
27
 
def main(outdir, compiler, template_file, header_list_file):
28
 
    if not os.path.isdir(outdir):
29
 
        os.mkdir(outdir)
30
 
 
31
 
    template = open(template_file, 'r').read()
32
 
    path_to_new = header_path('new', compiler)
33
 
 
34
 
    for header in open(header_list_file, 'r'):
35
 
        header = header.rstrip()
36
 
        if 0 == len(header) or is_comment(header):
37
 
            continue
38
 
 
39
 
        path = header_path(header, compiler)
40
 
        try:
41
 
            f = open(os.path.join(outdir, header), 'w')
42
 
            f.write(string.Template(template).substitute(HEADER=header,
43
 
                                                         HEADER_PATH=path,
44
 
                                                         NEW_HEADER_PATH=path_to_new))
45
 
        finally:
46
 
            f.close()
47
 
 
48
 
 
49
 
if __name__ == '__main__':
50
 
    if 5 != len(sys.argv):
51
 
        print >>sys.stderr, """Usage:
52
 
  python %s OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
53
 
"""% (sys.argv[0])
54
 
        sys.exit(1)
55
 
 
56
 
    main(*sys.argv[1:])