2015-12-21 23:10:17 +00:00
|
|
|
#!/usr/bin/python
|
2014-02-14 03:03:12 +00:00
|
|
|
#
|
|
|
|
# Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
2015-12-21 23:10:17 +00:00
|
|
|
"""This script wraps gyp and sets up build environments.
|
|
|
|
|
|
|
|
Build instructions:
|
|
|
|
|
|
|
|
1. Setup gyp: ./gyp_packager.py or use gclient runhooks
|
|
|
|
|
|
|
|
Ninja is the default build system. User can also change to make by
|
|
|
|
overriding GYP_GENERATORS to make, i.e.
|
|
|
|
"GYP_GENERATORS='make' gclient runhooks".
|
|
|
|
|
|
|
|
2. The first step generates the make files but does not start the
|
|
|
|
build process. Ninja is the default build system. Refer to Ninja
|
|
|
|
manual on how to do the build.
|
|
|
|
|
|
|
|
Common syntaxes: ninja -C out/{Debug/Release} [Module]
|
|
|
|
Module is optional. If not specified, build everything.
|
|
|
|
|
|
|
|
Step 1 is only required if there is any gyp file change. Otherwise, you
|
|
|
|
may just run ninja.
|
|
|
|
"""
|
2014-02-14 03:03:12 +00:00
|
|
|
|
2020-06-02 07:22:36 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2014-02-14 03:03:12 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2014-10-01 20:44:41 +00:00
|
|
|
checkout_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
src_dir = os.path.join(checkout_dir, 'packager')
|
2014-02-14 03:03:12 +00:00
|
|
|
|
2015-12-21 23:10:17 +00:00
|
|
|
# Workaround the dynamic path.
|
2021-06-18 19:23:22 +00:00
|
|
|
# pylint: disable=wrong-import-position
|
2015-12-21 23:10:17 +00:00
|
|
|
|
2014-02-20 01:51:18 +00:00
|
|
|
sys.path.insert(0, os.path.join(src_dir, 'build'))
|
2015-12-21 23:10:17 +00:00
|
|
|
import gyp_helper
|
2014-02-20 01:51:18 +00:00
|
|
|
|
2014-02-14 03:03:12 +00:00
|
|
|
sys.path.insert(0, os.path.join(src_dir, 'tools', 'gyp', 'pylib'))
|
2015-12-21 23:10:17 +00:00
|
|
|
import gyp
|
2014-02-14 03:03:12 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
args = sys.argv[1:]
|
|
|
|
|
2014-02-20 01:51:18 +00:00
|
|
|
# Allow src/.../chromium.gyp_env to define GYP variables.
|
|
|
|
gyp_helper.apply_chromium_gyp_env()
|
|
|
|
|
2014-02-14 03:03:12 +00:00
|
|
|
# If we didn't get a gyp file, then fall back to assuming 'packager.gyp' from
|
|
|
|
# the same directory as the script.
|
2020-06-11 22:03:01 +00:00
|
|
|
if not any(arg.endswith('.gyp') for arg in args):
|
2014-02-14 03:03:12 +00:00
|
|
|
args.append(os.path.join(src_dir, 'packager.gyp'))
|
|
|
|
|
2017-12-06 23:08:40 +00:00
|
|
|
# Always include Chromium's common.gypi and our common.gypi.
|
|
|
|
args.extend([
|
|
|
|
'-I' + os.path.join(src_dir, 'build', 'common.gypi'),
|
|
|
|
'-I' + os.path.join(src_dir, 'common.gypi')
|
|
|
|
])
|
2014-02-14 03:03:12 +00:00
|
|
|
|
2014-02-27 04:26:16 +00:00
|
|
|
# Set these default GYP_DEFINES if user does not set the value explicitly.
|
2015-12-21 23:10:17 +00:00
|
|
|
_DEFAULT_DEFINES = {'test_isolation_mode': 'noop',
|
2020-06-11 22:13:42 +00:00
|
|
|
'use_custom_libcxx': 0,
|
2015-12-21 23:10:17 +00:00
|
|
|
'use_glib': 0,
|
|
|
|
'use_openssl': 1,
|
2020-06-11 22:13:42 +00:00
|
|
|
'use_sysroot': 0,
|
2015-12-21 23:10:17 +00:00
|
|
|
'use_x11': 0,
|
2018-08-24 19:52:14 +00:00
|
|
|
'linux_use_bundled_binutils': 0,
|
|
|
|
'linux_use_bundled_gold': 0,
|
2016-08-17 21:42:23 +00:00
|
|
|
'linux_use_gold_flags': 0,
|
build: Stop using hermetic clang, libc++, etc
This brings our default build config more in line with what is
necessary for some platforms anyway: using the system-installed
toolchain and sysroot to build everything.
We will no longer fetch source or binaries for any specific build
tools, such as libc++, clang, gold, binutils, or valgrind.
The main part of this change is the changing of default gyp settings
in gyp_packager.py. For this, a bug in gyp_packager.py had to be
fixed, in which similar GYP_DEFINE key names (such as clang and
host_clang) would conflict, causing some defaults not to be installed
properly.
In order to enable clang=0 by default, some changes had to be made in
common.gypi:
- compiler macros added to fix a compatibility issue between
Chromium's base/mac/ folder and the actual OSX SDK
- replaced clang_warning_flags variables with standard cflags
settings, plus xcode_settings for OSX
- turned off warnings-as-errors for non-shaka code, rather than
allow-listing specific warning types, since we can't actually fix
those warnings on any platform
- disabled two specific warnings in shaka code, both of which are
caused by headers from our non-shaka dependencies
Also, one warning (missing "override" keyword) has been fixed in
vod_media_info_dump_muxer_listener.h.
Although these changes were done to make building simpler on a wider
array of platforms (arm64, for example), it seems to make the build a
bit faster, too. For me, at least, on my main Linux workstation:
- "gclient sync" now runs 20-30% faster
- "ninja -C out/Release" now runs 5-13% faster
The following environment variables are no longer required:
- DEPOT_TOOLS_WIN_TOOLCHAIN
- MACOSX_DEPLOYMENT_TARGET
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following GYP_DEFINES are no longer required for anyone:
- clang=0
- host_clang=0
- clang_xcode=1
- use_allocator=none
- use_experimental_allocator_shim=0
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following repos are no longer dependencies in gclient:
- binutils
- clang
- gold
- libc++
- libc++abi
- valgrind
The following gclient hooks have been removed:
- clang
- mac_toolchain
- sysroot
Change-Id: Ie94ccbeec722ab73c291cb7df897d20761a09a70
2021-07-28 20:01:19 +00:00
|
|
|
'clang': 0,
|
|
|
|
'host_clang': 0,
|
|
|
|
'clang_xcode': 1,
|
|
|
|
'use_allocator': 'none',
|
|
|
|
'mac_deployment_target': '10.10',
|
|
|
|
'use_experimental_allocator_shim': 0,
|
2016-08-17 21:42:23 +00:00
|
|
|
'clang_use_chrome_plugins': 0}
|
2016-01-25 21:39:02 +00:00
|
|
|
|
build: Stop using hermetic clang, libc++, etc
This brings our default build config more in line with what is
necessary for some platforms anyway: using the system-installed
toolchain and sysroot to build everything.
We will no longer fetch source or binaries for any specific build
tools, such as libc++, clang, gold, binutils, or valgrind.
The main part of this change is the changing of default gyp settings
in gyp_packager.py. For this, a bug in gyp_packager.py had to be
fixed, in which similar GYP_DEFINE key names (such as clang and
host_clang) would conflict, causing some defaults not to be installed
properly.
In order to enable clang=0 by default, some changes had to be made in
common.gypi:
- compiler macros added to fix a compatibility issue between
Chromium's base/mac/ folder and the actual OSX SDK
- replaced clang_warning_flags variables with standard cflags
settings, plus xcode_settings for OSX
- turned off warnings-as-errors for non-shaka code, rather than
allow-listing specific warning types, since we can't actually fix
those warnings on any platform
- disabled two specific warnings in shaka code, both of which are
caused by headers from our non-shaka dependencies
Also, one warning (missing "override" keyword) has been fixed in
vod_media_info_dump_muxer_listener.h.
Although these changes were done to make building simpler on a wider
array of platforms (arm64, for example), it seems to make the build a
bit faster, too. For me, at least, on my main Linux workstation:
- "gclient sync" now runs 20-30% faster
- "ninja -C out/Release" now runs 5-13% faster
The following environment variables are no longer required:
- DEPOT_TOOLS_WIN_TOOLCHAIN
- MACOSX_DEPLOYMENT_TARGET
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following GYP_DEFINES are no longer required for anyone:
- clang=0
- host_clang=0
- clang_xcode=1
- use_allocator=none
- use_experimental_allocator_shim=0
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following repos are no longer dependencies in gclient:
- binutils
- clang
- gold
- libc++
- libc++abi
- valgrind
The following gclient hooks have been removed:
- clang
- mac_toolchain
- sysroot
Change-Id: Ie94ccbeec722ab73c291cb7df897d20761a09a70
2021-07-28 20:01:19 +00:00
|
|
|
gyp_defines_str = os.environ.get('GYP_DEFINES', '')
|
|
|
|
user_gyp_defines_map = {}
|
|
|
|
for term in gyp_defines_str.split(' '):
|
|
|
|
if term:
|
|
|
|
key, value = term.strip().split('=')
|
|
|
|
user_gyp_defines_map[key] = value
|
|
|
|
|
2020-06-11 22:03:01 +00:00
|
|
|
for key, value in _DEFAULT_DEFINES.items():
|
build: Stop using hermetic clang, libc++, etc
This brings our default build config more in line with what is
necessary for some platforms anyway: using the system-installed
toolchain and sysroot to build everything.
We will no longer fetch source or binaries for any specific build
tools, such as libc++, clang, gold, binutils, or valgrind.
The main part of this change is the changing of default gyp settings
in gyp_packager.py. For this, a bug in gyp_packager.py had to be
fixed, in which similar GYP_DEFINE key names (such as clang and
host_clang) would conflict, causing some defaults not to be installed
properly.
In order to enable clang=0 by default, some changes had to be made in
common.gypi:
- compiler macros added to fix a compatibility issue between
Chromium's base/mac/ folder and the actual OSX SDK
- replaced clang_warning_flags variables with standard cflags
settings, plus xcode_settings for OSX
- turned off warnings-as-errors for non-shaka code, rather than
allow-listing specific warning types, since we can't actually fix
those warnings on any platform
- disabled two specific warnings in shaka code, both of which are
caused by headers from our non-shaka dependencies
Also, one warning (missing "override" keyword) has been fixed in
vod_media_info_dump_muxer_listener.h.
Although these changes were done to make building simpler on a wider
array of platforms (arm64, for example), it seems to make the build a
bit faster, too. For me, at least, on my main Linux workstation:
- "gclient sync" now runs 20-30% faster
- "ninja -C out/Release" now runs 5-13% faster
The following environment variables are no longer required:
- DEPOT_TOOLS_WIN_TOOLCHAIN
- MACOSX_DEPLOYMENT_TARGET
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following GYP_DEFINES are no longer required for anyone:
- clang=0
- host_clang=0
- clang_xcode=1
- use_allocator=none
- use_experimental_allocator_shim=0
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following repos are no longer dependencies in gclient:
- binutils
- clang
- gold
- libc++
- libc++abi
- valgrind
The following gclient hooks have been removed:
- clang
- mac_toolchain
- sysroot
Change-Id: Ie94ccbeec722ab73c291cb7df897d20761a09a70
2021-07-28 20:01:19 +00:00
|
|
|
if key not in user_gyp_defines_map:
|
|
|
|
gyp_defines_str += ' {0}={1}'.format(key, value)
|
|
|
|
os.environ['GYP_DEFINES'] = gyp_defines_str.strip()
|
2014-02-14 03:03:12 +00:00
|
|
|
|
2016-01-15 15:05:02 +00:00
|
|
|
# Default to ninja, but only if no generator has explicitly been set.
|
2020-06-11 22:03:01 +00:00
|
|
|
if 'GYP_GENERATORS' not in os.environ:
|
2016-01-15 15:05:02 +00:00
|
|
|
os.environ['GYP_GENERATORS'] = 'ninja'
|
|
|
|
|
build: Stop using hermetic clang, libc++, etc
This brings our default build config more in line with what is
necessary for some platforms anyway: using the system-installed
toolchain and sysroot to build everything.
We will no longer fetch source or binaries for any specific build
tools, such as libc++, clang, gold, binutils, or valgrind.
The main part of this change is the changing of default gyp settings
in gyp_packager.py. For this, a bug in gyp_packager.py had to be
fixed, in which similar GYP_DEFINE key names (such as clang and
host_clang) would conflict, causing some defaults not to be installed
properly.
In order to enable clang=0 by default, some changes had to be made in
common.gypi:
- compiler macros added to fix a compatibility issue between
Chromium's base/mac/ folder and the actual OSX SDK
- replaced clang_warning_flags variables with standard cflags
settings, plus xcode_settings for OSX
- turned off warnings-as-errors for non-shaka code, rather than
allow-listing specific warning types, since we can't actually fix
those warnings on any platform
- disabled two specific warnings in shaka code, both of which are
caused by headers from our non-shaka dependencies
Also, one warning (missing "override" keyword) has been fixed in
vod_media_info_dump_muxer_listener.h.
Although these changes were done to make building simpler on a wider
array of platforms (arm64, for example), it seems to make the build a
bit faster, too. For me, at least, on my main Linux workstation:
- "gclient sync" now runs 20-30% faster
- "ninja -C out/Release" now runs 5-13% faster
The following environment variables are no longer required:
- DEPOT_TOOLS_WIN_TOOLCHAIN
- MACOSX_DEPLOYMENT_TARGET
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following GYP_DEFINES are no longer required for anyone:
- clang=0
- host_clang=0
- clang_xcode=1
- use_allocator=none
- use_experimental_allocator_shim=0
Documentation, Dockerfiles, and GitHub Actions workflows have been
updated to reflect this.
The following repos are no longer dependencies in gclient:
- binutils
- clang
- gold
- libc++
- libc++abi
- valgrind
The following gclient hooks have been removed:
- clang
- mac_toolchain
- sysroot
Change-Id: Ie94ccbeec722ab73c291cb7df897d20761a09a70
2021-07-28 20:01:19 +00:00
|
|
|
# By default, don't download our own toolchain for Windows.
|
|
|
|
if 'DEPOT_TOOLS_WIN_TOOLCHAIN' not in os.environ:
|
|
|
|
os.environ['DEPOT_TOOLS_WIN_TOOLCHAIN'] = '0'
|
|
|
|
|
2014-02-14 03:03:12 +00:00
|
|
|
# There shouldn't be a circular dependency relationship between .gyp files,
|
|
|
|
# but in Chromium's .gyp files, on non-Mac platforms, circular relationships
|
|
|
|
# currently exist. The check for circular dependencies is currently
|
|
|
|
# bypassed on other platforms, but is left enabled on the Mac, where a
|
|
|
|
# violation of the rule causes Xcode to misbehave badly.
|
2016-01-15 15:05:02 +00:00
|
|
|
if 'xcode' not in os.environ['GYP_GENERATORS']:
|
2014-02-14 03:03:12 +00:00
|
|
|
args.append('--no-circular-check')
|
|
|
|
|
2014-10-01 20:44:41 +00:00
|
|
|
# TODO(kqyang): Find a better way to handle the depth. This workaround works
|
|
|
|
# only if this script is executed in 'src' directory.
|
2020-06-11 22:03:01 +00:00
|
|
|
if not any('--depth' in arg for arg in args):
|
2014-10-01 20:44:41 +00:00
|
|
|
args.append('--depth=packager')
|
|
|
|
|
2020-06-11 22:03:01 +00:00
|
|
|
if 'output_dir=' not in os.environ.get('GYP_GENERATOR_FLAGS', ''):
|
2016-01-14 23:40:46 +00:00
|
|
|
output_dir = os.path.join(checkout_dir, 'out')
|
|
|
|
gyp_generator_flags = 'output_dir="' + output_dir + '"'
|
|
|
|
if os.environ.get('GYP_GENERATOR_FLAGS'):
|
|
|
|
os.environ['GYP_GENERATOR_FLAGS'] += ' ' + gyp_generator_flags
|
|
|
|
else:
|
|
|
|
os.environ['GYP_GENERATOR_FLAGS'] = gyp_generator_flags
|
2014-10-01 20:44:41 +00:00
|
|
|
|
2020-06-02 07:22:36 +00:00
|
|
|
print('Updating projects from gyp files...')
|
2014-02-14 03:03:12 +00:00
|
|
|
sys.stdout.flush()
|
|
|
|
|
|
|
|
# Off we go...
|
|
|
|
sys.exit(gyp.main(args))
|