~ubuntu-branches/ubuntu/precise/enigmail/precise-security

« back to all changes in this revision

Viewing changes to build/link.py

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-11-12 16:36:01 UTC
  • mfrom: (0.12.15)
  • Revision ID: package-import@ubuntu.com-20121112163601-t8e8skdfi3ni9iqp
Tags: 2:1.4.6-0ubuntu0.12.04.1
* New upstream release v1.4.6
  - see LP: #1080212 for USN information
* Drop unneeded patches
  - remove debian/patches/correct-version-number.diff
  - remove debian/patches/dont_register_cids_multiple_times.diff
  - update debian/patches/series
* Support building in an objdir
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ***** BEGIN LICENSE BLOCK *****
2
 
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 
#
4
 
# The contents of this file are subject to the Mozilla Public License Version
5
 
# 1.1 (the "License"); you may not use this file except in compliance with
6
 
# the License. You may obtain a copy of the License at
7
 
# http://www.mozilla.org/MPL/
8
 
#
9
 
# Software distributed under the License is distributed on an "AS IS" basis,
10
 
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 
# for the specific language governing rights and limitations under the
12
 
# License.
13
 
#
14
 
# The Original Code is cl.py: a python wrapper for cl to automatically generate
15
 
# dependency information.
16
 
#
17
 
# The Initial Developer of the Original Code is
18
 
#   Mozilla Foundation.
19
 
# Portions created by the Initial Developer are Copyright (C) 2010
20
 
# the Initial Developer. All Rights Reserved.
21
 
#
22
 
# Contributor(s):
23
 
#   Ted Mielczarek <ted@mielczarek.org>
24
 
#
25
 
# Alternatively, the contents of this file may be used under the terms of
26
 
# either the GNU General Public License Version 2 or later (the "GPL"), or
27
 
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
 
# in which case the provisions of the GPL or the LGPL are applicable instead
29
 
# of those above. If you wish to allow use of your version of this file only
30
 
# under the terms of either the GPL or the LGPL, and not to allow others to
31
 
# use your version of this file under the terms of the MPL, indicate your
32
 
# decision by deleting the provisions above and replace them with the notice
33
 
# and other provisions required by the GPL or the LGPL. If you do not delete
34
 
# the provisions above, a recipient may use your version of this file under
35
 
# the terms of any one of the MPL, the GPL or the LGPL.
36
 
#
37
 
# ***** END LICENSE BLOCK *****
38
 
 
39
 
from __future__ import with_statement
40
 
import os, platform, subprocess, sys, threading, time
41
 
from win32 import procmem
42
 
 
43
 
def measure_vsize_threadfunc(proc, output_file):
44
 
    """
45
 
    Measure the virtual memory usage of |proc| at regular intervals
46
 
    until it exits, then print the maximum value and write it to
47
 
    |output_file|.
48
 
    """
49
 
    maxvsize = 0
50
 
    while proc.returncode is None:
51
 
        maxvsize, vsize = procmem.get_vmsize(proc._handle)
52
 
        time.sleep(0.5)
53
 
    print "linker max virtual size: %d" % maxvsize
54
 
    with open(output_file, "w") as f:
55
 
        f.write("%d\n" % maxvsize)
56
 
 
57
 
def measure_link_vsize(output_file, args):
58
 
    """
59
 
    Execute |args|, and measure the maximum virtual memory usage of the process,
60
 
    printing it to stdout when finished.
61
 
    """
62
 
    proc = subprocess.Popen(args)
63
 
    t = threading.Thread(target=measure_vsize_threadfunc,
64
 
                         args=(proc, output_file))
65
 
    t.start()
66
 
    # Wait for the linker to finish.
67
 
    exitcode = proc.wait()
68
 
    # ...and then wait for the background thread to finish.
69
 
    t.join()
70
 
    return exitcode
71
 
 
72
 
if __name__ == "__main__":
73
 
    if platform.system() != "Windows":
74
 
        print >>sys.stderr, "link.py is only for use on Windows!"
75
 
        sys.exit(1)
76
 
    if len(sys.argv) < 3:
77
 
        print >>sys.stderr, "Usage: link.py <output filename> <commandline>"
78
 
        sys.exit(1)
79
 
    sys.exit(measure_link_vsize(sys.argv[1], sys.argv[2:]))
 
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
from __future__ import with_statement
 
6
import os, subprocess, sys, threading, time
 
7
from win32 import procmem
 
8
 
 
9
def measure_vsize_threadfunc(proc, output_file):
 
10
    """
 
11
    Measure the virtual memory usage of |proc| at regular intervals
 
12
    until it exits, then print the maximum value and write it to
 
13
    |output_file|.
 
14
    """
 
15
    maxvsize = 0
 
16
    while proc.returncode is None:
 
17
        maxvsize, vsize = procmem.get_vmsize(proc._handle)
 
18
        time.sleep(0.5)
 
19
    print "TinderboxPrint: linker max vsize: %d" % maxvsize
 
20
    with open(output_file, "w") as f:
 
21
        f.write("%d\n" % maxvsize)
 
22
 
 
23
def measure_link_vsize(output_file, args):
 
24
    """
 
25
    Execute |args|, and measure the maximum virtual memory usage of the process,
 
26
    printing it to stdout when finished.
 
27
    """
 
28
    proc = subprocess.Popen(args)
 
29
    t = threading.Thread(target=measure_vsize_threadfunc,
 
30
                         args=(proc, output_file))
 
31
    t.start()
 
32
    # Wait for the linker to finish.
 
33
    exitcode = proc.wait()
 
34
    # ...and then wait for the background thread to finish.
 
35
    t.join()
 
36
    return exitcode
 
37
 
 
38
if __name__ == "__main__":
 
39
    if sys.platform != "win32":
 
40
        print >>sys.stderr, "link.py is only for use on Windows!"
 
41
        sys.exit(1)
 
42
    if len(sys.argv) < 3:
 
43
        print >>sys.stderr, "Usage: link.py <output filename> <commandline>"
 
44
        sys.exit(1)
 
45
    sys.exit(measure_link_vsize(sys.argv[1], sys.argv[2:]))