|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright 2010-2016, Google Inc. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions are |
| 7 | +# met: |
| 8 | +# |
| 9 | +# * Redistributions of source code must retain the above copyright |
| 10 | +# notice, this list of conditions and the following disclaimer. |
| 11 | +# * Redistributions in binary form must reproduce the above |
| 12 | +# copyright notice, this list of conditions and the following disclaimer |
| 13 | +# in the documentation and/or other materials provided with the |
| 14 | +# distribution. |
| 15 | +# * Neither the name of Google Inc. nor the names of its |
| 16 | +# contributors may be used to endorse or promote products derived from |
| 17 | +# this software without specific prior written permission. |
| 18 | +# |
| 19 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | + |
| 31 | +"""Script building Breakpad for Mozc/Mac. |
| 32 | +
|
| 33 | +././tools/build_breakpad.py |
| 34 | + --pbdir ./third_party/breakpad --outdir /tmp/breakpad |
| 35 | +""" |
| 36 | + |
| 37 | +import optparse |
| 38 | +import os |
| 39 | +import subprocess |
| 40 | +import sys |
| 41 | + |
| 42 | + |
| 43 | +def ParseOption(): |
| 44 | + parser = optparse.OptionParser() |
| 45 | + parser.add_option('--pbdir', default='./third_party/breakpad') |
| 46 | + parser.add_option('--outdir', default='./out_mac/Release/Breakpad') |
| 47 | + |
| 48 | + (opts, _) = parser.parse_args() |
| 49 | + return opts |
| 50 | + |
| 51 | + |
| 52 | +def ProcessCall(command): |
| 53 | + try: |
| 54 | + subprocess.check_output(command) |
| 55 | + except subprocess.CalledProcessError as e: |
| 56 | + print e.output |
| 57 | + sys.exit(e.returncode) |
| 58 | + print 'Done: %s' % ' '.join(command) |
| 59 | + |
| 60 | + |
| 61 | +def Xcodebuild(projdir, target, arch, outdir): |
| 62 | + ProcessCall([ |
| 63 | + 'xcodebuild', '-project', projdir, '-configuration', 'Release', |
| 64 | + '-target', target, '-arch', arch, '-sdk', 'macosx10.9', |
| 65 | + 'GCC_VERSION=com.apple.compilers.llvm.clang.1_0', |
| 66 | + 'CONFIGURATION_BUILD_DIR=%s' % outdir, |
| 67 | + ]) |
| 68 | + |
| 69 | + |
| 70 | +def BuildBreakpad(outdir): |
| 71 | + projdir = os.path.join(outdir, 'src/client/mac/Breakpad.xcodeproj') |
| 72 | + Xcodebuild(projdir, 'Breakpad', 'i386', outdir) |
| 73 | + |
| 74 | + |
| 75 | +def BuildDumpSyms(outdir): |
| 76 | + projdir = os.path.join(outdir, 'src/tools/mac/dump_syms/dump_syms.xcodeproj') |
| 77 | + Xcodebuild(projdir, 'dump_syms', 'x86_64', outdir) |
| 78 | + |
| 79 | + |
| 80 | +def BuildSymupload(outdir): |
| 81 | + projdir = os.path.join(outdir, 'src/tools/mac/symupload/symupload.xcodeproj') |
| 82 | + # This build fails with Xcode8/i386. |
| 83 | + Xcodebuild(projdir, 'symupload', 'x86_64', outdir) |
| 84 | + |
| 85 | + |
| 86 | +def CreateOutDir(pbdir, outdir): |
| 87 | + workdir = os.path.join(outdir, 'src') |
| 88 | + if not os.path.isdir(workdir): |
| 89 | + os.makedirs(workdir) |
| 90 | + ProcessCall(['rsync', '-avH', os.path.join(pbdir, 'src/'), workdir]) |
| 91 | + |
| 92 | + |
| 93 | +def main(): |
| 94 | + opts = ParseOption() |
| 95 | + pbdir = os.path.abspath(opts.pbdir) |
| 96 | + outdir = os.path.abspath(opts.outdir) |
| 97 | + |
| 98 | + CreateOutDir(pbdir, outdir) |
| 99 | + BuildBreakpad(outdir) |
| 100 | + BuildDumpSyms(outdir) |
| 101 | + BuildSymupload(outdir) |
| 102 | + |
| 103 | + |
| 104 | +if __name__ == '__main__': |
| 105 | + main() |
0 commit comments