From 4a1836050df3cd554f68708e0097769386e74f40 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Fri, 28 Mar 2014 17:26:06 +0000 Subject: [PATCH] Update libyuv build toolchain. Download and use GN similar to how WebRTC uses it for GYP/ninja generation Similar changes as done in https://webrtc-codereview.appspot.com/6939004 Add support for VS2013 compilation using the Chromium standalone toolchain. Similar changes: https://webrtc-codereview.appspot.com/9769004 Fix the valgrind wrapper script similar to https://webrtc-codereview.appspot.com/5589006 https://webrtc-codereview.appspot.com/6939004 Remove no longer needed cygwin mount hook. TEST=All trybots except iOS are passing. Those will have to be fixed in a future CL. BUG=310 TESTED=gclient sync on osx/ios R=tpsiaki@google.com Review URL: https://webrtc-codereview.appspot.com/10849004 git-svn-id: http://libyuv.googlecode.com/svn/trunk@991 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- BUILD.gn | 22 +++++++ DEPS | 77 ++++++++++++++++++++---- gyp_libyuv | 87 +++++++++++++++++++++++++++ gyp_libyuv.py | 24 ++++++++ tools/valgrind-libyuv/libyuv_tests.py | 6 ++ 5 files changed, 203 insertions(+), 13 deletions(-) create mode 100644 BUILD.gn create mode 100644 gyp_libyuv create mode 100644 gyp_libyuv.py diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 000000000..da35480aa --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright 2014 The LibYuv Project Authors. All rights reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file is copied and modified from Chromium (src/BUILD.gn). +group("root") { + external = true + + deps = [ + ] +} + +# A standard (non-group) target is required in the build to load any of the +# configurations, which is in turn required to load all of the build parameters +# (in build/config/BUILD.gn). +executable("dummy") { + external = true +} diff --git a/DEPS b/DEPS index af7600e0e..40b69b853 100644 --- a/DEPS +++ b/DEPS @@ -23,6 +23,9 @@ deps = { "../chromium_deps": File(Var("chromium_trunk") + "/src/DEPS@" + Var("chromium_revision")), + "../chromium_gn": + File(Var("chromium_trunk") + "/src/.gn@" + Var("chromium_revision")), + "build": Var("chromium_trunk") + "/src/build@" + Var("chromium_revision"), @@ -39,6 +42,9 @@ deps = { "tools/clang": Var("chromium_trunk") + "/src/tools/clang@" + Var("chromium_revision"), + "tools/gn": + Var("chromium_trunk") + "/src/tools/gn@" + Var("chromium_revision"), + "tools/gyp": From("chromium_deps", "src/tools/gyp"), @@ -74,6 +80,9 @@ deps_os = { "third_party/yasm/binaries": Var("chromium_trunk") + "/deps/third_party/yasm/binaries@" + Var("chromium_revision"), "third_party/yasm": None, + + "tools/find_depot_tools": + File(Var("chromium_trunk") + "/src/tools/find_depot_tools.py@" + Var("chromium_revision")), }, "unix": { "third_party/gold": @@ -84,7 +93,7 @@ deps_os = { From("chromium_deps", "src/third_party/android_tools"), "third_party/libjpeg": - From("chromium_deps", "src/third_party/libjpeg"), + Var("chromium_trunk") + "/src/third_party/libjpeg@" + Var("chromium_revision"), }, "ios": { # NSS, for SSLClientSocketNSS. @@ -105,6 +114,59 @@ deps_os = { } hooks = [ + { + # Copy .gn from temporary place (../chromium_gn) to root_dir. + "name": "copy .gn", + "pattern": ".", + "action": ["python", Var("root_dir") + "/build/cp.py", + Var("root_dir") + "/../chromium_gn/.gn", + Var("root_dir")], + }, + # Pull GN binaries. This needs to be before running GYP below. + { + "name": "gn_win", + "pattern": "tools/gn/bin/win/gn.exe.sha1", + "action": [ "download_from_google_storage", + "--no_resume", + "--platform=win32", + "--no_auth", + "--bucket", "chromium-gn", + "-s", Var("root_dir") + "/tools/gn/bin/win/gn.exe.sha1", + ], + }, + { + "name": "gn_mac", + "pattern": "tools/gn/bin/mac/gn.sha1", + "action": [ "download_from_google_storage", + "--no_resume", + "--platform=darwin", + "--no_auth", + "--bucket", "chromium-gn", + "-s", Var("root_dir") + "/tools/gn/bin/mac/gn.sha1", + ], + }, + { + "name": "gn_linux", + "pattern": "tools/gn/bin/linux/gn.sha1", + "action": [ "download_from_google_storage", + "--no_resume", + "--platform=linux*", + "--no_auth", + "--bucket", "chromium-gn", + "-s", Var("root_dir") + "/tools/gn/bin/linux/gn.sha1", + ], + }, + { + "name": "gn_linux32", + "pattern": "tools/gn/bin/linux/gn32.sha1", + "action": [ "download_from_google_storage", + "--no_resume", + "--platform=linux*", + "--no_auth", + "--bucket", "chromium-gn", + "-s", Var("root_dir") + "/tools/gn/bin/linux/gn32.sha1", + ], + }, { # Pull clang on mac. If nothing changed, or on non-mac platforms, this takes # zero seconds to run. If something changed, it downloads a prebuilt clang. @@ -115,17 +177,6 @@ hooks = [ { # A change to a .gyp, .gypi, or to GYP itself should run the generator. "pattern": ".", - "action": ["python", Var("root_dir") + "/build/gyp_chromium", - "--depth=" + Var("root_dir"), Var("root_dir") + "/all.gyp", - Var("extra_gyp_flag")], - }, - { - # Update the cygwin mount on Windows. - # This is necessary to get the correct mapping between e.g. /bin and the - # cygwin path on Windows. Without it we can't run bash scripts in actions. - # Ideally this should be solved in "pylib/gyp/msvs_emulation.py". - "pattern": ".", - "action": ["python", Var("root_dir") + "/build/win/setup_cygwin_mount.py", - "--win-only"], + "action": ["python", Var("root_dir") + "/gyp_libyuv"], }, ] diff --git a/gyp_libyuv b/gyp_libyuv new file mode 100644 index 000000000..be7cb7a68 --- /dev/null +++ b/gyp_libyuv @@ -0,0 +1,87 @@ +#!/usr/bin/env python +# +# Copyright 2014 The LibYuv Project Authors. All rights reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This script is used to run GYP for libyuv. It contains selected parts of the +# main function from the src/build/gyp_chromium file. + +import glob +import os +import shlex +import sys + +checkout_root = os.path.dirname(os.path.realpath(__file__)) + +sys.path.insert(0, os.path.join(checkout_root, 'build')) +sys.path.insert(0, os.path.join(checkout_root, 'tools', 'find_depot_tools')) +import gyp_chromium +import gyp_helper + +sys.path.insert(0, os.path.join(checkout_root, 'tools', 'gyp', 'pylib')) +import gyp + + +if __name__ == '__main__': + args = sys.argv[1:] + + # This could give false positives since it doesn't actually do real option + # parsing. Oh well. + gyp_file_specified = False + for arg in args: + if arg.endswith('.gyp'): + gyp_file_specified = True + break + + # If we didn't get a file, assume 'all.gyp' in the root of the checkout. + if not gyp_file_specified: + args.append(os.path.join(checkout_root, 'all.gyp')) + + # There shouldn't be a circular dependency relationship between .gyp files, + args.append('--no-circular-check') + + # Default to ninja unless GYP_GENERATORS is set. + if not os.environ.get('GYP_GENERATORS'): + os.environ['GYP_GENERATORS'] = 'ninja' + + vs2013_runtime_dll_dirs = gyp_chromium.DownloadVsToolChain() + + # Enforce gyp syntax checking. This adds about 20% execution time. + args.append('--check') + + supplemental_includes = gyp_chromium.GetSupplementalFiles() + gn_vars_dict = gyp_chromium.GetGypVarsForGN(supplemental_includes) + + # Automatically turn on crosscompile support for platforms that need it. + if all(('ninja' in os.environ.get('GYP_GENERATORS', ''), + gn_vars_dict.get('OS') in ['android', 'ios'], + 'GYP_CROSSCOMPILE' not in os.environ)): + os.environ['GYP_CROSSCOMPILE'] = '1' + + if not gyp_chromium.RunGN(gn_vars_dict): + sys.exit(1) + args.extend(['-I' + i for i in + gyp_chromium.additional_include_files(supplemental_includes, + args)]) + + # Set the gyp depth variable to the root of the checkout. + args.append('--depth=' + os.path.relpath(checkout_root)) + + print 'Updating projects from gyp files...' + sys.stdout.flush() + + # Off we go... + gyp_rc = gyp.main(args) + + if vs2013_runtime_dll_dirs: + x64_runtime, x86_runtime = vs2013_runtime_dll_dirs + gyp_chromium.CopyVsRuntimeDlls( + os.path.join(checkout_root, gyp_chromium.GetOutputDirectory()), + (x86_runtime, x64_runtime)) + + sys.exit(gyp_rc) diff --git a/gyp_libyuv.py b/gyp_libyuv.py new file mode 100644 index 000000000..3aeb1f33c --- /dev/null +++ b/gyp_libyuv.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# +# Copyright 2014 The LibYuv Project Authors. All rights reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file is (possibly, depending on python version) imported by +# gyp_webrtc when GYP_PARALLEL=1 and it creates sub-processes +# through the multiprocessing library. + +# Importing in Python 2.6 (fixed in 2.7) on Windows doesn't search for +# imports that don't end in .py (and aren't directories with an +# __init__.py). This wrapper makes "import gyp_webrtc" work with +# those old versions and makes it possible to execute gyp_webrtc.py +# directly on Windows where the extension is useful. + +import os + +path = os.path.abspath(os.path.split(__file__)[0]) +execfile(os.path.join(path, 'gyp_libyuv')) diff --git a/tools/valgrind-libyuv/libyuv_tests.py b/tools/valgrind-libyuv/libyuv_tests.py index 1b912b8ba..f45f47717 100755 --- a/tools/valgrind-libyuv/libyuv_tests.py +++ b/tools/valgrind-libyuv/libyuv_tests.py @@ -84,6 +84,8 @@ def main(_): help='Additional arguments to --gtest_filter') parser.add_option('', '--gtest_repeat', help='Argument for --gtest_repeat') + parser.add_option("--gtest_shuffle", action="store_true", default=False, + help="Randomize tests' orders on every iteration.") parser.add_option('-v', '--verbose', action='store_true', default=False, help='Verbose output - enable debug log messages') parser.add_option('', '--tool', dest='valgrind_tool', default='memcheck', @@ -95,6 +97,10 @@ def main(_): 'instead of /tmp.\nThis can be useful for tool ' 'developers/maintainers.\nPlease note that the ' '.logs directory will be clobbered on tool startup.')) + parser.add_option("--brave-new-test-launcher", action="store_true", + help="run the tests with --brave-new-test-launcher") + parser.add_option("--test-launcher-bot-mode", action="store_true", + help="run the tests with --test-launcher-bot-mode") options, args = parser.parse_args() if options.verbose: