mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2025-12-07 01:06:46 +08:00
Use DEPS for all dependencies + add PRESUBMIT.py
This changes libyuv to use the DEPS file for pulling down all dependencies (thus no Chromium checkout is needed any more). Add tools_libyuv directory to contain libyuv-specific tools (needed to avoid name collision with the now DEPSed tools/ directory of Chromium, which is needed by the toolchain). Add tools_libyuv/autoroller/roll_deps.py script to automatically roll all entries in the DEPS file (copied from WebRTC). third_party/ is now DEPSed as well, including the gtest configuration headers that used to live inside the libyuv repo. Add PRESUBMIT.py with a few simple checks + execution of PyLint and Python unit tests. For PyLint a pylintrc file was also added. Valgrind in tools_libyuv/valgrind was updated to make PRESUBMIT.py pass and remove old tsan suppressions (not used). Removed util/android/test_runner.py since it's no longer needed. Buildbot changes in https://chromium-review.googlesource.com/436464 are needed for the Memcheck bot to go green. BUG=libyuv:676 NOTRY=True Change-Id: Ib86fea2905a1656bba2933703ce5a59d29d8db6b Reviewed-on: https://chromium-review.googlesource.com/436264 Commit-Queue: Henrik Kjellander <kjellander@chromium.org> Reviewed-by: Frank Barchard <fbarchard@google.com>
This commit is contained in:
parent
76e7f104ae
commit
f49fde796f
83
.gitignore
vendored
83
.gitignore
vendored
@ -4,95 +4,18 @@ pin-log.txt
|
||||
/base
|
||||
/build
|
||||
/buildtools
|
||||
/chromium/.gclient.tmp
|
||||
/chromium/.gclient.tmp_entries
|
||||
/chromium/.last_sync_chromium
|
||||
/chromium/src/
|
||||
/google_apis
|
||||
/links
|
||||
/links.db
|
||||
/ios
|
||||
/mojo
|
||||
/native_client
|
||||
/net
|
||||
/out
|
||||
/sde-avx-sse-transition-out.txt
|
||||
/testing
|
||||
/third_party/accessibility_test_framework
|
||||
/third_party/android_platform
|
||||
/third_party/android_tools
|
||||
/third_party/apache_velocity
|
||||
/third_party/appurify-python
|
||||
/third_party/asan
|
||||
/third_party/ashmem
|
||||
/third_party/binutils
|
||||
/third_party/bouncycastle
|
||||
/third_party/byte_buddy
|
||||
/third_party/BUILD.gn
|
||||
/third_party/catapult
|
||||
/third_party/ced
|
||||
/third_party/class-dump
|
||||
/third_party/closure_compiler
|
||||
/third_party/drmemory
|
||||
/third_party/gflags/src
|
||||
/third_party/guava
|
||||
/third_party/hamcrest
|
||||
/third_party/icu
|
||||
/third_party/icu4j
|
||||
/third_party/ijar
|
||||
/third_party/instrumented_libraries
|
||||
/third_party/intellij
|
||||
/third_party/jsr-305
|
||||
/third_party/junit
|
||||
/third_party/libjpeg
|
||||
/third_party/libjpeg_turbo
|
||||
/third_party/libxml
|
||||
/third_party/llvm
|
||||
/third_party/llvm-build
|
||||
/third_party/lss
|
||||
/third_party/mockito
|
||||
/third_party/modp_b64
|
||||
/third_party/objenesis
|
||||
/third_party/ow2_asm
|
||||
/third_party/proguard
|
||||
/third_party/protobuf
|
||||
/third_party/requests
|
||||
/third_party/robolectric
|
||||
/third_party/sqlite4java
|
||||
/third_party/tcmalloc
|
||||
/third_party/WebKit
|
||||
/third_party/yasm
|
||||
/third_party/zlib
|
||||
/tools/android
|
||||
/tools/clang
|
||||
/tools/generate_library_loader
|
||||
/tools/gn
|
||||
/tools/grit
|
||||
/tools/gritsettings/README
|
||||
/tools/gritsettings/resource_ids
|
||||
/tools/gyp
|
||||
/tools/isolate_driver.py
|
||||
/tools/memory
|
||||
/tools/protoc_wrapper
|
||||
/tools/python
|
||||
/tools/sanitizer_options
|
||||
/tools/swarming_client
|
||||
/tools/tsan_suppressions
|
||||
/tools/valgrind
|
||||
/tools/valgrind-libyuv/libyuv_tests.bat
|
||||
/tools/valgrind-libyuv/libyuv_tests.py
|
||||
/tools/valgrind-libyuv/libyuv_tests.sh
|
||||
/tools/valgrind-libyuv/memcheck/OWNERS
|
||||
/tools/valgrind-libyuv/memcheck/PRESUBMIT.py
|
||||
/tools/valgrind-libyuv/memcheck/suppressions.txt
|
||||
/tools/valgrind-libyuv/memcheck/suppressions_mac.txt
|
||||
/tools/valgrind-libyuv/memcheck/suppressions_win32.txt
|
||||
/tools/valgrind-libyuv/tsan/OWNERS
|
||||
/tools/valgrind-libyuv/tsan/PRESUBMIT.py
|
||||
/tools/valgrind-libyuv/tsan/suppressions.txt
|
||||
/tools/valgrind-libyuv/tsan/suppressions_mac.txt
|
||||
/tools/valgrind-libyuv/tsan/suppressions_win32.txt
|
||||
/tools/vim
|
||||
/tools/win
|
||||
/third_party
|
||||
/tools
|
||||
|
||||
# Files generated by CMake build
|
||||
cmake_install.cmake
|
||||
|
||||
449
DEPS
449
DEPS
@ -1,39 +1,109 @@
|
||||
vars = {
|
||||
# Override root_dir in your .gclient's custom_vars to specify a custom root
|
||||
# folder name.
|
||||
'root_dir': 'libyuv',
|
||||
'extra_gyp_flag': '-Dextra_gyp_flag=0',
|
||||
'root_dir': Var('root_dir') + '',
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
|
||||
# Roll the Chromium Git hash to pick up newer versions of all the
|
||||
# dependencies and tools linked to in setup_links.py.
|
||||
'chromium_revision': '941118827f5240dedb40082cffb1ead6c6d621cc',
|
||||
'chromium_revision': '8346af5a710b5c692803beab335b5e5439883387',
|
||||
'swarming_revision': 'ebc8dab6f8b8d79ec221c94de39a921145abd404',
|
||||
# Three lines of non-changing comments so that
|
||||
# the commit queue can handle CLs rolling lss
|
||||
# and whatever else without interference from each other.
|
||||
'lss_revision': '3f6478ac95edf86cd3da300c2c0d34a438f5dbeb',
|
||||
# Three lines of non-changing comments so that
|
||||
# the commit queue can handle CLs rolling catapult
|
||||
# and whatever else without interference from each other.
|
||||
'catapult_revision': '4ee31ea3b497ffe08391e88a5434e0a340e48342',
|
||||
}
|
||||
|
||||
# NOTE: Use http rather than https; the latter can cause problems for users
|
||||
# behind proxies.
|
||||
deps = {
|
||||
Var('root_dir') + '/build':
|
||||
Var('chromium_git') + '/chromium/src/build' + '@' + '47e07d6798693fd71c02e25097c97865b5271c40',
|
||||
Var('root_dir') + '/buildtools':
|
||||
Var('chromium_git') + '/chromium/buildtools.git' + '@' + 'a7cc7a3e21a061975b33dcdcd81a9716ba614c3c',
|
||||
Var('root_dir') + '/testing':
|
||||
Var('chromium_git') + '/chromium/src/testing' + '@' + '178a302b13e943c679f3bbeb0a7e511f7c318404',
|
||||
Var('root_dir') + '/testing/gtest':
|
||||
Var('chromium_git') + '/external/github.com/google/googletest.git' + '@' + '6f8a66431cb592dad629028a50b3dd418a408c87',
|
||||
Var('root_dir') + '/testing/gmock':
|
||||
Var('chromium_git') + '/external/googlemock.git' + '@' + '0421b6f358139f02e102c9c332ce19a33faf75be', # from svn revision 566
|
||||
Var('root_dir') + '/third_party':
|
||||
Var('chromium_git') + '/chromium/src/third_party' + '@' + '4f196478f68c139a5deec388fd1f426a9251b4b0',
|
||||
Var('root_dir') + '/third_party/catapult':
|
||||
Var('chromium_git') + '/external/github.com/catapult-project/catapult.git' + '@' + Var('catapult_revision'),
|
||||
Var('root_dir') + '/third_party/colorama/src':
|
||||
Var('chromium_git') + '/external/colorama.git' + '@' + '799604a1041e9b3bc5d2789ecbd7e8db2e18e6b8',
|
||||
Var('root_dir') + '/third_party/libjpeg_turbo':
|
||||
Var('chromium_git') + '/chromium/deps/libjpeg_turbo.git' + '@' + '7260e4d8b8e1e40b17f03fafdf1cd83296900f76',
|
||||
Var('root_dir') + '/third_party/yasm/source/patched-yasm':
|
||||
Var('chromium_git') + '/chromium/deps/yasm/patched-yasm.git' + '@' + '7da28c6c7c6a1387217352ce02b31754deb54d2a',
|
||||
Var('root_dir') + '/tools':
|
||||
Var('chromium_git') + '/chromium/src/tools' + '@' + '54fd165044db88eca930ab9d20a6340b76136d91',
|
||||
Var('root_dir') + '/tools/gyp':
|
||||
Var('chromium_git') + '/external/gyp.git' + '@' + 'e7079f0e0e14108ab0dba58728ff219637458563',
|
||||
Var('root_dir') + '/tools/swarming_client':
|
||||
Var('chromium_git') + '/external/swarming.client.git' + '@' + Var('swarming_revision'),
|
||||
|
||||
# libyuv-only dependencies (not present in Chromium).
|
||||
Var('root_dir') + '/third_party/gflags':
|
||||
Var('chromium_git') + '/external/webrtc/deps/third_party/gflags' + '@' + '892576179b45861b53e04a112996a738309cf364',
|
||||
Var('root_dir') + '/third_party/gflags/src':
|
||||
Var('chromium_git') + '/external/github.com/gflags/gflags@03bebcb065c83beff83d50ae025a55a4bf94dfca',
|
||||
Var('chromium_git') + '/external/github.com/gflags/gflags' + '@' + '03bebcb065c83beff83d50ae025a55a4bf94dfca',
|
||||
Var('root_dir') + '/third_party/gtest-parallel':
|
||||
Var('chromium_git') + '/external/webrtc/deps/third_party/gtest-parallel' + '@' + '8768563f5c580f8fc416a13c35c8f23b8a602821',
|
||||
}
|
||||
|
||||
deps_os = {
|
||||
'android': {
|
||||
Var('root_dir') + '/base':
|
||||
Var('chromium_git') + '/chromium/src/base' + '@' + 'b9d4d9b0e5373bbdb5403c68d51e7385d78a09d0',
|
||||
Var('root_dir') + '/third_party/android_tools':
|
||||
Var('chromium_git') + '/android_tools.git' + '@' + 'b43a6a289a7588b1769814f04dd6c7d7176974cc',
|
||||
Var('root_dir') + '/third_party/ced/src':
|
||||
Var('chromium_git') + '/external/github.com/google/compact_enc_det.git' + '@' + '368a9cc09ad868a3d28f0b5ad4a733f263c46409',
|
||||
Var('root_dir') + '/third_party/icu':
|
||||
Var('chromium_git') + '/chromium/deps/icu.git' + '@' + '9cd2828740572ba6f694b9365236a8356fd06147',
|
||||
Var('root_dir') + '/third_party/jsr-305/src':
|
||||
Var('chromium_git') + '/external/jsr-305.git' + '@' + '642c508235471f7220af6d5df2d3210e3bfc0919',
|
||||
Var('root_dir') + '/third_party/junit/src':
|
||||
Var('chromium_git') + '/external/junit.git' + '@' + '64155f8a9babcfcf4263cf4d08253a1556e75481',
|
||||
Var('root_dir') + '/third_party/lss':
|
||||
Var('chromium_git') + '/linux-syscall-support.git' + '@' + Var('lss_revision'),
|
||||
Var('root_dir') + '/third_party/mockito/src':
|
||||
Var('chromium_git') + '/external/mockito/mockito.git' + '@' + 'de83ad4598ad4cf5ea53c69a8a8053780b04b850',
|
||||
Var('root_dir') + '/third_party/requests/src':
|
||||
Var('chromium_git') + '/external/github.com/kennethreitz/requests.git' + '@' + 'f172b30356d821d180fa4ecfa3e71c7274a32de4',
|
||||
Var('root_dir') + '/third_party/robolectric/robolectric':
|
||||
Var('chromium_git') + '/external/robolectric.git' + '@' + 'e38b49a12fdfa17a94f0382cc8ffaf69132fd09b',
|
||||
},
|
||||
'ios': {
|
||||
Var('root_dir') + '/ios':
|
||||
Var('chromium_git') + '/chromium/src/ios' + '@' + '291daef6af7764f8475089c65808d52ee50b496e',
|
||||
},
|
||||
'unix': {
|
||||
Var('root_dir') + '/third_party/lss':
|
||||
Var('chromium_git') + '/linux-syscall-support.git' + '@' + Var('lss_revision'),
|
||||
},
|
||||
'win': {
|
||||
# Dependencies used by libjpeg-turbo
|
||||
Var('root_dir') + '/third_party/yasm/binaries':
|
||||
Var('chromium_git') + '/chromium/deps/yasm/binaries.git' + '@' + '52f9b3f4b0aa06da24ef8b123058bb61ee468881',
|
||||
},
|
||||
}
|
||||
|
||||
# Define rules for which include paths are allowed in our source.
|
||||
include_rules = [ '+gflags' ]
|
||||
|
||||
pre_deps_hooks = [
|
||||
{
|
||||
# Remove any symlinks from before 177567c518b121731e507e9b9c4049c4dc96e4c8.
|
||||
# TODO(kjellander): Remove this in March 2017.
|
||||
'name': 'cleanup_links',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/cleanup_links.py'],
|
||||
},
|
||||
]
|
||||
|
||||
hooks = [
|
||||
{
|
||||
# Clone chromium and its deps.
|
||||
'name': 'sync chromium',
|
||||
'pattern': '.',
|
||||
'action': ['python', '-u', Var('root_dir') + '/sync_chromium.py',
|
||||
'--target-revision', Var('chromium_revision')],
|
||||
},
|
||||
{
|
||||
# Create links to shared dependencies in Chromium.
|
||||
'name': 'setup_links',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/setup_links.py'],
|
||||
},
|
||||
{
|
||||
# This clobbers when necessary (based on get_landmines.py). It should be
|
||||
# an early hook but it will need to be run after syncing Chromium and
|
||||
@ -44,9 +114,340 @@ hooks = [
|
||||
'python',
|
||||
Var('root_dir') + '/build/landmines.py',
|
||||
'--landmine-scripts',
|
||||
Var('root_dir') + '/tools/get_landmines.py',
|
||||
Var('root_dir') + '/tools_libyuv/get_landmines.py',
|
||||
'--src-dir',
|
||||
Var('root_dir'),
|
||||
Var('root_dir') + '',
|
||||
],
|
||||
},
|
||||
# Android dependencies. Many are downloaded using Google Storage these days.
|
||||
# They're copied from https://cs.chromium.org/chromium/src/DEPS for all
|
||||
# such dependencies we share with Chromium.
|
||||
{
|
||||
# This downloads SDK extras and puts them in the
|
||||
# third_party/android_tools/sdk/extras directory.
|
||||
'name': 'sdkextras',
|
||||
'pattern': '.',
|
||||
# When adding a new sdk extras package to download, add the package
|
||||
# directory and zip file to .gitignore in third_party/android_tools.
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/play_services/update.py',
|
||||
'download'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'intellij',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-intellij',
|
||||
'-l', 'third_party/intellij'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'javax_inject',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-javax-inject',
|
||||
'-l', 'third_party/javax_inject'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'hamcrest',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-hamcrest',
|
||||
'-l', 'third_party/hamcrest'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'guava',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-guava',
|
||||
'-l', 'third_party/guava'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'android_support_test_runner',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-android-support-test-runner',
|
||||
'-l', 'third_party/android_support_test_runner'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'byte_buddy',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-byte-buddy',
|
||||
'-l', 'third_party/byte_buddy'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'espresso',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-espresso',
|
||||
'-l', 'third_party/espresso'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'robolectric_libs',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-robolectric',
|
||||
'-l', 'third_party/robolectric'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'apache_velocity',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-apache-velocity',
|
||||
'-l', 'third_party/apache_velocity'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'ow2_asm',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-ow2-asm',
|
||||
'-l', 'third_party/ow2_asm'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'icu4j',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-icu4j',
|
||||
'-l', 'third_party/icu4j'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'accessibility_test_framework',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-accessibility-test-framework',
|
||||
'-l', 'third_party/accessibility_test_framework'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'bouncycastle',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-bouncycastle',
|
||||
'-l', 'third_party/bouncycastle'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'sqlite4java',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-sqlite4java',
|
||||
'-l', 'third_party/sqlite4java'
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'objenesis',
|
||||
'pattern': '.',
|
||||
'action': ['python',
|
||||
Var('root_dir') + '/build/android/update_deps/update_third_party_deps.py',
|
||||
'download',
|
||||
'-b', 'chromium-objenesis',
|
||||
'-l', 'third_party/objenesis'
|
||||
],
|
||||
},
|
||||
{
|
||||
# Downloads the current stable linux sysroot to build/linux/ if needed.
|
||||
# This sysroot updates at about the same rate that the chrome build deps
|
||||
# change. This script is a no-op except for linux users who are doing
|
||||
# official chrome builds or cross compiling.
|
||||
'name': 'sysroot',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/build/linux/sysroot_scripts/install-sysroot.py',
|
||||
'--running-as-hook'],
|
||||
},
|
||||
{
|
||||
# Update the Windows toolchain if necessary.
|
||||
'name': 'win_toolchain',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/build/vs_toolchain.py', 'update'],
|
||||
},
|
||||
# Pull binutils for linux, enabled debug fission for faster linking /
|
||||
# debugging when used with clang on Ubuntu Precise.
|
||||
# https://code.google.com/p/chromium/issues/detail?id=352046
|
||||
{
|
||||
'name': 'binutils',
|
||||
'pattern': Var('root_dir') + '/third_party/binutils',
|
||||
'action': [
|
||||
'python',
|
||||
Var('root_dir') + '/third_party/binutils/download.py',
|
||||
],
|
||||
},
|
||||
{
|
||||
# Pull clang if needed or requested via GYP_DEFINES.
|
||||
# Note: On Win, this should run after win_toolchain, as it may use it.
|
||||
'name': 'clang',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/tools/clang/scripts/update.py', '--if-needed'],
|
||||
},
|
||||
{
|
||||
# Update LASTCHANGE.
|
||||
'name': 'lastchange',
|
||||
'pattern': '.',
|
||||
'action': ['python', Var('root_dir') + '/build/util/lastchange.py',
|
||||
'-o', Var('root_dir') + '/build/util/LASTCHANGE'],
|
||||
},
|
||||
# Pull GN binaries.
|
||||
{
|
||||
'name': 'gn_win',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=win32',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-gn',
|
||||
'-s', Var('root_dir') + '/buildtools/win/gn.exe.sha1',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'gn_mac',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=darwin',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-gn',
|
||||
'-s', Var('root_dir') + '/buildtools/mac/gn.sha1',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'gn_linux64',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=linux*',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-gn',
|
||||
'-s', Var('root_dir') + '/buildtools/linux64/gn.sha1',
|
||||
],
|
||||
},
|
||||
# Pull clang-format binaries using checked-in hashes.
|
||||
{
|
||||
'name': 'clang_format_win',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=win32',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-clang-format',
|
||||
'-s', Var('root_dir') + '/buildtools/win/clang-format.exe.sha1',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'clang_format_mac',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=darwin',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-clang-format',
|
||||
'-s', Var('root_dir') + '/buildtools/mac/clang-format.sha1',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'clang_format_linux',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=linux*',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-clang-format',
|
||||
'-s', Var('root_dir') + '/buildtools/linux64/clang-format.sha1',
|
||||
],
|
||||
},
|
||||
# Pull luci-go binaries (isolate, swarming) using checked-in hashes.
|
||||
{
|
||||
'name': 'luci-go_win',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=win32',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-luci',
|
||||
'-d', Var('root_dir') + '/tools/luci-go/win64',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'luci-go_mac',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=darwin',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-luci',
|
||||
'-d', Var('root_dir') + '/tools/luci-go/mac64',
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'luci-go_linux',
|
||||
'pattern': '.',
|
||||
'action': [ 'download_from_google_storage',
|
||||
'--no_resume',
|
||||
'--platform=linux*',
|
||||
'--no_auth',
|
||||
'--bucket', 'chromium-luci',
|
||||
'-d', Var('root_dir') + '/tools/luci-go/linux64',
|
||||
],
|
||||
},
|
||||
{
|
||||
# Pull sanitizer-instrumented third-party libraries if requested via
|
||||
# GYP_DEFINES.
|
||||
# See src/third_party/instrumented_libraries/scripts/download_binaries.py.
|
||||
# TODO(kjellander): Update comment when GYP is completely cleaned up.
|
||||
'name': 'instrumented_libraries',
|
||||
'pattern': '\\.sha1',
|
||||
'action': ['python', Var('root_dir') + '/third_party/instrumented_libraries/scripts/download_binaries.py'],
|
||||
},
|
||||
{
|
||||
'name': 'clang_format_merge_driver',
|
||||
'pattern': '.',
|
||||
'action': [ 'python',
|
||||
Var('root_dir') + '/tools/clang_format_merge_driver/install_git_hook.py',
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
recursedeps = [
|
||||
# buildtools provides clang_format, libc++, and libc++abi.
|
||||
Var('root_dir') + '/buildtools',
|
||||
# android_tools manages the NDK.
|
||||
Var('root_dir') + '/third_party/android_tools',
|
||||
]
|
||||
|
||||
72
PRESUBMIT.py
Normal file
72
PRESUBMIT.py
Normal file
@ -0,0 +1,72 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def _RunPythonTests(input_api, output_api):
|
||||
def join(*args):
|
||||
return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
|
||||
|
||||
test_directories = [
|
||||
root for root, _, files in os.walk(join('tools_libyuv'))
|
||||
if any(f.endswith('_test.py') for f in files)
|
||||
]
|
||||
|
||||
tests = []
|
||||
for directory in test_directories:
|
||||
tests.extend(
|
||||
input_api.canned_checks.GetUnitTestsInDirectory(
|
||||
input_api,
|
||||
output_api,
|
||||
directory,
|
||||
whitelist=[r'.+_test\.py$']))
|
||||
return input_api.RunTests(tests, parallel=True)
|
||||
|
||||
|
||||
def _CommonChecks(input_api, output_api):
|
||||
"""Checks common to both upload and commit."""
|
||||
results = []
|
||||
results.extend(input_api.canned_checks.RunPylint(input_api, output_api,
|
||||
black_list=(r'^base[\\\/].*\.py$',
|
||||
r'^build[\\\/].*\.py$',
|
||||
r'^buildtools[\\\/].*\.py$',
|
||||
r'^ios[\\\/].*\.py$',
|
||||
r'^out.*[\\\/].*\.py$',
|
||||
r'^testing[\\\/].*\.py$',
|
||||
r'^third_party[\\\/].*\.py$',
|
||||
r'^tools[\\\/].*\.py$',
|
||||
# TODO(kjellander): should arguably be checked.
|
||||
r'^tools_libyuv[\\\/]valgrind[\\\/].*\.py$',
|
||||
r'^xcodebuild.*[\\\/].*\.py$',),
|
||||
disabled_warnings=['F0401', # Failed to import x
|
||||
'E0611', # No package y in x
|
||||
'W0232', # Class has no __init__ method
|
||||
],
|
||||
pylintrc='pylintrc'))
|
||||
results.extend(_RunPythonTests(input_api, output_api))
|
||||
return results
|
||||
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(
|
||||
input_api.canned_checks.CheckGNFormatted(input_api, output_api))
|
||||
return results
|
||||
|
||||
|
||||
def CheckChangeOnCommit(input_api, output_api):
|
||||
results = []
|
||||
results.extend(_CommonChecks(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckOwners(input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckChangeWasUploaded(
|
||||
input_api, output_api))
|
||||
results.extend(input_api.canned_checks.CheckChangeHasDescription(
|
||||
input_api, output_api))
|
||||
return results
|
||||
@ -28,3 +28,19 @@ enable_java_templates = true
|
||||
asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
|
||||
lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
|
||||
tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
|
||||
|
||||
msan_blacklist_path =
|
||||
rebase_path("//tools_libyuv/msan/blacklist.txt", root_build_dir)
|
||||
ubsan_blacklist_path =
|
||||
rebase_path("//tools_libyuv/ubsan/blacklist.txt", root_build_dir)
|
||||
ubsan_vptr_blacklist_path =
|
||||
rebase_path("//tools_libyuv/ubsan/vptr_blacklist.txt", root_build_dir)
|
||||
|
||||
# For Chromium, Android 32-bit non-component, non-clang builds hit a 4GiB size
|
||||
# limit, making them requiring symbol_level=2. WebRTC doesn't hit that problem
|
||||
# so we just ignore that assert. See https://crbug.com/648948 for more info.
|
||||
ignore_elf32_limitations = true
|
||||
|
||||
# Use system Xcode installation instead of the Chromium bundled Mac toolchain,
|
||||
# since it contains only SDK 10.11, not 10.12 which WebRTC needs.
|
||||
use_system_xcode = true
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
solutions = [{
|
||||
'name': 'src',
|
||||
'url': 'https://chromium.googlesource.com/chromium/src.git',
|
||||
'deps_file': '.DEPS.git',
|
||||
'managed': False,
|
||||
'custom_deps': {
|
||||
# Skip syncing some large dependencies Libyuv will never need.
|
||||
'src/third_party/cld_2/src': None,
|
||||
'src/third_party/ffmpeg': None,
|
||||
'src/third_party/hunspell_dictionaries': None,
|
||||
'src/third_party/liblouis/src': None,
|
||||
'src/third_party/pdfium': None,
|
||||
'src/third_party/skia': None,
|
||||
'src/third_party/trace-viewer': None,
|
||||
'src/third_party/webrtc': None,
|
||||
},
|
||||
'safesync_url': ''
|
||||
}]
|
||||
|
||||
cache_dir = None
|
||||
@ -1,5 +0,0 @@
|
||||
This .gclient file is used to do download a copy of Chromium.
|
||||
Libyuv uses the Chromium build toolchain and a number of shared
|
||||
dependencies by creating symlinks to folders in this checkout,
|
||||
using the ../setup_links.py script.
|
||||
|
||||
107
cleanup_links.py
Executable file
107
cleanup_links.py
Executable file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 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 is a copy of the file from WebRTC in:
|
||||
# https://chromium.googlesource.com/external/webrtc/+/master/cleanup_links.py
|
||||
|
||||
"""Script to cleanup symlinks created from setup_links.py.
|
||||
|
||||
Before 177567c518b121731e507e9b9c4049c4dc96e4c8 (#15754) we had a Chromium
|
||||
checkout which we created symlinks into. In order to do clean syncs after
|
||||
landing that change, this script cleans up any old symlinks, avoiding annoying
|
||||
manual cleanup needed in order to complete gclient sync.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import shelve
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
LINKS_DB = 'links'
|
||||
|
||||
# Version management to make future upgrades/downgrades easier to support.
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
class WebRTCLinkSetup(object):
|
||||
def __init__(self, links_db, dry_run=False):
|
||||
self._dry_run = dry_run
|
||||
self._links_db = links_db
|
||||
|
||||
def CleanupLinks(self):
|
||||
logging.debug('CleanupLinks')
|
||||
for source, link_path in self._links_db.iteritems():
|
||||
if source == 'SCHEMA_VERSION':
|
||||
continue
|
||||
if os.path.islink(link_path) or sys.platform.startswith('win'):
|
||||
# os.path.islink() always returns false on Windows
|
||||
# See http://bugs.python.org/issue13143.
|
||||
logging.debug('Removing link to %s at %s', source, link_path)
|
||||
if not self._dry_run:
|
||||
if os.path.exists(link_path):
|
||||
if sys.platform.startswith('win') and os.path.isdir(link_path):
|
||||
subprocess.check_call(['rmdir', '/q', '/s', link_path],
|
||||
shell=True)
|
||||
else:
|
||||
os.remove(link_path)
|
||||
del self._links_db[source]
|
||||
|
||||
|
||||
def _initialize_database(filename):
|
||||
links_database = shelve.open(filename)
|
||||
# Wipe the database if this version of the script ends up looking at a
|
||||
# newer (future) version of the links db, just to be sure.
|
||||
version = links_database.get('SCHEMA_VERSION')
|
||||
if version and version != SCHEMA_VERSION:
|
||||
logging.info('Found database with schema version %s while this script only '
|
||||
'supports %s. Wiping previous database contents.', version,
|
||||
SCHEMA_VERSION)
|
||||
links_database.clear()
|
||||
links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
|
||||
return links_database
|
||||
|
||||
|
||||
def main():
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-d', '--dry-run', action='store_true', default=False,
|
||||
help='Print what would be done, but don\'t perform any '
|
||||
'operations. This will automatically set logging to '
|
||||
'verbose.')
|
||||
parser.add_option('-v', '--verbose', action='store_const',
|
||||
const=logging.DEBUG, default=logging.INFO,
|
||||
help='Print verbose output for debugging.')
|
||||
options, _ = parser.parse_args()
|
||||
|
||||
if options.dry_run:
|
||||
options.verbose = logging.DEBUG
|
||||
logging.basicConfig(format='%(message)s', level=options.verbose)
|
||||
|
||||
# Work from the root directory of the checkout.
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(script_dir)
|
||||
|
||||
# The database file gets .db appended on some platforms.
|
||||
db_filenames = [LINKS_DB, LINKS_DB + '.db']
|
||||
if any(os.path.isfile(f) for f in db_filenames):
|
||||
links_database = _initialize_database(LINKS_DB)
|
||||
try:
|
||||
symlink_creator = WebRTCLinkSetup(links_database, options.dry_run)
|
||||
symlink_creator.CleanupLinks()
|
||||
finally:
|
||||
for f in db_filenames:
|
||||
if os.path.isfile(f):
|
||||
os.remove(f)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@ -173,15 +173,15 @@ arm64 disassembly:
|
||||
|
||||
Running tests:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
|
||||
|
||||
Running test as benchmark:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1"
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1"
|
||||
|
||||
Running test with C code:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
|
||||
|
||||
#### Building with GN
|
||||
|
||||
|
||||
@ -174,15 +174,15 @@ arm disassembly:
|
||||
|
||||
Running tests:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=*
|
||||
|
||||
Running test as benchmark:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1 --libyuv_cpu_info=-1"
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=-1 --libyuv_cpu_info=-1"
|
||||
|
||||
Running test with C code:
|
||||
|
||||
util/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
|
||||
build/android/test_runner.py gtest -s libyuv_unittest -t 7200 --verbose --release --gtest_filter=* -a "--libyuv_width=1280 --libyuv_height=720 --libyuv_repeat=999 --libyuv_flags=1 --libyuv_cpu_info=1"
|
||||
|
||||
### Build targets
|
||||
|
||||
|
||||
17
pylintrc
Normal file
17
pylintrc
Normal file
@ -0,0 +1,17 @@
|
||||
[MESSAGES CONTROL]
|
||||
|
||||
# Disable the message, report, category or checker with the given id(s).
|
||||
# TODO(kjellander): Reduce this list to as small as possible.
|
||||
disable=I0010,I0011,bad-continuation,broad-except,duplicate-code,eval-used,exec-used,fixme,invalid-name,missing-docstring,no-init,no-member,too-few-public-methods,too-many-ancestors,too-many-arguments,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-lines,too-many-locals,too-many-public-methods,too-many-return-statements,too-many-statements
|
||||
|
||||
|
||||
[REPORTS]
|
||||
|
||||
# Don't write out full reports, just messages.
|
||||
reports=no
|
||||
|
||||
|
||||
[FORMAT]
|
||||
|
||||
# We use two spaces for indents, instead of the usual four spaces or tab.
|
||||
indent-string=' '
|
||||
501
setup_links.py
501
setup_links.py
@ -1,501 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2014 The WebRTC 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.
|
||||
|
||||
"""Setup links to a Chromium checkout for WebRTC.
|
||||
|
||||
WebRTC standalone shares a lot of dependencies and build tools with Chromium.
|
||||
To do this, many of the paths of a Chromium checkout is emulated by creating
|
||||
symlinks to files and directories. This script handles the setup of symlinks to
|
||||
achieve this.
|
||||
"""
|
||||
|
||||
|
||||
import ctypes
|
||||
import errno
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import shelve
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
|
||||
DIRECTORIES = [
|
||||
'build',
|
||||
'buildtools',
|
||||
'mojo', # TODO(kjellander): Remove, see webrtc:5629.
|
||||
'native_client',
|
||||
'net',
|
||||
'testing',
|
||||
'third_party/binutils',
|
||||
'third_party/drmemory',
|
||||
'third_party/instrumented_libraries',
|
||||
'third_party/libjpeg',
|
||||
'third_party/libjpeg_turbo',
|
||||
'third_party/llvm-build',
|
||||
'third_party/lss',
|
||||
'third_party/proguard',
|
||||
'third_party/tcmalloc',
|
||||
'third_party/yasm',
|
||||
'third_party/WebKit', # TODO(kjellander): Remove, see webrtc:5629.
|
||||
'tools/clang',
|
||||
'tools/gn',
|
||||
'tools/gyp',
|
||||
'tools/memory',
|
||||
'tools/python',
|
||||
'tools/swarming_client',
|
||||
'tools/valgrind',
|
||||
'tools/vim',
|
||||
'tools/win',
|
||||
]
|
||||
|
||||
from sync_chromium import get_target_os_list
|
||||
target_os = get_target_os_list()
|
||||
if 'android' in target_os:
|
||||
DIRECTORIES += [
|
||||
'base',
|
||||
'third_party/accessibility_test_framework',
|
||||
'third_party/android_platform',
|
||||
'third_party/android_tools',
|
||||
'third_party/apache_velocity',
|
||||
'third_party/appurify-python',
|
||||
'third_party/ashmem',
|
||||
'third_party/bouncycastle',
|
||||
'third_party/byte_buddy',
|
||||
'third_party/catapult',
|
||||
'third_party/ced',
|
||||
'third_party/closure_compiler',
|
||||
'third_party/guava',
|
||||
'third_party/hamcrest',
|
||||
'third_party/icu',
|
||||
'third_party/icu4j',
|
||||
'third_party/ijar',
|
||||
'third_party/intellij',
|
||||
'third_party/jsr-305',
|
||||
'third_party/junit',
|
||||
'third_party/libxml',
|
||||
'third_party/mockito',
|
||||
'third_party/modp_b64',
|
||||
'third_party/objenesis',
|
||||
'third_party/ow2_asm',
|
||||
'third_party/protobuf',
|
||||
'third_party/requests',
|
||||
'third_party/robolectric',
|
||||
'third_party/sqlite4java',
|
||||
'third_party/zlib',
|
||||
'tools/android',
|
||||
'tools/grit',
|
||||
]
|
||||
if 'ios' in target_os:
|
||||
DIRECTORIES.append('third_party/class-dump')
|
||||
|
||||
FILES = {
|
||||
'tools/isolate_driver.py': None,
|
||||
'third_party/BUILD.gn': None,
|
||||
}
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
CHROMIUM_CHECKOUT = os.path.join('chromium', 'src')
|
||||
LINKS_DB = 'links'
|
||||
|
||||
# Version management to make future upgrades/downgrades easier to support.
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
|
||||
def query_yes_no(question, default=False):
|
||||
"""Ask a yes/no question via raw_input() and return their answer.
|
||||
|
||||
Modified from http://stackoverflow.com/a/3041990.
|
||||
"""
|
||||
prompt = " [%s/%%s]: "
|
||||
prompt = prompt % ('Y' if default is True else 'y')
|
||||
prompt = prompt % ('N' if default is False else 'n')
|
||||
|
||||
if default is None:
|
||||
default = 'INVALID'
|
||||
|
||||
while True:
|
||||
sys.stdout.write(question + prompt)
|
||||
choice = raw_input().lower()
|
||||
if choice == '' and default != 'INVALID':
|
||||
return default
|
||||
|
||||
if 'yes'.startswith(choice):
|
||||
return True
|
||||
elif 'no'.startswith(choice):
|
||||
return False
|
||||
|
||||
print "Please respond with 'yes' or 'no' (or 'y' or 'n')."
|
||||
|
||||
|
||||
# Actions
|
||||
class Action(object):
|
||||
def __init__(self, dangerous):
|
||||
self.dangerous = dangerous
|
||||
|
||||
def announce(self, planning):
|
||||
"""Log a description of this action.
|
||||
|
||||
Args:
|
||||
planning - True iff we're in the planning stage, False if we're in the
|
||||
doit stage.
|
||||
"""
|
||||
pass
|
||||
|
||||
def doit(self, links_db):
|
||||
"""Execute the action, recording what we did to links_db, if necessary."""
|
||||
pass
|
||||
|
||||
|
||||
class Remove(Action):
|
||||
def __init__(self, path, dangerous):
|
||||
super(Remove, self).__init__(dangerous)
|
||||
self._priority = 0
|
||||
self._path = path
|
||||
|
||||
def announce(self, planning):
|
||||
log = logging.warn
|
||||
filesystem_type = 'file'
|
||||
if not self.dangerous:
|
||||
log = logging.info
|
||||
filesystem_type = 'link'
|
||||
if planning:
|
||||
log('Planning to remove %s: %s', filesystem_type, self._path)
|
||||
else:
|
||||
log('Removing %s: %s', filesystem_type, self._path)
|
||||
|
||||
def doit(self, _):
|
||||
os.remove(self._path)
|
||||
|
||||
|
||||
class Rmtree(Action):
|
||||
def __init__(self, path):
|
||||
super(Rmtree, self).__init__(dangerous=True)
|
||||
self._priority = 0
|
||||
self._path = path
|
||||
|
||||
def announce(self, planning):
|
||||
if planning:
|
||||
logging.warn('Planning to remove directory: %s', self._path)
|
||||
else:
|
||||
logging.warn('Removing directory: %s', self._path)
|
||||
|
||||
def doit(self, _):
|
||||
if sys.platform.startswith('win'):
|
||||
# shutil.rmtree() doesn't work on Windows if any of the directories are
|
||||
# read-only.
|
||||
subprocess.check_call(['rd', '/q', '/s', self._path], shell=True)
|
||||
else:
|
||||
shutil.rmtree(self._path)
|
||||
|
||||
|
||||
class Makedirs(Action):
|
||||
def __init__(self, path):
|
||||
super(Makedirs, self).__init__(dangerous=False)
|
||||
self._priority = 1
|
||||
self._path = path
|
||||
|
||||
def doit(self, _):
|
||||
try:
|
||||
os.makedirs(self._path)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
|
||||
class Symlink(Action):
|
||||
def __init__(self, source_path, link_path):
|
||||
super(Symlink, self).__init__(dangerous=False)
|
||||
self._priority = 2
|
||||
self._source_path = source_path
|
||||
self._link_path = link_path
|
||||
|
||||
def announce(self, planning):
|
||||
if planning:
|
||||
logging.info(
|
||||
'Planning to create link from %s to %s', self._link_path,
|
||||
self._source_path)
|
||||
else:
|
||||
logging.debug(
|
||||
'Linking from %s to %s', self._link_path, self._source_path)
|
||||
|
||||
def doit(self, links_db):
|
||||
# Files not in the root directory need relative path calculation.
|
||||
# On Windows, use absolute paths instead since NTFS doesn't seem to support
|
||||
# relative paths for symlinks.
|
||||
if sys.platform.startswith('win'):
|
||||
source_path = os.path.abspath(self._source_path)
|
||||
else:
|
||||
if os.path.dirname(self._link_path) != self._link_path:
|
||||
source_path = os.path.relpath(self._source_path,
|
||||
os.path.dirname(self._link_path))
|
||||
|
||||
os.symlink(source_path, os.path.abspath(self._link_path))
|
||||
links_db[self._source_path] = self._link_path
|
||||
|
||||
|
||||
class LinkError(IOError):
|
||||
"""Failed to create a link."""
|
||||
pass
|
||||
|
||||
|
||||
# Use junctions instead of symlinks on the Windows platform.
|
||||
if sys.platform.startswith('win'):
|
||||
def symlink(source_path, link_path):
|
||||
if os.path.isdir(source_path):
|
||||
subprocess.check_call(['cmd.exe', '/c', 'mklink', '/J', link_path,
|
||||
source_path])
|
||||
else:
|
||||
# Don't create symlinks to files on Windows, just copy the file instead
|
||||
# (there's no way to create a link without administrator's privileges).
|
||||
shutil.copy(source_path, link_path)
|
||||
os.symlink = symlink
|
||||
|
||||
|
||||
class WebRTCLinkSetup(object):
|
||||
def __init__(self, links_db, force=False, dry_run=False, prompt=False):
|
||||
self._force = force
|
||||
self._dry_run = dry_run
|
||||
self._prompt = prompt
|
||||
self._links_db = links_db
|
||||
|
||||
def CreateLinks(self, on_bot):
|
||||
logging.debug('CreateLinks')
|
||||
# First, make a plan of action
|
||||
actions = []
|
||||
|
||||
for source_path, link_path in FILES.iteritems():
|
||||
actions += self._ActionForPath(
|
||||
source_path, link_path, check_fn=os.path.isfile, check_msg='files')
|
||||
for source_dir in DIRECTORIES:
|
||||
actions += self._ActionForPath(
|
||||
source_dir, None, check_fn=os.path.isdir,
|
||||
check_msg='directories')
|
||||
|
||||
if not on_bot and self._force:
|
||||
# When making the manual switch from legacy SVN checkouts to the new
|
||||
# Git-based Chromium DEPS, the .gclient_entries file that contains cached
|
||||
# URLs for all DEPS entries must be removed to avoid future sync problems.
|
||||
entries_file = os.path.join(os.path.dirname(ROOT_DIR), '.gclient_entries')
|
||||
if os.path.exists(entries_file):
|
||||
actions.append(Remove(entries_file, dangerous=True))
|
||||
|
||||
actions.sort()
|
||||
|
||||
if self._dry_run:
|
||||
for action in actions:
|
||||
action.announce(planning=True)
|
||||
logging.info('Not doing anything because dry-run was specified.')
|
||||
sys.exit(0)
|
||||
|
||||
if any(a.dangerous for a in actions):
|
||||
logging.warn('Dangerous actions:')
|
||||
for action in (a for a in actions if a.dangerous):
|
||||
action.announce(planning=True)
|
||||
print
|
||||
|
||||
if not self._force:
|
||||
logging.error(textwrap.dedent("""\
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
A C T I O N R E Q I R E D
|
||||
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
Setting up the checkout requires creating symlinks to directories in the
|
||||
Chromium checkout inside chromium/src.
|
||||
To avoid disrupting developers, we've chosen to not delete directories
|
||||
forcibly, in case you have some work in progress in one of them :)
|
||||
|
||||
ACTION REQUIRED:
|
||||
Before running `gclient sync|runhooks` again, you must run:
|
||||
%s%s --force
|
||||
|
||||
Which will replace all directories which now must be symlinks, after
|
||||
prompting with a summary of the work-to-be-done.
|
||||
"""), 'python ' if sys.platform.startswith('win') else '', __file__)
|
||||
sys.exit(1)
|
||||
elif self._prompt:
|
||||
if not query_yes_no('Would you like to perform the above plan?'):
|
||||
sys.exit(1)
|
||||
|
||||
for action in actions:
|
||||
action.announce(planning=False)
|
||||
action.doit(self._links_db)
|
||||
|
||||
if not on_bot and self._force:
|
||||
logging.info('Completed!\n\nNow run `gclient sync|runhooks` again to '
|
||||
'let the remaining hooks (that probably were interrupted) '
|
||||
'execute.')
|
||||
|
||||
def CleanupLinks(self):
|
||||
logging.debug('CleanupLinks')
|
||||
for source, link_path in self._links_db.iteritems():
|
||||
if source == 'SCHEMA_VERSION':
|
||||
continue
|
||||
if os.path.islink(link_path) or sys.platform.startswith('win'):
|
||||
# os.path.islink() always returns false on Windows
|
||||
# See http://bugs.python.org/issue13143.
|
||||
logging.debug('Removing link to %s at %s', source, link_path)
|
||||
if not self._dry_run:
|
||||
if os.path.exists(link_path):
|
||||
if sys.platform.startswith('win') and os.path.isdir(link_path):
|
||||
subprocess.check_call(['rmdir', '/q', '/s', link_path],
|
||||
shell=True)
|
||||
else:
|
||||
os.remove(link_path)
|
||||
del self._links_db[source]
|
||||
|
||||
@staticmethod
|
||||
def _ActionForPath(source_path, link_path=None, check_fn=None,
|
||||
check_msg=None):
|
||||
"""Create zero or more Actions to link to a file or directory.
|
||||
|
||||
This will be a symlink on POSIX platforms. On Windows it will result in:
|
||||
* a junction for directories
|
||||
* a copied file for single files.
|
||||
|
||||
Args:
|
||||
source_path: Path relative to the Chromium checkout root.
|
||||
For readability, the path may contain slashes, which will
|
||||
automatically be converted to the right path delimiter on Windows.
|
||||
link_path: The location for the link to create. If omitted it will be the
|
||||
same path as source_path.
|
||||
check_fn: A function returning true if the type of filesystem object is
|
||||
correct for the attempted call. Otherwise an error message with
|
||||
check_msg will be printed.
|
||||
check_msg: String used to inform the user of an invalid attempt to create
|
||||
a file.
|
||||
Returns:
|
||||
A list of Action objects.
|
||||
"""
|
||||
def fix_separators(path):
|
||||
if sys.platform.startswith('win'):
|
||||
return path.replace(os.altsep, os.sep)
|
||||
else:
|
||||
return path
|
||||
|
||||
assert check_fn
|
||||
assert check_msg
|
||||
link_path = link_path or source_path
|
||||
link_path = fix_separators(link_path)
|
||||
|
||||
source_path = fix_separators(source_path)
|
||||
source_path = os.path.join(CHROMIUM_CHECKOUT, source_path)
|
||||
if os.path.exists(source_path) and not check_fn:
|
||||
raise LinkError('Can only to link to %s: tried to link to: %s' %
|
||||
(check_msg, source_path))
|
||||
|
||||
if not os.path.exists(source_path):
|
||||
logging.debug('Silently ignoring missing source: %s. This is to avoid '
|
||||
'errors on platform-specific dependencies.', source_path)
|
||||
return []
|
||||
|
||||
actions = []
|
||||
|
||||
if os.path.exists(link_path) or os.path.islink(link_path):
|
||||
if os.path.islink(link_path):
|
||||
actions.append(Remove(link_path, dangerous=False))
|
||||
elif os.path.isfile(link_path):
|
||||
actions.append(Remove(link_path, dangerous=True))
|
||||
elif os.path.isdir(link_path):
|
||||
actions.append(Rmtree(link_path))
|
||||
else:
|
||||
raise LinkError('Don\'t know how to plan: %s' % link_path)
|
||||
|
||||
# Create parent directories to the target link if needed.
|
||||
target_parent_dirs = os.path.dirname(link_path)
|
||||
if (target_parent_dirs and
|
||||
target_parent_dirs != link_path and
|
||||
not os.path.exists(target_parent_dirs)):
|
||||
actions.append(Makedirs(target_parent_dirs))
|
||||
|
||||
actions.append(Symlink(source_path, link_path))
|
||||
|
||||
return actions
|
||||
|
||||
def _initialize_database(filename):
|
||||
links_database = shelve.open(filename)
|
||||
|
||||
# Wipe the database if this version of the script ends up looking at a
|
||||
# newer (future) version of the links db, just to be sure.
|
||||
version = links_database.get('SCHEMA_VERSION')
|
||||
if version and version != SCHEMA_VERSION:
|
||||
logging.info('Found database with schema version %s while this script only '
|
||||
'supports %s. Wiping previous database contents.', version,
|
||||
SCHEMA_VERSION)
|
||||
links_database.clear()
|
||||
links_database['SCHEMA_VERSION'] = SCHEMA_VERSION
|
||||
return links_database
|
||||
|
||||
|
||||
def main():
|
||||
on_bot = os.environ.get('CHROME_HEADLESS') == '1'
|
||||
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option('-d', '--dry-run', action='store_true', default=False,
|
||||
help='Print what would be done, but don\'t perform any '
|
||||
'operations. This will automatically set logging to '
|
||||
'verbose.')
|
||||
parser.add_option('-c', '--clean-only', action='store_true', default=False,
|
||||
help='Only clean previously created links, don\'t create '
|
||||
'new ones. This will automatically set logging to '
|
||||
'verbose.')
|
||||
parser.add_option('-f', '--force', action='store_true', default=on_bot,
|
||||
help='Force link creation. CAUTION: This deletes existing '
|
||||
'folders and files in the locations where links are '
|
||||
'about to be created.')
|
||||
parser.add_option('-n', '--no-prompt', action='store_false', dest='prompt',
|
||||
default=(not on_bot),
|
||||
help='Prompt if we\'re planning to do a dangerous action')
|
||||
parser.add_option('-v', '--verbose', action='store_const',
|
||||
const=logging.DEBUG, default=logging.INFO,
|
||||
help='Print verbose output for debugging.')
|
||||
options, _ = parser.parse_args()
|
||||
|
||||
if options.dry_run or options.force or options.clean_only:
|
||||
options.verbose = logging.DEBUG
|
||||
logging.basicConfig(format='%(message)s', level=options.verbose)
|
||||
|
||||
# Work from the root directory of the checkout.
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
os.chdir(script_dir)
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
def is_admin():
|
||||
try:
|
||||
return os.getuid() == 0
|
||||
except AttributeError:
|
||||
return ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||
if is_admin():
|
||||
logging.warning('WARNING: On Windows, you no longer need run as '
|
||||
'administrator. Please run with user account privileges.')
|
||||
|
||||
if not os.path.exists(CHROMIUM_CHECKOUT):
|
||||
logging.error('Cannot find a Chromium checkout at %s. Did you run "gclient '
|
||||
'sync" before running this script?', CHROMIUM_CHECKOUT)
|
||||
return 2
|
||||
|
||||
links_database = _initialize_database(LINKS_DB)
|
||||
try:
|
||||
symlink_creator = WebRTCLinkSetup(links_database, options.force,
|
||||
options.dry_run, options.prompt)
|
||||
symlink_creator.CleanupLinks()
|
||||
if not options.clean_only:
|
||||
symlink_creator.CreateLinks(on_bot)
|
||||
except LinkError as e:
|
||||
print >> sys.stderr, e.message
|
||||
return 3
|
||||
finally:
|
||||
links_database.close()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
154
sync_chromium.py
154
sync_chromium.py
@ -1,154 +0,0 @@
|
||||
#!/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.
|
||||
|
||||
"""Script to download a Chromium checkout into the workspace.
|
||||
|
||||
The script downloads a full Chromium Git clone and its DEPS.
|
||||
|
||||
The following environment variable can be used to alter the behavior:
|
||||
* CHROMIUM_NO_HISTORY - If set to 1, a Git checkout with no history will be
|
||||
downloaded. This is consumes less bandwidth and disk space but is known to be
|
||||
slower in general if you have a high-speed connection.
|
||||
|
||||
After a successful sync has completed, a .last_sync_chromium file is written to
|
||||
the chromium directory. While it exists, no more gclient sync operations will be
|
||||
performed until the --target-revision changes or the SCRIPT_VERSION constant is
|
||||
incremented. The file can be removed manually to force a new sync.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Bump this whenever the algorithm changes and you need bots/devs to re-sync,
|
||||
# ignoring the .last_sync_chromium file
|
||||
SCRIPT_VERSION = 4
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
CHROMIUM_NO_HISTORY = 'CHROMIUM_NO_HISTORY'
|
||||
|
||||
def _parse_gclient_dict():
|
||||
gclient_dict = {}
|
||||
try:
|
||||
main_gclient = os.path.join(os.path.dirname(ROOT_DIR), '.gclient')
|
||||
with open(main_gclient, 'rb') as deps_content:
|
||||
exec(deps_content, gclient_dict)
|
||||
except Exception as e:
|
||||
print >> sys.stderr, 'error while parsing .gclient:', e
|
||||
return gclient_dict
|
||||
|
||||
|
||||
def get_cache_dir():
|
||||
return _parse_gclient_dict().get('cache_dir')
|
||||
|
||||
|
||||
def get_target_os_list():
|
||||
return ','.join(_parse_gclient_dict().get('target_os', []))
|
||||
|
||||
|
||||
def main():
|
||||
CR_DIR = os.path.join(ROOT_DIR, 'chromium')
|
||||
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--target-revision', required=True,
|
||||
help='The target chromium git revision [REQUIRED]')
|
||||
p.add_argument('--chromium-dir', default=CR_DIR,
|
||||
help=('The path to the chromium directory to sync '
|
||||
'(default: %(default)r)'))
|
||||
opts = p.parse_args()
|
||||
opts.chromium_dir = os.path.abspath(opts.chromium_dir)
|
||||
|
||||
target_os_list = get_target_os_list()
|
||||
|
||||
# Do a quick check to see if we were successful last time to make runhooks
|
||||
# sooper fast.
|
||||
flag_file = os.path.join(opts.chromium_dir, '.last_sync_chromium')
|
||||
flag_file_content = '\n'.join([
|
||||
str(SCRIPT_VERSION),
|
||||
opts.target_revision,
|
||||
repr(target_os_list),
|
||||
])
|
||||
if (os.path.exists(os.path.join(opts.chromium_dir, 'src')) and
|
||||
os.path.exists(flag_file)):
|
||||
with open(flag_file, 'r') as f:
|
||||
if f.read() == flag_file_content:
|
||||
print 'Chromium already up to date: ', opts.target_revision
|
||||
return 0
|
||||
os.unlink(flag_file)
|
||||
|
||||
env = os.environ.copy()
|
||||
|
||||
# Avoid downloading NaCl toolchain as part of the Chromium hooks.
|
||||
env['GYP_CHROMIUM_NO_ACTION'] = '1'
|
||||
gclient_cmd = 'gclient.bat' if sys.platform.startswith('win') else 'gclient'
|
||||
args = [
|
||||
gclient_cmd, 'sync', '--force', '--revision', 'src@'+opts.target_revision
|
||||
]
|
||||
|
||||
if os.environ.get('CHROME_HEADLESS') == '1':
|
||||
# Running on a buildbot.
|
||||
args.append('-vvv')
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
cache_path = os.path.join(os.path.splitdrive(ROOT_DIR)[0] + os.path.sep,
|
||||
'b', 'git-cache')
|
||||
else:
|
||||
cache_path = '/b/git-cache'
|
||||
else:
|
||||
# Support developers setting the cache_dir in .gclient.
|
||||
cache_path = get_cache_dir()
|
||||
|
||||
# Allow for users with poor internet connections to download a Git clone
|
||||
# without history (saves several gigs but is generally slower and doesn't work
|
||||
# with the Git cache).
|
||||
if os.environ.get(CHROMIUM_NO_HISTORY) == '1':
|
||||
if cache_path:
|
||||
print >> sys.stderr, (
|
||||
'You cannot use "no-history" mode for syncing Chrome (i.e. set the '
|
||||
'%s environment variable to 1) when you have cache_dir configured in '
|
||||
'your .gclient.' % CHROMIUM_NO_HISTORY)
|
||||
return 1
|
||||
args.append('--no-history')
|
||||
gclient_entries_file = os.path.join(opts.chromium_dir, '.gclient_entries')
|
||||
else:
|
||||
# Write a temporary .gclient file that has the cache_dir variable added.
|
||||
gclientfile = os.path.join(opts.chromium_dir, '.gclient')
|
||||
with open(gclientfile, 'rb') as spec:
|
||||
spec = spec.read().splitlines()
|
||||
spec[-1] = 'cache_dir = %r' % (cache_path,)
|
||||
with open(gclientfile + '.tmp', 'wb') as f:
|
||||
f.write('\n'.join(spec))
|
||||
|
||||
args += [
|
||||
'--gclientfile', '.gclient.tmp',
|
||||
'--delete_unversioned_trees', '--reset', '--upstream'
|
||||
]
|
||||
gclient_entries_file = os.path.join(opts.chromium_dir,
|
||||
'.gclient.tmp_entries')
|
||||
|
||||
# To avoid gclient sync problems when DEPS entries have been removed we must
|
||||
# wipe the gclient's entries file that contains cached URLs for all DEPS.
|
||||
if os.path.exists(gclient_entries_file):
|
||||
os.unlink(gclient_entries_file)
|
||||
|
||||
if target_os_list:
|
||||
args += ['--deps=' + target_os_list]
|
||||
|
||||
print 'Running "%s" in %s' % (' '.join(args), opts.chromium_dir)
|
||||
ret = subprocess.call(args, cwd=opts.chromium_dir, env=env)
|
||||
if ret == 0:
|
||||
with open(flag_file, 'wb') as f:
|
||||
f.write(flag_file_content)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
76
third_party/gflags/BUILD.gn
vendored
76
third_party/gflags/BUILD.gn
vendored
@ -1,76 +0,0 @@
|
||||
#
|
||||
# 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 is a copy of WebRTC's BUILD.gn.
|
||||
|
||||
if (is_win) {
|
||||
gflags_gen_arch_root = "gen/win"
|
||||
} else {
|
||||
gflags_gen_arch_root = "gen/posix"
|
||||
}
|
||||
|
||||
config("gflags_config") {
|
||||
include_dirs = [
|
||||
"$gflags_gen_arch_root/include", # For configured files.
|
||||
"src/src", # For everything else.
|
||||
]
|
||||
|
||||
defines = [
|
||||
# These macros exist so flags and symbols are properly exported when
|
||||
# building DLLs. Since we don't build DLLs, we need to disable them.
|
||||
"GFLAGS_DLL_DECL=",
|
||||
"GFLAGS_DLL_DECLARE_FLAG=",
|
||||
"GFLAGS_DLL_DEFINE_FLAG=",
|
||||
]
|
||||
|
||||
# GN orders flags on a target before flags from configs. The default config
|
||||
# adds -Wall, and this flag have to be after -Wall -- so they need to
|
||||
# come from a config and can't be on the target directly.
|
||||
if (is_clang) {
|
||||
cflags = [ "-Wno-unused-local-typedef" ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("gflags") {
|
||||
cflags = []
|
||||
sources = [
|
||||
"src/src/gflags.cc",
|
||||
"src/src/gflags_completions.cc",
|
||||
"src/src/gflags_reporting.cc",
|
||||
]
|
||||
if (is_win) {
|
||||
sources += [ "src/src/windows_port.cc" ]
|
||||
|
||||
cflags += [
|
||||
"/wd4005", # WIN32_LEAN_AND_MEAN.
|
||||
"/wd4267", # Conversion from size_t to "type".
|
||||
]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"$gflags_gen_arch_root/include/gflags", # For configured files.
|
||||
"$gflags_gen_arch_root/include/private", # For config.h
|
||||
]
|
||||
|
||||
public_configs = [ ":gflags_config" ]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
|
||||
if (is_win) {
|
||||
configs -= [ "//build/config/win:unicode" ]
|
||||
}
|
||||
|
||||
if (is_clang) {
|
||||
# TODO(andrew): Look into fixing this warning upstream:
|
||||
# http://code.google.com/p/webrtc/issues/detail?id=760
|
||||
configs -= [ "//build/config/clang:extra_warnings" ]
|
||||
cflags += [ "-Wno-microsoft-include" ]
|
||||
}
|
||||
}
|
||||
28
third_party/gflags/LICENSE
vendored
28
third_party/gflags/LICENSE
vendored
@ -1,28 +0,0 @@
|
||||
Copyright (c) 2006, Google Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
28
third_party/gflags/README.libyuv
vendored
28
third_party/gflags/README.libyuv
vendored
@ -1,28 +0,0 @@
|
||||
URL: https://github.com/gflags/gflags
|
||||
Version: 2.1.2
|
||||
License: New BSD
|
||||
License File: LICENSE
|
||||
|
||||
Description:
|
||||
The gflags package contains a library that implements commandline
|
||||
flags processing. As such it's a replacement for getopt(). It has
|
||||
increased flexibility, including built-in support for C++ types like
|
||||
string, and the ability to define flags in the source file in which
|
||||
they're used.
|
||||
|
||||
Local Modifications: None
|
||||
|
||||
|
||||
How to update platform configuration files:
|
||||
The gen/ directory contains pre-generated configuration header files.
|
||||
Historically, all operating systems and architectures have generated
|
||||
similar configurations except for Windows. This is why there's only
|
||||
posix and win directories below gen/.
|
||||
When rolling gflags to a newer version, it's a good idea to check if
|
||||
new configuration files needs to be generated as well.
|
||||
Do this by running ./configure in the newly checked out version of
|
||||
gflags. Then diff the generated files with the ones below gen/.
|
||||
If you notice a diff, update the files with the updated ones.
|
||||
If you suspect platform dependend changes other than Windows, you'll
|
||||
have to checkout gflags on the other platforms as well and run
|
||||
./configure there too.
|
||||
573
third_party/gflags/gen/posix/include/gflags/gflags.h
vendored
573
third_party/gflags/gen/posix/include/gflags/gflags.h
vendored
@ -1,573 +0,0 @@
|
||||
// Copyright (c) 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This is the file that should be included by any file which declares
|
||||
// or defines a command line flag or wants to parse command line flags
|
||||
// or print a program usage message (which will include information about
|
||||
// flags). Executive summary, in the form of an example foo.cc file:
|
||||
//
|
||||
// #include "foo.h" // foo.h has a line "DECLARE_int32(start);"
|
||||
// #include "validators.h" // hypothetical file defining ValidateIsFile()
|
||||
//
|
||||
// DEFINE_int32(end, 1000, "The last record to read");
|
||||
//
|
||||
// DEFINE_string(filename, "my_file.txt", "The file to read");
|
||||
// // Crash if the specified file does not exist.
|
||||
// static bool dummy = RegisterFlagValidator(&FLAGS_filename,
|
||||
// &ValidateIsFile);
|
||||
//
|
||||
// DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
|
||||
//
|
||||
// void MyFunc() {
|
||||
// if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
|
||||
// }
|
||||
//
|
||||
// Then, at the command-line:
|
||||
// ./foo --noverbose --start=5 --end=100
|
||||
//
|
||||
// For more details, see
|
||||
// doc/gflags.html
|
||||
//
|
||||
// --- A note about thread-safety:
|
||||
//
|
||||
// We describe many functions in this routine as being thread-hostile,
|
||||
// thread-compatible, or thread-safe. Here are the meanings we use:
|
||||
//
|
||||
// thread-safe: it is safe for multiple threads to call this routine
|
||||
// (or, when referring to a class, methods of this class)
|
||||
// concurrently.
|
||||
// thread-hostile: it is not safe for multiple threads to call this
|
||||
// routine (or methods of this class) concurrently. In gflags,
|
||||
// most thread-hostile routines are intended to be called early in,
|
||||
// or even before, main() -- that is, before threads are spawned.
|
||||
// thread-compatible: it is safe for multiple threads to read from
|
||||
// this variable (when applied to variables), or to call const
|
||||
// methods of this class (when applied to classes), as long as no
|
||||
// other thread is writing to the variable or calling non-const
|
||||
// methods of this class.
|
||||
|
||||
#ifndef GFLAGS_GFLAGS_H_
|
||||
#define GFLAGS_GFLAGS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gflags_declare.h" // IWYU pragma: export
|
||||
|
||||
|
||||
// We always want to export variables defined in user code
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
# ifdef _MSC_VER
|
||||
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DEFINE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// To actually define a flag in a file, use DEFINE_bool,
|
||||
// DEFINE_string, etc. at the bottom of this file. You may also find
|
||||
// it useful to register a validator with the flag. This ensures that
|
||||
// when the flag is parsed from the commandline, or is later set via
|
||||
// SetCommandLineOption, we call the validation function. It is _not_
|
||||
// called when you assign the value to the flag directly using the = operator.
|
||||
//
|
||||
// The validation function should return true if the flag value is valid, and
|
||||
// false otherwise. If the function returns false for the new setting of the
|
||||
// flag, the flag will retain its current value. If it returns false for the
|
||||
// default value, ParseCommandLineFlags() will die.
|
||||
//
|
||||
// This function is safe to call at global construct time (as in the
|
||||
// example below).
|
||||
//
|
||||
// Example use:
|
||||
// static bool ValidatePort(const char* flagname, int32 value) {
|
||||
// if (value > 0 && value < 32768) // value is ok
|
||||
// return true;
|
||||
// printf("Invalid value for --%s: %d\n", flagname, (int)value);
|
||||
// return false;
|
||||
// }
|
||||
// DEFINE_int32(port, 0, "What port to listen on");
|
||||
// static bool dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
|
||||
|
||||
// Returns true if successfully registered, false if not (because the
|
||||
// first argument doesn't point to a command-line flag, or because a
|
||||
// validator is already registered for this flag).
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const std::string* flag, bool (*validate_fn)(const char*, const std::string&));
|
||||
|
||||
// Convenience macro for the registration of a flag validator
|
||||
#define DEFINE_validator(name, validator) \
|
||||
static const bool name##_validator_registered = \
|
||||
GFLAGS_NAMESPACE::RegisterFlagValidator(&FLAGS_##name, validator)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// These methods are the best way to get access to info about the
|
||||
// list of commandline flags. Note that these routines are pretty slow.
|
||||
// GetAllFlags: mostly-complete info about the list, sorted by file.
|
||||
// ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
|
||||
// ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
|
||||
//
|
||||
// In addition to accessing flags, you can also access argv[0] (the program
|
||||
// name) and argv (the entire commandline), which we sock away a copy of.
|
||||
// These variables are static, so you should only set them once.
|
||||
//
|
||||
// No need to export this data only structure from DLL, avoiding VS warning 4251.
|
||||
struct CommandLineFlagInfo {
|
||||
std::string name; // the name of the flag
|
||||
std::string type; // the type of the flag: int32, etc
|
||||
std::string description; // the "help text" associated with the flag
|
||||
std::string current_value; // the current value, as a string
|
||||
std::string default_value; // the default value, as a string
|
||||
std::string filename; // 'cleaned' version of filename holding the flag
|
||||
bool has_validator_fn; // true if RegisterFlagValidator called on this flag
|
||||
bool is_default; // true if the flag has the default value and
|
||||
// has not been set explicitly from the cmdline
|
||||
// or via SetCommandLineOption
|
||||
const void* flag_ptr; // pointer to the flag's current value (i.e. FLAGS_foo)
|
||||
};
|
||||
|
||||
// Using this inside of a validator is a recipe for a deadlock.
|
||||
// TODO(user) Fix locking when validators are running, to make it safe to
|
||||
// call validators during ParseAllFlags.
|
||||
// Also make sure then to uncomment the corresponding unit test in
|
||||
// gflags_unittest.sh
|
||||
extern GFLAGS_DLL_DECL void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
|
||||
// These two are actually defined in gflags_reporting.cc.
|
||||
extern GFLAGS_DLL_DECL void ShowUsageWithFlags(const char *argv0); // what --help does
|
||||
extern GFLAGS_DLL_DECL void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
|
||||
|
||||
// Create a descriptive string for a flag.
|
||||
// Goes to some trouble to make pretty line breaks.
|
||||
extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
||||
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetArgv(int argc, const char** argv);
|
||||
|
||||
// The following functions are thread-safe as long as SetArgv() is
|
||||
// only called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const std::vector<std::string>& GetArgvs();
|
||||
extern GFLAGS_DLL_DECL const char* GetArgv(); // all of argv as a string
|
||||
extern GFLAGS_DLL_DECL const char* GetArgv0(); // only argv0
|
||||
extern GFLAGS_DLL_DECL uint32 GetArgvSum(); // simple checksum of argv
|
||||
extern GFLAGS_DLL_DECL const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
|
||||
extern GFLAGS_DLL_DECL const char* ProgramInvocationShortName(); // basename(argv0)
|
||||
|
||||
// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
|
||||
// called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const char* ProgramUsage(); // string set by SetUsageMessage()
|
||||
|
||||
// VersionString() is thread-safe as long as SetVersionString() is only
|
||||
// called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const char* VersionString(); // string set by SetVersionString()
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Normally you access commandline flags by just saying "if (FLAGS_foo)"
|
||||
// or whatever, and set them by calling "FLAGS_foo = bar" (or, more
|
||||
// commonly, via the DEFINE_foo macro). But if you need a bit more
|
||||
// control, we have programmatic ways to get/set the flags as well.
|
||||
// These programmatic ways to access flags are thread-safe, but direct
|
||||
// access is only thread-compatible.
|
||||
|
||||
// Return true iff the flagname was found.
|
||||
// OUTPUT is set to the flag's value, or unchanged if we return false.
|
||||
extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string* OUTPUT);
|
||||
|
||||
// Return true iff the flagname was found. OUTPUT is set to the flag's
|
||||
// CommandLineFlagInfo or unchanged if we return false.
|
||||
extern GFLAGS_DLL_DECL bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT);
|
||||
|
||||
// Return the CommandLineFlagInfo of the flagname. exit() if name not found.
|
||||
// Example usage, to check if a flag's value is currently the default value:
|
||||
// if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
|
||||
extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
||||
|
||||
enum GFLAGS_DLL_DECL FlagSettingMode {
|
||||
// update the flag's value (can call this multiple times).
|
||||
SET_FLAGS_VALUE,
|
||||
// update the flag's value, but *only if* it has not yet been updated
|
||||
// with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef".
|
||||
SET_FLAG_IF_DEFAULT,
|
||||
// set the flag's default value to this. If the flag has not yet updated
|
||||
// yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef")
|
||||
// change the flag's current value to the new default value as well.
|
||||
SET_FLAGS_DEFAULT
|
||||
};
|
||||
|
||||
// Set a particular flag ("command line option"). Returns a string
|
||||
// describing the new value that the option has been set to. The
|
||||
// return value API is not well-specified, so basically just depend on
|
||||
// it to be empty if the setting failed for some reason -- the name is
|
||||
// not a valid flag name, or the value is not a valid value -- and
|
||||
// non-empty else.
|
||||
|
||||
// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
|
||||
extern GFLAGS_DLL_DECL std::string SetCommandLineOption (const char* name, const char* value);
|
||||
extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name, const char* value, FlagSettingMode set_mode);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Saves the states (value, default value, whether the user has set
|
||||
// the flag, registered validators, etc) of all flags, and restores
|
||||
// them when the FlagSaver is destroyed. This is very useful in
|
||||
// tests, say, when you want to let your tests change the flags, but
|
||||
// make sure that they get reverted to the original states when your
|
||||
// test is complete.
|
||||
//
|
||||
// Example usage:
|
||||
// void TestFoo() {
|
||||
// FlagSaver s1;
|
||||
// FLAG_foo = false;
|
||||
// FLAG_bar = "some value";
|
||||
//
|
||||
// // test happens here. You can return at any time
|
||||
// // without worrying about restoring the FLAG values.
|
||||
// }
|
||||
//
|
||||
// Note: This class is marked with GFLAGS_ATTRIBUTE_UNUSED because all
|
||||
// the work is done in the constructor and destructor, so in the standard
|
||||
// usage example above, the compiler would complain that it's an
|
||||
// unused variable.
|
||||
//
|
||||
// This class is thread-safe. However, its destructor writes to
|
||||
// exactly the set of flags that have changed value during its
|
||||
// lifetime, so concurrent _direct_ access to those flags
|
||||
// (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe.
|
||||
|
||||
class GFLAGS_DLL_DECL FlagSaver {
|
||||
public:
|
||||
FlagSaver();
|
||||
~FlagSaver();
|
||||
|
||||
private:
|
||||
class FlagSaverImpl* impl_; // we use pimpl here to keep API steady
|
||||
|
||||
FlagSaver(const FlagSaver&); // no copying!
|
||||
void operator=(const FlagSaver&);
|
||||
}__attribute((unused));
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Some deprecated or hopefully-soon-to-be-deprecated functions.
|
||||
|
||||
// This is often used for logging. TODO(csilvers): figure out a better way
|
||||
extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
|
||||
// Usually where this is used, a FlagSaver should be used instead.
|
||||
extern GFLAGS_DLL_DECL
|
||||
bool ReadFlagsFromString(const std::string& flagfilecontents,
|
||||
const char* prog_name,
|
||||
bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
|
||||
// These let you manually implement --flagfile functionality.
|
||||
// DEPRECATED.
|
||||
extern GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
|
||||
extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name, bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Useful routines for initializing flags from the environment.
|
||||
// In each case, if 'varname' does not exist in the environment
|
||||
// return defval. If 'varname' does exist but is not valid
|
||||
// (e.g., not a number for an int32 flag), abort with an error.
|
||||
// Otherwise, return the value. NOTE: for booleans, for true use
|
||||
// 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
|
||||
|
||||
extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
|
||||
extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
|
||||
extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
|
||||
extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
||||
extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
|
||||
extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char *defval);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// The next two functions parse gflags from main():
|
||||
|
||||
// Set the "usage" message for this program. For example:
|
||||
// string usage("This program does nothing. Sample usage:\n");
|
||||
// usage += argv[0] + " <uselessarg1> <uselessarg2>";
|
||||
// SetUsageMessage(usage);
|
||||
// Do not include commandline flags in the usage: we do that for you!
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetUsageMessage(const std::string& usage);
|
||||
|
||||
// Sets the version string, which is emitted with --version.
|
||||
// For instance: SetVersionString("1.3");
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetVersionString(const std::string& version);
|
||||
|
||||
|
||||
// Looks for flags in argv and parses them. Rearranges argv to put
|
||||
// flags first, or removes them entirely if remove_flags is true.
|
||||
// If a flag is defined more than once in the command line or flag
|
||||
// file, the last definition is used. Returns the index (into argv)
|
||||
// of the first non-flag argument.
|
||||
// See top-of-file for more details on this function.
|
||||
#ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
|
||||
extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
|
||||
#endif
|
||||
|
||||
|
||||
// Calls to ParseCommandLineNonHelpFlags and then to
|
||||
// HandleCommandLineHelpFlags can be used instead of a call to
|
||||
// ParseCommandLineFlags during initialization, in order to allow for
|
||||
// changing default values for some FLAGS (via
|
||||
// e.g. SetCommandLineOptionWithMode calls) between the time of
|
||||
// command line parsing and the time of dumping help information for
|
||||
// the flags as a result of command line parsing. If a flag is
|
||||
// defined more than once in the command line or flag file, the last
|
||||
// definition is used. Returns the index (into argv) of the first
|
||||
// non-flag argument. (If remove_flags is true, will always return 1.)
|
||||
extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv, bool remove_flags);
|
||||
|
||||
// This is actually defined in gflags_reporting.cc.
|
||||
// This function is misnamed (it also handles --version, etc.), but
|
||||
// it's too late to change that now. :-(
|
||||
extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags(); // in gflags_reporting.cc
|
||||
|
||||
// Allow command line reparsing. Disables the error normally
|
||||
// generated when an unknown flag is found, since it may be found in a
|
||||
// later parse. Thread-hostile; meant to be called before any threads
|
||||
// are spawned.
|
||||
extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
|
||||
|
||||
// Reparse the flags that have not yet been recognized. Only flags
|
||||
// registered since the last parse will be recognized. Any flag value
|
||||
// must be provided as part of the argument using "=", not as a
|
||||
// separate command line argument that follows the flag argument.
|
||||
// Intended for handling flags from dynamically loaded libraries,
|
||||
// since their flags are not registered until they are loaded.
|
||||
extern GFLAGS_DLL_DECL void ReparseCommandLineNonHelpFlags();
|
||||
|
||||
// Clean up memory allocated by flags. This is only needed to reduce
|
||||
// the quantity of "potentially leaked" reports emitted by memory
|
||||
// debugging tools such as valgrind. It is not required for normal
|
||||
// operation, or for the google perftools heap-checker. It must only
|
||||
// be called when the process is about to exit, and all threads that
|
||||
// might access flags are quiescent. Referencing flags after this is
|
||||
// called will have unexpected consequences. This is not safe to run
|
||||
// when multiple threads might be running: the function is
|
||||
// thread-hostile.
|
||||
extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Now come the command line flag declaration/definition macros that
|
||||
// will actually be used. They're kind of hairy. A major reason
|
||||
// for this is initialization: we want people to be able to access
|
||||
// variables in global constructors and have that not crash, even if
|
||||
// their global constructor runs before the global constructor here.
|
||||
// (Obviously, we can't guarantee the flags will have the correct
|
||||
// default value in that case, but at least accessing them is safe.)
|
||||
// The only way to do that is have flags point to a static buffer.
|
||||
// So we make one, using a union to ensure proper alignment, and
|
||||
// then use placement-new to actually set up the flag with the
|
||||
// correct default value. In the same vein, we have to worry about
|
||||
// flag access in global destructors, so FlagRegisterer has to be
|
||||
// careful never to destroy the flag-values it constructs.
|
||||
//
|
||||
// Note that when we define a flag variable FLAGS_<name>, we also
|
||||
// preemptively define a junk variable, FLAGS_no<name>. This is to
|
||||
// cause a link-time error if someone tries to define 2 flags with
|
||||
// names like "logging" and "nologging". We do this because a bool
|
||||
// flag FLAG can be set from the command line to true with a "-FLAG"
|
||||
// argument, and to false with a "-noFLAG" argument, and so this can
|
||||
// potentially avert confusion.
|
||||
//
|
||||
// We also put flags into their own namespace. It is purposefully
|
||||
// named in an opaque way that people should have trouble typing
|
||||
// directly. The idea is that DEFINE puts the flag in the weird
|
||||
// namespace, and DECLARE imports the flag from there into the current
|
||||
// namespace. The net result is to force people to use DECLARE to get
|
||||
// access to a flag, rather than saying "extern GFLAGS_DLL_DECL bool FLAGS_whatever;"
|
||||
// or some such instead. We want this so we can put extra
|
||||
// functionality (like sanity-checking) in DECLARE if we want, and
|
||||
// make sure it is picked up everywhere.
|
||||
//
|
||||
// We also put the type of the variable in the namespace, so that
|
||||
// people can't DECLARE_int32 something that they DEFINE_bool'd
|
||||
// elsewhere.
|
||||
|
||||
class GFLAGS_DLL_DECL FlagRegisterer {
|
||||
public:
|
||||
FlagRegisterer(const char* name, const char* type,
|
||||
const char* help, const char* filename,
|
||||
void* current_storage, void* defvalue_storage);
|
||||
};
|
||||
|
||||
// If your application #defines STRIP_FLAG_HELP to a non-zero value
|
||||
// before #including this file, we remove the help message from the
|
||||
// binary file. This can reduce the size of the resulting binary
|
||||
// somewhat, and may also be useful for security reasons.
|
||||
|
||||
extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
|
||||
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
||||
|
||||
#ifndef SWIG // In swig, ignore the main flag declarations
|
||||
|
||||
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
|
||||
// Need this construct to avoid the 'defined but not used' warning.
|
||||
#define MAYBE_STRIPPED_HELP(txt) \
|
||||
(false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
|
||||
#else
|
||||
#define MAYBE_STRIPPED_HELP(txt) txt
|
||||
#endif
|
||||
|
||||
// Each command-line flag has two variables associated with it: one
|
||||
// with the current value, and one with the default value. However,
|
||||
// we have a third variable, which is where value is assigned; it's a
|
||||
// constant. This guarantees that FLAG_##value is initialized at
|
||||
// static initialization time (e.g. before program-start) rather than
|
||||
// than global construction time (which is after program-start but
|
||||
// before main), at least when 'value' is a compile-time constant. We
|
||||
// use a small trick for the "default value" variable, and call it
|
||||
// FLAGS_no<name>. This serves the second purpose of assuring a
|
||||
// compile error if someone tries to define a flag named no<name>
|
||||
// which is illegal (--foo and --nofoo both affect the "foo" flag).
|
||||
#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
|
||||
namespace fL##shorttype { \
|
||||
static const type FLAGS_nono##name = value; \
|
||||
/* We always want to export defined variables, dll or no */ \
|
||||
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
|
||||
type FLAGS_no##name = FLAGS_nono##name; \
|
||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
||||
&FLAGS_##name, &FLAGS_no##name); \
|
||||
} \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
// For DEFINE_bool, we want to do the extra check that the passed-in
|
||||
// value is actually a bool, and not a string or something that can be
|
||||
// coerced to a bool. These declarations (no definition needed!) will
|
||||
// help us do that, and never evaluate From, which is important.
|
||||
// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
|
||||
// that the compiler have different sizes for bool & double. Since
|
||||
// this is not guaranteed by the standard, we check it with a
|
||||
// COMPILE_ASSERT.
|
||||
namespace fLB {
|
||||
struct CompileAssert {};
|
||||
typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
|
||||
(sizeof(double) != sizeof(bool)) ? 1 : -1];
|
||||
template<typename From> double GFLAGS_DLL_DECL IsBoolFlag(const From& from);
|
||||
GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
|
||||
} // namespace fLB
|
||||
|
||||
// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
|
||||
// are in a separate include, gflags_declare.h, for reducing
|
||||
// the physical transitive size for DECLARE use.
|
||||
#define DEFINE_bool(name, val, txt) \
|
||||
namespace fLB { \
|
||||
typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
|
||||
(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double))? 1: -1]; \
|
||||
} \
|
||||
DEFINE_VARIABLE(bool, B, name, val, txt)
|
||||
|
||||
#define DEFINE_int32(name, val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_int64(name, val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_uint64(name,val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint64, U64, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_double(name, val, txt) \
|
||||
DEFINE_VARIABLE(double, D, name, val, txt)
|
||||
|
||||
// Strings are trickier, because they're not a POD, so we can't
|
||||
// construct them at static-initialization time (instead they get
|
||||
// constructed at global-constructor time, which is much later). To
|
||||
// try to avoid crashes in that case, we use a char buffer to store
|
||||
// the string, which we can static-initialize, and then placement-new
|
||||
// into it later. It's not perfect, but the best we can do.
|
||||
|
||||
namespace fLS {
|
||||
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
const char *value) {
|
||||
return new(stringspot) clstring(value);
|
||||
}
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
const clstring &value) {
|
||||
return new(stringspot) clstring(value);
|
||||
}
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
int value);
|
||||
} // namespace fLS
|
||||
|
||||
// We need to define a var named FLAGS_no##name so people don't define
|
||||
// --string and --nostring. And we need a temporary place to put val
|
||||
// so we don't have to evaluate it twice. Two great needs that go
|
||||
// great together!
|
||||
// The weird 'using' + 'extern' inside the fLS namespace is to work around
|
||||
// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See
|
||||
// http://code.google.com/p/google-gflags/issues/detail?id=20
|
||||
#define DEFINE_string(name, val, txt) \
|
||||
namespace fLS { \
|
||||
using ::fLS::clstring; \
|
||||
static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \
|
||||
clstring* const FLAGS_no##name = ::fLS:: \
|
||||
dont_pass0toDEFINE_string(s_##name[0].s, \
|
||||
val); \
|
||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
||||
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
||||
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
||||
using fLS::FLAGS_##name; \
|
||||
clstring& FLAGS_##name = *FLAGS_no##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
#endif // SWIG
|
||||
|
||||
|
||||
// Import gflags library symbols into alternative/deprecated namespace(s)
|
||||
#include "gflags_gflags.h"
|
||||
|
||||
|
||||
#endif // GFLAGS_GFLAGS_H_
|
||||
@ -1,121 +0,0 @@
|
||||
// Copyright (c) 2008, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---
|
||||
|
||||
//
|
||||
// Implement helpful bash-style command line flag completions
|
||||
//
|
||||
// ** Functional API:
|
||||
// HandleCommandLineCompletions() should be called early during
|
||||
// program startup, but after command line flag code has been
|
||||
// initialized, such as the beginning of HandleCommandLineHelpFlags().
|
||||
// It checks the value of the flag --tab_completion_word. If this
|
||||
// flag is empty, nothing happens here. If it contains a string,
|
||||
// however, then HandleCommandLineCompletions() will hijack the
|
||||
// process, attempting to identify the intention behind this
|
||||
// completion. Regardless of the outcome of this deduction, the
|
||||
// process will be terminated, similar to --helpshort flag
|
||||
// handling.
|
||||
//
|
||||
// ** Overview of Bash completions:
|
||||
// Bash can be told to programatically determine completions for the
|
||||
// current 'cursor word'. It does this by (in this case) invoking a
|
||||
// command with some additional arguments identifying the command
|
||||
// being executed, the word being completed, and the previous word
|
||||
// (if any). Bash then expects a sequence of output lines to be
|
||||
// printed to stdout. If these lines all contain a common prefix
|
||||
// longer than the cursor word, bash will replace the cursor word
|
||||
// with that common prefix, and display nothing. If there isn't such
|
||||
// a common prefix, bash will display the lines in pages using 'more'.
|
||||
//
|
||||
// ** Strategy taken for command line completions:
|
||||
// If we can deduce either the exact flag intended, or a common flag
|
||||
// prefix, we'll output exactly that. Otherwise, if information
|
||||
// must be displayed to the user, we'll take the opportunity to add
|
||||
// some helpful information beyond just the flag name (specifically,
|
||||
// we'll include the default flag value and as much of the flag's
|
||||
// description as can fit on a single terminal line width, as specified
|
||||
// by the flag --tab_completion_columns). Furthermore, we'll try to
|
||||
// make bash order the output such that the most useful or relevent
|
||||
// flags are the most likely to be shown at the top.
|
||||
//
|
||||
// ** Additional features:
|
||||
// To assist in finding that one really useful flag, substring matching
|
||||
// was implemented. Before pressing a <TAB> to get completion for the
|
||||
// current word, you can append one or more '?' to the flag to do
|
||||
// substring matching. Here's the semantics:
|
||||
// --foo<TAB> Show me all flags with names prefixed by 'foo'
|
||||
// --foo?<TAB> Show me all flags with 'foo' somewhere in the name
|
||||
// --foo??<TAB> Same as prior case, but also search in module
|
||||
// definition path for 'foo'
|
||||
// --foo???<TAB> Same as prior case, but also search in flag
|
||||
// descriptions for 'foo'
|
||||
// Finally, we'll trim the output to a relatively small number of
|
||||
// flags to keep bash quiet about the verbosity of output. If one
|
||||
// really wanted to see all possible matches, appending a '+' to the
|
||||
// search word will force the exhaustive list of matches to be printed.
|
||||
//
|
||||
// ** How to have bash accept completions from a binary:
|
||||
// Bash requires that it be informed about each command that programmatic
|
||||
// completion should be enabled for. Example addition to a .bashrc
|
||||
// file would be (your path to gflags_completions.sh file may differ):
|
||||
|
||||
/*
|
||||
$ complete -o bashdefault -o default -o nospace -C \
|
||||
'/home/build/eng/bash/bash_completions.sh --tab_completion_columns $COLUMNS' \
|
||||
time env binary_name another_binary [...]
|
||||
*/
|
||||
|
||||
// This would allow the following to work:
|
||||
// $ /path/to/binary_name --vmodule<TAB>
|
||||
// Or:
|
||||
// $ ./bin/path/another_binary --gfs_u<TAB>
|
||||
// (etc)
|
||||
//
|
||||
// Sadly, it appears that bash gives no easy way to force this behavior for
|
||||
// all commands. That's where the "time" in the above example comes in.
|
||||
// If you haven't specifically added a command to the list of completion
|
||||
// supported commands, you can still get completions by prefixing the
|
||||
// entire command with "env".
|
||||
// $ env /some/brand/new/binary --vmod<TAB>
|
||||
// Assuming that "binary" is a newly compiled binary, this should still
|
||||
// produce the expected completion output.
|
||||
|
||||
|
||||
#ifndef GFLAGS_COMPLETIONS_H_
|
||||
#define GFLAGS_COMPLETIONS_H_
|
||||
|
||||
namespace google {
|
||||
|
||||
extern void HandleCommandLineCompletions(void);
|
||||
|
||||
}
|
||||
|
||||
#endif // GFLAGS_COMPLETIONS_H_
|
||||
@ -1,141 +0,0 @@
|
||||
// Copyright (c) 1999, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
//
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This is the file that should be included by any file which declares
|
||||
// command line flag.
|
||||
|
||||
#ifndef GFLAGS_DECLARE_H_
|
||||
#define GFLAGS_DECLARE_H_
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Namespace of gflags library symbols.
|
||||
#define GFLAGS_NAMESPACE google
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows DLL import/export.
|
||||
|
||||
// We always want to import the symbols of the gflags library
|
||||
#ifndef GFLAGS_DLL_DECL
|
||||
# if 0 && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL __declspec(dllimport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// We always want to import variables declared in user code
|
||||
#ifndef GFLAGS_DLL_DECLARE_FLAG
|
||||
# ifdef _MSC_VER
|
||||
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECLARE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Flag types
|
||||
#include <string>
|
||||
#if 1
|
||||
# include <stdint.h> // the normal place uint32_t is defined
|
||||
#elif 1
|
||||
# include <sys/types.h> // the normal place u_int32_t is defined
|
||||
#elif 1
|
||||
# include <inttypes.h> // a third place for uint32_t or u_int32_t
|
||||
#endif
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
#if 1 // C99
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#elif 0 // BSD
|
||||
typedef int32_t int32;
|
||||
typedef u_int32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef u_int64_t uint64;
|
||||
#elif 0 // Windows
|
||||
typedef __int32 int32;
|
||||
typedef unsigned __int32 uint32;
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#else
|
||||
# error Do not know how to define a 32-bit integer quantity on your system
|
||||
#endif
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
||||
|
||||
namespace fLS {
|
||||
|
||||
// The meaning of "string" might be different between now and when the
|
||||
// macros below get invoked (e.g., if someone is experimenting with
|
||||
// other string implementations that get defined after this file is
|
||||
// included). Save the current meaning now and use it in the macros.
|
||||
typedef std::string clstring;
|
||||
|
||||
} // namespace fLS
|
||||
|
||||
|
||||
#define DECLARE_VARIABLE(type, shorttype, name) \
|
||||
/* We always want to import declared variables, dll or no */ \
|
||||
namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
#define DECLARE_bool(name) \
|
||||
DECLARE_VARIABLE(bool, B, name)
|
||||
|
||||
#define DECLARE_int32(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
|
||||
|
||||
#define DECLARE_int64(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
|
||||
|
||||
#define DECLARE_uint64(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
|
||||
|
||||
#define DECLARE_double(name) \
|
||||
DECLARE_VARIABLE(double, D, name)
|
||||
|
||||
#define DECLARE_string(name) \
|
||||
/* We always want to import declared variables, dll or no */ \
|
||||
namespace fLS { \
|
||||
using ::fLS::clstring; \
|
||||
extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
|
||||
#endif // GFLAGS_DECLARE_H_
|
||||
@ -1,101 +0,0 @@
|
||||
// Copyright (c) 2014, Andreas Schuh
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Imports the gflags library symbols into an alternative/deprecated namespace.
|
||||
|
||||
#ifndef GFLAGS_GFLAGS_H_
|
||||
# error The internal header gflags_gflags.h may only be included by gflags.h
|
||||
#endif
|
||||
|
||||
#ifndef GFLAGS_NS_GFLAGS_H_
|
||||
#define GFLAGS_NS_GFLAGS_H_
|
||||
|
||||
|
||||
namespace gflags {
|
||||
|
||||
|
||||
using GFLAGS_NAMESPACE::int32;
|
||||
using GFLAGS_NAMESPACE::uint32;
|
||||
using GFLAGS_NAMESPACE::int64;
|
||||
using GFLAGS_NAMESPACE::uint64;
|
||||
|
||||
using GFLAGS_NAMESPACE::RegisterFlagValidator;
|
||||
using GFLAGS_NAMESPACE::CommandLineFlagInfo;
|
||||
using GFLAGS_NAMESPACE::GetAllFlags;
|
||||
using GFLAGS_NAMESPACE::ShowUsageWithFlags;
|
||||
using GFLAGS_NAMESPACE::ShowUsageWithFlagsRestrict;
|
||||
using GFLAGS_NAMESPACE::DescribeOneFlag;
|
||||
using GFLAGS_NAMESPACE::SetArgv;
|
||||
using GFLAGS_NAMESPACE::GetArgvs;
|
||||
using GFLAGS_NAMESPACE::GetArgv;
|
||||
using GFLAGS_NAMESPACE::GetArgv0;
|
||||
using GFLAGS_NAMESPACE::GetArgvSum;
|
||||
using GFLAGS_NAMESPACE::ProgramInvocationName;
|
||||
using GFLAGS_NAMESPACE::ProgramInvocationShortName;
|
||||
using GFLAGS_NAMESPACE::ProgramUsage;
|
||||
using GFLAGS_NAMESPACE::VersionString;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineOption;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineFlagInfo;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineFlagInfoOrDie;
|
||||
using GFLAGS_NAMESPACE::FlagSettingMode;
|
||||
using GFLAGS_NAMESPACE::SET_FLAGS_VALUE;
|
||||
using GFLAGS_NAMESPACE::SET_FLAG_IF_DEFAULT;
|
||||
using GFLAGS_NAMESPACE::SET_FLAGS_DEFAULT;
|
||||
using GFLAGS_NAMESPACE::SetCommandLineOption;
|
||||
using GFLAGS_NAMESPACE::SetCommandLineOptionWithMode;
|
||||
using GFLAGS_NAMESPACE::FlagSaver;
|
||||
using GFLAGS_NAMESPACE::CommandlineFlagsIntoString;
|
||||
using GFLAGS_NAMESPACE::ReadFlagsFromString;
|
||||
using GFLAGS_NAMESPACE::AppendFlagsIntoFile;
|
||||
using GFLAGS_NAMESPACE::ReadFromFlagsFile;
|
||||
using GFLAGS_NAMESPACE::BoolFromEnv;
|
||||
using GFLAGS_NAMESPACE::Int32FromEnv;
|
||||
using GFLAGS_NAMESPACE::Int64FromEnv;
|
||||
using GFLAGS_NAMESPACE::Uint64FromEnv;
|
||||
using GFLAGS_NAMESPACE::DoubleFromEnv;
|
||||
using GFLAGS_NAMESPACE::StringFromEnv;
|
||||
using GFLAGS_NAMESPACE::SetUsageMessage;
|
||||
using GFLAGS_NAMESPACE::SetVersionString;
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineNonHelpFlags;
|
||||
using GFLAGS_NAMESPACE::HandleCommandLineHelpFlags;
|
||||
using GFLAGS_NAMESPACE::AllowCommandLineReparsing;
|
||||
using GFLAGS_NAMESPACE::ReparseCommandLineNonHelpFlags;
|
||||
using GFLAGS_NAMESPACE::ShutDownCommandLineFlags;
|
||||
using GFLAGS_NAMESPACE::FlagRegisterer;
|
||||
|
||||
#ifndef SWIG
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineFlags;
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace gflags
|
||||
|
||||
|
||||
#endif // GFLAGS_NS_GFLAGS_H_
|
||||
@ -1,112 +0,0 @@
|
||||
/* Generated from config.h.in during build configuration using CMake. */
|
||||
|
||||
// Note: This header file is only used internally. It is not part of public interface!
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// System checks
|
||||
|
||||
// Define if you build this library for a MS Windows OS.
|
||||
/* #undef OS_WINDOWS */
|
||||
|
||||
// Define if you have the <stdint.h> header file.
|
||||
#define HAVE_STDINT_H
|
||||
|
||||
// Define if you have the <sys/types.h> header file.
|
||||
#define HAVE_SYS_TYPES_H
|
||||
|
||||
// Define if you have the <inttypes.h> header file.
|
||||
#define HAVE_INTTYPES_H
|
||||
|
||||
// Define if you have the <sys/stat.h> header file.
|
||||
#define HAVE_SYS_STAT_H
|
||||
|
||||
// Define if you have the <unistd.h> header file.
|
||||
#define HAVE_UNISTD_H
|
||||
|
||||
// Define if you have the <fnmatch.h> header file.
|
||||
#define HAVE_FNMATCH_H
|
||||
|
||||
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
|
||||
/* #undef HAVE_SHLWAPI_H */
|
||||
|
||||
// Define if you have the strtoll function.
|
||||
#define HAVE_STRTOLL
|
||||
|
||||
// Define if you have the strtoq function.
|
||||
/* #undef HAVE_STRTOQ */
|
||||
|
||||
// Define if you have the <pthread.h> header file.
|
||||
#define HAVE_PTHREAD
|
||||
|
||||
// Define if your pthread library defines the type pthread_rwlock_t
|
||||
#define HAVE_RWLOCK
|
||||
|
||||
// gcc requires this to get PRId64, etc.
|
||||
#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
|
||||
# define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Package information
|
||||
|
||||
// Name of package.
|
||||
#define PACKAGE gflags
|
||||
|
||||
// Define to the full name of this package.
|
||||
#define PACKAGE_NAME gflags
|
||||
|
||||
// Define to the full name and version of this package.
|
||||
#define PACKAGE_STRING gflags 2.2.0
|
||||
|
||||
// Define to the one symbol short name of this package.
|
||||
#define PACKAGE_TARNAME gflags-2.2.0
|
||||
|
||||
// Define to the version of this package.
|
||||
#define PACKAGE_VERSION 2.2.0
|
||||
|
||||
// Version number of package.
|
||||
#define VERSION PACKAGE_VERSION
|
||||
|
||||
// Define to the address where bug reports for this package should be sent.
|
||||
#define PACKAGE_BUGREPORT https://github.com/schuhschuh/gflags/issues
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Path separator
|
||||
#ifndef PATH_SEPARATOR
|
||||
# ifdef OS_WINDOWS
|
||||
# define PATH_SEPARATOR '\\'
|
||||
# else
|
||||
# define PATH_SEPARATOR '/'
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows
|
||||
|
||||
// Whether gflags library is a DLL.
|
||||
#ifndef GFLAGS_IS_A_DLL
|
||||
# define GFLAGS_IS_A_DLL 0
|
||||
#endif
|
||||
|
||||
// Always export symbols when compiling a shared library as this file is only
|
||||
// included by internal modules when building the gflags library itself.
|
||||
// The gflags_declare.h header file will set it to import these symbols otherwise.
|
||||
#ifndef GFLAGS_DLL_DECL
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECL
|
||||
# endif
|
||||
#endif
|
||||
// Flags defined by the gflags library itself must be exported
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL
|
||||
#endif
|
||||
|
||||
#ifdef OS_WINDOWS
|
||||
// The unittests import the symbols of the shared gflags library
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
|
||||
# endif
|
||||
# include "windows_port.h"
|
||||
#endif
|
||||
573
third_party/gflags/gen/win/include/gflags/gflags.h
vendored
573
third_party/gflags/gen/win/include/gflags/gflags.h
vendored
@ -1,573 +0,0 @@
|
||||
// Copyright (c) 2006, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This is the file that should be included by any file which declares
|
||||
// or defines a command line flag or wants to parse command line flags
|
||||
// or print a program usage message (which will include information about
|
||||
// flags). Executive summary, in the form of an example foo.cc file:
|
||||
//
|
||||
// #include "foo.h" // foo.h has a line "DECLARE_int32(start);"
|
||||
// #include "validators.h" // hypothetical file defining ValidateIsFile()
|
||||
//
|
||||
// DEFINE_int32(end, 1000, "The last record to read");
|
||||
//
|
||||
// DEFINE_string(filename, "my_file.txt", "The file to read");
|
||||
// // Crash if the specified file does not exist.
|
||||
// static bool dummy = RegisterFlagValidator(&FLAGS_filename,
|
||||
// &ValidateIsFile);
|
||||
//
|
||||
// DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
|
||||
//
|
||||
// void MyFunc() {
|
||||
// if (FLAGS_verbose) printf("Records %d-%d\n", FLAGS_start, FLAGS_end);
|
||||
// }
|
||||
//
|
||||
// Then, at the command-line:
|
||||
// ./foo --noverbose --start=5 --end=100
|
||||
//
|
||||
// For more details, see
|
||||
// doc/gflags.html
|
||||
//
|
||||
// --- A note about thread-safety:
|
||||
//
|
||||
// We describe many functions in this routine as being thread-hostile,
|
||||
// thread-compatible, or thread-safe. Here are the meanings we use:
|
||||
//
|
||||
// thread-safe: it is safe for multiple threads to call this routine
|
||||
// (or, when referring to a class, methods of this class)
|
||||
// concurrently.
|
||||
// thread-hostile: it is not safe for multiple threads to call this
|
||||
// routine (or methods of this class) concurrently. In gflags,
|
||||
// most thread-hostile routines are intended to be called early in,
|
||||
// or even before, main() -- that is, before threads are spawned.
|
||||
// thread-compatible: it is safe for multiple threads to read from
|
||||
// this variable (when applied to variables), or to call const
|
||||
// methods of this class (when applied to classes), as long as no
|
||||
// other thread is writing to the variable or calling non-const
|
||||
// methods of this class.
|
||||
|
||||
#ifndef GFLAGS_GFLAGS_H_
|
||||
#define GFLAGS_GFLAGS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "gflags_declare.h" // IWYU pragma: export
|
||||
|
||||
|
||||
// We always want to export variables defined in user code
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
# ifdef _MSC_VER
|
||||
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DEFINE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// To actually define a flag in a file, use DEFINE_bool,
|
||||
// DEFINE_string, etc. at the bottom of this file. You may also find
|
||||
// it useful to register a validator with the flag. This ensures that
|
||||
// when the flag is parsed from the commandline, or is later set via
|
||||
// SetCommandLineOption, we call the validation function. It is _not_
|
||||
// called when you assign the value to the flag directly using the = operator.
|
||||
//
|
||||
// The validation function should return true if the flag value is valid, and
|
||||
// false otherwise. If the function returns false for the new setting of the
|
||||
// flag, the flag will retain its current value. If it returns false for the
|
||||
// default value, ParseCommandLineFlags() will die.
|
||||
//
|
||||
// This function is safe to call at global construct time (as in the
|
||||
// example below).
|
||||
//
|
||||
// Example use:
|
||||
// static bool ValidatePort(const char* flagname, int32 value) {
|
||||
// if (value > 0 && value < 32768) // value is ok
|
||||
// return true;
|
||||
// printf("Invalid value for --%s: %d\n", flagname, (int)value);
|
||||
// return false;
|
||||
// }
|
||||
// DEFINE_int32(port, 0, "What port to listen on");
|
||||
// static bool dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
|
||||
|
||||
// Returns true if successfully registered, false if not (because the
|
||||
// first argument doesn't point to a command-line flag, or because a
|
||||
// validator is already registered for this flag).
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const bool* flag, bool (*validate_fn)(const char*, bool));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int32* flag, bool (*validate_fn)(const char*, int32));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const int64* flag, bool (*validate_fn)(const char*, int64));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const uint64* flag, bool (*validate_fn)(const char*, uint64));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const double* flag, bool (*validate_fn)(const char*, double));
|
||||
extern GFLAGS_DLL_DECL bool RegisterFlagValidator(const std::string* flag, bool (*validate_fn)(const char*, const std::string&));
|
||||
|
||||
// Convenience macro for the registration of a flag validator
|
||||
#define DEFINE_validator(name, validator) \
|
||||
static const bool name##_validator_registered = \
|
||||
GFLAGS_NAMESPACE::RegisterFlagValidator(&FLAGS_##name, validator)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// These methods are the best way to get access to info about the
|
||||
// list of commandline flags. Note that these routines are pretty slow.
|
||||
// GetAllFlags: mostly-complete info about the list, sorted by file.
|
||||
// ShowUsageWithFlags: pretty-prints the list to stdout (what --help does)
|
||||
// ShowUsageWithFlagsRestrict: limit to filenames with restrict as a substr
|
||||
//
|
||||
// In addition to accessing flags, you can also access argv[0] (the program
|
||||
// name) and argv (the entire commandline), which we sock away a copy of.
|
||||
// These variables are static, so you should only set them once.
|
||||
//
|
||||
// No need to export this data only structure from DLL, avoiding VS warning 4251.
|
||||
struct CommandLineFlagInfo {
|
||||
std::string name; // the name of the flag
|
||||
std::string type; // the type of the flag: int32, etc
|
||||
std::string description; // the "help text" associated with the flag
|
||||
std::string current_value; // the current value, as a string
|
||||
std::string default_value; // the default value, as a string
|
||||
std::string filename; // 'cleaned' version of filename holding the flag
|
||||
bool has_validator_fn; // true if RegisterFlagValidator called on this flag
|
||||
bool is_default; // true if the flag has the default value and
|
||||
// has not been set explicitly from the cmdline
|
||||
// or via SetCommandLineOption
|
||||
const void* flag_ptr; // pointer to the flag's current value (i.e. FLAGS_foo)
|
||||
};
|
||||
|
||||
// Using this inside of a validator is a recipe for a deadlock.
|
||||
// TODO(user) Fix locking when validators are running, to make it safe to
|
||||
// call validators during ParseAllFlags.
|
||||
// Also make sure then to uncomment the corresponding unit test in
|
||||
// gflags_unittest.sh
|
||||
extern GFLAGS_DLL_DECL void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
|
||||
// These two are actually defined in gflags_reporting.cc.
|
||||
extern GFLAGS_DLL_DECL void ShowUsageWithFlags(const char *argv0); // what --help does
|
||||
extern GFLAGS_DLL_DECL void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
|
||||
|
||||
// Create a descriptive string for a flag.
|
||||
// Goes to some trouble to make pretty line breaks.
|
||||
extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
||||
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetArgv(int argc, const char** argv);
|
||||
|
||||
// The following functions are thread-safe as long as SetArgv() is
|
||||
// only called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const std::vector<std::string>& GetArgvs();
|
||||
extern GFLAGS_DLL_DECL const char* GetArgv(); // all of argv as a string
|
||||
extern GFLAGS_DLL_DECL const char* GetArgv0(); // only argv0
|
||||
extern GFLAGS_DLL_DECL uint32 GetArgvSum(); // simple checksum of argv
|
||||
extern GFLAGS_DLL_DECL const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
|
||||
extern GFLAGS_DLL_DECL const char* ProgramInvocationShortName(); // basename(argv0)
|
||||
|
||||
// ProgramUsage() is thread-safe as long as SetUsageMessage() is only
|
||||
// called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const char* ProgramUsage(); // string set by SetUsageMessage()
|
||||
|
||||
// VersionString() is thread-safe as long as SetVersionString() is only
|
||||
// called before any threads start.
|
||||
extern GFLAGS_DLL_DECL const char* VersionString(); // string set by SetVersionString()
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Normally you access commandline flags by just saying "if (FLAGS_foo)"
|
||||
// or whatever, and set them by calling "FLAGS_foo = bar" (or, more
|
||||
// commonly, via the DEFINE_foo macro). But if you need a bit more
|
||||
// control, we have programmatic ways to get/set the flags as well.
|
||||
// These programmatic ways to access flags are thread-safe, but direct
|
||||
// access is only thread-compatible.
|
||||
|
||||
// Return true iff the flagname was found.
|
||||
// OUTPUT is set to the flag's value, or unchanged if we return false.
|
||||
extern GFLAGS_DLL_DECL bool GetCommandLineOption(const char* name, std::string* OUTPUT);
|
||||
|
||||
// Return true iff the flagname was found. OUTPUT is set to the flag's
|
||||
// CommandLineFlagInfo or unchanged if we return false.
|
||||
extern GFLAGS_DLL_DECL bool GetCommandLineFlagInfo(const char* name, CommandLineFlagInfo* OUTPUT);
|
||||
|
||||
// Return the CommandLineFlagInfo of the flagname. exit() if name not found.
|
||||
// Example usage, to check if a flag's value is currently the default value:
|
||||
// if (GetCommandLineFlagInfoOrDie("foo").is_default) ...
|
||||
extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
||||
|
||||
enum GFLAGS_DLL_DECL FlagSettingMode {
|
||||
// update the flag's value (can call this multiple times).
|
||||
SET_FLAGS_VALUE,
|
||||
// update the flag's value, but *only if* it has not yet been updated
|
||||
// with SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef".
|
||||
SET_FLAG_IF_DEFAULT,
|
||||
// set the flag's default value to this. If the flag has not yet updated
|
||||
// yet (via SET_FLAGS_VALUE, SET_FLAG_IF_DEFAULT, or "FLAGS_xxx = nondef")
|
||||
// change the flag's current value to the new default value as well.
|
||||
SET_FLAGS_DEFAULT
|
||||
};
|
||||
|
||||
// Set a particular flag ("command line option"). Returns a string
|
||||
// describing the new value that the option has been set to. The
|
||||
// return value API is not well-specified, so basically just depend on
|
||||
// it to be empty if the setting failed for some reason -- the name is
|
||||
// not a valid flag name, or the value is not a valid value -- and
|
||||
// non-empty else.
|
||||
|
||||
// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
|
||||
extern GFLAGS_DLL_DECL std::string SetCommandLineOption (const char* name, const char* value);
|
||||
extern GFLAGS_DLL_DECL std::string SetCommandLineOptionWithMode(const char* name, const char* value, FlagSettingMode set_mode);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Saves the states (value, default value, whether the user has set
|
||||
// the flag, registered validators, etc) of all flags, and restores
|
||||
// them when the FlagSaver is destroyed. This is very useful in
|
||||
// tests, say, when you want to let your tests change the flags, but
|
||||
// make sure that they get reverted to the original states when your
|
||||
// test is complete.
|
||||
//
|
||||
// Example usage:
|
||||
// void TestFoo() {
|
||||
// FlagSaver s1;
|
||||
// FLAG_foo = false;
|
||||
// FLAG_bar = "some value";
|
||||
//
|
||||
// // test happens here. You can return at any time
|
||||
// // without worrying about restoring the FLAG values.
|
||||
// }
|
||||
//
|
||||
// Note: This class is marked with GFLAGS_ATTRIBUTE_UNUSED because all
|
||||
// the work is done in the constructor and destructor, so in the standard
|
||||
// usage example above, the compiler would complain that it's an
|
||||
// unused variable.
|
||||
//
|
||||
// This class is thread-safe. However, its destructor writes to
|
||||
// exactly the set of flags that have changed value during its
|
||||
// lifetime, so concurrent _direct_ access to those flags
|
||||
// (i.e. FLAGS_foo instead of {Get,Set}CommandLineOption()) is unsafe.
|
||||
|
||||
class GFLAGS_DLL_DECL FlagSaver {
|
||||
public:
|
||||
FlagSaver();
|
||||
~FlagSaver();
|
||||
|
||||
private:
|
||||
class FlagSaverImpl* impl_; // we use pimpl here to keep API steady
|
||||
|
||||
FlagSaver(const FlagSaver&); // no copying!
|
||||
void operator=(const FlagSaver&);
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Some deprecated or hopefully-soon-to-be-deprecated functions.
|
||||
|
||||
// This is often used for logging. TODO(csilvers): figure out a better way
|
||||
extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
|
||||
// Usually where this is used, a FlagSaver should be used instead.
|
||||
extern GFLAGS_DLL_DECL
|
||||
bool ReadFlagsFromString(const std::string& flagfilecontents,
|
||||
const char* prog_name,
|
||||
bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
|
||||
// These let you manually implement --flagfile functionality.
|
||||
// DEPRECATED.
|
||||
extern GFLAGS_DLL_DECL bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
|
||||
extern GFLAGS_DLL_DECL bool ReadFromFlagsFile(const std::string& filename, const char* prog_name, bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Useful routines for initializing flags from the environment.
|
||||
// In each case, if 'varname' does not exist in the environment
|
||||
// return defval. If 'varname' does exist but is not valid
|
||||
// (e.g., not a number for an int32 flag), abort with an error.
|
||||
// Otherwise, return the value. NOTE: for booleans, for true use
|
||||
// 't' or 'T' or 'true' or '1', for false 'f' or 'F' or 'false' or '0'.
|
||||
|
||||
extern GFLAGS_DLL_DECL bool BoolFromEnv(const char *varname, bool defval);
|
||||
extern GFLAGS_DLL_DECL int32 Int32FromEnv(const char *varname, int32 defval);
|
||||
extern GFLAGS_DLL_DECL int64 Int64FromEnv(const char *varname, int64 defval);
|
||||
extern GFLAGS_DLL_DECL uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
||||
extern GFLAGS_DLL_DECL double DoubleFromEnv(const char *varname, double defval);
|
||||
extern GFLAGS_DLL_DECL const char *StringFromEnv(const char *varname, const char *defval);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// The next two functions parse gflags from main():
|
||||
|
||||
// Set the "usage" message for this program. For example:
|
||||
// string usage("This program does nothing. Sample usage:\n");
|
||||
// usage += argv[0] + " <uselessarg1> <uselessarg2>";
|
||||
// SetUsageMessage(usage);
|
||||
// Do not include commandline flags in the usage: we do that for you!
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetUsageMessage(const std::string& usage);
|
||||
|
||||
// Sets the version string, which is emitted with --version.
|
||||
// For instance: SetVersionString("1.3");
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern GFLAGS_DLL_DECL void SetVersionString(const std::string& version);
|
||||
|
||||
|
||||
// Looks for flags in argv and parses them. Rearranges argv to put
|
||||
// flags first, or removes them entirely if remove_flags is true.
|
||||
// If a flag is defined more than once in the command line or flag
|
||||
// file, the last definition is used. Returns the index (into argv)
|
||||
// of the first non-flag argument.
|
||||
// See top-of-file for more details on this function.
|
||||
#ifndef SWIG // In swig, use ParseCommandLineFlagsScript() instead.
|
||||
extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
|
||||
#endif
|
||||
|
||||
|
||||
// Calls to ParseCommandLineNonHelpFlags and then to
|
||||
// HandleCommandLineHelpFlags can be used instead of a call to
|
||||
// ParseCommandLineFlags during initialization, in order to allow for
|
||||
// changing default values for some FLAGS (via
|
||||
// e.g. SetCommandLineOptionWithMode calls) between the time of
|
||||
// command line parsing and the time of dumping help information for
|
||||
// the flags as a result of command line parsing. If a flag is
|
||||
// defined more than once in the command line or flag file, the last
|
||||
// definition is used. Returns the index (into argv) of the first
|
||||
// non-flag argument. (If remove_flags is true, will always return 1.)
|
||||
extern GFLAGS_DLL_DECL uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv, bool remove_flags);
|
||||
|
||||
// This is actually defined in gflags_reporting.cc.
|
||||
// This function is misnamed (it also handles --version, etc.), but
|
||||
// it's too late to change that now. :-(
|
||||
extern GFLAGS_DLL_DECL void HandleCommandLineHelpFlags(); // in gflags_reporting.cc
|
||||
|
||||
// Allow command line reparsing. Disables the error normally
|
||||
// generated when an unknown flag is found, since it may be found in a
|
||||
// later parse. Thread-hostile; meant to be called before any threads
|
||||
// are spawned.
|
||||
extern GFLAGS_DLL_DECL void AllowCommandLineReparsing();
|
||||
|
||||
// Reparse the flags that have not yet been recognized. Only flags
|
||||
// registered since the last parse will be recognized. Any flag value
|
||||
// must be provided as part of the argument using "=", not as a
|
||||
// separate command line argument that follows the flag argument.
|
||||
// Intended for handling flags from dynamically loaded libraries,
|
||||
// since their flags are not registered until they are loaded.
|
||||
extern GFLAGS_DLL_DECL void ReparseCommandLineNonHelpFlags();
|
||||
|
||||
// Clean up memory allocated by flags. This is only needed to reduce
|
||||
// the quantity of "potentially leaked" reports emitted by memory
|
||||
// debugging tools such as valgrind. It is not required for normal
|
||||
// operation, or for the google perftools heap-checker. It must only
|
||||
// be called when the process is about to exit, and all threads that
|
||||
// might access flags are quiescent. Referencing flags after this is
|
||||
// called will have unexpected consequences. This is not safe to run
|
||||
// when multiple threads might be running: the function is
|
||||
// thread-hostile.
|
||||
extern GFLAGS_DLL_DECL void ShutDownCommandLineFlags();
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Now come the command line flag declaration/definition macros that
|
||||
// will actually be used. They're kind of hairy. A major reason
|
||||
// for this is initialization: we want people to be able to access
|
||||
// variables in global constructors and have that not crash, even if
|
||||
// their global constructor runs before the global constructor here.
|
||||
// (Obviously, we can't guarantee the flags will have the correct
|
||||
// default value in that case, but at least accessing them is safe.)
|
||||
// The only way to do that is have flags point to a static buffer.
|
||||
// So we make one, using a union to ensure proper alignment, and
|
||||
// then use placement-new to actually set up the flag with the
|
||||
// correct default value. In the same vein, we have to worry about
|
||||
// flag access in global destructors, so FlagRegisterer has to be
|
||||
// careful never to destroy the flag-values it constructs.
|
||||
//
|
||||
// Note that when we define a flag variable FLAGS_<name>, we also
|
||||
// preemptively define a junk variable, FLAGS_no<name>. This is to
|
||||
// cause a link-time error if someone tries to define 2 flags with
|
||||
// names like "logging" and "nologging". We do this because a bool
|
||||
// flag FLAG can be set from the command line to true with a "-FLAG"
|
||||
// argument, and to false with a "-noFLAG" argument, and so this can
|
||||
// potentially avert confusion.
|
||||
//
|
||||
// We also put flags into their own namespace. It is purposefully
|
||||
// named in an opaque way that people should have trouble typing
|
||||
// directly. The idea is that DEFINE puts the flag in the weird
|
||||
// namespace, and DECLARE imports the flag from there into the current
|
||||
// namespace. The net result is to force people to use DECLARE to get
|
||||
// access to a flag, rather than saying "extern GFLAGS_DLL_DECL bool FLAGS_whatever;"
|
||||
// or some such instead. We want this so we can put extra
|
||||
// functionality (like sanity-checking) in DECLARE if we want, and
|
||||
// make sure it is picked up everywhere.
|
||||
//
|
||||
// We also put the type of the variable in the namespace, so that
|
||||
// people can't DECLARE_int32 something that they DEFINE_bool'd
|
||||
// elsewhere.
|
||||
|
||||
class GFLAGS_DLL_DECL FlagRegisterer {
|
||||
public:
|
||||
FlagRegisterer(const char* name, const char* type,
|
||||
const char* help, const char* filename,
|
||||
void* current_storage, void* defvalue_storage);
|
||||
};
|
||||
|
||||
// If your application #defines STRIP_FLAG_HELP to a non-zero value
|
||||
// before #including this file, we remove the help message from the
|
||||
// binary file. This can reduce the size of the resulting binary
|
||||
// somewhat, and may also be useful for security reasons.
|
||||
|
||||
extern GFLAGS_DLL_DECL const char kStrippedFlagHelp[];
|
||||
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
||||
|
||||
#ifndef SWIG // In swig, ignore the main flag declarations
|
||||
|
||||
#if defined(STRIP_FLAG_HELP) && STRIP_FLAG_HELP > 0
|
||||
// Need this construct to avoid the 'defined but not used' warning.
|
||||
#define MAYBE_STRIPPED_HELP(txt) \
|
||||
(false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
|
||||
#else
|
||||
#define MAYBE_STRIPPED_HELP(txt) txt
|
||||
#endif
|
||||
|
||||
// Each command-line flag has two variables associated with it: one
|
||||
// with the current value, and one with the default value. However,
|
||||
// we have a third variable, which is where value is assigned; it's a
|
||||
// constant. This guarantees that FLAG_##value is initialized at
|
||||
// static initialization time (e.g. before program-start) rather than
|
||||
// than global construction time (which is after program-start but
|
||||
// before main), at least when 'value' is a compile-time constant. We
|
||||
// use a small trick for the "default value" variable, and call it
|
||||
// FLAGS_no<name>. This serves the second purpose of assuring a
|
||||
// compile error if someone tries to define a flag named no<name>
|
||||
// which is illegal (--foo and --nofoo both affect the "foo" flag).
|
||||
#define DEFINE_VARIABLE(type, shorttype, name, value, help) \
|
||||
namespace fL##shorttype { \
|
||||
static const type FLAGS_nono##name = value; \
|
||||
/* We always want to export defined variables, dll or no */ \
|
||||
GFLAGS_DLL_DEFINE_FLAG type FLAGS_##name = FLAGS_nono##name; \
|
||||
type FLAGS_no##name = FLAGS_nono##name; \
|
||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
||||
&FLAGS_##name, &FLAGS_no##name); \
|
||||
} \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
// For DEFINE_bool, we want to do the extra check that the passed-in
|
||||
// value is actually a bool, and not a string or something that can be
|
||||
// coerced to a bool. These declarations (no definition needed!) will
|
||||
// help us do that, and never evaluate From, which is important.
|
||||
// We'll use 'sizeof(IsBool(val))' to distinguish. This code requires
|
||||
// that the compiler have different sizes for bool & double. Since
|
||||
// this is not guaranteed by the standard, we check it with a
|
||||
// COMPILE_ASSERT.
|
||||
namespace fLB {
|
||||
struct CompileAssert {};
|
||||
typedef CompileAssert expected_sizeof_double_neq_sizeof_bool[
|
||||
(sizeof(double) != sizeof(bool)) ? 1 : -1];
|
||||
template<typename From> double GFLAGS_DLL_DECL IsBoolFlag(const From& from);
|
||||
GFLAGS_DLL_DECL bool IsBoolFlag(bool from);
|
||||
} // namespace fLB
|
||||
|
||||
// Here are the actual DEFINE_*-macros. The respective DECLARE_*-macros
|
||||
// are in a separate include, gflags_declare.h, for reducing
|
||||
// the physical transitive size for DECLARE use.
|
||||
#define DEFINE_bool(name, val, txt) \
|
||||
namespace fLB { \
|
||||
typedef ::fLB::CompileAssert FLAG_##name##_value_is_not_a_bool[ \
|
||||
(sizeof(::fLB::IsBoolFlag(val)) != sizeof(double))? 1: -1]; \
|
||||
} \
|
||||
DEFINE_VARIABLE(bool, B, name, val, txt)
|
||||
|
||||
#define DEFINE_int32(name, val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_int64(name, val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int64, I64, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_uint64(name,val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint64, U64, \
|
||||
name, val, txt)
|
||||
|
||||
#define DEFINE_double(name, val, txt) \
|
||||
DEFINE_VARIABLE(double, D, name, val, txt)
|
||||
|
||||
// Strings are trickier, because they're not a POD, so we can't
|
||||
// construct them at static-initialization time (instead they get
|
||||
// constructed at global-constructor time, which is much later). To
|
||||
// try to avoid crashes in that case, we use a char buffer to store
|
||||
// the string, which we can static-initialize, and then placement-new
|
||||
// into it later. It's not perfect, but the best we can do.
|
||||
|
||||
namespace fLS {
|
||||
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
const char *value) {
|
||||
return new(stringspot) clstring(value);
|
||||
}
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
const clstring &value) {
|
||||
return new(stringspot) clstring(value);
|
||||
}
|
||||
inline clstring* dont_pass0toDEFINE_string(char *stringspot,
|
||||
int value);
|
||||
} // namespace fLS
|
||||
|
||||
// We need to define a var named FLAGS_no##name so people don't define
|
||||
// --string and --nostring. And we need a temporary place to put val
|
||||
// so we don't have to evaluate it twice. Two great needs that go
|
||||
// great together!
|
||||
// The weird 'using' + 'extern' inside the fLS namespace is to work around
|
||||
// an unknown compiler bug/issue with the gcc 4.2.1 on SUSE 10. See
|
||||
// http://code.google.com/p/google-gflags/issues/detail?id=20
|
||||
#define DEFINE_string(name, val, txt) \
|
||||
namespace fLS { \
|
||||
using ::fLS::clstring; \
|
||||
static union { void* align; char s[sizeof(clstring)]; } s_##name[2]; \
|
||||
clstring* const FLAGS_no##name = ::fLS:: \
|
||||
dont_pass0toDEFINE_string(s_##name[0].s, \
|
||||
val); \
|
||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
||||
s_##name[0].s, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
||||
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
||||
using fLS::FLAGS_##name; \
|
||||
clstring& FLAGS_##name = *FLAGS_no##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
#endif // SWIG
|
||||
|
||||
|
||||
// Import gflags library symbols into alternative/deprecated namespace(s)
|
||||
#include "gflags_gflags.h"
|
||||
|
||||
|
||||
#endif // GFLAGS_GFLAGS_H_
|
||||
@ -1,121 +0,0 @@
|
||||
// Copyright (c) 2008, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---
|
||||
|
||||
//
|
||||
// Implement helpful bash-style command line flag completions
|
||||
//
|
||||
// ** Functional API:
|
||||
// HandleCommandLineCompletions() should be called early during
|
||||
// program startup, but after command line flag code has been
|
||||
// initialized, such as the beginning of HandleCommandLineHelpFlags().
|
||||
// It checks the value of the flag --tab_completion_word. If this
|
||||
// flag is empty, nothing happens here. If it contains a string,
|
||||
// however, then HandleCommandLineCompletions() will hijack the
|
||||
// process, attempting to identify the intention behind this
|
||||
// completion. Regardless of the outcome of this deduction, the
|
||||
// process will be terminated, similar to --helpshort flag
|
||||
// handling.
|
||||
//
|
||||
// ** Overview of Bash completions:
|
||||
// Bash can be told to programatically determine completions for the
|
||||
// current 'cursor word'. It does this by (in this case) invoking a
|
||||
// command with some additional arguments identifying the command
|
||||
// being executed, the word being completed, and the previous word
|
||||
// (if any). Bash then expects a sequence of output lines to be
|
||||
// printed to stdout. If these lines all contain a common prefix
|
||||
// longer than the cursor word, bash will replace the cursor word
|
||||
// with that common prefix, and display nothing. If there isn't such
|
||||
// a common prefix, bash will display the lines in pages using 'more'.
|
||||
//
|
||||
// ** Strategy taken for command line completions:
|
||||
// If we can deduce either the exact flag intended, or a common flag
|
||||
// prefix, we'll output exactly that. Otherwise, if information
|
||||
// must be displayed to the user, we'll take the opportunity to add
|
||||
// some helpful information beyond just the flag name (specifically,
|
||||
// we'll include the default flag value and as much of the flag's
|
||||
// description as can fit on a single terminal line width, as specified
|
||||
// by the flag --tab_completion_columns). Furthermore, we'll try to
|
||||
// make bash order the output such that the most useful or relevent
|
||||
// flags are the most likely to be shown at the top.
|
||||
//
|
||||
// ** Additional features:
|
||||
// To assist in finding that one really useful flag, substring matching
|
||||
// was implemented. Before pressing a <TAB> to get completion for the
|
||||
// current word, you can append one or more '?' to the flag to do
|
||||
// substring matching. Here's the semantics:
|
||||
// --foo<TAB> Show me all flags with names prefixed by 'foo'
|
||||
// --foo?<TAB> Show me all flags with 'foo' somewhere in the name
|
||||
// --foo??<TAB> Same as prior case, but also search in module
|
||||
// definition path for 'foo'
|
||||
// --foo???<TAB> Same as prior case, but also search in flag
|
||||
// descriptions for 'foo'
|
||||
// Finally, we'll trim the output to a relatively small number of
|
||||
// flags to keep bash quiet about the verbosity of output. If one
|
||||
// really wanted to see all possible matches, appending a '+' to the
|
||||
// search word will force the exhaustive list of matches to be printed.
|
||||
//
|
||||
// ** How to have bash accept completions from a binary:
|
||||
// Bash requires that it be informed about each command that programmatic
|
||||
// completion should be enabled for. Example addition to a .bashrc
|
||||
// file would be (your path to gflags_completions.sh file may differ):
|
||||
|
||||
/*
|
||||
$ complete -o bashdefault -o default -o nospace -C \
|
||||
'/home/build/eng/bash/bash_completions.sh --tab_completion_columns $COLUMNS' \
|
||||
time env binary_name another_binary [...]
|
||||
*/
|
||||
|
||||
// This would allow the following to work:
|
||||
// $ /path/to/binary_name --vmodule<TAB>
|
||||
// Or:
|
||||
// $ ./bin/path/another_binary --gfs_u<TAB>
|
||||
// (etc)
|
||||
//
|
||||
// Sadly, it appears that bash gives no easy way to force this behavior for
|
||||
// all commands. That's where the "time" in the above example comes in.
|
||||
// If you haven't specifically added a command to the list of completion
|
||||
// supported commands, you can still get completions by prefixing the
|
||||
// entire command with "env".
|
||||
// $ env /some/brand/new/binary --vmod<TAB>
|
||||
// Assuming that "binary" is a newly compiled binary, this should still
|
||||
// produce the expected completion output.
|
||||
|
||||
|
||||
#ifndef GFLAGS_COMPLETIONS_H_
|
||||
#define GFLAGS_COMPLETIONS_H_
|
||||
|
||||
namespace google {
|
||||
|
||||
extern void HandleCommandLineCompletions(void);
|
||||
|
||||
}
|
||||
|
||||
#endif // GFLAGS_COMPLETIONS_H_
|
||||
@ -1,141 +0,0 @@
|
||||
// Copyright (c) 1999, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
//
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This is the file that should be included by any file which declares
|
||||
// command line flag.
|
||||
|
||||
#ifndef GFLAGS_DECLARE_H_
|
||||
#define GFLAGS_DECLARE_H_
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Namespace of gflags library symbols.
|
||||
#define GFLAGS_NAMESPACE google
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows DLL import/export.
|
||||
|
||||
// We always want to import the symbols of the gflags library
|
||||
#ifndef GFLAGS_DLL_DECL
|
||||
# if 0 && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL __declspec(dllimport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// We always want to import variables declared in user code
|
||||
#ifndef GFLAGS_DLL_DECLARE_FLAG
|
||||
# ifdef _MSC_VER
|
||||
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECLARE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Flag types
|
||||
#include <string>
|
||||
#if 1
|
||||
# include <stdint.h> // the normal place uint32_t is defined
|
||||
#elif 1
|
||||
# include <sys/types.h> // the normal place u_int32_t is defined
|
||||
#elif 0
|
||||
# include <inttypes.h> // a third place for uint32_t or u_int32_t
|
||||
#endif
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
#if 0 // C99
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#elif 0 // BSD
|
||||
typedef int32_t int32;
|
||||
typedef u_int32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef u_int64_t uint64;
|
||||
#elif 1 // Windows
|
||||
typedef __int32 int32;
|
||||
typedef unsigned __int32 uint32;
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#else
|
||||
# error Do not know how to define a 32-bit integer quantity on your system
|
||||
#endif
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
||||
|
||||
namespace fLS {
|
||||
|
||||
// The meaning of "string" might be different between now and when the
|
||||
// macros below get invoked (e.g., if someone is experimenting with
|
||||
// other string implementations that get defined after this file is
|
||||
// included). Save the current meaning now and use it in the macros.
|
||||
typedef std::string clstring;
|
||||
|
||||
} // namespace fLS
|
||||
|
||||
|
||||
#define DECLARE_VARIABLE(type, shorttype, name) \
|
||||
/* We always want to import declared variables, dll or no */ \
|
||||
namespace fL##shorttype { extern GFLAGS_DLL_DECLARE_FLAG type FLAGS_##name; } \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
#define DECLARE_bool(name) \
|
||||
DECLARE_VARIABLE(bool, B, name)
|
||||
|
||||
#define DECLARE_int32(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int32, I, name)
|
||||
|
||||
#define DECLARE_int64(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::int64, I64, name)
|
||||
|
||||
#define DECLARE_uint64(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint64, U64, name)
|
||||
|
||||
#define DECLARE_double(name) \
|
||||
DECLARE_VARIABLE(double, D, name)
|
||||
|
||||
#define DECLARE_string(name) \
|
||||
/* We always want to import declared variables, dll or no */ \
|
||||
namespace fLS { \
|
||||
using ::fLS::clstring; \
|
||||
extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
|
||||
#endif // GFLAGS_DECLARE_H_
|
||||
@ -1,101 +0,0 @@
|
||||
// Copyright (c) 2014, Andreas Schuh
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Imports the gflags library symbols into an alternative/deprecated namespace.
|
||||
|
||||
#ifndef GFLAGS_GFLAGS_H_
|
||||
# error The internal header gflags_gflags.h may only be included by gflags.h
|
||||
#endif
|
||||
|
||||
#ifndef GFLAGS_NS_GFLAGS_H_
|
||||
#define GFLAGS_NS_GFLAGS_H_
|
||||
|
||||
|
||||
namespace gflags {
|
||||
|
||||
|
||||
using GFLAGS_NAMESPACE::int32;
|
||||
using GFLAGS_NAMESPACE::uint32;
|
||||
using GFLAGS_NAMESPACE::int64;
|
||||
using GFLAGS_NAMESPACE::uint64;
|
||||
|
||||
using GFLAGS_NAMESPACE::RegisterFlagValidator;
|
||||
using GFLAGS_NAMESPACE::CommandLineFlagInfo;
|
||||
using GFLAGS_NAMESPACE::GetAllFlags;
|
||||
using GFLAGS_NAMESPACE::ShowUsageWithFlags;
|
||||
using GFLAGS_NAMESPACE::ShowUsageWithFlagsRestrict;
|
||||
using GFLAGS_NAMESPACE::DescribeOneFlag;
|
||||
using GFLAGS_NAMESPACE::SetArgv;
|
||||
using GFLAGS_NAMESPACE::GetArgvs;
|
||||
using GFLAGS_NAMESPACE::GetArgv;
|
||||
using GFLAGS_NAMESPACE::GetArgv0;
|
||||
using GFLAGS_NAMESPACE::GetArgvSum;
|
||||
using GFLAGS_NAMESPACE::ProgramInvocationName;
|
||||
using GFLAGS_NAMESPACE::ProgramInvocationShortName;
|
||||
using GFLAGS_NAMESPACE::ProgramUsage;
|
||||
using GFLAGS_NAMESPACE::VersionString;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineOption;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineFlagInfo;
|
||||
using GFLAGS_NAMESPACE::GetCommandLineFlagInfoOrDie;
|
||||
using GFLAGS_NAMESPACE::FlagSettingMode;
|
||||
using GFLAGS_NAMESPACE::SET_FLAGS_VALUE;
|
||||
using GFLAGS_NAMESPACE::SET_FLAG_IF_DEFAULT;
|
||||
using GFLAGS_NAMESPACE::SET_FLAGS_DEFAULT;
|
||||
using GFLAGS_NAMESPACE::SetCommandLineOption;
|
||||
using GFLAGS_NAMESPACE::SetCommandLineOptionWithMode;
|
||||
using GFLAGS_NAMESPACE::FlagSaver;
|
||||
using GFLAGS_NAMESPACE::CommandlineFlagsIntoString;
|
||||
using GFLAGS_NAMESPACE::ReadFlagsFromString;
|
||||
using GFLAGS_NAMESPACE::AppendFlagsIntoFile;
|
||||
using GFLAGS_NAMESPACE::ReadFromFlagsFile;
|
||||
using GFLAGS_NAMESPACE::BoolFromEnv;
|
||||
using GFLAGS_NAMESPACE::Int32FromEnv;
|
||||
using GFLAGS_NAMESPACE::Int64FromEnv;
|
||||
using GFLAGS_NAMESPACE::Uint64FromEnv;
|
||||
using GFLAGS_NAMESPACE::DoubleFromEnv;
|
||||
using GFLAGS_NAMESPACE::StringFromEnv;
|
||||
using GFLAGS_NAMESPACE::SetUsageMessage;
|
||||
using GFLAGS_NAMESPACE::SetVersionString;
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineNonHelpFlags;
|
||||
using GFLAGS_NAMESPACE::HandleCommandLineHelpFlags;
|
||||
using GFLAGS_NAMESPACE::AllowCommandLineReparsing;
|
||||
using GFLAGS_NAMESPACE::ReparseCommandLineNonHelpFlags;
|
||||
using GFLAGS_NAMESPACE::ShutDownCommandLineFlags;
|
||||
using GFLAGS_NAMESPACE::FlagRegisterer;
|
||||
|
||||
#ifndef SWIG
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineFlags;
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace gflags
|
||||
|
||||
|
||||
#endif // GFLAGS_NS_GFLAGS_H_
|
||||
112
third_party/gflags/gen/win/include/private/config.h
vendored
112
third_party/gflags/gen/win/include/private/config.h
vendored
@ -1,112 +0,0 @@
|
||||
/* Generated from config.h.in during build configuration using CMake. */
|
||||
|
||||
// Note: This header file is only used internally. It is not part of public interface!
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// System checks
|
||||
|
||||
// Define if you build this library for a MS Windows OS.
|
||||
#define OS_WINDOWS
|
||||
|
||||
// Define if you have the <stdint.h> header file.
|
||||
#define HAVE_STDINT_H
|
||||
|
||||
// Define if you have the <sys/types.h> header file.
|
||||
#define HAVE_SYS_TYPES_H
|
||||
|
||||
// Define if you have the <inttypes.h> header file.
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
// Define if you have the <sys/stat.h> header file.
|
||||
#define HAVE_SYS_STAT_H
|
||||
|
||||
// Define if you have the <unistd.h> header file.
|
||||
/* #undef HAVE_UNISTD_H */
|
||||
|
||||
// Define if you have the <fnmatch.h> header file.
|
||||
/* #undef HAVE_FNMATCH_H */
|
||||
|
||||
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
|
||||
#define HAVE_SHLWAPI_H
|
||||
|
||||
// Define if you have the strtoll function.
|
||||
/* #undef HAVE_STRTOLL */
|
||||
|
||||
// Define if you have the strtoq function.
|
||||
/* #undef HAVE_STRTOQ */
|
||||
|
||||
// Define if you have the <pthread.h> header file.
|
||||
/* #undef HAVE_PTHREAD */
|
||||
|
||||
// Define if your pthread library defines the type pthread_rwlock_t
|
||||
/* #undef HAVE_RWLOCK */
|
||||
|
||||
// gcc requires this to get PRId64, etc.
|
||||
#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
|
||||
# define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Package information
|
||||
|
||||
// Name of package.
|
||||
#define PACKAGE gflags
|
||||
|
||||
// Define to the full name of this package.
|
||||
#define PACKAGE_NAME gflags
|
||||
|
||||
// Define to the full name and version of this package.
|
||||
#define PACKAGE_STRING gflags 2.2.0
|
||||
|
||||
// Define to the one symbol short name of this package.
|
||||
#define PACKAGE_TARNAME gflags-2.2.0
|
||||
|
||||
// Define to the version of this package.
|
||||
#define PACKAGE_VERSION 2.2.0
|
||||
|
||||
// Version number of package.
|
||||
#define VERSION PACKAGE_VERSION
|
||||
|
||||
// Define to the address where bug reports for this package should be sent.
|
||||
#define PACKAGE_BUGREPORT https://github.com/schuhschuh/gflags/issues
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Path separator
|
||||
#ifndef PATH_SEPARATOR
|
||||
# ifdef OS_WINDOWS
|
||||
# define PATH_SEPARATOR '\\'
|
||||
# else
|
||||
# define PATH_SEPARATOR '/'
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows
|
||||
|
||||
// Whether gflags library is a DLL.
|
||||
#ifndef GFLAGS_IS_A_DLL
|
||||
# define GFLAGS_IS_A_DLL 0
|
||||
#endif
|
||||
|
||||
// Always export symbols when compiling a shared library as this file is only
|
||||
// included by internal modules when building the gflags library itself.
|
||||
// The gflags_declare.h header file will set it to import these symbols otherwise.
|
||||
#ifndef GFLAGS_DLL_DECL
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DECL
|
||||
# endif
|
||||
#endif
|
||||
// Flags defined by the gflags library itself must be exported
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
# define GFLAGS_DLL_DEFINE_FLAG GFLAGS_DLL_DECL
|
||||
#endif
|
||||
|
||||
#ifdef OS_WINDOWS
|
||||
// The unittests import the symbols of the shared gflags library
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
|
||||
# endif
|
||||
# include "windows_port.h"
|
||||
#endif
|
||||
92
third_party/gflags/gflags.gyp
vendored
92
third_party/gflags/gflags.gyp
vendored
@ -1,92 +0,0 @@
|
||||
#
|
||||
# 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 is a copy of WebRTC's gflags.gyp.
|
||||
|
||||
{
|
||||
'variables': {
|
||||
'gflags_root': '<(DEPTH)/third_party/gflags',
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'gflags_gen_arch_root': '<(gflags_root)/gen/win',
|
||||
}, {
|
||||
'gflags_gen_arch_root': '<(gflags_root)/gen/posix',
|
||||
}],
|
||||
],
|
||||
},
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'gflags',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
'<(gflags_gen_arch_root)/include/gflags', # For configured files.
|
||||
'<(gflags_gen_arch_root)/include/private', # For config.h
|
||||
'<(gflags_root)/src/src', # For everything else.
|
||||
],
|
||||
'defines': [
|
||||
# These macros exist so flags and symbols are properly
|
||||
# exported when building DLLs. Since we don't build DLLs, we
|
||||
# need to disable them.
|
||||
'GFLAGS_DLL_DECL=',
|
||||
'GFLAGS_DLL_DECLARE_FLAG=',
|
||||
'GFLAGS_DLL_DEFINE_FLAG=',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'<(gflags_gen_arch_root)/include', # For configured files.
|
||||
'<(gflags_root)/src/src', # For everything else.
|
||||
],
|
||||
'defines': [
|
||||
'GFLAGS_DLL_DECL=',
|
||||
'GFLAGS_DLL_DECLARE_FLAG=',
|
||||
'GFLAGS_DLL_DEFINE_FLAG=',
|
||||
],
|
||||
},
|
||||
'sources': [
|
||||
'src/src/gflags.cc',
|
||||
'src/src/gflags_completions.cc',
|
||||
'src/src/gflags_reporting.cc',
|
||||
],
|
||||
'conditions': [
|
||||
['OS=="win"', {
|
||||
'sources': [
|
||||
'src/src/windows_port.cc',
|
||||
],
|
||||
'msvs_disabled_warnings': [
|
||||
4005, # WIN32_LEAN_AND_MEAN redefinition.
|
||||
4267, # Conversion from size_t to "type".
|
||||
],
|
||||
'configurations': {
|
||||
'Common_Base': {
|
||||
'msvs_configuration_attributes': {
|
||||
'CharacterSet': '2', # Use Multi-byte Character Set.
|
||||
},
|
||||
},
|
||||
},
|
||||
}],
|
||||
# TODO(andrew): Look into fixing this warning upstream:
|
||||
# http://code.google.com/p/webrtc/issues/detail?id=760
|
||||
['OS=="win" and clang==1', {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'AdditionalOptions': [
|
||||
'-Wno-microsoft-include',
|
||||
],
|
||||
},
|
||||
},
|
||||
}],
|
||||
['clang==1', {
|
||||
'cflags': [
|
||||
'-Wno-microsoft-include',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
This is a dummy configuration file to workaround the assumption of the grit
|
||||
resource file being located here in the Chromium build toolchain.
|
||||
|
||||
This is only needed for our Android native tests to be able to include the
|
||||
build/apk_test.gypi GYP file and depend on the
|
||||
<(DEPTH)/testing/android/native_test.gyp:native_test_native_code target in
|
||||
Chromium.
|
||||
@ -1,15 +0,0 @@
|
||||
# Copyright (c) 2015 The WebRTC 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.
|
||||
|
||||
{
|
||||
"SRCDIR": "../..",
|
||||
|
||||
"chromium/src/net/base/net_resources.grd": {
|
||||
"includes": [4000],
|
||||
},
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
*
|
||||
@ -1,41 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright (c) 2012 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.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
"""
|
||||
Copied from Chrome's src/tools/valgrind/tsan/PRESUBMIT.py
|
||||
|
||||
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
|
||||
for more details on the presubmit API built into gcl.
|
||||
"""
|
||||
|
||||
def CheckChange(input_api, output_api):
|
||||
"""Checks the TSan suppressions files for bad suppressions."""
|
||||
|
||||
# Add the path to the Chrome valgrind dir to the import path:
|
||||
tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..',
|
||||
'valgrind')
|
||||
sys.path.append(tools_vg_path)
|
||||
import suppressions
|
||||
|
||||
return suppressions.PresubmitCheck(input_api, output_api)
|
||||
|
||||
def CheckChangeOnUpload(input_api, output_api):
|
||||
return CheckChange(input_api, output_api)
|
||||
|
||||
def CheckChangeOnCommit(input_api, output_api):
|
||||
return CheckChange(input_api, output_api)
|
||||
|
||||
def GetPreferredTrySlaves():
|
||||
# We don't have any tsan slaves yet, so there's no use for this method.
|
||||
# When we have, the slave name(s) should be put into this list.
|
||||
return []
|
||||
@ -1,5 +0,0 @@
|
||||
# This file is used in addition to the one already maintained in Chrome.
|
||||
# It acts as a place holder for future additions for this project.
|
||||
# It must exist for the Python wrapper script to work properly.
|
||||
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
# This file is used in addition to the one already maintained in Chrome.
|
||||
# It acts as a place holder for future additions for this project.
|
||||
# It must exist for the Python wrapper script to work properly.
|
||||
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
# This file is used in addition to the one already maintained in Chrome.
|
||||
# It acts as a place holder for future additions for this project.
|
||||
# It must exist for the Python wrapper script to work properly.
|
||||
|
||||
|
||||
482
tools_libyuv/autoroller/roll_deps.py
Executable file
482
tools_libyuv/autoroller/roll_deps.py
Executable file
@ -0,0 +1,482 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 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 is a modified copy of the script in
|
||||
# https://chromium.googlesource.com/external/webrtc/+/master/tools-webrtc/autoroller/roll_deps.py
|
||||
# customized for libyuv.
|
||||
|
||||
|
||||
"""Script to automatically roll dependencies in the libyuv DEPS file."""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import collections
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib
|
||||
|
||||
|
||||
# Skip these dependencies (list without solution name prefix).
|
||||
DONT_AUTOROLL_THESE = [
|
||||
'src/third_party/gflags/src',
|
||||
]
|
||||
|
||||
LIBYUV_URL = 'https://chromium.googlesource.com/libyuv/libyuv'
|
||||
CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src'
|
||||
CHROMIUM_COMMIT_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s'
|
||||
CHROMIUM_LOG_TEMPLATE = CHROMIUM_SRC_URL + '/+log/%s'
|
||||
CHROMIUM_FILE_TEMPLATE = CHROMIUM_SRC_URL + '/+/%s/%s'
|
||||
|
||||
COMMIT_POSITION_RE = re.compile('^Cr-Commit-Position: .*#([0-9]+).*$')
|
||||
CLANG_REVISION_RE = re.compile(r'^CLANG_REVISION = \'(\d+)\'$')
|
||||
ROLL_BRANCH_NAME = 'roll_chromium_revision'
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
CHECKOUT_SRC_DIR = os.path.realpath(os.path.join(SCRIPT_DIR, os.pardir,
|
||||
os.pardir))
|
||||
CHECKOUT_ROOT_DIR = os.path.realpath(os.path.join(CHECKOUT_SRC_DIR, os.pardir))
|
||||
|
||||
sys.path.append(os.path.join(CHECKOUT_SRC_DIR, 'build'))
|
||||
import find_depot_tools
|
||||
find_depot_tools.add_depot_tools_to_path()
|
||||
from gclient import GClientKeywords
|
||||
|
||||
CLANG_UPDATE_SCRIPT_URL_PATH = 'tools/clang/scripts/update.py'
|
||||
CLANG_UPDATE_SCRIPT_LOCAL_PATH = os.path.join(CHECKOUT_SRC_DIR, 'tools',
|
||||
'clang', 'scripts', 'update.py')
|
||||
|
||||
DepsEntry = collections.namedtuple('DepsEntry', 'path url revision')
|
||||
ChangedDep = collections.namedtuple('ChangedDep',
|
||||
'path url current_rev new_rev')
|
||||
|
||||
class RollError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def ParseDepsDict(deps_content):
|
||||
local_scope = {}
|
||||
var = GClientKeywords.VarImpl({}, local_scope)
|
||||
global_scope = {
|
||||
'From': GClientKeywords.FromImpl,
|
||||
'Var': var.Lookup,
|
||||
'deps_os': {},
|
||||
}
|
||||
exec(deps_content, global_scope, local_scope)
|
||||
return local_scope
|
||||
|
||||
|
||||
def ParseLocalDepsFile(filename):
|
||||
with open(filename, 'rb') as f:
|
||||
deps_content = f.read()
|
||||
return ParseDepsDict(deps_content)
|
||||
|
||||
|
||||
def ParseRemoteCrDepsFile(revision):
|
||||
deps_content = ReadRemoteCrFile('DEPS', revision)
|
||||
return ParseDepsDict(deps_content)
|
||||
|
||||
|
||||
def ParseCommitPosition(commit_message):
|
||||
for line in reversed(commit_message.splitlines()):
|
||||
m = COMMIT_POSITION_RE.match(line.strip())
|
||||
if m:
|
||||
return m.group(1)
|
||||
logging.error('Failed to parse commit position id from:\n%s\n',
|
||||
commit_message)
|
||||
sys.exit(-1)
|
||||
|
||||
|
||||
def _RunCommand(command, working_dir=None, ignore_exit_code=False,
|
||||
extra_env=None):
|
||||
"""Runs a command and returns the output from that command.
|
||||
|
||||
If the command fails (exit code != 0), the function will exit the process.
|
||||
|
||||
Returns:
|
||||
A tuple containing the stdout and stderr outputs as strings.
|
||||
"""
|
||||
working_dir = working_dir or CHECKOUT_SRC_DIR
|
||||
logging.debug('CMD: %s CWD: %s', ' '.join(command), working_dir)
|
||||
env = os.environ.copy()
|
||||
if extra_env:
|
||||
assert all(type(value) == str for value in extra_env.values())
|
||||
logging.debug('extra env: %s', extra_env)
|
||||
env.update(extra_env)
|
||||
p = subprocess.Popen(command, stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE, env=env,
|
||||
cwd=working_dir, universal_newlines=True)
|
||||
std_output = p.stdout.read()
|
||||
err_output = p.stderr.read()
|
||||
p.wait()
|
||||
p.stdout.close()
|
||||
p.stderr.close()
|
||||
if not ignore_exit_code and p.returncode != 0:
|
||||
logging.error('Command failed: %s\n'
|
||||
'stdout:\n%s\n'
|
||||
'stderr:\n%s\n', ' '.join(command), std_output, err_output)
|
||||
sys.exit(p.returncode)
|
||||
return std_output, err_output
|
||||
|
||||
|
||||
def _GetBranches():
|
||||
"""Returns a tuple of active,branches.
|
||||
|
||||
The 'active' is the name of the currently active branch and 'branches' is a
|
||||
list of all branches.
|
||||
"""
|
||||
lines = _RunCommand(['git', 'branch'])[0].split('\n')
|
||||
branches = []
|
||||
active = ''
|
||||
for line in lines:
|
||||
if '*' in line:
|
||||
# The assumption is that the first char will always be the '*'.
|
||||
active = line[1:].strip()
|
||||
branches.append(active)
|
||||
else:
|
||||
branch = line.strip()
|
||||
if branch:
|
||||
branches.append(branch)
|
||||
return active, branches
|
||||
|
||||
|
||||
def _ReadGitilesContent(url):
|
||||
# Download and decode BASE64 content until
|
||||
# https://code.google.com/p/gitiles/issues/detail?id=7 is fixed.
|
||||
base64_content = ReadUrlContent(url + '?format=TEXT')
|
||||
return base64.b64decode(base64_content[0])
|
||||
|
||||
|
||||
def ReadRemoteCrFile(path_below_src, revision):
|
||||
"""Reads a remote Chromium file of a specific revision. Returns a string."""
|
||||
return _ReadGitilesContent(CHROMIUM_FILE_TEMPLATE % (revision,
|
||||
path_below_src))
|
||||
|
||||
|
||||
def ReadRemoteCrCommit(revision):
|
||||
"""Reads a remote Chromium commit message. Returns a string."""
|
||||
return _ReadGitilesContent(CHROMIUM_COMMIT_TEMPLATE % revision)
|
||||
|
||||
|
||||
def ReadUrlContent(url):
|
||||
"""Connect to a remote host and read the contents. Returns a list of lines."""
|
||||
conn = urllib.urlopen(url)
|
||||
try:
|
||||
return conn.readlines()
|
||||
except IOError as e:
|
||||
logging.exception('Error connecting to %s. Error: %s', url, e)
|
||||
raise
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
def GetMatchingDepsEntries(depsentry_dict, dir_path):
|
||||
"""Gets all deps entries matching the provided path.
|
||||
|
||||
This list may contain more than one DepsEntry object.
|
||||
Example: dir_path='src/testing' would give results containing both
|
||||
'src/testing/gtest' and 'src/testing/gmock' deps entries for Chromium's DEPS.
|
||||
Example 2: dir_path='src/build' should return 'src/build' but not
|
||||
'src/buildtools'.
|
||||
|
||||
Returns:
|
||||
A list of DepsEntry objects.
|
||||
"""
|
||||
result = []
|
||||
for path, depsentry in depsentry_dict.iteritems():
|
||||
if path == dir_path:
|
||||
result.append(depsentry)
|
||||
else:
|
||||
parts = path.split('/')
|
||||
if all(part == parts[i]
|
||||
for i, part in enumerate(dir_path.split('/'))):
|
||||
result.append(depsentry)
|
||||
return result
|
||||
|
||||
|
||||
def BuildDepsentryDict(deps_dict):
|
||||
"""Builds a dict of paths to DepsEntry objects from a raw parsed deps dict."""
|
||||
result = {}
|
||||
def AddDepsEntries(deps_subdict):
|
||||
for path, deps_url in deps_subdict.iteritems():
|
||||
if not result.has_key(path):
|
||||
url, revision = deps_url.split('@') if deps_url else (None, None)
|
||||
result[path] = DepsEntry(path, url, revision)
|
||||
|
||||
AddDepsEntries(deps_dict['deps'])
|
||||
for deps_os in ['win', 'mac', 'unix', 'android', 'ios', 'unix']:
|
||||
AddDepsEntries(deps_dict.get('deps_os', {}).get(deps_os, {}))
|
||||
return result
|
||||
|
||||
|
||||
def CalculateChangedDeps(libyuv_deps, new_cr_deps):
|
||||
"""
|
||||
Calculate changed deps entries based on entries defined in the libyuv DEPS
|
||||
file:
|
||||
- If a shared dependency with the Chromium DEPS file: roll it to the same
|
||||
revision as Chromium (i.e. entry in the new_cr_deps dict)
|
||||
- If it's a Chromium sub-directory, roll it to the HEAD revision (notice
|
||||
this means it may be ahead of the chromium_revision, but generally these
|
||||
should be close).
|
||||
- If it's another DEPS entry (not shared with Chromium), roll it to HEAD
|
||||
unless it's configured to be skipped.
|
||||
|
||||
Returns:
|
||||
A list of ChangedDep objects representing the changed deps.
|
||||
"""
|
||||
result = []
|
||||
libyuv_entries = BuildDepsentryDict(libyuv_deps)
|
||||
new_cr_entries = BuildDepsentryDict(new_cr_deps)
|
||||
for path, libyuv_deps_entry in libyuv_entries.iteritems():
|
||||
if path in DONT_AUTOROLL_THESE:
|
||||
continue
|
||||
cr_deps_entry = new_cr_entries.get(path)
|
||||
if cr_deps_entry:
|
||||
# Use the revision from Chromium's DEPS file.
|
||||
new_rev = cr_deps_entry.revision
|
||||
assert libyuv_deps_entry.url == cr_deps_entry.url, (
|
||||
'Libyuv DEPS entry %s has a different URL (%s) than Chromium (%s).' %
|
||||
(path, libyuv_deps_entry.url, cr_deps_entry.url))
|
||||
else:
|
||||
# Use the HEAD of the deps repo.
|
||||
stdout, _ = _RunCommand(['git', 'ls-remote', libyuv_deps_entry.url,
|
||||
'HEAD'])
|
||||
new_rev = stdout.strip().split('\t')[0]
|
||||
|
||||
# Check if an update is necessary.
|
||||
if libyuv_deps_entry.revision != new_rev:
|
||||
logging.debug('Roll dependency %s to %s', path, new_rev)
|
||||
result.append(ChangedDep(path, libyuv_deps_entry.url,
|
||||
libyuv_deps_entry.revision, new_rev))
|
||||
return sorted(result)
|
||||
|
||||
|
||||
def CalculateChangedClang(new_cr_rev):
|
||||
def GetClangRev(lines):
|
||||
for line in lines:
|
||||
match = CLANG_REVISION_RE.match(line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
raise RollError('Could not parse Clang revision!')
|
||||
|
||||
with open(CLANG_UPDATE_SCRIPT_LOCAL_PATH, 'rb') as f:
|
||||
current_lines = f.readlines()
|
||||
current_rev = GetClangRev(current_lines)
|
||||
|
||||
new_clang_update_py = ReadRemoteCrFile(CLANG_UPDATE_SCRIPT_URL_PATH,
|
||||
new_cr_rev).splitlines()
|
||||
new_rev = GetClangRev(new_clang_update_py)
|
||||
return ChangedDep(CLANG_UPDATE_SCRIPT_LOCAL_PATH, None, current_rev, new_rev)
|
||||
|
||||
|
||||
def GenerateCommitMessage(current_cr_rev, new_cr_rev, current_commit_pos,
|
||||
new_commit_pos, changed_deps_list, clang_change):
|
||||
current_cr_rev = current_cr_rev[0:10]
|
||||
new_cr_rev = new_cr_rev[0:10]
|
||||
rev_interval = '%s..%s' % (current_cr_rev, new_cr_rev)
|
||||
git_number_interval = '%s:%s' % (current_commit_pos, new_commit_pos)
|
||||
|
||||
commit_msg = ['Roll chromium_revision %s (%s)\n' % (rev_interval,
|
||||
git_number_interval)]
|
||||
commit_msg.append('Change log: %s' % (CHROMIUM_LOG_TEMPLATE % rev_interval))
|
||||
commit_msg.append('Full diff: %s\n' % (CHROMIUM_COMMIT_TEMPLATE %
|
||||
rev_interval))
|
||||
# TBR field will be empty unless in some custom cases, where some engineers
|
||||
# are added.
|
||||
tbr_authors = ''
|
||||
if changed_deps_list:
|
||||
commit_msg.append('Changed dependencies:')
|
||||
|
||||
for c in changed_deps_list:
|
||||
commit_msg.append('* %s: %s/+log/%s..%s' % (c.path, c.url,
|
||||
c.current_rev[0:10],
|
||||
c.new_rev[0:10]))
|
||||
change_url = CHROMIUM_FILE_TEMPLATE % (rev_interval, 'DEPS')
|
||||
commit_msg.append('DEPS diff: %s\n' % change_url)
|
||||
else:
|
||||
commit_msg.append('No dependencies changed.')
|
||||
|
||||
if clang_change.current_rev != clang_change.new_rev:
|
||||
commit_msg.append('Clang version changed %s:%s' %
|
||||
(clang_change.current_rev, clang_change.new_rev))
|
||||
change_url = CHROMIUM_FILE_TEMPLATE % (rev_interval,
|
||||
CLANG_UPDATE_SCRIPT_URL_PATH)
|
||||
commit_msg.append('Details: %s\n' % change_url)
|
||||
else:
|
||||
commit_msg.append('No update to Clang.\n')
|
||||
|
||||
commit_msg.append('TBR=%s' % tbr_authors)
|
||||
commit_msg.append('BUG=None')
|
||||
return '\n'.join(commit_msg)
|
||||
|
||||
|
||||
def UpdateDepsFile(deps_filename, old_cr_revision, new_cr_revision,
|
||||
changed_deps):
|
||||
"""Update the DEPS file with the new revision."""
|
||||
|
||||
# Update the chromium_revision variable.
|
||||
with open(deps_filename, 'rb') as deps_file:
|
||||
deps_content = deps_file.read()
|
||||
deps_content = deps_content.replace(old_cr_revision, new_cr_revision)
|
||||
with open(deps_filename, 'wb') as deps_file:
|
||||
deps_file.write(deps_content)
|
||||
|
||||
# Update each individual DEPS entry.
|
||||
for dep in changed_deps:
|
||||
local_dep_dir = os.path.join(CHECKOUT_ROOT_DIR, dep.path)
|
||||
if not os.path.isdir(local_dep_dir):
|
||||
raise RollError(
|
||||
'Cannot find local directory %s. Either run\n'
|
||||
'gclient sync --deps=all\n'
|
||||
'or make sure the .gclient file for your solution contains all '
|
||||
'platforms in the target_os list, i.e.\n'
|
||||
'target_os = ["android", "unix", "mac", "ios", "win"];\n'
|
||||
'Then run "gclient sync" again.' % local_dep_dir)
|
||||
_, stderr = _RunCommand(
|
||||
['roll-dep-svn', '--no-verify-revision', dep.path, dep.new_rev],
|
||||
working_dir=CHECKOUT_SRC_DIR, ignore_exit_code=True)
|
||||
if stderr:
|
||||
logging.warning('roll-dep-svn: %s', stderr)
|
||||
|
||||
|
||||
def _IsTreeClean():
|
||||
stdout, _ = _RunCommand(['git', 'status', '--porcelain'])
|
||||
if len(stdout) == 0:
|
||||
return True
|
||||
|
||||
logging.error('Dirty/unversioned files:\n%s', stdout)
|
||||
return False
|
||||
|
||||
|
||||
def _EnsureUpdatedMasterBranch(dry_run):
|
||||
current_branch = _RunCommand(
|
||||
['git', 'rev-parse', '--abbrev-ref', 'HEAD'])[0].splitlines()[0]
|
||||
if current_branch != 'master':
|
||||
logging.error('Please checkout the master branch and re-run this script.')
|
||||
if not dry_run:
|
||||
sys.exit(-1)
|
||||
|
||||
logging.info('Updating master branch...')
|
||||
_RunCommand(['git', 'pull'])
|
||||
|
||||
|
||||
def _CreateRollBranch(dry_run):
|
||||
logging.info('Creating roll branch: %s', ROLL_BRANCH_NAME)
|
||||
if not dry_run:
|
||||
_RunCommand(['git', 'checkout', '-b', ROLL_BRANCH_NAME])
|
||||
|
||||
|
||||
def _RemovePreviousRollBranch(dry_run):
|
||||
active_branch, branches = _GetBranches()
|
||||
if active_branch == ROLL_BRANCH_NAME:
|
||||
active_branch = 'master'
|
||||
if ROLL_BRANCH_NAME in branches:
|
||||
logging.info('Removing previous roll branch (%s)', ROLL_BRANCH_NAME)
|
||||
if not dry_run:
|
||||
_RunCommand(['git', 'checkout', active_branch])
|
||||
_RunCommand(['git', 'branch', '-D', ROLL_BRANCH_NAME])
|
||||
|
||||
|
||||
def _LocalCommit(commit_msg, dry_run):
|
||||
logging.info('Committing changes locally.')
|
||||
if not dry_run:
|
||||
_RunCommand(['git', 'add', '--update', '.'])
|
||||
_RunCommand(['git', 'commit', '-m', commit_msg])
|
||||
|
||||
|
||||
def _UploadCL(dry_run, rietveld_email=None):
|
||||
logging.info('Uploading CL...')
|
||||
if not dry_run:
|
||||
cmd = ['git', 'cl', 'upload', '-f']
|
||||
if rietveld_email:
|
||||
cmd.append('--email=%s' % rietveld_email)
|
||||
_RunCommand(cmd, extra_env={'EDITOR': 'true'})
|
||||
|
||||
|
||||
def _SendToCQ(dry_run, skip_cq):
|
||||
logging.info('Sending the CL to the CQ...')
|
||||
if not dry_run and not skip_cq:
|
||||
_RunCommand(['git', 'cl', 'set_commit'])
|
||||
logging.info('Sent the CL to the CQ.')
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser()
|
||||
p.add_argument('--clean', action='store_true', default=False,
|
||||
help='Removes any previous local roll branch.')
|
||||
p.add_argument('-r', '--revision',
|
||||
help=('Chromium Git revision to roll to. Defaults to the '
|
||||
'Chromium HEAD revision if omitted.'))
|
||||
p.add_argument('-u', '--rietveld-email',
|
||||
help=('E-mail address to use for creating the CL at Rietveld'
|
||||
'If omitted a previously cached one will be used or an '
|
||||
'error will be thrown during upload.'))
|
||||
p.add_argument('--dry-run', action='store_true', default=False,
|
||||
help=('Calculate changes and modify DEPS, but don\'t create '
|
||||
'any local branch, commit, upload CL or send any '
|
||||
'tryjobs.'))
|
||||
p.add_argument('-i', '--ignore-unclean-workdir', action='store_true',
|
||||
default=False,
|
||||
help=('Ignore if the current branch is not master or if there '
|
||||
'are uncommitted changes (default: %(default)s).'))
|
||||
p.add_argument('--skip-cq', action='store_true', default=False,
|
||||
help='Skip sending the CL to the CQ (default: %(default)s)')
|
||||
p.add_argument('-v', '--verbose', action='store_true', default=False,
|
||||
help='Be extra verbose in printing of log messages.')
|
||||
opts = p.parse_args()
|
||||
|
||||
if opts.verbose:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
else:
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
if not opts.ignore_unclean_workdir and not _IsTreeClean():
|
||||
logging.error('Please clean your local checkout first.')
|
||||
return 1
|
||||
|
||||
if opts.clean:
|
||||
_RemovePreviousRollBranch(opts.dry_run)
|
||||
|
||||
if not opts.ignore_unclean_workdir:
|
||||
_EnsureUpdatedMasterBranch(opts.dry_run)
|
||||
|
||||
new_cr_rev = opts.revision
|
||||
if not new_cr_rev:
|
||||
stdout, _ = _RunCommand(['git', 'ls-remote', CHROMIUM_SRC_URL, 'HEAD'])
|
||||
head_rev = stdout.strip().split('\t')[0]
|
||||
logging.info('No revision specified. Using HEAD: %s', head_rev)
|
||||
new_cr_rev = head_rev
|
||||
|
||||
deps_filename = os.path.join(CHECKOUT_SRC_DIR, 'DEPS')
|
||||
libyuv_deps = ParseLocalDepsFile(deps_filename)
|
||||
current_cr_rev = libyuv_deps['vars']['chromium_revision']
|
||||
|
||||
current_commit_pos = ParseCommitPosition(ReadRemoteCrCommit(current_cr_rev))
|
||||
new_commit_pos = ParseCommitPosition(ReadRemoteCrCommit(new_cr_rev))
|
||||
|
||||
new_cr_deps = ParseRemoteCrDepsFile(new_cr_rev)
|
||||
changed_deps = CalculateChangedDeps(libyuv_deps, new_cr_deps)
|
||||
clang_change = CalculateChangedClang(new_cr_rev)
|
||||
commit_msg = GenerateCommitMessage(current_cr_rev, new_cr_rev,
|
||||
current_commit_pos, new_commit_pos,
|
||||
changed_deps, clang_change)
|
||||
logging.debug('Commit message:\n%s', commit_msg)
|
||||
|
||||
_CreateRollBranch(opts.dry_run)
|
||||
UpdateDepsFile(deps_filename, current_cr_rev, new_cr_rev, changed_deps)
|
||||
_LocalCommit(commit_msg, opts.dry_run)
|
||||
_UploadCL(opts.dry_run, opts.rietveld_email)
|
||||
_SendToCQ(opts.dry_run, opts.skip_cq)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
BIN
tools_libyuv/autoroller/unittests/.DS_Store
vendored
Normal file
BIN
tools_libyuv/autoroller/unittests/.DS_Store
vendored
Normal file
Binary file not shown.
143
tools_libyuv/autoroller/unittests/roll_deps_test.py
Executable file
143
tools_libyuv/autoroller/unittests/roll_deps_test.py
Executable file
@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2017 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.
|
||||
|
||||
import glob
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
PARENT_DIR = os.path.join(SCRIPT_DIR, os.pardir)
|
||||
sys.path.append(PARENT_DIR)
|
||||
import roll_deps
|
||||
from roll_deps import CalculateChangedDeps, GetMatchingDepsEntries, \
|
||||
ParseDepsDict, ParseLocalDepsFile, UpdateDepsFile
|
||||
|
||||
|
||||
TEST_DATA_VARS = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d',
|
||||
}
|
||||
|
||||
DEPS_ENTRIES = {
|
||||
'src/build': 'https://build.com',
|
||||
'src/buildtools': 'https://buildtools.com',
|
||||
'src/testing/gtest': 'https://gtest.com',
|
||||
'src/testing/gmock': 'https://gmock.com',
|
||||
}
|
||||
|
||||
BUILD_OLD_REV = '52f7afeca991d96d68cf0507e20dbdd5b845691f'
|
||||
BUILD_NEW_REV = 'HEAD'
|
||||
BUILDTOOLS_OLD_REV = '64e38f0cebdde27aa0cfb405f330063582f9ac76'
|
||||
BUILDTOOLS_NEW_REV = '55ad626b08ef971fd82a62b7abb325359542952b'
|
||||
|
||||
|
||||
class TestError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class FakeCmd(object):
|
||||
def __init__(self):
|
||||
self.expectations = []
|
||||
|
||||
def add_expectation(self, *args, **kwargs):
|
||||
returns = kwargs.pop('_returns', None)
|
||||
self.expectations.append((args, kwargs, returns))
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
if not self.expectations:
|
||||
raise TestError('Got unexpected\n%s\n%s' % (args, kwargs))
|
||||
exp_args, exp_kwargs, exp_returns = self.expectations.pop(0)
|
||||
if args != exp_args or kwargs != exp_kwargs:
|
||||
message = 'Expected:\n args: %s\n kwargs: %s\n' % (exp_args, exp_kwargs)
|
||||
message += 'Got:\n args: %s\n kwargs: %s\n' % (args, kwargs)
|
||||
raise TestError(message)
|
||||
return exp_returns
|
||||
|
||||
|
||||
class TestRollChromiumRevision(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self._output_dir = tempfile.mkdtemp()
|
||||
for test_file in glob.glob(os.path.join(SCRIPT_DIR, 'testdata', '*')):
|
||||
shutil.copy(test_file, self._output_dir)
|
||||
self._libyuv_depsfile = os.path.join(self._output_dir, 'DEPS')
|
||||
self._old_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.old')
|
||||
self._new_cr_depsfile = os.path.join(self._output_dir, 'DEPS.chromium.new')
|
||||
|
||||
self.fake = FakeCmd()
|
||||
self.old_RunCommand = getattr(roll_deps, '_RunCommand')
|
||||
setattr(roll_deps, '_RunCommand', self.fake)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self._output_dir, ignore_errors=True)
|
||||
self.assertEqual(self.fake.expectations, [])
|
||||
setattr(roll_deps, '_RunCommand', self.old_RunCommand)
|
||||
|
||||
def testUpdateDepsFile(self):
|
||||
new_rev = 'aaaaabbbbbcccccdddddeeeeefffff0000011111'
|
||||
|
||||
current_rev = TEST_DATA_VARS['chromium_revision']
|
||||
UpdateDepsFile(self._libyuv_depsfile, current_rev, new_rev, [])
|
||||
with open(self._libyuv_depsfile) as deps_file:
|
||||
deps_contents = deps_file.read()
|
||||
self.assertTrue(new_rev in deps_contents,
|
||||
'Failed to find %s in\n%s' % (new_rev, deps_contents))
|
||||
|
||||
def testParseDepsDict(self):
|
||||
with open(self._libyuv_depsfile) as deps_file:
|
||||
deps_contents = deps_file.read()
|
||||
local_scope = ParseDepsDict(deps_contents)
|
||||
vars_dict = local_scope['vars']
|
||||
|
||||
def assertVar(variable_name):
|
||||
self.assertEquals(vars_dict[variable_name], TEST_DATA_VARS[variable_name])
|
||||
assertVar('chromium_git')
|
||||
assertVar('chromium_revision')
|
||||
self.assertEquals(len(local_scope['deps']), 3)
|
||||
|
||||
def testGetMatchingDepsEntriesReturnsPathInSimpleCase(self):
|
||||
entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing/gtest')
|
||||
self.assertEquals(len(entries), 1)
|
||||
self.assertEquals(entries[0], DEPS_ENTRIES['src/testing/gtest'])
|
||||
|
||||
def testGetMatchingDepsEntriesHandlesSimilarStartingPaths(self):
|
||||
entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/testing')
|
||||
self.assertEquals(len(entries), 2)
|
||||
|
||||
def testGetMatchingDepsEntriesHandlesTwoPathsWithIdenticalFirstParts(self):
|
||||
entries = GetMatchingDepsEntries(DEPS_ENTRIES, 'src/build')
|
||||
self.assertEquals(len(entries), 1)
|
||||
self.assertEquals(entries[0], DEPS_ENTRIES['src/build'])
|
||||
|
||||
def testCalculateChangedDeps(self):
|
||||
_SetupGitLsRemoteCall(self.fake,
|
||||
'https://chromium.googlesource.com/chromium/src/build', BUILD_NEW_REV)
|
||||
libyuv_deps = ParseLocalDepsFile(self._libyuv_depsfile)
|
||||
new_cr_deps = ParseLocalDepsFile(self._new_cr_depsfile)
|
||||
changed_deps = CalculateChangedDeps(libyuv_deps, new_cr_deps)
|
||||
self.assertEquals(len(changed_deps), 2)
|
||||
self.assertEquals(changed_deps[0].path, 'src/build')
|
||||
self.assertEquals(changed_deps[0].current_rev, BUILD_OLD_REV)
|
||||
self.assertEquals(changed_deps[0].new_rev, BUILD_NEW_REV)
|
||||
|
||||
self.assertEquals(changed_deps[1].path, 'src/buildtools')
|
||||
self.assertEquals(changed_deps[1].current_rev, BUILDTOOLS_OLD_REV)
|
||||
self.assertEquals(changed_deps[1].new_rev, BUILDTOOLS_NEW_REV)
|
||||
|
||||
|
||||
def _SetupGitLsRemoteCall(cmd_fake, url, revision):
|
||||
cmd = ['git', 'ls-remote', url, revision]
|
||||
cmd_fake.add_expectation(cmd, _returns=(revision, None))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
20
tools_libyuv/autoroller/unittests/testdata/DEPS
vendored
Normal file
20
tools_libyuv/autoroller/unittests/testdata/DEPS
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# DEPS file for unit tests.
|
||||
|
||||
vars = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
'chromium_revision': '1b9c098a08e40114e44b6c1ec33ddf95c40b901d',
|
||||
}
|
||||
|
||||
deps = {
|
||||
# Entry that is a directory in Chromium, so we're using a Git subtree mirror for it.
|
||||
'src/build':
|
||||
Var('chromium_git') + '/chromium/src/build' + '@' + '52f7afeca991d96d68cf0507e20dbdd5b845691f',
|
||||
|
||||
# Entry that's also a DEPS entry in the Chromium DEPS file.
|
||||
'src/buildtools':
|
||||
Var('chromium_git') + '/chromium/buildtools.git' + '@' + '64e38f0cebdde27aa0cfb405f330063582f9ac76',
|
||||
|
||||
# Entry only present in libyuv, not Chromium.
|
||||
'src/third_party/gflags/src':
|
||||
Var('chromium_git') + '/external/github.com/gflags/gflags@03bebcb065c83beff83d50ae025a55a4bf94dfca',
|
||||
}
|
||||
13
tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new
vendored
Normal file
13
tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.new
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# DEPS file for unit tests.
|
||||
|
||||
vars = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
|
||||
# This is updated compared to the DEPS.chromium.old file.
|
||||
'buildtools_revision': '55ad626b08ef971fd82a62b7abb325359542952b',
|
||||
}
|
||||
|
||||
deps = {
|
||||
'src/buildtools':
|
||||
Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'),
|
||||
}
|
||||
13
tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old
vendored
Normal file
13
tools_libyuv/autoroller/unittests/testdata/DEPS.chromium.old
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
# DEPS file for unit tests.
|
||||
|
||||
vars = {
|
||||
'chromium_git': 'https://chromium.googlesource.com',
|
||||
|
||||
# This is and older revision than DEPS.chromium.new file.
|
||||
'buildtools_revision': '64e38f0cebdde27aa0cfb405f330063582f9ac76',
|
||||
}
|
||||
|
||||
deps = {
|
||||
'src/buildtools':
|
||||
Var('chromium_git') + '/chromium/buildtools.git' + '@' + Var('buildtools_revision'),
|
||||
}
|
||||
@ -53,16 +53,17 @@ class LibyuvTest(chrome_tests.ChromeTests):
|
||||
# this script's location. If Mac or Windows is executing, additional
|
||||
# platform specific files have also been added.
|
||||
# Since only the ones located below this directory is added, we must also
|
||||
# add the ones maintained by Chrome, located in ../valgrind.
|
||||
# add the ones maintained by Chrome, located in ../../tools/valgrind.
|
||||
|
||||
# The idea is to look for --suppression arguments in the cmd list and add a
|
||||
# modified copy of each suppression file, for the corresponding file in
|
||||
# ../valgrind. If we would simply replace 'valgrind-libyuv' with 'valgrind'
|
||||
# we may produce invalid paths if other parts of the path contain that
|
||||
# string. That's why the code below only replaces the end of the path.
|
||||
# ../../tools/valgrind.
|
||||
script_dir = path_utils.ScriptDir()
|
||||
old_base, _ = os.path.split(script_dir)
|
||||
new_dir = os.path.join(old_base, 'valgrind')
|
||||
|
||||
checkout_src = os.path.abspath(os.path.join(script_dir, os.pardir,
|
||||
os.pardir))
|
||||
new_dir = os.path.join(checkout_src, 'tools', 'valgrind')
|
||||
add_suppressions = []
|
||||
for token in cmd:
|
||||
if '--suppressions' in token:
|
||||
@ -22,8 +22,8 @@ def CheckChange(input_api, output_api):
|
||||
"""Checks the memcheck suppressions files for bad data."""
|
||||
|
||||
# Add the path to the Chrome valgrind dir to the import path:
|
||||
tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..',
|
||||
'valgrind')
|
||||
tools_vg_path = os.path.join(input_api.PresubmitLocalPath(), '..', '..', '..',
|
||||
'tools', 'valgrind')
|
||||
sys.path.append(tools_vg_path)
|
||||
import suppressions
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
#!/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.
|
||||
|
||||
"""
|
||||
Runs tests on Android devices.
|
||||
|
||||
This script exists to avoid Libyuv being broken by changes in the Chrome Android
|
||||
test execution toolchain. It also conveniently sets the CHECKOUT_SOURCE_ROOT
|
||||
environment variable.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(__file__)
|
||||
ROOT_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir))
|
||||
CHROMIUM_BUILD_ANDROID_DIR = os.path.join(ROOT_DIR, 'build', 'android')
|
||||
sys.path.insert(0, CHROMIUM_BUILD_ANDROID_DIR)
|
||||
|
||||
|
||||
import test_runner # pylint: disable=W0406
|
||||
|
||||
def main():
|
||||
# Override environment variable to make it possible for the scripts to find
|
||||
# the root directory (our symlinking of the Chromium build toolchain would
|
||||
# otherwise make them fail to do so).
|
||||
os.environ['CHECKOUT_SOURCE_ROOT'] = ROOT_DIR
|
||||
return test_runner.main()
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
Loading…
x
Reference in New Issue
Block a user