2014-07-30 23:24:58 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2016-01-27 11:05:20 -05:00
|
|
|
|
|
|
|
def ChooseDependencyPath(local_path, external_path):
|
|
|
|
"""Chooses between a dependency located at local path and an external path.
|
|
|
|
|
|
|
|
The local path, used in standalone builds, is preferred. If it is not present
|
|
|
|
but the external path is, the external path will be used. If neither path is
|
|
|
|
present, the local path will be used, so that error messages uniformly refer
|
|
|
|
to the local path.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
local_path: The preferred local path to use for a standalone build.
|
|
|
|
external_path: The external path to fall back to.
|
|
|
|
|
|
|
|
Returns:
|
2017-02-16 13:26:54 -05:00
|
|
|
A 2-tuple. The first element is None or 'external', depending on whether
|
|
|
|
local_path or external_path was chosen. The second element is the chosen
|
|
|
|
path.
|
2016-01-27 11:05:20 -05:00
|
|
|
"""
|
|
|
|
if os.path.exists(local_path) or not os.path.exists(external_path):
|
2017-02-16 13:26:54 -05:00
|
|
|
return (None, local_path)
|
2016-01-27 11:05:20 -05:00
|
|
|
return ('external', external_path)
|
|
|
|
|
|
|
|
|
2014-07-30 23:24:58 -04:00
|
|
|
script_dir = os.path.dirname(__file__)
|
2016-01-27 11:05:20 -05:00
|
|
|
crashpad_dir = (os.path.dirname(script_dir) if script_dir not in ('', os.curdir)
|
|
|
|
else os.pardir)
|
|
|
|
|
|
|
|
sys.path.insert(0,
|
|
|
|
ChooseDependencyPath(os.path.join(crashpad_dir, 'third_party', 'gyp', 'gyp',
|
|
|
|
'pylib'),
|
2016-01-27 16:49:23 -05:00
|
|
|
os.path.join(crashpad_dir, os.pardir, os.pardir, 'gyp',
|
2016-01-27 11:05:20 -05:00
|
|
|
'pylib'))[1])
|
2014-07-30 23:24:58 -04:00
|
|
|
|
|
|
|
import gyp
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
|
2014-07-30 23:24:58 -04:00
|
|
|
def main(args):
|
|
|
|
if 'GYP_GENERATORS' not in os.environ:
|
|
|
|
os.environ['GYP_GENERATORS'] = 'ninja'
|
|
|
|
|
2016-01-27 11:05:20 -05:00
|
|
|
crashpad_dir_or_dot = crashpad_dir if crashpad_dir is not '' else os.curdir
|
2014-07-30 23:24:58 -04:00
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
(dependencies, mini_chromium_common_gypi) = (ChooseDependencyPath(
|
2016-01-27 11:05:20 -05:00
|
|
|
os.path.join(crashpad_dir, 'third_party', 'mini_chromium',
|
|
|
|
'mini_chromium', 'build', 'common.gypi'),
|
2016-01-27 16:49:23 -05:00
|
|
|
os.path.join(crashpad_dir, os.pardir, os.pardir, 'mini_chromium',
|
|
|
|
'mini_chromium', 'build', 'common.gypi')))
|
2017-02-16 13:26:54 -05:00
|
|
|
if dependencies is not None:
|
|
|
|
args.extend(['-D', 'crashpad_dependencies=%s' % dependencies])
|
2017-10-12 12:42:28 -04:00
|
|
|
args.extend(['--include', mini_chromium_common_gypi])
|
2014-07-30 23:24:58 -04:00
|
|
|
args.extend(['--depth', crashpad_dir_or_dot])
|
|
|
|
args.append(os.path.join(crashpad_dir, 'crashpad.gyp'))
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
result = gyp.main(args)
|
|
|
|
if result != 0:
|
|
|
|
return result
|
|
|
|
|
|
|
|
if sys.platform == 'win32':
|
2017-03-22 17:34:54 -04:00
|
|
|
# Check to make sure that no target_arch was specified. target_arch may be
|
|
|
|
# set during a cross build, such as a cross build for Android.
|
|
|
|
has_target_arch = False
|
2017-11-29 13:26:55 -05:00
|
|
|
for arg_index in range(0, len(args)):
|
2017-03-22 17:34:54 -04:00
|
|
|
arg = args[arg_index]
|
|
|
|
if (arg.startswith('-Dtarget_arch=') or
|
|
|
|
(arg == '-D' and arg_index + 1 < len(args) and
|
|
|
|
args[arg_index + 1].startswith('target_arch='))):
|
|
|
|
has_target_arch = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if not has_target_arch:
|
|
|
|
# Also generate the x86 build.
|
|
|
|
result = gyp.main(args + ['-D', 'target_arch=ia32', '-G', 'config=Debug'])
|
|
|
|
if result != 0:
|
|
|
|
return result
|
|
|
|
result = gyp.main(
|
|
|
|
args + ['-D', 'target_arch=ia32', '-G', 'config=Release'])
|
2015-09-18 16:06:05 -07:00
|
|
|
|
|
|
|
return result
|
|
|
|
|
2014-07-30 23:24:58 -04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(main(sys.argv[1:]))
|