mirror of
https://github.com/gflags/gflags.git
synced 2025-04-20 12:08:47 +00:00
Compare commits
453 commits
Author | SHA1 | Date | |
---|---|---|---|
|
52e94563eb | ||
|
c1f63a168d | ||
|
70c01a642f | ||
|
b364def945 | ||
|
58cf1ef6d0 | ||
|
3c4399ba46 | ||
|
03a4842c9c | ||
|
82793e3f38 | ||
|
c196ce6baa | ||
|
3df39f3a03 | ||
|
a738fdf933 | ||
|
b7fd838331 | ||
|
986e8eed00 | ||
|
9ca7e9ee7a | ||
|
4ace06d024 | ||
|
827c769e5f | ||
|
5d5a6c5501 | ||
|
a386bd0f20 | ||
|
cb68d9eeb8 | ||
|
ae2fae5645 | ||
|
1c86423887 | ||
|
8843f88b69 | ||
|
4405871443 | ||
|
f7388c6655 | ||
|
84968c6bb2 | ||
|
1137acc9e0 | ||
|
ef8e134d48 | ||
|
addd749114 | ||
|
2e227c3daa | ||
|
d9b184bd00 | ||
|
6c8f50b567 | ||
|
6d224d34b6 | ||
|
0b7f8db2c6 | ||
|
f40e43a628 | ||
|
57c5913fb8 | ||
|
2cac878761 | ||
|
28f50e0fed | ||
|
1005485222 | ||
|
be65295633 | ||
|
524b83d026 | ||
|
34819405ab | ||
|
00fcadd9b8 | ||
|
498cfa8b13 | ||
|
e171aa2d15 | ||
|
3d2a101c9e | ||
|
af502c8176 | ||
|
0f439e8407 | ||
|
83fecd3ed0 | ||
|
8411df715c | ||
|
4c0bbc0604 | ||
|
0c7012d647 | ||
|
b051bace27 | ||
|
7e70988188 | ||
|
754d3329a6 | ||
|
82456f220f | ||
|
3e2e349307 | ||
|
c0b1add45f | ||
|
f1ea012a41 | ||
|
b0c4cd29e4 | ||
|
04c8ce76e2 | ||
|
d4a050d173 | ||
|
48677f930d | ||
|
6e536553ef | ||
|
cad38c919c | ||
|
2c49763b73 | ||
|
660603a3df | ||
|
679df49798 | ||
|
48cdc79332 | ||
|
518267d34f | ||
|
f7228d77b5 | ||
|
8b39845d6f | ||
|
9ab4d115cb | ||
|
e292e0452f | ||
|
6d1c363dde | ||
|
77592648e3 | ||
|
23348465a0 | ||
|
60784b53e3 | ||
|
57ceb0ecc8 | ||
|
7d36353579 | ||
|
aa2d0f7b4e | ||
|
4663c80d3a | ||
|
46f73f88b1 | ||
|
66d4386d0e | ||
|
6348ea9d7e | ||
|
3d5bc48dc8 | ||
|
74603f5ed3 | ||
|
4a694e8736 | ||
|
21c7bcd895 | ||
|
95ffb27c9c | ||
|
80ebb424a5 | ||
|
652651b421 | ||
|
9314597d4b | ||
|
48f409438b | ||
|
30dbc81fb5 | ||
|
8935ef4526 | ||
|
20858a49e0 | ||
|
ac6834e979 | ||
|
22ed2ce6c8 | ||
|
f8a0efe03a | ||
|
2f336a2a87 | ||
|
971dd2a4fa | ||
|
c6b937797c | ||
|
84ab952375 | ||
|
78c66b3726 | ||
|
b872d6b5d4 | ||
|
37c4c58371 | ||
|
37e2867335 | ||
|
8f2c22a03f | ||
|
ea6144e243 | ||
|
86d67a3f49 | ||
|
c94a60e2f6 | ||
|
3e7ef74a07 | ||
|
18469830ae | ||
|
3886da50e1 | ||
|
6c0ee003e8 | ||
|
3064f63a6e | ||
|
14c0e93755 | ||
|
cce68f0c9c | ||
|
f4eace1331 | ||
|
408061b469 | ||
|
7d31c02de8 | ||
|
a69b2544d6 | ||
|
15394d356c | ||
|
e58e5303d6 | ||
|
435f949dbb | ||
|
22e4a534c1 | ||
|
c713d2e789 | ||
|
b16653edf0 | ||
|
ec4b5daadf | ||
|
f0be9c88ca | ||
|
78cab6c649 | ||
|
4667f41317 | ||
|
a5a1b28767 | ||
|
7ba9921866 | ||
|
30519426c3 | ||
|
3c0ad4fc9e | ||
|
a1e461d61d | ||
|
46ea10f071 | ||
|
fe57e5af4d | ||
|
fa2663839c | ||
|
5ef4c3c076 | ||
|
2e4159fbe5 | ||
|
3e946c9ebc | ||
|
546819b1d9 | ||
|
0c17f1ee02 | ||
|
ac1a925c2b | ||
|
d701ceac73 | ||
|
7ae23fd1e7 | ||
|
8de80b9a2d | ||
|
eff38cbc18 | ||
|
9353bca5e9 | ||
|
81d8a9234b | ||
|
eaf05340dc | ||
|
74bcd20c0e | ||
|
45341954bc | ||
|
5e3070670f | ||
|
687b2c56d2 | ||
|
58441994df | ||
|
1c8285fd63 | ||
|
ea1cc83b50 | ||
|
12d810d8e6 | ||
|
389ef3f737 | ||
|
752c63249b | ||
|
f9e69b3531 | ||
|
7a21c16f00 | ||
|
a4382e5f37 | ||
|
2de6bf3904 | ||
|
91e16eeff1 | ||
|
b686469597 | ||
|
e50698c200 | ||
|
18cb422451 | ||
|
799e910c74 | ||
|
abe4b10c33 | ||
|
221f327749 | ||
|
2a3454c104 | ||
|
545e9df567 | ||
|
6bd636c964 | ||
|
dd48d704c5 | ||
|
9ef0d5220e | ||
|
02f3189788 | ||
|
92865cee87 | ||
|
8ac4bc41aa | ||
|
b90a325ef3 | ||
|
3ae911f3e7 | ||
|
16651b7870 | ||
|
762f9cbb65 | ||
|
7a69001868 | ||
|
3f968fc16b | ||
|
40b85b18de | ||
|
f9fa30506c | ||
|
b572a72daa | ||
|
03bebcb065 | ||
|
366e9d335c | ||
|
4f100cb6a0 | ||
|
d78b00d2de | ||
|
9db828953a | ||
|
4e61c45ef9 | ||
|
f0523f14a9 | ||
|
4a56d614cf | ||
|
58345b18d9 | ||
|
d4e971c10b | ||
|
16a168763e | ||
|
f4f524df1f | ||
|
73178f0051 | ||
|
e1d15b3340 | ||
|
ed1d91f912 | ||
|
71c656e0e9 | ||
|
73b67041d8 | ||
|
2e5b884fce | ||
|
7eb3d365e3 | ||
|
ccff5658e0 | ||
|
33fc9997bd | ||
|
c3fd5432c3 | ||
|
745082dbd3 | ||
|
73bb1e87c9 | ||
|
5f29c4b940 | ||
|
d7a69edf66 | ||
|
9e937e80fb | ||
|
a9b983a827 | ||
|
f9e1ffaa39 | ||
|
a4bae965eb | ||
|
14e1138441 | ||
|
2861b1c269 | ||
|
06ccc16dec | ||
|
a819f0f019 | ||
|
64ac2e30b6 | ||
|
51f1db7431 | ||
|
35fcdb3b2f | ||
|
3398e7b0c9 | ||
|
13cf9e1b39 | ||
|
afbf3f22ff | ||
|
7fc7826cc1 | ||
|
4b771465b1 | ||
|
76c53b710e | ||
|
2b8deaa5e0 | ||
|
7b5b080a06 | ||
|
64cf9f3249 | ||
|
67dc01d3e0 | ||
|
04c73f86c3 | ||
|
02e8c78f9d | ||
|
957aa3aa62 | ||
|
0133710d47 | ||
|
d8d218ac6f | ||
|
957f0d291c | ||
|
63b9776eee | ||
|
3a49eafd20 | ||
|
6e390924d3 | ||
|
2614f123fd | ||
|
eb89101a1a | ||
|
2a40e19137 | ||
|
376ef823be | ||
|
76cbe0d003 | ||
|
2b81a76bed | ||
|
659b440f9e | ||
|
a93de007a6 | ||
|
05b155ff59 | ||
|
cd7aece14e | ||
|
b8c6fef385 | ||
|
bf889786c2 | ||
|
e160474c52 | ||
|
6828323bc6 | ||
|
31f0e290d6 | ||
|
3c30390ac4 | ||
|
e9144aa159 | ||
|
44d1d163cc | ||
|
d9d06b99a4 | ||
|
55490439d0 | ||
|
e65f49a4cd | ||
|
dc2b2c7fec | ||
|
cac974eb07 | ||
|
44a58145e3 | ||
|
07031f9703 | ||
|
4003103499 | ||
|
cf0619e458 | ||
|
eb3b78a4ff | ||
|
ef5c5474b2 | ||
|
0890b699e9 | ||
|
eb5e1f7fe4 | ||
|
7bc160b304 | ||
|
dc8543a473 | ||
|
9a257c0b66 | ||
|
94c23575c7 | ||
|
0f2751ebfb | ||
|
020dc487c3 | ||
|
0c6e5fdb3f | ||
|
38c4402f58 | ||
|
7c80cfd87c | ||
|
30d045d0ec | ||
|
aff8ef820a | ||
|
38213112a5 | ||
|
4aa1984c51 | ||
|
6040eac5b3 | ||
|
09f7800768 | ||
|
bbe1895559 | ||
|
3fd9fa7000 | ||
|
cf40f73c40 | ||
|
0e1c5ce039 | ||
|
2a9ef084a9 | ||
|
0c15028124 | ||
|
d699559081 | ||
|
04a30c86de | ||
|
882db5d018 | ||
|
33e2cbe2c6 | ||
|
3e96a19026 | ||
|
0100be50ec | ||
|
76f2ffadb4 | ||
|
978c567d02 | ||
|
06ad5027d2 | ||
|
a49a656f1e | ||
|
e8890f274a | ||
|
fc6e079cfc | ||
|
52bf642cf8 | ||
|
4b1ca7d5f1 | ||
|
4258af12b7 | ||
|
313e39e323 | ||
|
dc9674ee46 | ||
|
b6f61ab0ce | ||
|
26a35dd2e4 | ||
|
37a9a90d1d | ||
|
516e028901 | ||
|
13fe86b8fe | ||
|
bf139ea0a8 | ||
|
cb62c00354 | ||
|
9ecc4cab3b | ||
|
ec4ddb403a | ||
|
ddc5357419 | ||
|
9242578bc1 | ||
|
acb460af9e | ||
|
41181669d1 | ||
|
dbc09f12db | ||
|
13025b119f | ||
|
0b116eb439 | ||
|
5250372ab6 | ||
|
9d686e7107 | ||
|
3d142b88d7 | ||
|
8566bcf1eb | ||
|
6e9f41669e | ||
|
d8c6a552aa | ||
|
b18fe77ecd | ||
|
b8f5717416 | ||
|
492ac156bc | ||
|
cf92ec3bf0 | ||
|
1e0b54c6ed | ||
|
e491f0161d | ||
|
e31f179ae0 | ||
|
6b7be9a00a | ||
|
a0dca4df0c | ||
|
eeb4db3234 | ||
|
107681258b | ||
|
8d3797cd15 | ||
|
8d93bca20a | ||
|
0d9486f9a3 | ||
|
505686bd7a | ||
|
c94e9bec36 | ||
|
bf918e630f | ||
|
33ee7ad6ef | ||
|
cb00fb9ec7 | ||
|
c6a9986fa0 | ||
|
7b63ae8f8a | ||
|
9b3c4a81c2 | ||
|
f1e7b37c48 | ||
|
1b1b61d305 | ||
|
c5627a75bc | ||
|
6e4c22e982 | ||
|
f479174573 | ||
|
a4c4a01a37 | ||
|
8477f3174e | ||
|
f0f565fb0f | ||
|
8a563cfca3 | ||
|
15bc2d6c15 | ||
|
70eac23c1b | ||
|
b2180eb52c | ||
|
efc6908bce | ||
|
eb92d6edce | ||
|
38b662ab07 | ||
|
2bd1aeeeb7 | ||
|
d0882077b3 | ||
|
fb21f3cca0 | ||
|
0c65228956 | ||
|
3900860906 | ||
|
01d810e3c0 | ||
|
48316bd345 | ||
|
27c0c9ef79 | ||
|
459e529168 | ||
|
99f52df612 | ||
|
667c52be59 | ||
|
3c0cd06b6d | ||
|
1c9f065dd0 | ||
|
7abcbdcbbd | ||
|
ac3cb02be8 | ||
|
126f36b826 | ||
|
620557ccbc | ||
|
5564469b96 | ||
|
7a07439cf6 | ||
|
2ec91bffad | ||
|
ffbc1cea57 | ||
|
6ec7d7f81e | ||
|
43a33dcd53 | ||
|
42a0018843 | ||
|
6f2a78a26f | ||
|
4eb2cb223b | ||
|
f7e89ba9ea | ||
|
3624d33ae5 | ||
|
392eb67dbf | ||
|
2eed08d94a | ||
|
5ed8ae17a9 | ||
|
4328de857d | ||
|
dba41e672c | ||
|
45a53dea87 | ||
|
8011f61247 | ||
|
f098a54822 | ||
|
1235a6d519 | ||
|
6b215b0a3a | ||
|
e88280ed85 | ||
|
8306eef3ec | ||
|
f18772936d | ||
|
ec7c7a209d | ||
|
80912052d0 | ||
|
be2da58d73 | ||
|
2535e43dd2 | ||
|
c23c6c6fc8 | ||
|
17a627a413 | ||
|
ee44191125 | ||
|
9bf7e65f08 | ||
|
6b70a75081 | ||
|
29f02f9896 | ||
|
10caa99e2d | ||
|
874aed5db7 | ||
|
1b8e9bab5e | ||
|
beb69a876b | ||
|
8233556d44 | ||
|
404970d679 | ||
|
a923d3338e | ||
|
357b3d9d0b | ||
|
b5cdac9950 | ||
|
917f4e7bf3 | ||
|
b7ea065962 | ||
|
69ecf71511 | ||
|
eacb7924c8 | ||
|
ac2abfc8c8 | ||
|
b4bf72b051 | ||
|
71e1be97d8 | ||
|
24b4c59e69 | ||
|
0baf4ab4f6 | ||
|
84b18ac090 | ||
|
3c624b701e | ||
|
c44e0559cf | ||
|
20500a9e59 | ||
|
31226b61f2 | ||
|
31c8edc53e | ||
|
ab3d7650dc | ||
|
688ea02a69 | ||
|
de718176a2 |
100 changed files with 5157 additions and 50723 deletions
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# treat all files in this repository as text files
|
||||
# and normalize them to LF line endings when committed
|
||||
* text
|
51
.github/workflows/test.yml
vendored
Normal file
51
.github/workflows/test.yml
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
name: Build and Run Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: test-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Test on ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
# - macos-latest
|
||||
# - windows-latest
|
||||
cmake:
|
||||
- '4.0'
|
||||
- '3.31'
|
||||
fail-fast: false
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout Project
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup cmake
|
||||
uses: jwlawson/actions-setup-cmake@802fa1a2c4e212495c05bf94dba2704a92a472be # v2.0.2
|
||||
with:
|
||||
cmake-version: ${{ matrix.cmake }}
|
||||
- name: Setup Ninja
|
||||
uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
|
||||
- name: Configure CMake
|
||||
run: |
|
||||
cmake -B build -G Ninja \
|
||||
-D CMAKE_CXX_COMPILER=clang++ \
|
||||
-D CMAKE_BUILD_TYPE=Release \
|
||||
-D GFLAGS_BUILD_SHARED_LIBS=ON \
|
||||
-D GFLAGS_BUILD_STATIC_LIBS=ON \
|
||||
-D GFLAGS_BUILD_TESTING=ON
|
||||
- name: Build Tests
|
||||
run: cmake --build build --config Release
|
||||
- name: Run Tests
|
||||
run: cd build && ctest
|
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
/xcode/
|
||||
/build/
|
||||
/builds/
|
||||
/build-*/
|
||||
/_build/
|
||||
.DS_Store
|
||||
CMakeCache.txt
|
||||
DartConfiguration.tcl
|
||||
Makefile
|
||||
CMakeFiles/
|
||||
/Testing/
|
||||
/include/gflags/config.h
|
||||
/include/gflags/gflags_completions.h
|
||||
/include/gflags/gflags_declare.h
|
||||
/include/gflags/gflags.h
|
||||
/lib/
|
||||
/test/gflags_unittest_main.cc
|
||||
/test/gflags_unittest-main.cc
|
||||
/packages/
|
||||
CMakeLists.txt.user
|
||||
/bazel-bin
|
||||
/bazel-genfiles
|
||||
/bazel-gflags
|
||||
/bazel-out
|
||||
/bazel-testlogs
|
2
AUTHORS
2
AUTHORS
|
@ -1,2 +0,0 @@
|
|||
opensource@google.com
|
||||
|
2
AUTHORS.txt
Normal file
2
AUTHORS.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
google-gflags@googlegroups.com
|
||||
|
26
BUILD
Normal file
26
BUILD
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Bazel (http://bazel.io/) BUILD file for gflags.
|
||||
#
|
||||
# See INSTALL.md for instructions for adding gflags to a Bazel workspace.
|
||||
|
||||
licenses(["notice"])
|
||||
|
||||
exports_files([
|
||||
"src/gflags_completions.sh",
|
||||
"COPYING.txt",
|
||||
])
|
||||
|
||||
config_setting(
|
||||
name = "x64_windows",
|
||||
values = {"cpu": "x64_windows"},
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "android",
|
||||
values = {"crosstool_top": "//external:android/crosstool"},
|
||||
)
|
||||
|
||||
load(":bazel/gflags.bzl", "gflags_library", "gflags_sources")
|
||||
|
||||
(hdrs, srcs) = gflags_sources(namespace=["google", "gflags"])
|
||||
gflags_library(hdrs=hdrs, srcs=srcs, threads=0)
|
||||
gflags_library(hdrs=hdrs, srcs=srcs, threads=1)
|
754
CMakeLists.txt
Normal file
754
CMakeLists.txt
Normal file
|
@ -0,0 +1,754 @@
|
|||
## CMake configuration file of gflags project
|
||||
##
|
||||
## This CMakeLists.txt defines some gflags specific configuration variables
|
||||
## using the "gflags_define" utility macro. The default values of these variables
|
||||
## can be overridden either on the CMake command-line using the -D option of
|
||||
## the cmake command or in a super-project which includes the gflags source
|
||||
## tree by setting the GFLAGS_<varname> CMake variables before adding the
|
||||
## gflags source directory via CMake's "add_subdirectory" command. Only when
|
||||
## the non-cached variable GFLAGS_IS_SUBPROJECT has a value equivalent to FALSE,
|
||||
## these configuration variables are added to the CMake cache so they can be
|
||||
## edited in the CMake GUI. By default, GFLAGS_IS_SUBPROJECT is set to TRUE when
|
||||
## the CMAKE_SOURCE_DIR is not identical to the directory of this CMakeLists.txt
|
||||
## file, i.e., the top-level directory of the gflags project source tree.
|
||||
##
|
||||
## When this project is a subproject (GFLAGS_IS_SUBPROJECT is TRUE), the default
|
||||
## settings are such that only the static single-threaded library is built without
|
||||
## installation of the gflags files. The "gflags::gflags" target is in this case an ALIAS
|
||||
## library target for the "gflags_nothreads_static" library target. Targets which
|
||||
## depend on the gflags library should link to the "gflags::gflags" library target.
|
||||
##
|
||||
## Example CMakeLists.txt of user project which requires separate gflags installation:
|
||||
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
##
|
||||
## project(Foo)
|
||||
##
|
||||
## find_package(gflags REQUIRED)
|
||||
##
|
||||
## add_executable(foo src/foo.cc)
|
||||
## target_link_libraries(foo gflags::gflags)
|
||||
##
|
||||
## Example CMakeLists.txt of user project which requires separate single-threaded static gflags installation:
|
||||
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
##
|
||||
## project(Foo)
|
||||
##
|
||||
## find_package(gflags COMPONENTS nothreads_static)
|
||||
##
|
||||
## add_executable(foo src/foo.cc)
|
||||
## target_link_libraries(foo gflags::gflags)
|
||||
##
|
||||
## Example CMakeLists.txt of super-project which contains gflags source tree:
|
||||
## cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
|
||||
##
|
||||
## project(Foo)
|
||||
##
|
||||
## add_subdirectory(gflags)
|
||||
##
|
||||
## add_executable(foo src/foo.cc)
|
||||
## target_link_libraries(foo gflags::gflags)
|
||||
##
|
||||
## Variables to configure the source files:
|
||||
## - GFLAGS_IS_A_DLL
|
||||
## - GFLAGS_NAMESPACE
|
||||
## - GFLAGS_ATTRIBUTE_UNUSED
|
||||
## - GFLAGS_INTTYPES_FORMAT
|
||||
##
|
||||
## Variables to configure the build:
|
||||
## - GFLAGS_SOVERSION
|
||||
## - GFLAGS_BUILD_SHARED_LIBS
|
||||
## - GFLAGS_BUILD_STATIC_LIBS
|
||||
## - GFLAGS_BUILD_gflags_LIB
|
||||
## - GFLAGS_BUILD_gflags_nothreads_LIB
|
||||
## - GFLAGS_BUILD_TESTING
|
||||
## - GFLAGS_BUILD_PACKAGING
|
||||
##
|
||||
## Variables to configure the installation:
|
||||
## - GFLAGS_INCLUDE_DIR
|
||||
## - GFLAGS_LIBRARY_INSTALL_DIR or LIB_INSTALL_DIR or LIB_SUFFIX
|
||||
## - GFLAGS_INSTALL_HEADERS
|
||||
## - GFLAGS_INSTALL_SHARED_LIBS
|
||||
## - GFLAGS_INSTALL_STATIC_LIBS
|
||||
|
||||
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
if (POLICY CMP0042)
|
||||
cmake_policy (SET CMP0042 NEW)
|
||||
endif ()
|
||||
|
||||
if (POLICY CMP0048)
|
||||
cmake_policy (SET CMP0048 NEW)
|
||||
endif ()
|
||||
|
||||
if (POLICY CMP0063)
|
||||
cmake_policy (SET CMP0063 NEW)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# includes
|
||||
include ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# package information
|
||||
set (PACKAGE_NAME "gflags")
|
||||
set (PACKAGE_VERSION "2.2.2")
|
||||
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
||||
set (PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
|
||||
set (PACKAGE_BUGREPORT "https://github.com/gflags/gflags/issues")
|
||||
set (PACKAGE_DESCRIPTION "A commandline flags library that allows for distributed flags.")
|
||||
set (PACKAGE_URL "http://gflags.github.io/gflags")
|
||||
|
||||
project (${PACKAGE_NAME} VERSION ${PACKAGE_VERSION} LANGUAGES CXX)
|
||||
if (CMAKE_VERSION VERSION_LESS 3.4)
|
||||
# C language still needed because the following required CMake modules
|
||||
# (or their dependencies, respectively) are not correctly handling
|
||||
# the case where only CXX is enabled
|
||||
# - CheckTypeSize.cmake (fixed in CMake 3.1, cf. https://cmake.org/Bug/view.php?id=14056)
|
||||
# - FindThreads.cmake (fixed in CMake 3.4, cf. https://cmake.org/Bug/view.php?id=14905)
|
||||
enable_language (C)
|
||||
endif ()
|
||||
|
||||
version_numbers (
|
||||
${PACKAGE_VERSION}
|
||||
PACKAGE_VERSION_MAJOR
|
||||
PACKAGE_VERSION_MINOR
|
||||
PACKAGE_VERSION_PATCH
|
||||
)
|
||||
|
||||
# shared library ABI version number, can be overridden by package maintainers
|
||||
# using -DGFLAGS_SOVERSION=XXX on the command-line
|
||||
if (GFLAGS_SOVERSION)
|
||||
set (PACKAGE_SOVERSION "${GFLAGS_SOVERSION}")
|
||||
else ()
|
||||
# TODO: Change default SOVERSION back to PACKAGE_VERSION_MAJOR with the
|
||||
# next increase of major version number (i.e., 3.0.0 -> SOVERSION 3)
|
||||
# The <major>.<minor> SOVERSION should be used for the 2.x releases
|
||||
# versions only which temporarily broke the API by changing the default
|
||||
# namespace from "google" to "gflags".
|
||||
set (PACKAGE_SOVERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
|
||||
endif ()
|
||||
|
||||
# when gflags is included as subproject (e.g., as Git submodule/subtree) in the source
|
||||
# tree of a project that uses it, no variables should be added to the CMake cache;
|
||||
# users may set the non-cached variable GFLAGS_IS_SUBPROJECT before add_subdirectory(gflags)
|
||||
if (NOT DEFINED GFLAGS_IS_SUBPROJECT)
|
||||
if ("^${CMAKE_SOURCE_DIR}$" STREQUAL "^${PROJECT_SOURCE_DIR}$")
|
||||
set (GFLAGS_IS_SUBPROJECT FALSE)
|
||||
else ()
|
||||
set (GFLAGS_IS_SUBPROJECT TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# prefix for package variables in CMake configuration file
|
||||
string (TOUPPER "${PACKAGE_NAME}" PACKAGE_PREFIX)
|
||||
|
||||
# convert file path on Windows with back slashes to path with forward slashes
|
||||
# otherwise this causes an issue with the cmake_install.cmake script
|
||||
file (TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# options
|
||||
|
||||
# maintain binary backwards compatibility with gflags library version <= 2.0,
|
||||
# but at the same time enable the use of the preferred new "gflags" namespace
|
||||
gflags_define (STRING NAMESPACE "Name(s) of library namespace (separate multiple options by semicolon)" "google;${PACKAGE_NAME}" "${PACKAGE_NAME}")
|
||||
gflags_property (NAMESPACE ADVANCED TRUE)
|
||||
set (GFLAGS_NAMESPACE_SECONDARY "${NAMESPACE}")
|
||||
list (REMOVE_DUPLICATES GFLAGS_NAMESPACE_SECONDARY)
|
||||
if (NOT GFLAGS_NAMESPACE_SECONDARY)
|
||||
message (FATAL_ERROR "GFLAGS_NAMESPACE must be set to one (or more) valid C++ namespace identifier(s separated by semicolon \";\").")
|
||||
endif ()
|
||||
foreach (ns IN LISTS GFLAGS_NAMESPACE_SECONDARY)
|
||||
if (NOT ns MATCHES "^[a-zA-Z][a-zA-Z0-9_]*$")
|
||||
message (FATAL_ERROR "GFLAGS_NAMESPACE contains invalid namespace identifier: ${ns}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
list (GET GFLAGS_NAMESPACE_SECONDARY 0 GFLAGS_NAMESPACE)
|
||||
list (REMOVE_AT GFLAGS_NAMESPACE_SECONDARY 0)
|
||||
|
||||
# cached build options when gflags is not a subproject, otherwise non-cached CMake variables
|
||||
# usage: gflags_define(BOOL <name> <doc> <default> [<subproject default>])
|
||||
gflags_define (BOOL BUILD_SHARED_LIBS "Request build of shared libraries." OFF OFF)
|
||||
gflags_define (BOOL BUILD_STATIC_LIBS "Request build of static libraries (default if BUILD_SHARED_LIBS is OFF)." OFF ON)
|
||||
gflags_define (BOOL BUILD_gflags_LIB "Request build of the multi-threaded gflags library." ON OFF)
|
||||
gflags_define (BOOL BUILD_gflags_nothreads_LIB "Request build of the single-threaded gflags library." ON ON)
|
||||
gflags_define (BOOL BUILD_PACKAGING "Enable build of distribution packages using CPack." OFF OFF)
|
||||
gflags_define (BOOL BUILD_TESTING "Enable build of the unit tests and their execution using CTest." OFF OFF)
|
||||
gflags_define (BOOL INSTALL_HEADERS "Request installation of headers and other development files." ON OFF)
|
||||
gflags_define (BOOL INSTALL_SHARED_LIBS "Request installation of shared libraries." ON ON)
|
||||
gflags_define (BOOL INSTALL_STATIC_LIBS "Request installation of static libraries." ON OFF)
|
||||
gflags_define (BOOL REGISTER_BUILD_DIR "Request entry of build directory in CMake's package registry." OFF OFF)
|
||||
gflags_define (BOOL REGISTER_INSTALL_PREFIX "Request entry of installed package in CMake's package registry." ON OFF)
|
||||
gflags_define (BOOL EXPORT_NAMESPACE_SET "Request export namespace targets set." ON ON)
|
||||
gflags_define (BOOL EXPORT_NONAMESPACE_SET "Request export nonamespace targets set." ON OFF)
|
||||
|
||||
gflags_property (BUILD_STATIC_LIBS ADVANCED TRUE)
|
||||
gflags_property (INSTALL_HEADERS ADVANCED TRUE)
|
||||
gflags_property (INSTALL_SHARED_LIBS ADVANCED TRUE)
|
||||
gflags_property (INSTALL_STATIC_LIBS ADVANCED TRUE)
|
||||
|
||||
if (NOT GFLAGS_IS_SUBPROJECT)
|
||||
foreach (varname IN ITEMS CMAKE_INSTALL_PREFIX)
|
||||
gflags_property (${varname} ADVANCED FALSE)
|
||||
endforeach ()
|
||||
foreach (varname IN ITEMS CMAKE_CONFIGURATION_TYPES CMAKE_OSX_ARCHITECTURES CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT)
|
||||
gflags_property (${varname} ADVANCED TRUE)
|
||||
endforeach ()
|
||||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CXX_FLAGS)
|
||||
gflags_set (CMAKE_BUILD_TYPE Release)
|
||||
endif ()
|
||||
if (CMAKE_CONFIGURATION_TYPES)
|
||||
gflags_property (CMAKE_BUILD_TYPE STRINGS "${CMAKE_CONFIGURATION_TYPES}")
|
||||
endif ()
|
||||
endif () # NOT GFLAGS_IS_SUBPROJECT
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
|
||||
set (BUILD_STATIC_LIBS ON)
|
||||
endif ()
|
||||
if (NOT BUILD_gflags_LIB AND NOT BUILD_gflags_nothreads_LIB)
|
||||
message (FATAL_ERROR "At least one of [GFLAGS_]BUILD_gflags_LIB and [GFLAGS_]BUILD_gflags_nothreads_LIB must be ON.")
|
||||
endif ()
|
||||
|
||||
gflags_define (STRING INCLUDE_DIR "Name of include directory of installed header files relative to CMAKE_INSTALL_PREFIX/include/" "${PACKAGE_NAME}")
|
||||
gflags_property (INCLUDE_DIR ADVANCED TRUE)
|
||||
file (TO_CMAKE_PATH "${INCLUDE_DIR}" INCLUDE_DIR)
|
||||
if (IS_ABSOLUTE INCLUDE_DIR)
|
||||
message (FATAL_ERROR "[GFLAGS_]INCLUDE_DIR must be a path relative to CMAKE_INSTALL_PREFIX/include/")
|
||||
endif ()
|
||||
if (INCLUDE_DIR MATCHES "^\\.\\.[/\\]")
|
||||
message (FATAL_ERROR "[GFLAGS_]INCLUDE_DIR must not start with parent directory reference (../)")
|
||||
endif ()
|
||||
set (GFLAGS_INCLUDE_DIR "${INCLUDE_DIR}")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# system checks
|
||||
include (CheckTypeSize)
|
||||
include (CheckIncludeFileCXX)
|
||||
include (CheckCXXSymbolExists)
|
||||
|
||||
if (WIN32 AND NOT CYGWIN)
|
||||
set (OS_WINDOWS 1)
|
||||
else ()
|
||||
set (OS_WINDOWS 0)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
set (HAVE_SYS_TYPES_H 1)
|
||||
set (HAVE_STDDEF_H 1) # used by CheckTypeSize module
|
||||
set (HAVE_UNISTD_H 0)
|
||||
set (HAVE_SYS_STAT_H 1)
|
||||
set (HAVE_SHLWAPI_H 1)
|
||||
if (MSVC_VERSION VERSION_LESS 1600)
|
||||
check_include_file_cxx ("stdint.h" HAVE_STDINT_H)
|
||||
bool_to_int (HAVE_STDINT_H) # used in #if directive
|
||||
else ()
|
||||
set (HAVE_STDINT_H 1)
|
||||
endif ()
|
||||
if (MSVC_VERSION VERSION_LESS 1800)
|
||||
check_include_file_cxx ("inttypes.h" HAVE_INTTYPES_H)
|
||||
bool_to_int (HAVE_INTTYPES_H) # used in #if directive
|
||||
else ()
|
||||
set (HAVE_INTTYPES_H 1)
|
||||
endif ()
|
||||
else ()
|
||||
foreach (fname IN ITEMS unistd stdint inttypes sys/types sys/stat fnmatch)
|
||||
string (TOUPPER "${fname}" FNAME)
|
||||
string (REPLACE "/" "_" FNAME "${FNAME}")
|
||||
if (NOT HAVE_${FNAME}_H)
|
||||
check_include_file_cxx ("${fname}.h" HAVE_${FNAME}_H)
|
||||
endif ()
|
||||
endforeach ()
|
||||
if (NOT HAVE_FNMATCH_H AND OS_WINDOWS)
|
||||
check_include_file_cxx ("shlwapi.h" HAVE_SHLWAPI_H)
|
||||
endif ()
|
||||
# the following are used in #if directives not #ifdef
|
||||
bool_to_int (HAVE_STDINT_H)
|
||||
bool_to_int (HAVE_SYS_TYPES_H)
|
||||
bool_to_int (HAVE_INTTYPES_H)
|
||||
endif ()
|
||||
|
||||
gflags_define (STRING INTTYPES_FORMAT "Format of integer types: \"C99\" (uint32_t), \"BSD\" (u_int32_t), \"VC7\" (__int32)" "")
|
||||
gflags_property (INTTYPES_FORMAT STRINGS "C99;BSD;VC7")
|
||||
gflags_property (INTTYPES_FORMAT ADVANCED TRUE)
|
||||
if (NOT INTTYPES_FORMAT)
|
||||
set (TYPES uint32_t u_int32_t)
|
||||
if (MSVC)
|
||||
list (INSERT TYPES 0 __int32)
|
||||
endif ()
|
||||
foreach (type IN LISTS TYPES)
|
||||
check_type_size (${type} ${type} LANGUAGE CXX)
|
||||
if (HAVE_${type})
|
||||
break ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
if (HAVE_uint32_t)
|
||||
gflags_set (INTTYPES_FORMAT C99)
|
||||
elseif (HAVE_u_int32_t)
|
||||
gflags_set (INTTYPES_FORMAT BSD)
|
||||
elseif (HAVE___int32)
|
||||
gflags_set (INTTYPES_FORMAT VC7)
|
||||
else ()
|
||||
gflags_property (INTTYPES_FORMAT ADVANCED FALSE)
|
||||
message (FATAL_ERROR "Do not know how to define a 32-bit integer quantity on your system!"
|
||||
" Neither uint32_t, u_int32_t, nor __int32 seem to be available."
|
||||
" Set [GFLAGS_]INTTYPES_FORMAT to either C99, BSD, or VC7 and try again.")
|
||||
endif ()
|
||||
endif ()
|
||||
# use of special characters in strings to circumvent bug #0008226
|
||||
if ("^${INTTYPES_FORMAT}$" STREQUAL "^WIN$")
|
||||
gflags_set (INTTYPES_FORMAT VC7)
|
||||
endif ()
|
||||
if (NOT INTTYPES_FORMAT MATCHES "^(C99|BSD|VC7)$")
|
||||
message (FATAL_ERROR "Invalid value for [GFLAGS_]INTTYPES_FORMAT! Choose one of \"C99\", \"BSD\", or \"VC7\"")
|
||||
endif ()
|
||||
set (GFLAGS_INTTYPES_FORMAT "${INTTYPES_FORMAT}")
|
||||
set (GFLAGS_INTTYPES_FORMAT_C99 0)
|
||||
set (GFLAGS_INTTYPES_FORMAT_BSD 0)
|
||||
set (GFLAGS_INTTYPES_FORMAT_VC7 0)
|
||||
set ("GFLAGS_INTTYPES_FORMAT_${INTTYPES_FORMAT}" 1)
|
||||
|
||||
if (MSVC)
|
||||
set (HAVE_strtoll 0)
|
||||
set (HAVE_strtoq 0)
|
||||
else ()
|
||||
check_cxx_symbol_exists (strtoll stdlib.h HAVE_STRTOLL)
|
||||
if (NOT HAVE_STRTOLL)
|
||||
check_cxx_symbol_exists (strtoq stdlib.h HAVE_STRTOQ)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (BUILD_gflags_LIB)
|
||||
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package (Threads)
|
||||
if (Threads_FOUND AND CMAKE_USE_PTHREADS_INIT)
|
||||
set (HAVE_PTHREAD 1)
|
||||
check_type_size (pthread_rwlock_t RWLOCK LANGUAGE CXX)
|
||||
else ()
|
||||
set (HAVE_PTHREAD 0)
|
||||
endif ()
|
||||
if (UNIX AND NOT HAVE_PTHREAD)
|
||||
if (CMAKE_HAVE_PTHREAD_H)
|
||||
set (what "library")
|
||||
else ()
|
||||
set (what ".h file")
|
||||
endif ()
|
||||
message (FATAL_ERROR "Could not find pthread${what}. Check the log file"
|
||||
"\n\t${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
|
||||
"\nor disable the build of the multi-threaded gflags library (BUILD_gflags_LIB=OFF).")
|
||||
endif ()
|
||||
else ()
|
||||
set (HAVE_PTHREAD 0)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# source files - excluding root subdirectory and/or .in suffix
|
||||
set (PUBLIC_HDRS
|
||||
"gflags.h"
|
||||
"gflags_declare.h"
|
||||
"gflags_completions.h"
|
||||
)
|
||||
|
||||
if (GFLAGS_NAMESPACE_SECONDARY)
|
||||
set (INCLUDE_GFLAGS_NS_H "// Import gflags library symbols into alternative/deprecated namespace(s)")
|
||||
foreach (ns IN LISTS GFLAGS_NAMESPACE_SECONDARY)
|
||||
string (TOUPPER "${ns}" NS)
|
||||
set (gflags_ns_h "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/gflags_${ns}.h")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/src/gflags_ns.h.in" "${gflags_ns_h}" @ONLY)
|
||||
list (APPEND PUBLIC_HDRS "${gflags_ns_h}")
|
||||
set (INCLUDE_GFLAGS_NS_H "${INCLUDE_GFLAGS_NS_H}\n#include \"gflags_${ns}.h\"")
|
||||
endforeach ()
|
||||
else ()
|
||||
set (INCLUDE_GFLAGS_NS_H)
|
||||
endif ()
|
||||
|
||||
set (PRIVATE_HDRS
|
||||
"defines.h"
|
||||
"config.h"
|
||||
"util.h"
|
||||
"mutex.h"
|
||||
)
|
||||
|
||||
set (GFLAGS_SRCS
|
||||
"gflags.cc"
|
||||
"gflags_reporting.cc"
|
||||
"gflags_completions.cc"
|
||||
)
|
||||
|
||||
if (OS_WINDOWS)
|
||||
list (APPEND PRIVATE_HDRS "windows_port.h")
|
||||
list (APPEND GFLAGS_SRCS "windows_port.cc")
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# configure source files
|
||||
if (NOT DEFINED GFLAGS_ATTRIBUTE_UNUSED)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (GFLAGS_ATTRIBUTE_UNUSED "__attribute((unused))")
|
||||
else ()
|
||||
set (GFLAGS_ATTRIBUTE_UNUSED)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# whenever we build a shared library (DLL on Windows), configure the public
|
||||
# headers of the API for use of this shared library rather than the optionally
|
||||
# also build statically linked library; users can override GFLAGS_DLL_DECL
|
||||
# in particular, this done by setting the INTERFACE_COMPILE_DEFINITIONS of
|
||||
# static libraries to include an empty definition for GFLAGS_DLL_DECL
|
||||
if (NOT DEFINED GFLAGS_IS_A_DLL)
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set (GFLAGS_IS_A_DLL 1)
|
||||
else ()
|
||||
set (GFLAGS_IS_A_DLL 0)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
configure_headers (PUBLIC_HDRS ${PUBLIC_HDRS})
|
||||
configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS})
|
||||
configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS})
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# output directories
|
||||
if (NOT GFLAGS_IS_SUBPROJECT)
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "lib")
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib")
|
||||
endif ()
|
||||
# Set postfixes for generated libraries based on buildtype.
|
||||
set(CMAKE_RELEASE_POSTFIX "")
|
||||
set(CMAKE_DEBUG_POSTFIX "_debug")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# installation directories
|
||||
if (OS_WINDOWS AND NOT MINGW)
|
||||
set (RUNTIME_INSTALL_DIR "bin")
|
||||
set (LIBRARY_INSTALL_DIR "lib")
|
||||
set (INCLUDE_INSTALL_DIR "include")
|
||||
set (CONFIG_INSTALL_DIR "lib/cmake/${PACKAGE_NAME}")
|
||||
set (PKGCONFIG_INSTALL_DIR)
|
||||
else ()
|
||||
set (RUNTIME_INSTALL_DIR bin)
|
||||
# The LIB_INSTALL_DIR and LIB_SUFFIX variables are used by the Fedora
|
||||
# package maintainers. Also package maintainers of other distribution
|
||||
# packages need to be able to specify the name of the library directory.
|
||||
if (NOT GFLAGS_LIBRARY_INSTALL_DIR AND LIB_INSTALL_DIR)
|
||||
set (GFLAGS_LIBRARY_INSTALL_DIR "${LIB_INSTALL_DIR}")
|
||||
endif ()
|
||||
gflags_define (PATH LIBRARY_INSTALL_DIR "Directory of installed libraries, e.g., \"lib64\"" "lib${LIB_SUFFIX}")
|
||||
gflags_property (LIBRARY_INSTALL_DIR ADVANCED TRUE)
|
||||
set (INCLUDE_INSTALL_DIR include)
|
||||
set (CONFIG_INSTALL_DIR ${LIBRARY_INSTALL_DIR}/cmake/${PACKAGE_NAME})
|
||||
set (PKGCONFIG_INSTALL_DIR ${LIBRARY_INSTALL_DIR}/pkgconfig)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# add library targets
|
||||
set (TARGETS)
|
||||
# static vs. shared
|
||||
foreach (TYPE IN ITEMS STATIC SHARED)
|
||||
if (BUILD_${TYPE}_LIBS)
|
||||
string (TOLOWER "${TYPE}" type)
|
||||
# whether or not targets are a DLL
|
||||
if (OS_WINDOWS AND "^${TYPE}$" STREQUAL "^SHARED$")
|
||||
set (GFLAGS_IS_A_DLL 1)
|
||||
else ()
|
||||
set (GFLAGS_IS_A_DLL 0)
|
||||
endif ()
|
||||
# filename suffix for static libraries on Windows for MSVC toolchain only
|
||||
if (OS_WINDOWS AND NOT MINGW AND "^${TYPE}$" STREQUAL "^STATIC$")
|
||||
set (type_suffix "_${type}")
|
||||
else ()
|
||||
set (type_suffix "")
|
||||
endif ()
|
||||
# multi-threaded vs. single-threaded
|
||||
foreach (opts IN ITEMS "" _nothreads)
|
||||
if (BUILD_gflags${opts}_LIB)
|
||||
set (target_name "gflags${opts}_${type}")
|
||||
add_library (${target_name} ${TYPE} ${GFLAGS_SRCS} ${PRIVATE_HDRS} ${PUBLIC_HDRS})
|
||||
set_target_properties (${target_name} PROPERTIES
|
||||
OUTPUT_NAME "gflags${opts}${type_suffix}"
|
||||
VERSION "${PACKAGE_VERSION}"
|
||||
SOVERSION "${PACKAGE_SOVERSION}"
|
||||
)
|
||||
set (include_dirs "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>")
|
||||
if (INSTALL_HEADERS)
|
||||
list (APPEND include_dirs "$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>")
|
||||
endif ()
|
||||
target_include_directories (${target_name}
|
||||
PUBLIC "${include_dirs}"
|
||||
PRIVATE "${PROJECT_SOURCE_DIR}/src;${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}"
|
||||
)
|
||||
target_compile_definitions (${target_name} PUBLIC GFLAGS_IS_A_DLL=${GFLAGS_IS_A_DLL})
|
||||
if (opts MATCHES "nothreads")
|
||||
target_compile_definitions (${target_name} PRIVATE NO_THREADS)
|
||||
elseif (CMAKE_USE_PTHREADS_INIT)
|
||||
target_link_libraries (${target_name} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif ()
|
||||
if (HAVE_SHLWAPI_H)
|
||||
target_link_libraries (${target_name} shlwapi.lib)
|
||||
endif ()
|
||||
list (APPEND TARGETS ${target_name})
|
||||
# add convenience make target for build of both shared and static libraries
|
||||
if (NOT GFLAGS_IS_SUBPROJECT)
|
||||
if (NOT TARGET gflags${opts})
|
||||
add_custom_target (gflags${opts})
|
||||
endif ()
|
||||
add_dependencies (gflags${opts} ${target_name})
|
||||
endif ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# add ALIAS target for use in super-project, prefer static over shared, single-threaded over multi-threaded
|
||||
if (GFLAGS_IS_SUBPROJECT)
|
||||
foreach (type IN ITEMS static shared)
|
||||
foreach (opts IN ITEMS "_nothreads" "")
|
||||
if (TARGET gflags${opts}_${type})
|
||||
# Define "gflags" alias for super-projects treating targets of this library as part of their own project
|
||||
# (also for backwards compatibility with gflags 2.2.1 which only defined this alias)
|
||||
add_library (gflags ALIAS gflags${opts}_${type})
|
||||
# Define "gflags::gflags" alias for projects that support both find_package(gflags) and add_subdirectory(gflags)
|
||||
add_library (gflags::gflags ALIAS gflags${opts}_${type})
|
||||
break ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
if (TARGET gflags::gflags)
|
||||
break ()
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# installation rules
|
||||
set (EXPORT_NAME ${PACKAGE_NAME}-targets)
|
||||
file (RELATIVE_PATH INSTALL_PREFIX_REL2CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake" @ONLY)
|
||||
configure_file (cmake/version.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake" @ONLY)
|
||||
|
||||
if (BUILD_SHARED_LIBS AND INSTALL_SHARED_LIBS)
|
||||
foreach (opts IN ITEMS "" _nothreads)
|
||||
if (BUILD_gflags${opts}_LIB)
|
||||
install (TARGETS gflags${opts}_shared
|
||||
EXPORT ${EXPORT_NAME}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
)
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
if (BUILD_STATIC_LIBS AND INSTALL_STATIC_LIBS)
|
||||
foreach (opts IN ITEMS "" _nothreads)
|
||||
if (BUILD_gflags${opts}_LIB)
|
||||
install (TARGETS gflags${opts}_static
|
||||
EXPORT ${EXPORT_NAME}
|
||||
RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
|
||||
LIBRARY DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR}
|
||||
)
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
|
||||
if (INSTALL_HEADERS)
|
||||
install (FILES ${PUBLIC_HDRS} DESTINATION ${INCLUDE_INSTALL_DIR}/${GFLAGS_INCLUDE_DIR})
|
||||
install (
|
||||
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-install.cmake"
|
||||
RENAME ${PACKAGE_NAME}-config.cmake
|
||||
DESTINATION ${CONFIG_INSTALL_DIR}
|
||||
)
|
||||
install (
|
||||
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config-version.cmake"
|
||||
DESTINATION ${CONFIG_INSTALL_DIR}
|
||||
)
|
||||
if (EXPORT_NAMESPACE_SET)
|
||||
install (
|
||||
EXPORT ${EXPORT_NAME}
|
||||
NAMESPACE ${PACKAGE_NAME}::
|
||||
DESTINATION ${CONFIG_INSTALL_DIR}
|
||||
)
|
||||
endif ()
|
||||
if (EXPORT_NONAMESPACE_SET)
|
||||
install (
|
||||
EXPORT ${EXPORT_NAME}
|
||||
FILE ${PACKAGE_NAME}-nonamespace-targets.cmake
|
||||
DESTINATION ${CONFIG_INSTALL_DIR}
|
||||
)
|
||||
endif ()
|
||||
if (UNIX)
|
||||
install (PROGRAMS src/gflags_completions.sh DESTINATION ${RUNTIME_INSTALL_DIR})
|
||||
endif ()
|
||||
if (PKGCONFIG_INSTALL_DIR)
|
||||
configure_file ("cmake/package.pc.in" "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}.pc" @ONLY)
|
||||
install (FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}.pc" DESTINATION "${PKGCONFIG_INSTALL_DIR}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# support direct use of build tree
|
||||
set (INSTALL_PREFIX_REL2CONFIG_DIR .)
|
||||
if (EXPORT_NAMESPACE_SET)
|
||||
export (
|
||||
TARGETS ${TARGETS}
|
||||
NAMESPACE ${PACKAGE_NAME}::
|
||||
FILE "${PROJECT_BINARY_DIR}/${EXPORT_NAME}.cmake"
|
||||
)
|
||||
endif ()
|
||||
if (EXPORT_NONAMESPACE_SET)
|
||||
export (
|
||||
TARGETS ${TARGETS}
|
||||
FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-nonamespace-targets.cmake"
|
||||
)
|
||||
endif ()
|
||||
if (REGISTER_BUILD_DIR)
|
||||
export (PACKAGE ${PACKAGE_NAME})
|
||||
endif ()
|
||||
if (REGISTER_INSTALL_PREFIX)
|
||||
register_gflags_package(${CONFIG_INSTALL_DIR})
|
||||
endif ()
|
||||
configure_file (cmake/config.cmake.in "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-config.cmake" @ONLY)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# testing - MUST follow the generation of the build tree config file
|
||||
if (BUILD_TESTING)
|
||||
include (CTest)
|
||||
add_subdirectory (test)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# packaging
|
||||
if (BUILD_PACKAGING)
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS AND NOT INSTALL_HEADERS)
|
||||
message (WARNING "Package will contain static libraries without headers!"
|
||||
"\nRecommended options for generation of runtime package:"
|
||||
"\n BUILD_SHARED_LIBS=ON"
|
||||
"\n BUILD_STATIC_LIBS=OFF"
|
||||
"\n INSTALL_HEADERS=OFF"
|
||||
"\n INSTALL_SHARED_LIBS=ON"
|
||||
"\nRecommended options for generation of development package:"
|
||||
"\n BUILD_SHARED_LIBS=ON"
|
||||
"\n BUILD_STATIC_LIBS=ON"
|
||||
"\n INSTALL_HEADERS=ON"
|
||||
"\n INSTALL_SHARED_LIBS=ON"
|
||||
"\n INSTALL_STATIC_LIBS=ON"
|
||||
)
|
||||
endif ()
|
||||
|
||||
# default package generators
|
||||
if (APPLE)
|
||||
set (PACKAGE_GENERATOR "PackageMaker")
|
||||
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
|
||||
elseif (UNIX)
|
||||
set (PACKAGE_GENERATOR "DEB;RPM")
|
||||
set (PACKAGE_SOURCE_GENERATOR "TGZ;ZIP")
|
||||
else ()
|
||||
set (PACKAGE_GENERATOR "ZIP")
|
||||
set (PACKAGE_SOURCE_GENERATOR "ZIP")
|
||||
endif ()
|
||||
|
||||
# used package generators
|
||||
set (CPACK_GENERATOR "${PACKAGE_GENERATOR}" CACHE STRING "List of binary package generators (CPack).")
|
||||
set (CPACK_SOURCE_GENERATOR "${PACKAGE_SOURCE_GENERATOR}" CACHE STRING "List of source package generators (CPack).")
|
||||
mark_as_advanced (CPACK_GENERATOR CPACK_SOURCE_GENERATOR)
|
||||
|
||||
# some package generators (e.g., PackageMaker) do not allow .md extension
|
||||
configure_file ("${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_BINARY_DIR}/README.txt" COPYONLY)
|
||||
|
||||
# common package information
|
||||
set (CPACK_PACKAGE_VENDOR "Andreas Schuh")
|
||||
set (CPACK_PACKAGE_CONTACT "google-gflags@googlegroups.com")
|
||||
set (CPACK_PACKAGE_NAME "${PACKAGE_NAME}")
|
||||
set (CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
|
||||
set (CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}")
|
||||
set (CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}")
|
||||
set (CPACK_PACKAGE_VERSION_PATCH "${PACKAGE_VERSION_PATCH}")
|
||||
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}")
|
||||
set (CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
|
||||
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/COPYING.txt")
|
||||
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
|
||||
set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
|
||||
set (CPACK_OUTPUT_FILE_PREFIX packages)
|
||||
set (CPACK_PACKAGE_RELOCATABLE TRUE)
|
||||
set (CPACK_MONOLITHIC_INSTALL TRUE)
|
||||
|
||||
# RPM package information -- used in cmake/package.cmake.in also for DEB
|
||||
set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
|
||||
set (CPACK_RPM_PACKAGE_LICENSE "BSD")
|
||||
set (CPACK_RPM_PACKAGE_URL "${PACKAGE_URL}")
|
||||
set (CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_LIST_DIR}/ChangeLog.txt")
|
||||
|
||||
if (INSTALL_HEADERS)
|
||||
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/doc/index.html")
|
||||
else ()
|
||||
set (CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_LIST_DIR}/cmake/README_runtime.txt")
|
||||
endif ()
|
||||
|
||||
# system/architecture
|
||||
if (WINDOWS)
|
||||
if (CMAKE_CL_64)
|
||||
set (CPACK_SYSTEM_NAME "win64")
|
||||
else ()
|
||||
set (CPACK_SYSTEM_NAME "win32")
|
||||
endif ()
|
||||
set (CPACK_PACKAGE_ARCHITECTURE)
|
||||
elseif (APPLE)
|
||||
set (CPACK_PACKAGE_ARCHITECTURE darwin)
|
||||
else ()
|
||||
string (TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)
|
||||
if (CMAKE_CXX_FLAGS MATCHES "-m32")
|
||||
set (CPACK_PACKAGE_ARCHITECTURE i386)
|
||||
else ()
|
||||
execute_process (
|
||||
COMMAND dpkg --print-architecture
|
||||
RESULT_VARIABLE RV
|
||||
OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE
|
||||
)
|
||||
if (RV EQUAL 0)
|
||||
string (STRIP "${CPACK_PACKAGE_ARCHITECTURE}" CPACK_PACKAGE_ARCHITECTURE)
|
||||
else ()
|
||||
execute_process (COMMAND uname -m OUTPUT_VARIABLE CPACK_PACKAGE_ARCHITECTURE)
|
||||
if (CPACK_PACKAGE_ARCHITECTURE MATCHES "x86_64")
|
||||
set (CPACK_PACKAGE_ARCHITECTURE amd64)
|
||||
else ()
|
||||
set (CPACK_PACKAGE_ARCHITECTURE i386)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# source package settings
|
||||
set (CPACK_SOURCE_TOPLEVEL_TAG "source")
|
||||
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git/;\\\\.swp$;\\\\.#;/#;\\\\.*~;cscope\\\\.*;/[Bb]uild[.+-_a-zA-Z0-9]*/")
|
||||
|
||||
# default binary package settings
|
||||
set (CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE)
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
|
||||
if (CPACK_PACKAGE_ARCHITECTURE)
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_ARCHITECTURE}")
|
||||
endif ()
|
||||
|
||||
# generator specific configuration file
|
||||
#
|
||||
# allow package maintainers to use their own configuration file
|
||||
# $ cmake -DCPACK_PROJECT_CONFIG_FILE:FILE=/path/to/package/config
|
||||
if (NOT CPACK_PROJECT_CONFIG_FILE)
|
||||
configure_file (
|
||||
"${CMAKE_CURRENT_LIST_DIR}/cmake/package.cmake.in"
|
||||
"${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake" @ONLY
|
||||
)
|
||||
set (CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-package.cmake")
|
||||
endif ()
|
||||
|
||||
include (CPack)
|
||||
|
||||
endif () # BUILD_PACKAGING
|
||||
|
||||
if (NOT GFLAGS_IS_SUBPROJECT AND NOT TARGET uninstall)
|
||||
configure_file (
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" @ONLY
|
||||
)
|
||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
endif ()
|
127
ChangeLog
127
ChangeLog
|
@ -1,127 +0,0 @@
|
|||
Tue Apr 14 12:35:25 2009 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 1.1
|
||||
* Add both foo and nofoo for boolean flags, with --undefok (andychu)
|
||||
* Better document how validators work (wojtekm)
|
||||
* Improve binary-detection for bash-completion (mtamsky)
|
||||
* Python: Add a concept of "key flags", used with --help (salcianu)
|
||||
* Python: Robustify flag_values (salcianu)
|
||||
* Python: Add a new DEFINE_bool alias (keir, andrewliu)
|
||||
* Python: Do module introspection based on module name (dsturtevant)
|
||||
* Fix autoconf a bit better, especially on windows and solaris (ajenjo)
|
||||
* BUG FIX: gflags_nothreads was linking against the wrong lib (ajenjo)
|
||||
* BUG FIX: threads-detection failed on FreeBSD; replace it (ajenjo)
|
||||
* PORTABILITY: Quiet an internal compiler error with SUSE 10 (csilvers)
|
||||
* PORTABILITY: Update deb.sh for more recenty debuilds (csilvers)
|
||||
* PORTABILITY: #include more headers to satify new gcc's (csilvers)
|
||||
* INSTALL: Updated to autoconf 2.61 and libtool 1.5.26 (csilvers)
|
||||
|
||||
Fri Oct 3 15:16:46 2008 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 1.0
|
||||
* Add a missing newline to an error string (bcmills)
|
||||
* (otherwise exactly the same as gflags 1.0rc2)
|
||||
|
||||
Thu Sep 18 12:58:05 2008 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 1.0rc2
|
||||
* Report current flag values in --helpxml (hdn)
|
||||
* Fix compilation troubles with gcc 4.3.3 (simonb)
|
||||
* BUG FIX: I was missing a std:: in DECLARE_string (csilvers)
|
||||
* BUG FIX: Clarify in docs how to specify --bool flags (csilvers)
|
||||
* BUG FIX: Fix --helpshort for source files not in a subdir (csilvers)
|
||||
* BUG FIX: Fix python unittest for 64-bit builds (bcmills)
|
||||
|
||||
Tue Aug 19 16:15:48 2008
|
||||
|
||||
* google-gflags: version 1.0rc1
|
||||
* Move #include files from google/ to gflags/ (csilvers)
|
||||
* Small optimizations to reduce binary (library) size (jyrki)
|
||||
* BUGFIX: forgot a std:: in one of the .h files (csilvers)
|
||||
* Speed up locking by making sure calls are inlined (ajenjo)
|
||||
* 64-BIT COMPATIBILITY: Use %PRId64 instead of %lld (csilvers)
|
||||
* PORTABILITY: fix Makefile to work with Cygwin (ajenjo)
|
||||
* PORTABILITY: fix code to compile under Visual Studio (ajenjo)
|
||||
* PORTABILITY: fix code to compile under Solaris 10 with CC (csilvers)
|
||||
|
||||
Mon Jul 21 23:01:38 2008 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.9
|
||||
* Add the ability to validate a command-line flag (csilvers)
|
||||
* Add completion support for commandline flags in bash (daven)
|
||||
* Add -W compile flags to Makefile, when using gcc (csilvers)
|
||||
* Allow helpstring to be NULL (cristianoc)
|
||||
* Improved documentation of classes in the .cc file (csilvers)
|
||||
* Fix python bug with AppendFlagValues + shortnames (jjtswan)
|
||||
* Use bool instead of int for boolean flags in gflags.py (bcmills)
|
||||
* Simplify the way we declare flags, now more foolproof (csilvers)
|
||||
* Better error messages when bool flags collide (colohan)
|
||||
* Only evaluate DEFINE_foo macro args once (csilvers)
|
||||
|
||||
Wed Mar 26 15:20:18 2008 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.8
|
||||
* Export DescribeOneFlag() in the API
|
||||
* Add support for automatic line wrapping at 80 cols for gflags.py
|
||||
* Bugfix: do not treat an isolated "-" the same as an isolated "--"
|
||||
* Update rpm spec to point to Google Code rather than sourceforge (!)
|
||||
* Improve documentation (including documenting thread-safety)
|
||||
* Improve #include hygiene
|
||||
* Improve testing
|
||||
|
||||
Thu Oct 18 11:33:20 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.7
|
||||
* Deal even more correctly with libpthread not linked in (csilvers)
|
||||
* Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe)
|
||||
* Be more accurate printing default flag values in --help (dsturtevant)
|
||||
* Reduce .o file size a bit by using shorter namespace names (jeff)
|
||||
* Use relative install path, so 'setup.py --home' works (csilvers)
|
||||
* Notice when a boolean flag has a non-boolean default (bnmouli)
|
||||
* Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie)
|
||||
* Fix "no modules match" message for --helpshort, etc (hendrie)
|
||||
|
||||
Wed Aug 15 07:35:51 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.6
|
||||
* Deal correctly with case that libpthread is not linked in (csilvers)
|
||||
* Update Makefile/tests so we pass "make distcheck" (csilvers)
|
||||
* Document and test that last assignment to a flag wins (wan)
|
||||
|
||||
Tue Jun 12 15:23:42 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.5
|
||||
* Include all m4 macros in the distribution (csilvers)
|
||||
* Python: Fix broken data_files field in setup.py (sidlon)
|
||||
* Python: better string serliaizing and unparsing (abo, csimmons)
|
||||
* Fix checks for NaN and inf to work with Mac OS X (csilvers)
|
||||
|
||||
Thu Apr 19 15:15:07 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.4
|
||||
* Remove is_default from GetCommandLineFlagInfo (csilvers)
|
||||
* Portability fixes: includes, strtoll, gcc4.3 errors (csilvers)
|
||||
* A few doc typo cleanups (csilvers)
|
||||
|
||||
Wed Mar 28 12:15:56 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.3
|
||||
* python portability fix: use popen instead of subprocess (csilvers)
|
||||
* Add is_default to CommandLineFlagInfo (pchien)
|
||||
* Make docs a bit prettier (csilvers)
|
||||
* Actually include the python files in the distribution! :-/ (csilvers)
|
||||
|
||||
Mon Jan 22 15:33:06 2007 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: version 0.2
|
||||
* added support for python commandlineflags, as well as c++
|
||||
* gflags2man, a script to turn flags into a man page (dchristian)
|
||||
|
||||
Wed Dec 13 12:37:19 2006 Google Inc. <opensource@google.com>
|
||||
|
||||
* google-gflags: initial release:
|
||||
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.
|
276
ChangeLog.txt
Normal file
276
ChangeLog.txt
Normal file
|
@ -0,0 +1,276 @@
|
|||
* Sun Nov 11 2018 - Andreas Schuh <andreas.schuh.84@gmail.com>
|
||||
|
||||
- gflags: version 2.2.2
|
||||
Fixed 267: Support build with GCC option "-fvisibility=hidden".
|
||||
Fixed 262: Declare FLAGS_no##name variables as static to avoid "previous extern" warning.
|
||||
Fixed 261: Declare FlagRegisterer c’tor explicit template instanations as extern in header
|
||||
Fixed 257: Build with _UNICODE support on Windows.
|
||||
Fixed 233/234/235: Move CMake defines that are unused by Bazel to separate header; makes config.h private again
|
||||
Fixed 228: Build with recent MinGW versions that define setenv.
|
||||
Fixed 226: Remove obsolete and unused CleanFileName code
|
||||
Merged 266: Various PVS Studio and GCC warnings.
|
||||
Merged 258: Fix build with some Clang variants that define "restrict" macro.
|
||||
Merged 252: Update documentation on how to use Bazel.
|
||||
Merged 249: Use "_debug" postfix for debug libraries.
|
||||
Merged 247: CMake "project" VERSION; no enable_testing(); "gflags::" import target prefix.
|
||||
Merged 246: Add Bazel-on-Windows support.
|
||||
Merged 239: Use GFLAGS_NAMESPACE instead of "gflags" in test executable.
|
||||
Merged 237: Removed unused functions; fixes compilation with -Werror compiler option.
|
||||
Merged 232: Fix typo in Bazel's BUILD definition
|
||||
Merged 230: Remove using ::fLS::clstring.
|
||||
Merged 221: Add convenience 'uninstall' target
|
||||
|
||||
* Tue Jul 11 2017 - Andreas Schuh <andreas.schuh.84@gmail.com>
|
||||
|
||||
- gflags: version 2.2.1
|
||||
- Link to online documentation in README
|
||||
- Merged 194: Include utils by file instead of CMAKE_MODULE_PATH search
|
||||
- Merged 195: Remove unused program_name variable
|
||||
- Merged 196: Enable language C for older CMake versions when needed
|
||||
- Merged 202: Changed include directory in bazel build
|
||||
- Merged 207: Mark single argument constructors in mutex.h as explicit
|
||||
- Merged 209: Use inttypes.h on VC++ 2013 and later
|
||||
- Merged 212: Fix statically linked gflags library with MSVC
|
||||
- Merged 213: Modify installation paths on Windows for vcpkg
|
||||
- Merged 215: Fix static initialization order fiasco caused by global registry lock
|
||||
- Merged 216: Fix use of ARGC in CMake macros
|
||||
- Merged 222: Static code analyzer error regarding strncmp with empty kRootDir
|
||||
- Merged 224: Check HAVE_STDINT_H or HAVE_INTTYPES_H for older MSVC versions
|
||||
|
||||
* Fri Nov 25 2016 - Andreas Schuh <andreas.schuh.84@gmail.com>
|
||||
|
||||
- gflags: version 2.2.0
|
||||
- Merged 178: Implicitly convert dashes in option names to underscores
|
||||
- Merged 159: CI builds and automatic tests with Travis CI and AppVeyor
|
||||
- Merged 158: Use enum for flag value types
|
||||
- Merged 126: File name postfix for static libraries on Windows
|
||||
- Closed issue 120: Configure and install gflags.pc file for pkg-config users
|
||||
- Fixed issue 127: snprintf already defined when building with MSVC 2015
|
||||
- Fixed issue 51/138: Memory leaks reported by valgrind
|
||||
- Fixed issue 173: Validate flags only once
|
||||
- Fixed issue 168: Unsigned and signed comparison in gflags_reporting.cc
|
||||
- Fixed issues 176/153: Add -lpthread link argument to Bazel build, refactor BUILD rules
|
||||
- Fixed issue 89: Add GFLAGS_IS_A_DLL to imported CMake target INTERFACE_COMPILE_DEFINITIONS
|
||||
- Fixed issue 104: Set INTERFACE_INCLUDE_DIRECTORIES of exported CMake targets
|
||||
- Fixed issue 174: Missing gflags-targets.cmake file after installation
|
||||
- Fixed issue 186: Error linking to gflags IMPLIB with MSVC using CMake
|
||||
- Closed issue 106: Add example project to test use of gflags library
|
||||
|
||||
* Tue Mar 24 2014 - Andreas Schuh <andreas.schuh.84@gmail.com>
|
||||
|
||||
- gflags: version 2.1.2
|
||||
- Moved project to GitHub
|
||||
- Added GFLAGS_NAMESPACE definition to gflags_declare.h
|
||||
- Fixed issue 94: Keep "google" as primary namespace and import symbols into "gflags" namespace
|
||||
- Fixed issue 96: Fix binary ABI compatibility with gflags 2.0 using "google" as primary namespace
|
||||
- Fixed issue 97/101: Removed (patched) CMake modules and enabled C language instead
|
||||
- Fixed issue 103: Set CMake policy CMP0042 to silence warning regarding MACOS_RPATH setting
|
||||
|
||||
* Sun Mar 20 2014 - Andreas Schuh <google-gflags@googlegroups.com>
|
||||
|
||||
- gflags: version 2.1.1
|
||||
- Fixed issue 77: GFLAGS_IS_A_DLL expands to empty string in gflags_declare.h
|
||||
- Fixed issue 79: GFLAGS_NAMESPACE not expanded to actual namespace in gflags_declare.h
|
||||
- Fixed issue 80: Allow include path to differ from GFLAGS_NAMESPACE
|
||||
|
||||
* Thu Mar 20 2014 - Andreas Schuh <google-gflags@googlegroups.com>
|
||||
|
||||
- gflags: version 2.1.0
|
||||
- Build system configuration using CMake instead of autotools
|
||||
- CPack packaging support for Debian/Ubuntu, Red Hat, and Mac OS X
|
||||
- Fixed issue 54: Fix "invalid suffix on literal" (C++11)
|
||||
- Fixed issue 57: Use _strdup instead of strdup on Windows
|
||||
- Fixed issue 62: Change all preprocessor include guards to start with GFLAGS_
|
||||
- Fixed issue 64: Add DEFINE_validator macro
|
||||
- Fixed issue 73: Warnings in Visual Studio 2010 and unable to compile unit test
|
||||
|
||||
* Wed Jan 25 2012 - Google Inc. <google-gflags@googlegroups.com>
|
||||
|
||||
- gflags: version 2.0
|
||||
- Changed the 'official' gflags email in setup.py/etc
|
||||
- Renamed google-gflags.sln to gflags.sln
|
||||
- Changed copyright text to reflect Google's relinquished ownership
|
||||
|
||||
* Tue Dec 20 2011 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.7
|
||||
- Add CommandLineFlagInfo::flag_ptr pointing to current storage (musji)
|
||||
- PORTING: flush after writing to stderr, needed on cygwin
|
||||
- PORTING: Clean up the GFLAGS_DLL_DECL stuff better
|
||||
- Fix a bug in StringPrintf() that affected large strings (csilvers)
|
||||
- Die at configure-time when g++ isn't installed
|
||||
|
||||
* Fri Jul 29 2011 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.6
|
||||
- BUGFIX: Fix a bug where we were leaving out a required $(top_srcdir)
|
||||
- Fix definition of clstring (jyrki)
|
||||
- Split up flag declares into its own file (jyrki)
|
||||
- Add --version support (csilvers)
|
||||
- Update the README for gflags with static libs
|
||||
- Update acx_pthread.m4 for nostdlib
|
||||
- Change ReparseCommandLineFlags to return void (csilvers)
|
||||
- Some doc typofixes and example augmentation (various)
|
||||
|
||||
* Mon Jan 24 2011 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.5
|
||||
- Better reporting of current vs default value (handler)
|
||||
- Add API for cleaning up of memory at program-exit (jmarantz)
|
||||
- Fix macros to work inside namespaces (csilvers)
|
||||
- Use our own string typedef in case string is redefined (csilvers)
|
||||
- Updated to autoconf 2.65
|
||||
|
||||
* Wed Oct 13 2010 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.4
|
||||
- Add a check to prevent passing 0 to DEFINE_string (jorg)
|
||||
- Reduce compile (.o) size (jyrki)
|
||||
- Some small changes to quiet debug compiles (alexk)
|
||||
- PORTING: better support static linking on windows (csilvers)
|
||||
- DOCUMENTATION: change default values, use validators, etc.
|
||||
- Update the NEWS file to be non-empty
|
||||
- Add pkg-config (.pc) files for libgflags and libgflags_nothreads
|
||||
|
||||
* Mon Jan 4 2010 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.3
|
||||
- PORTABILITY: can now build and run tests under MSVC (csilvers)
|
||||
- Remove the python gflags code, which is now its own package (tansell)
|
||||
- Clarify that "last flag wins" in the docs (csilvers)
|
||||
- Comment danger of using GetAllFlags in validators (wojtekm)
|
||||
- PORTABILITY: Some fixes necessary for c++0x (mboerger)
|
||||
- Makefile fix: $(srcdir) -> $(top_srcdir) in one place (csilvres)
|
||||
- INSTALL: autotools to autoconf v2.64 + automake v1.11 (csilvers)
|
||||
|
||||
* Thu Sep 10 2009 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.2
|
||||
- PORTABILITY: can now build and run tests under mingw (csilvers)
|
||||
- Using a string arg for a bool flag is a compile-time error (rbayardo)
|
||||
- Add --helpxml to gflags.py (salcianu)
|
||||
- Protect against a hypothetical global d'tor mutex problem (csilvers)
|
||||
- BUGFIX: can now define a flag after 'using namespace google' (hamaji)
|
||||
|
||||
* Tue Apr 14 2009 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.1
|
||||
- Add both foo and nofoo for boolean flags, with --undefok (andychu)
|
||||
- Better document how validators work (wojtekm)
|
||||
- Improve binary-detection for bash-completion (mtamsky)
|
||||
- Python: Add a concept of "key flags", used with --help (salcianu)
|
||||
- Python: Robustify flag_values (salcianu)
|
||||
- Python: Add a new DEFINE_bool alias (keir, andrewliu)
|
||||
- Python: Do module introspection based on module name (dsturtevant)
|
||||
- Fix autoconf a bit better, especially on windows and solaris (ajenjo)
|
||||
- BUG FIX: gflags_nothreads was linking against the wrong lib (ajenjo)
|
||||
- BUG FIX: threads-detection failed on FreeBSD; replace it (ajenjo)
|
||||
- PORTABILITY: Quiet an internal compiler error with SUSE 10 (csilvers)
|
||||
- PORTABILITY: Update deb.sh for more recently debuilds (csilvers)
|
||||
- PORTABILITY: #include more headers to satisfy new gcc's (csilvers)
|
||||
- INSTALL: Updated to autoconf 2.61 and libtool 1.5.26 (csilvers)
|
||||
|
||||
* Fri Oct 3 2008 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.0
|
||||
- Add a missing newline to an error string (bcmills)
|
||||
- (otherwise exactly the same as gflags 1.0rc2)
|
||||
|
||||
* Thu Sep 18 2008 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.0rc2
|
||||
- Report current flag values in --helpxml (hdn)
|
||||
- Fix compilation troubles with gcc 4.3.3 (simonb)
|
||||
- BUG FIX: I was missing a std:: in DECLARE_string (csilvers)
|
||||
- BUG FIX: Clarify in docs how to specify --bool flags (csilvers)
|
||||
- BUG FIX: Fix --helpshort for source files not in a subdir (csilvers)
|
||||
- BUG FIX: Fix python unittest for 64-bit builds (bcmills)
|
||||
|
||||
* Tue Aug 19 2008 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 1.0rc1
|
||||
- Move #include files from google/ to gflags/ (csilvers)
|
||||
- Small optimizations to reduce binary (library) size (jyrki)
|
||||
- BUGFIX: forgot a std:: in one of the .h files (csilvers)
|
||||
- Speed up locking by making sure calls are inlined (ajenjo)
|
||||
- 64-BIT COMPATIBILITY: Use %PRId64 instead of %lld (csilvers)
|
||||
- PORTABILITY: fix Makefile to work with Cygwin (ajenjo)
|
||||
- PORTABILITY: fix code to compile under Visual Studio (ajenjo)
|
||||
- PORTABILITY: fix code to compile under Solaris 10 with CC (csilvers)
|
||||
|
||||
* Mon Jul 21 2008 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.9
|
||||
- Add the ability to validate a command-line flag (csilvers)
|
||||
- Add completion support for commandline flags in bash (daven)
|
||||
- Add -W compile flags to Makefile, when using gcc (csilvers)
|
||||
- Allow helpstring to be NULL (cristianoc)
|
||||
- Improved documentation of classes in the .cc file (csilvers)
|
||||
- Fix python bug with AppendFlagValues + shortnames (jjtswan)
|
||||
- Use bool instead of int for boolean flags in gflags.py (bcmills)
|
||||
- Simplify the way we declare flags, now more foolproof (csilvers)
|
||||
- Better error messages when bool flags collide (colohan)
|
||||
- Only evaluate DEFINE_foo macro args once (csilvers)
|
||||
|
||||
* Wed Mar 26 2008 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.8
|
||||
- Export DescribeOneFlag() in the API
|
||||
- Add support for automatic line wrapping at 80 cols for gflags.py
|
||||
- Bugfix: do not treat an isolated "-" the same as an isolated "--"
|
||||
- Update rpm spec to point to Google Code rather than sourceforge (!)
|
||||
- Improve documentation (including documenting thread-safety)
|
||||
- Improve #include hygiene
|
||||
- Improve testing
|
||||
|
||||
* Thu Oct 18 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.7
|
||||
- Deal even more correctly with libpthread not linked in (csilvers)
|
||||
- Add STRIP_LOG, an improved DO_NOT_SHOW_COMMANDLINE_HELP (sioffe)
|
||||
- Be more accurate printing default flag values in --help (dsturtevant)
|
||||
- Reduce .o file size a bit by using shorter namespace names (jeff)
|
||||
- Use relative install path, so 'setup.py --home' works (csilvers)
|
||||
- Notice when a boolean flag has a non-boolean default (bnmouli)
|
||||
- Broaden --helpshort to match foo-main.cc and foo_main.cc (hendrie)
|
||||
- Fix "no modules match" message for --helpshort, etc (hendrie)
|
||||
|
||||
* Wed Aug 15 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.6
|
||||
- Deal correctly with case that libpthread is not linked in (csilvers)
|
||||
- Update Makefile/tests so we pass "make distcheck" (csilvers)
|
||||
- Document and test that last assignment to a flag wins (wan)
|
||||
|
||||
* Tue Jun 12 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.5
|
||||
- Include all m4 macros in the distribution (csilvers)
|
||||
- Python: Fix broken data_files field in setup.py (sidlon)
|
||||
- Python: better string serializing and unparsing (abo, csimmons)
|
||||
- Fix checks for NaN and inf to work with Mac OS X (csilvers)
|
||||
|
||||
* Thu Apr 19 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.4
|
||||
- Remove is_default from GetCommandLineFlagInfo (csilvers)
|
||||
- Portability fixes: includes, strtoll, gcc4.3 errors (csilvers)
|
||||
- A few doc typo cleanups (csilvers)
|
||||
|
||||
* Wed Mar 28 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.3
|
||||
- python portability fix: use popen instead of subprocess (csilvers)
|
||||
- Add is_default to CommandLineFlagInfo (pchien)
|
||||
- Make docs a bit prettier (csilvers)
|
||||
- Actually include the python files in the distribution! :-/ (csilvers)
|
||||
|
||||
* Mon Jan 22 2007 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.2
|
||||
- added support for python commandlineflags, as well as c++
|
||||
- gflags2man, a script to turn flags into a man page (dchristian)
|
||||
|
||||
* Wed Dec 13 2006 - Google Inc. <opensource@google.com>
|
||||
|
||||
- google-gflags: version 0.1
|
236
INSTALL
236
INSTALL
|
@ -1,236 +0,0 @@
|
|||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script). Here is a another example:
|
||||
|
||||
/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
|
||||
configuration-related scripts to be executed by `/bin/bash'.
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
97
INSTALL.md
Normal file
97
INSTALL.md
Normal file
|
@ -0,0 +1,97 @@
|
|||
# Installing a binary distribution package
|
||||
|
||||
No official binary distribution packages are provided by the gflags developers.
|
||||
There may, however, be binary packages available for your operating system.
|
||||
Please consult also the package repositories of your Linux distribution.
|
||||
|
||||
On Debian/Ubuntu Linux, gflags can be installed using the following command:
|
||||
|
||||
sudo apt-get install libgflags-dev
|
||||
|
||||
On macOS, [Homebrew](https://brew.sh/) includes a formula for gflags:
|
||||
|
||||
brew install gflags
|
||||
|
||||
|
||||
# Compiling the source code with Bazel
|
||||
|
||||
To use gflags in a [Bazel](http://bazel.io) project, map it in as an external
|
||||
dependency by editing your WORKSPACE file:
|
||||
|
||||
git_repository(
|
||||
name = "com_github_gflags_gflags",
|
||||
commit = "<INSERT COMMIT SHA HERE>",
|
||||
remote = "https://github.com/gflags/gflags.git",
|
||||
)
|
||||
|
||||
You can then add `@com_github_gflags_gflags//:gflags` to the `deps` section of a
|
||||
`cc_binary` or `cc_library` rule, and `#include <gflags/gflags.h>` to include it
|
||||
in your source code.
|
||||
|
||||
|
||||
# Compiling the source code with vcpkg
|
||||
|
||||
You can download and install gflags using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh
|
||||
./vcpkg integrate install
|
||||
vcpkg install gflags
|
||||
|
||||
The gflags port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
|
||||
# Compiling the source code with CMake
|
||||
|
||||
The build system of gflags is since version 2.1 based on [CMake](http://cmake.org).
|
||||
The common steps to build, test, and install software are therefore:
|
||||
|
||||
1. Extract source files.
|
||||
2. Create build directory and change to it.
|
||||
3. Run CMake to configure the build tree.
|
||||
4. Build the software using selected build tool.
|
||||
5. Test the built software.
|
||||
6. Install the built files.
|
||||
|
||||
On Unix-like systems with GNU Make as build tool, these build steps can be
|
||||
summarized by the following sequence of commands executed in a shell,
|
||||
where ```$package``` and ```$version``` are shell variables which represent
|
||||
the name of this package and the obtained version of the software.
|
||||
|
||||
$ tar xzf gflags-$version-source.tar.gz
|
||||
$ cd gflags-$version
|
||||
$ mkdir build && cd build
|
||||
$ ccmake ..
|
||||
|
||||
- Press 'c' to configure the build system and 'e' to ignore warnings.
|
||||
- Set CMAKE_INSTALL_PREFIX and other CMake variables and options.
|
||||
- Continue pressing 'c' until the option 'g' is available.
|
||||
- Then press 'g' to generate the configuration files for GNU Make.
|
||||
|
||||
$ make
|
||||
$ make test (optional)
|
||||
$ make install (optional)
|
||||
|
||||
In the following, only gflags-specific CMake settings available to
|
||||
configure the build and installation are documented. Note that most of these
|
||||
variables are for advanced users and binary package maintainers only.
|
||||
They usually do not have to be modified.
|
||||
|
||||
|
||||
CMake Option | Description
|
||||
--------------------------- | -------------------------------------------------------
|
||||
CMAKE_INSTALL_PREFIX | Installation directory, e.g., "/usr/local" on Unix and "C:\Program Files\gflags" on Windows.
|
||||
BUILD_SHARED_LIBS | Request build of dynamic link libraries.
|
||||
BUILD_STATIC_LIBS | Request build of static link libraries. Implied if BUILD_SHARED_LIBS is OFF.
|
||||
BUILD_PACKAGING | Enable binary package generation using CPack.
|
||||
BUILD_TESTING | Build tests for execution by CTest.
|
||||
BUILD_NC_TESTS | Request inclusion of negative compilation tests (requires Python).
|
||||
BUILD_CONFIG_TESTS | Request inclusion of package configuration tests (requires Python).
|
||||
BUILD_gflags_LIBS | Request build of multi-threaded gflags libraries (if threading library found).
|
||||
BUILD_gflags_nothreads_LIBS | Request build of single-threaded gflags libraries.
|
||||
GFLAGS_NAMESPACE | Name of the C++ namespace to be used by the gflags library. Note that the public source header files are installed in a subdirectory named after this namespace. To maintain backwards compatibility with the Google Commandline Flags, set this variable to "google". The default is "gflags".
|
||||
GFLAGS_INTTYPES_FORMAT | String identifying format of built-in integer types.
|
||||
GFLAGS_INCLUDE_DIR | Name of headers installation directory relative to CMAKE_INSTALL_PREFIX.
|
||||
LIBRARY_INSTALL_DIR | Name of library installation directory relative to CMAKE_INSTALL_PREFIX.
|
||||
INSTALL_HEADERS | Request installation of public header files.
|
4
MODULE.bazel
Normal file
4
MODULE.bazel
Normal file
|
@ -0,0 +1,4 @@
|
|||
module(
|
||||
name = "gflags",
|
||||
compatibility_level = 1,
|
||||
)
|
142
Makefile.am
142
Makefile.am
|
@ -1,142 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
# Make sure that when we re-make ./configure, we get the macros we need
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
# This is so we can #include <gflags/foo>
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
# This is mostly based on configure options
|
||||
AM_CXXFLAGS =
|
||||
|
||||
# These are good warnings to turn on by default,
|
||||
if GCC
|
||||
AM_CXXFLAGS += -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
|
||||
endif
|
||||
|
||||
# The -no-undefined flag allows libtool to generate shared libraries for
|
||||
# Cygwin and MinGW. LIBSTDCXX_LA_LINKER_FLAG is used to fix a Solaris bug.
|
||||
AM_LDFLAGS = -no-undefined $(LIBSTDCXX_LA_LINKER_FLAG)
|
||||
|
||||
gflagsincludedir = $(includedir)/gflags
|
||||
## The .h files you want to install (that is, .h files that people
|
||||
## who install this package can include in their own applications.)
|
||||
gflagsinclude_HEADERS = src/gflags/gflags.h src/gflags/gflags_completions.h
|
||||
|
||||
# This is for backwards compatibility only.
|
||||
googleincludedir = $(includedir)/google
|
||||
googleinclude_HEADERS = src/google/gflags.h src/google/gflags_completions.h
|
||||
|
||||
bin_SCRIPTS = src/gflags_completions.sh
|
||||
|
||||
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
|
||||
## This is for HTML and other documentation you want to install.
|
||||
## Add your documentation files (in doc/) in addition to these
|
||||
## top-level boilerplate files. Also add a TODO file if you have one.
|
||||
dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README \
|
||||
doc/designstyle.css doc/gflags.html
|
||||
|
||||
## The libraries (.so's) you want to install
|
||||
lib_LTLIBRARIES =
|
||||
|
||||
## unittests you want to run when people type 'make check'.
|
||||
## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
|
||||
## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
|
||||
## but it only seems to take effect for *binary* unittests (argh!)
|
||||
TESTS =
|
||||
TESTS_ENVIRONMENT = SRCDIR="$(top_srcdir)"
|
||||
check_SCRIPTS =
|
||||
# Every time you add a unittest to check_SCRIPTS, add it here too
|
||||
noinst_SCRIPTS =
|
||||
# Used for auto-generated source files
|
||||
CLEANFILES =
|
||||
|
||||
## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
|
||||
|
||||
GFLAGS_SOURCES = $(gflagsinclude_HEADERS) src/config.h src/mutex.h \
|
||||
src/gflags.cc src/gflags_reporting.cc \
|
||||
src/gflags_completions.cc
|
||||
|
||||
lib_LTLIBRARIES += libgflags.la
|
||||
libgflags_la_SOURCES = $(GFLAGS_SOURCES)
|
||||
libgflags_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG
|
||||
libgflags_la_LDFLAGS = $(PTHREAD_CFLAGS)
|
||||
libgflags_la_LIBADD = $(PTHREAD_LIBS)
|
||||
|
||||
lib_LTLIBRARIES += libgflags_nothreads.la
|
||||
libgflags_nothreads_la_SOURCES = $(GFLAGS_SOURCES)
|
||||
libgflags_nothreads_la_CXXFLAGS = -DNDEBUG -DNO_THREADS
|
||||
|
||||
TESTS += gflags_unittest$(EXEEXT)
|
||||
gflags_unittest_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
|
||||
src/gflags_unittest.cc
|
||||
gflags_unittest_CXXFLAGS = $(PTHREAD_CFLAGS)
|
||||
gflags_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
||||
gflags_unittest_LDADD = libgflags.la
|
||||
|
||||
# Also make sure this works when we don't link in pthreads
|
||||
TESTS += gflags_nothreads_unittest$(EXEEXT)
|
||||
gflags_nothreads_unittest_SOURCES = $(gflags_unittest_SOURCES)
|
||||
gflags_nothreads_unittest_LDADD = libgflags_nothreads.la
|
||||
|
||||
# We also want to test that things work properly when the file that
|
||||
# holds main() has a name ending with -main or _main. To keep the
|
||||
# Makefile small :-), we test the no-threads version of these.
|
||||
TESTS += gflags_unittest2$(EXEEXT)
|
||||
gflags_unittest2_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
|
||||
src/gflags_unittest-main.cc
|
||||
gflags_unittest2_LDADD = libgflags_nothreads.la
|
||||
src/gflags_unittest-main.cc: src/gflags_unittest.cc
|
||||
rm -f src/gflags_unittest-main.cc
|
||||
cp -p src/gflags_unittest.cc src/gflags_unittest-main.cc
|
||||
CLEANFILES += src/gflags_unittest-main.cc
|
||||
|
||||
TESTS += gflags_unittest3$(EXEEXT)
|
||||
gflags_unittest3_SOURCES = $(gflagsinclude_HEADERS) src/config.h \
|
||||
src/gflags_unittest_main.cc
|
||||
gflags_unittest3_LDADD = libgflags_nothreads.la
|
||||
src/gflags_unittest_main.cc: src/gflags_unittest.cc
|
||||
rm -f src/gflags_unittest_main.cc
|
||||
cp -p src/gflags_unittest.cc src/gflags_unittest_main.cc
|
||||
CLEANFILES += src/gflags_unittest_main.cc
|
||||
|
||||
# Some buggy sh's ignore "" instead of treating it as a positional
|
||||
# parameter. Since we use "" in this script, we prefer bash if we
|
||||
# can. If there's no bash, we fall back to sh.
|
||||
check_SCRIPTS += gflags_unittest_sh
|
||||
noinst_SCRIPTS += src/gflags_unittest.sh
|
||||
dist_noinst_DATA = src/gflags_unittest_flagfile
|
||||
gflags_unittest_sh: gflags_unittest$(EXEEXT) \
|
||||
gflags_unittest2$(EXEEXT) \
|
||||
gflags_unittest3$(EXEEXT)
|
||||
bash --version >/dev/null && export SH=bash || export SH=sh; \
|
||||
$$SH "$(top_srcdir)/src/gflags_unittest.sh" "$(PWD)/gflags_unittest" \
|
||||
"$(top_srcdir)"
|
||||
|
||||
# These aren't part of the c++ source, but we want them to be distributed
|
||||
PYTHON = python/setup.py \
|
||||
python/gflags.py \
|
||||
python/gflags2man.py \
|
||||
python/gflags_unittest.py \
|
||||
python/test_module_foo.py \
|
||||
python/test_module_bar.py
|
||||
|
||||
|
||||
## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
|
||||
|
||||
|
||||
## This should always include $(TESTS), but may also include other
|
||||
## binaries that you compile but don't want automatically installed.
|
||||
noinst_PROGRAMS = $(TESTS)
|
||||
|
||||
rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
|
||||
@cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
|
||||
|
||||
deb: dist-gzip packages/deb.sh packages/deb/*
|
||||
@cd packages && ./deb.sh ${PACKAGE} ${VERSION}
|
||||
|
||||
libtool: $(LIBTOOL_DEPS)
|
||||
$(SHELL) ./config.status --recheck
|
||||
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
|
||||
libtool $(SCRIPTS) $(PYTHON) \
|
||||
src/solaris/libstdc++.la
|
1077
Makefile.in
1077
Makefile.in
File diff suppressed because it is too large
Load diff
16
README
16
README
|
@ -1,16 +0,0 @@
|
|||
This repository contains both a C++ and a python implementation of the
|
||||
Google commandline flags module. Documentation for the C++
|
||||
implementation is in doc/. Documentation for the python
|
||||
implementation is at the top of gflags/flags.py.
|
||||
|
||||
See INSTALL for (generic) installation instructions for C++: basically
|
||||
./configure && make && make install
|
||||
|
||||
To install the python module, run
|
||||
cd python; python ./setup.py install
|
||||
|
||||
When you install the python library, you also get a helper
|
||||
application, gflags2man.py, installed into /usr/local/bin. You can
|
||||
run gflags2man.py to create an instant man page, with all the
|
||||
commandline flags and their docs, for any C++ or python program you've
|
||||
written using the gflags library.
|
319
README.md
Normal file
319
README.md
Normal file
|
@ -0,0 +1,319 @@
|
|||
[](https://github.com/gflags/gflags/actions/workflows/test.yml)
|
||||
|
||||
The documentation of the gflags library is available online at https://gflags.github.io/gflags/.
|
||||
|
||||
|
||||
11 November 2018
|
||||
----------------
|
||||
|
||||
I've just released gflags 2.2.2.
|
||||
|
||||
This maintenance release improves life of Bazel users (no more "config.h" leaking into global include paths),
|
||||
fixes build with recent MinGW versions, and silences a number of static code analyzer and compiler warnings.
|
||||
The build targets exported by the CMake configuration of this library are now also prefixed by the package
|
||||
name "gflags::" following a more recent (unwritten) CMake convention. The unprefixed target names are still
|
||||
supported to avoid that dependent projects have to be modified due to this change in imported target names.
|
||||
|
||||
Please report any further issues with this release using the GitHub issue tracker.
|
||||
|
||||
|
||||
11 July 2017
|
||||
------------
|
||||
|
||||
I've just released gflags 2.2.1.
|
||||
|
||||
This maintenance release primarily fixes build issues on Windows and
|
||||
false alarms reported by static code analyzers.
|
||||
|
||||
Please report any further issues with this release using the GitHub issue tracker.
|
||||
|
||||
|
||||
25 November 2016
|
||||
----------------
|
||||
|
||||
I've finally released gflags 2.2.0.
|
||||
|
||||
This release adds support for use of the gflags library as external dependency
|
||||
not only in projects using CMake, but also [Bazel](https://bazel.build/),
|
||||
or [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/).
|
||||
One new minor feature is added in this release: when a command flag argument
|
||||
contains dashes, these are implicitly converted to underscores.
|
||||
This is to allow those used to separate words of the flag name by dashes
|
||||
to do so, while the flag variable names are required to use underscores.
|
||||
|
||||
Memory leaks reported by valgrind should be resolved by this release.
|
||||
This release fixes build errors with MS Visual Studio 2015.
|
||||
|
||||
Please report any further issues with this release using the GitHub issue tracker.
|
||||
|
||||
|
||||
24 March 2015
|
||||
-------------
|
||||
|
||||
I've just released gflags 2.1.2.
|
||||
|
||||
This release completes the namespace change fixes. In particular,
|
||||
it restores binary ABI compatibility with release version 2.0.
|
||||
The deprecated "google" namespace is by default still kept as
|
||||
primary namespace while symbols are imported into the new "gflags" namespace.
|
||||
This can be overridden using the CMake variable GFLAGS_NAMESPACE.
|
||||
|
||||
Other fixes of the build configuration are related to the (patched)
|
||||
CMake modules FindThreads.cmake and CheckTypeSize.cmake. These have
|
||||
been removed and instead the C language is enabled again even though
|
||||
gflags is written in C++ only.
|
||||
|
||||
This release also marks the complete move of the gflags project
|
||||
from Google Code to GitHub. Email addresses of original issue
|
||||
reporters got lost in the process. Given the age of most issue reports,
|
||||
this should be negligible.
|
||||
|
||||
Please report any further issues using the GitHub issue tracker.
|
||||
|
||||
|
||||
30 March 2014
|
||||
-------------
|
||||
|
||||
I've just released gflags 2.1.1.
|
||||
|
||||
This release fixes a few bugs in the configuration of gflags\_declare.h
|
||||
and adds a separate GFLAGS\_INCLUDE\_DIR CMake variable to the build configuration.
|
||||
Setting GFLAGS\_NAMESPACE to "google" no longer changes also the include
|
||||
path of the public header files. This allows the use of the library with
|
||||
other Google projects such as glog which still use the deprecated "google"
|
||||
namespace for the gflags library, but include it as "gflags/gflags.h".
|
||||
|
||||
20 March 2014
|
||||
-------------
|
||||
|
||||
I've just released gflags 2.1.
|
||||
|
||||
The major changes are the use of CMake for the build configuration instead
|
||||
of the autotools and packaging support through CPack. The default namespace
|
||||
of all C++ symbols is now "gflags" instead of "google". This can be
|
||||
configured via the GFLAGS\_NAMESPACE variable.
|
||||
|
||||
This release compiles with all major compilers without warnings and passed
|
||||
the unit tests on Ubuntu 12.04, Windows 7 (Visual Studio 2008 and 2010,
|
||||
Cygwin, MinGW), and Mac OS X (Xcode 5.1).
|
||||
|
||||
The SVN repository on Google Code is now frozen and replaced by a Git
|
||||
repository such that it can be used as Git submodule by projects. The main
|
||||
hosting of this project remains at Google Code. Thanks to the distributed
|
||||
character of Git, I can push (and pull) changes from both GitHub and Google Code
|
||||
in order to keep the two public repositories in sync.
|
||||
When fixing an issue for a pull request through either of these hosting
|
||||
platforms, please reference the issue number as
|
||||
[described here](https://code.google.com/p/support/wiki/IssueTracker#Integration_with_version_control).
|
||||
For the further development, I am following the
|
||||
[Git branching model](http://nvie.com/posts/a-successful-git-branching-model/)
|
||||
with feature branch names prefixed by "feature/" and bugfix branch names
|
||||
prefixed by "bugfix/", respectively.
|
||||
|
||||
Binary and source [packages](https://github.com/schuhschuh/gflags/releases) are available on GitHub.
|
||||
|
||||
|
||||
14 January 2014
|
||||
---------------
|
||||
|
||||
The migration of the build system to CMake is almost complete.
|
||||
What remains to be done is rewriting the tests in Python such they can be
|
||||
executed on non-Unix platforms and splitting them up into separate CTest tests.
|
||||
Though merging these changes into the master branch yet remains to be done,
|
||||
it is recommended to already start using the
|
||||
[cmake-migration](https://github.com/schuhschuh/gflags/tree/cmake-migration) branch.
|
||||
|
||||
|
||||
20 April 2013
|
||||
-------------
|
||||
|
||||
More than a year has past since I (Andreas) took over the maintenance for
|
||||
`gflags`. Only few minor changes have been made since then, much to my regret.
|
||||
To get more involved and stimulate participation in the further
|
||||
development of the library, I moved the project source code today to
|
||||
[GitHub](https://github.com/schuhschuh/gflags).
|
||||
I believe that the strengths of [Git](http://git-scm.com/) will allow for better community collaboration
|
||||
as well as ease the integration of changes made by others. I encourage everyone
|
||||
who would like to contribute to send me pull requests.
|
||||
Git's lightweight feature branches will also provide the right tool for more
|
||||
radical changes which should only be merged back into the master branch
|
||||
after these are complete and implement the desired behavior.
|
||||
|
||||
The SVN repository remains accessible at Google Code and I will keep the
|
||||
master branch of the Git repository hosted at GitHub and the trunk of the
|
||||
Subversion repository synchronized. Initially, I was going to simply switch the
|
||||
Google Code project to Git, but in this case the SVN repository would be
|
||||
frozen and force everyone who would like the latest development changes to
|
||||
use Git as well. Therefore I decided to host the public Git repository at GitHub
|
||||
instead.
|
||||
|
||||
Please continue to report any issues with gflags on Google Code. The GitHub project will
|
||||
only be used to host the Git repository.
|
||||
|
||||
One major change of the project structure I have in mind for the next weeks
|
||||
is the migration from autotools to [CMake](http://www.cmake.org/).
|
||||
Check out the (unstable!)
|
||||
[cmake-migration](https://github.com/schuhschuh/gflags/tree/cmake-migration)
|
||||
branch on GitHub for details.
|
||||
|
||||
|
||||
25 January 2012
|
||||
---------------
|
||||
|
||||
I've just released gflags 2.0.
|
||||
|
||||
The `google-gflags` project has been renamed to `gflags`. I
|
||||
(csilvers) am stepping down as maintainer, to be replaced by Andreas
|
||||
Schuh. Welcome to the team, Andreas! I've seen the energy you have
|
||||
around gflags and the ideas you have for the project going forward,
|
||||
and look forward to having you on the team.
|
||||
|
||||
I bumped the major version number up to 2 to reflect the new community
|
||||
ownership of the project. All the [changes](ChangeLog.txt)
|
||||
are related to the renaming. There are no functional changes from
|
||||
gflags 1.7. In particular, I've kept the code in the namespace
|
||||
`google`, though in a future version it should be renamed to `gflags`.
|
||||
I've also kept the `/usr/local/include/google/` subdirectory as
|
||||
synonym of `/usr/local/include/gflags/`, though the former name has
|
||||
been obsolete for some time now.
|
||||
|
||||
|
||||
18 January 2011
|
||||
---------------
|
||||
|
||||
The `google-gflags` Google Code page has been renamed to
|
||||
`gflags`, in preparation for the project being renamed to
|
||||
`gflags`. In the coming weeks, I'll be stepping down as
|
||||
maintainer for the gflags project, and as part of that Google is
|
||||
relinquishing ownership of the project; it will now be entirely
|
||||
community run. The name change reflects that shift.
|
||||
|
||||
|
||||
20 December 2011
|
||||
----------------
|
||||
|
||||
I've just released gflags 1.7. This is a minor release; the major
|
||||
change is that `CommandLineFlagInfo` now exports the address in memory
|
||||
where the flag is located. There has also been a bugfix involving
|
||||
very long --help strings, and some other minor [changes](ChangeLog.txt).
|
||||
|
||||
29 July 2011
|
||||
------------
|
||||
|
||||
I've just released gflags 1.6. The major new feature in this release
|
||||
is support for setting version info, so that --version does something
|
||||
useful.
|
||||
|
||||
One minor change has required bumping the library number:
|
||||
`ReparseCommandlineFlags` now returns `void` instead of `int` (the int
|
||||
return value was always meaningless). Though I doubt anyone ever used
|
||||
this (meaningless) return value, technically it's a change to the ABI
|
||||
that requires a version bump. A bit sad.
|
||||
|
||||
There's also a procedural change with this release: I've changed the
|
||||
internal tools used to integrate Google-supplied patches for gflags
|
||||
into the opensource release. These new tools should result in more
|
||||
frequent updates with better change descriptions. They will also
|
||||
result in future `ChangeLog` entries being much more verbose (for better
|
||||
or for worse).
|
||||
|
||||
See the [ChangeLog](ChangeLog.txt) for a full list of changes for this release.
|
||||
|
||||
24 January 2011
|
||||
---------------
|
||||
|
||||
I've just released gflags 1.5. This release has only minor changes
|
||||
from 1.4, including some slightly better reporting in --help, and
|
||||
an new memory-cleanup function that can help when running gflags-using
|
||||
libraries under valgrind. The major change is to fix up the macros
|
||||
(`DEFINE_bool` and the like) to work more reliably inside namespaces.
|
||||
|
||||
If you have not had a problem with these macros, and don't need any of
|
||||
the other changes described, there is no need to upgrade. See the
|
||||
[ChangeLog](ChangeLog.txt) for a full list of changes for this release.
|
||||
|
||||
11 October 2010
|
||||
---------------
|
||||
|
||||
I've just released gflags 1.4. This release has only minor changes
|
||||
from 1.3, including some documentation tweaks and some work to make
|
||||
the library smaller. If 1.3 is working well for you, there's no
|
||||
particular reason to upgrade.
|
||||
|
||||
4 January 2010
|
||||
--------------
|
||||
|
||||
I've just released gflags 1.3. gflags now compiles under MSVC, and
|
||||
all tests pass. I **really** never thought non-unix-y Windows folks
|
||||
would want gflags, but at least some of them do.
|
||||
|
||||
The major news, though, is that I've separated out the python package
|
||||
into its own library, [python-gflags](http://code.google.com/p/python-gflags).
|
||||
If you're interested in the Python version of gflags, that's the place to
|
||||
get it now.
|
||||
|
||||
10 September 2009
|
||||
-----------------
|
||||
|
||||
I've just released gflags 1.2. The major change from gflags 1.1 is it
|
||||
now compiles under MinGW (as well as cygwin), and all tests pass. I
|
||||
never thought Windows folks would want unix-style command-line flags,
|
||||
since they're so different from the Windows style, but I guess I was
|
||||
wrong!
|
||||
|
||||
The other changes are minor, such as support for --htmlxml in the
|
||||
python version of gflags.
|
||||
|
||||
15 April 2009
|
||||
-------------
|
||||
|
||||
I've just released gflags 1.1. It has only minor changes fdrom gflags
|
||||
1.0 (see the [ChangeLog](ChangeLog.txt) for details).
|
||||
The major change is that I moved to a new system for creating .deb and .rpm files.
|
||||
This allows me to create x86\_64 deb and rpm files.
|
||||
|
||||
In the process of moving to this new system, I noticed an
|
||||
inconsistency: the tar.gz and .rpm files created libraries named
|
||||
libgflags.so, but the deb file created libgoogle-gflags.so. I have
|
||||
fixed the deb file to create libraries like the others. I'm no expert
|
||||
in debian packaging, but I believe this has caused the package name to
|
||||
change as well. Please let me know (at
|
||||
[[mailto:google-gflags@googlegroups.com](mailto:google-gflags@googlegroups.com)
|
||||
google-gflags@googlegroups.com]) if this causes problems for you --
|
||||
especially if you know of a fix! I would be happy to change the deb
|
||||
packages to add symlinks from the old library name to the new
|
||||
(libgoogle-gflags.so -> libgflags.so), but that is beyond my knowledge
|
||||
of how to make .debs.
|
||||
|
||||
If you've tried to install a .rpm or .deb and it doesn't work for you,
|
||||
let me know. I'm excited to finally have 64-bit package files, but
|
||||
there may still be some wrinkles in the new system to iron out.
|
||||
|
||||
1 October 2008
|
||||
--------------
|
||||
|
||||
gflags 1.0rc2 was out for a few weeks without any issues, so gflags
|
||||
1.0 is now released. This is much like gflags 0.9. The major change
|
||||
is that the .h files have been moved from `/usr/include/google` to
|
||||
`/usr/include/gflags`. While I have backwards-compatibility
|
||||
forwarding headeds in place, please rewrite existing code to say
|
||||
```
|
||||
#include <gflags/gflags.h>
|
||||
```
|
||||
instead of
|
||||
```
|
||||
#include <google/gflags.h>
|
||||
```
|
||||
|
||||
I've kept the default namespace to google. You can still change with
|
||||
with the appropriate flag to the configure script (`./configure
|
||||
--help` to see the flags). If you have feedback as to whether the
|
||||
default namespace should change to gflags, which would be a
|
||||
non-backwards-compatible change, send mail to
|
||||
`google-gflags@googlegroups.com`!
|
||||
|
||||
Version 1.0 also has some neat new features, like support for bash
|
||||
commandline-completion of help flags. See the [ChangeLog](ChangeLog.txt)
|
||||
for more details.
|
||||
|
||||
If I don't hear any bad news for a few weeks, I'll release 1.0-final.
|
6
WORKSPACE
Normal file
6
WORKSPACE
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Copyright 2006 Google Inc. All Rights Reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the COPYING.txt file.
|
||||
|
||||
# Bazel (http://bazel.io/) WORKSPACE file for gflags.
|
||||
workspace(name="com_github_gflags_gflags")
|
7519
aclocal.m4
vendored
7519
aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
55
autogen.sh
55
autogen.sh
|
@ -1,55 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Before using, you should figure out all the .m4 macros that your
|
||||
# configure.m4 script needs and make sure they exist in the m4/
|
||||
# directory.
|
||||
#
|
||||
# These are the files that this script might edit:
|
||||
# aclocal.m4 configure Makefile.in src/config.h.in \
|
||||
# depcomp config.guess config.sub install-sh missing mkinstalldirs \
|
||||
# ltmain.sh
|
||||
#
|
||||
# Here's a command you can run to see what files aclocal will import:
|
||||
# aclocal -I ../autoconf --output=- | sed -n 's/^m4_include..\([^]]*\).*/\1/p'
|
||||
|
||||
set -ex
|
||||
rm -rf autom4te.cache
|
||||
|
||||
trap 'rm -f aclocal.m4.tmp' EXIT
|
||||
|
||||
# Use version 1.9 of aclocal and automake if available.
|
||||
ACLOCAL=aclocal-1.9
|
||||
if test -z `which "$ACLOCAL"`; then
|
||||
ACLOCAL=aclocal
|
||||
fi
|
||||
|
||||
AUTOMAKE=automake-1.9
|
||||
if test -z `which "$AUTOMAKE"`; then
|
||||
AUTOMAKE=automake
|
||||
fi
|
||||
|
||||
# glibtoolize is used for Mac OS X
|
||||
LIBTOOLIZE=libtoolize
|
||||
if test -z `which "$LIBTOOLIZE"`; then
|
||||
LIBTOOLIZE=glibtoolize
|
||||
fi
|
||||
|
||||
# aclocal tries to overwrite aclocal.m4 even if the contents haven't
|
||||
# changed, which is annoying when the file is not open for edit (in
|
||||
# p4). We work around this by writing to a temp file and just
|
||||
# updating the timestamp if the file hasn't change.
|
||||
"$ACLOCAL" --force -I m4 --output=aclocal.m4.tmp
|
||||
if cmp aclocal.m4.tmp aclocal.m4; then
|
||||
touch aclocal.m4 # pretend that we regenerated the file
|
||||
rm -f aclocal.m4.tmp
|
||||
else
|
||||
mv aclocal.m4.tmp aclocal.m4 # we did set -e above, so we die if this fails
|
||||
fi
|
||||
|
||||
grep -q LIBTOOL configure.ac && "$LIBTOOLIZE" -c -f
|
||||
autoconf -f -W all,no-obsolete
|
||||
autoheader -f -W all
|
||||
"$AUTOMAKE" -a -c -f -W all
|
||||
|
||||
rm -rf autom4te.cache
|
||||
exit 0
|
5
bazel/expanded_template/BUILD
Normal file
5
bazel/expanded_template/BUILD
Normal file
|
@ -0,0 +1,5 @@
|
|||
cc_binary(
|
||||
name = "expand_template",
|
||||
srcs = ["expand_template.cc"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
63
bazel/expanded_template/expand_template.cc
Normal file
63
bazel/expanded_template/expand_template.cc
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <streambuf>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
|
||||
struct Substitution {
|
||||
std::basic_regex<char> regex;
|
||||
std::string replacement;
|
||||
};
|
||||
|
||||
// Simple app that does a regex search-and-replace on a template
|
||||
// and outputs the result.
|
||||
//
|
||||
// To invoke:
|
||||
// expand_template
|
||||
// --template PATH
|
||||
// --output PATH
|
||||
// regex0;replacement0
|
||||
// regex1;replacement1
|
||||
// ...
|
||||
//
|
||||
// Since it's only used as a private implementation detail of a rule and not
|
||||
// user invoked we don't bother with error checking.
|
||||
int main(int argc, const char** argv) {
|
||||
// Parse args.
|
||||
const char* template_path = nullptr;
|
||||
const char* output_path = nullptr;
|
||||
std::vector<Substitution> substitutions;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
const char* arg = argv[i];
|
||||
if (strcmp(arg, "--template") == 0) {
|
||||
template_path = argv[++i];
|
||||
} else if (strcmp(arg, "--output") == 0) {
|
||||
output_path = argv[++i];
|
||||
} else {
|
||||
const char* mid = strchr(arg, ';');
|
||||
if (mid != nullptr) {
|
||||
substitutions.push_back(Substitution{
|
||||
std::basic_regex<char>(arg, mid - arg),
|
||||
std::string(mid + 1),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read template.
|
||||
std::ifstream ifs(template_path);
|
||||
std::string str(std::istreambuf_iterator<char>(ifs),
|
||||
(std::istreambuf_iterator<char>()));
|
||||
|
||||
// Apply regexes.
|
||||
for (const auto& subst : substitutions) {
|
||||
str = std::regex_replace(str, subst.regex, subst.replacement);
|
||||
}
|
||||
|
||||
// Output file.
|
||||
std::ofstream file(output_path);
|
||||
file << str;
|
||||
|
||||
return 0;
|
||||
}
|
35
bazel/expanded_template/expanded_template.bzl
Normal file
35
bazel/expanded_template/expanded_template.bzl
Normal file
|
@ -0,0 +1,35 @@
|
|||
def _impl(ctx):
|
||||
args = ctx.actions.args()
|
||||
args.add("--template", ctx.file.template)
|
||||
args.add("--output", ctx.outputs.out)
|
||||
args.add_all([k + ';' + v for k, v in ctx.attr.substitutions.items()])
|
||||
ctx.actions.run(
|
||||
executable = ctx.executable._bin,
|
||||
arguments = [args],
|
||||
inputs = [ctx.file.template],
|
||||
outputs = [ctx.outputs.out],
|
||||
)
|
||||
return [
|
||||
DefaultInfo(
|
||||
files = depset(direct = [ctx.outputs.out]),
|
||||
runfiles = ctx.runfiles(files = [ctx.outputs.out]),
|
||||
),
|
||||
]
|
||||
|
||||
expanded_template = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
"out": attr.output(mandatory = True),
|
||||
"template": attr.label(
|
||||
allow_single_file = True,
|
||||
mandatory = True,
|
||||
),
|
||||
"substitutions": attr.string_dict(),
|
||||
"_bin": attr.label(
|
||||
default = "//bazel/expanded_template:expand_template",
|
||||
executable = True,
|
||||
allow_single_file = True,
|
||||
cfg = "host",
|
||||
),
|
||||
},
|
||||
)
|
108
bazel/gflags.bzl
Normal file
108
bazel/gflags.bzl
Normal file
|
@ -0,0 +1,108 @@
|
|||
load("//bazel/expanded_template:expanded_template.bzl", "expanded_template")
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add native rules to configure source files
|
||||
def gflags_sources(namespace = ["google", "gflags"]):
|
||||
expanded_template(
|
||||
name = "gflags_declare_h",
|
||||
template = "src/gflags_declare.h.in",
|
||||
out = "gflags_declare.h",
|
||||
substitutions = {
|
||||
"@GFLAGS_NAMESPACE@": namespace[0],
|
||||
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@": "1",
|
||||
"@([A-Z0-9_]+)@": "0",
|
||||
},
|
||||
)
|
||||
gflags_ns_h_files = []
|
||||
for ns in namespace[1:]:
|
||||
gflags_ns_h_file = "gflags_{}.h".format(ns)
|
||||
expanded_template(
|
||||
name = gflags_ns_h_file.replace(".", "_"),
|
||||
template = "src/gflags_ns.h.in",
|
||||
out = gflags_ns_h_file,
|
||||
substitutions = {
|
||||
"@ns@": ns,
|
||||
"@NS@": ns.upper(),
|
||||
},
|
||||
)
|
||||
gflags_ns_h_files.append(gflags_ns_h_file)
|
||||
expanded_template(
|
||||
name = "gflags_h",
|
||||
template = "src/gflags.h.in",
|
||||
out = "gflags.h",
|
||||
substitutions = {
|
||||
"@GFLAGS_ATTRIBUTE_UNUSED@": "",
|
||||
"@INCLUDE_GFLAGS_NS_H@": "\n".join(["#include \"gflags/{}\"".format(hdr) for hdr in gflags_ns_h_files]),
|
||||
},
|
||||
)
|
||||
expanded_template(
|
||||
name = "gflags_completions_h",
|
||||
template = "src/gflags_completions.h.in",
|
||||
out = "gflags_completions.h",
|
||||
substitutions = {
|
||||
"@GFLAGS_NAMESPACE@": namespace[0],
|
||||
},
|
||||
)
|
||||
hdrs = [":gflags_h", ":gflags_declare_h", ":gflags_completions_h"]
|
||||
hdrs.extend([":" + hdr.replace(".", "_") for hdr in gflags_ns_h_files])
|
||||
srcs = [
|
||||
"src/config.h",
|
||||
"src/gflags.cc",
|
||||
"src/gflags_completions.cc",
|
||||
"src/gflags_reporting.cc",
|
||||
"src/mutex.h",
|
||||
"src/util.h",
|
||||
] + select({
|
||||
"//:x64_windows": [
|
||||
"src/windows_port.cc",
|
||||
"src/windows_port.h",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
return [hdrs, srcs]
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Add native rule to build gflags library
|
||||
def gflags_library(hdrs = [], srcs = [], threads = 1):
|
||||
name = "gflags"
|
||||
copts = [
|
||||
"-DGFLAGS_BAZEL_BUILD",
|
||||
"-DGFLAGS_INTTYPES_FORMAT_C99",
|
||||
"-DGFLAGS_IS_A_DLL=0",
|
||||
# macros otherwise defined by CMake configured defines.h file
|
||||
"-DHAVE_STDINT_H",
|
||||
"-DHAVE_SYS_TYPES_H",
|
||||
"-DHAVE_INTTYPES_H",
|
||||
"-DHAVE_SYS_STAT_H",
|
||||
"-DHAVE_STRTOLL",
|
||||
"-DHAVE_STRTOQ",
|
||||
"-DHAVE_RWLOCK",
|
||||
] + select({
|
||||
"//:x64_windows": [
|
||||
"-DOS_WINDOWS",
|
||||
],
|
||||
"//conditions:default": [
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_FNMATCH_H",
|
||||
"-DHAVE_PTHREAD",
|
||||
],
|
||||
})
|
||||
linkopts = []
|
||||
if threads:
|
||||
linkopts += select({
|
||||
"//:android": [],
|
||||
"//:x64_windows": [],
|
||||
"//conditions:default": ["-lpthread"],
|
||||
})
|
||||
else:
|
||||
name += "_nothreads"
|
||||
copts += ["-DNO_THREADS"]
|
||||
native.cc_library(
|
||||
name = name,
|
||||
hdrs = hdrs,
|
||||
srcs = srcs,
|
||||
copts = copts,
|
||||
linkopts = linkopts,
|
||||
visibility = ["//visibility:public"],
|
||||
include_prefix = "gflags",
|
||||
)
|
4
cmake/README_runtime.txt
Normal file
4
cmake/README_runtime.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
This package contains runtime libraries only which are required
|
||||
by applications that use these libraries for the commandline flags
|
||||
processing. If you want to develop such application, download
|
||||
and install the development package instead.
|
26
cmake/cmake_uninstall.cmake.in
Normal file
26
cmake/cmake_uninstall.cmake.in
Normal file
|
@ -0,0 +1,26 @@
|
|||
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||
set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
|
||||
endif ()
|
||||
message(${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||
foreach(file ${files})
|
||||
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
exec_program(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
if(NOT "${rm_retval}" STREQUAL 0)
|
||||
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||
endforeach(file)
|
183
cmake/config.cmake.in
Normal file
183
cmake/config.cmake.in
Normal file
|
@ -0,0 +1,183 @@
|
|||
## gflags CMake configuration file
|
||||
|
||||
# library version information
|
||||
set (@PACKAGE_PREFIX@_VERSION_STRING "@PACKAGE_VERSION@")
|
||||
set (@PACKAGE_PREFIX@_VERSION_MAJOR @PACKAGE_VERSION_MAJOR@)
|
||||
set (@PACKAGE_PREFIX@_VERSION_MINOR @PACKAGE_VERSION_MINOR@)
|
||||
set (@PACKAGE_PREFIX@_VERSION_PATCH @PACKAGE_VERSION_PATCH@)
|
||||
|
||||
# import targets
|
||||
if (NOT DEFINED @PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
|
||||
set (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE FALSE)
|
||||
endif ()
|
||||
if (@PACKAGE_PREFIX@_USE_TARGET_NAMESPACE)
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@.cmake")
|
||||
set (@PACKAGE_PREFIX@_TARGET_NAMESPACE @PACKAGE_NAME@)
|
||||
else ()
|
||||
include ("${CMAKE_CURRENT_LIST_DIR}/@PACKAGE_NAME@-nonamespace-targets.cmake")
|
||||
set (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
|
||||
endif ()
|
||||
if (@PACKAGE_PREFIX@_TARGET_NAMESPACE)
|
||||
set (@PACKAGE_PREFIX@_TARGET_PREFIX ${@PACKAGE_PREFIX@_TARGET_NAMESPACE}::)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_TARGET_PREFIX)
|
||||
endif ()
|
||||
|
||||
# installation prefix
|
||||
get_filename_component (CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
get_filename_component (_INSTALL_PREFIX "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_PREFIX_REL2CONFIG_DIR@" ABSOLUTE)
|
||||
|
||||
# include directory
|
||||
#
|
||||
# Newer versions of CMake set the INTERFACE_INCLUDE_DIRECTORIES property
|
||||
# of the imported targets. It is hence not necessary to add this path
|
||||
# manually to the include search path for targets which link to gflags.
|
||||
set (@PACKAGE_PREFIX@_INCLUDE_DIR "${_INSTALL_PREFIX}/@INCLUDE_INSTALL_DIR@")
|
||||
|
||||
if (@PACKAGE_NAME@_FIND_COMPONENTS)
|
||||
foreach (@PACKAGE_NAME@_FIND_COMPONENT IN LISTS @PACKAGE_NAME@_FIND_COMPONENTS)
|
||||
if (@PACKAGE_NAME@_FIND_REQUIRED_${@PACKAGE_NAME@_FIND_COMPONENT} AND NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_${@PACKAGE_NAME@_FIND_COMPONENT})
|
||||
message (FATAL_ERROR "Package @PACKAGE_NAME@ was installed without required component ${@PACKAGE_PREFIX@_TARGET_PREFIX}${@PACKAGE_NAME@_FIND_COMPONENT}!")
|
||||
endif ()
|
||||
endforeach ()
|
||||
list (GET @PACKAGE_NAME@_FIND_COMPONENTS 0 @PACKAGE_NAME@_FIND_COMPONENT)
|
||||
else ()
|
||||
set (@PACKAGE_NAME@_FIND_COMPONENT)
|
||||
endif ()
|
||||
|
||||
# default settings of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS
|
||||
#
|
||||
# It is recommended to use either one of the following find_package commands
|
||||
# instead of setting the @PACKAGE_PREFIX@_(SHARED|NOTHREADS) variables:
|
||||
# - find_package(@PACKAGE_NAME@ REQUIRED)
|
||||
# - find_package(@PACKAGE_NAME@ COMPONENTS nothreads_static)
|
||||
# - find_package(@PACKAGE_NAME@ COMPONENTS nothreads_shared)
|
||||
# - find_package(@PACKAGE_NAME@ COMPONENTS static)
|
||||
# - find_package(@PACKAGE_NAME@ COMPONENTS shared)
|
||||
if (NOT DEFINED @PACKAGE_PREFIX@_SHARED)
|
||||
if (DEFINED @PACKAGE_NAME@_SHARED)
|
||||
set (@PACKAGE_PREFIX@_SHARED ${@PACKAGE_NAME@_SHARED})
|
||||
elseif (@PACKAGE_NAME@_FIND_COMPONENT)
|
||||
if (@PACKAGE_NAME@_FIND_COMPONENT MATCHES "shared")
|
||||
set (@PACKAGE_PREFIX@_SHARED TRUE)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_SHARED FALSE)
|
||||
endif ()
|
||||
elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
|
||||
set (@PACKAGE_PREFIX@_SHARED TRUE)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_SHARED FALSE)
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT DEFINED @PACKAGE_PREFIX@_NOTHREADS)
|
||||
if (DEFINED @PACKAGE_NAME@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS ${@PACKAGE_NAME@_NOTHREADS})
|
||||
elseif (@PACKAGE_NAME@_FIND_COMPONENT)
|
||||
if (@PACKAGE_NAME@_FIND_COMPONENT MATCHES "nothreads")
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
|
||||
endif ()
|
||||
elseif (TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static OR TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS FALSE)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_NOTHREADS TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# choose imported library target
|
||||
if (NOT @PACKAGE_PREFIX@_TARGET)
|
||||
if (@PACKAGE_NAME@_TARGET)
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_NAME@_TARGET})
|
||||
elseif (@PACKAGE_PREFIX@_SHARED)
|
||||
if (@PACKAGE_PREFIX@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_shared)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_shared)
|
||||
endif ()
|
||||
else ()
|
||||
if (@PACKAGE_PREFIX@_NOTHREADS)
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_nothreads_static)
|
||||
else ()
|
||||
set (@PACKAGE_PREFIX@_TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@_static)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET})
|
||||
message (FATAL_ERROR "Your @PACKAGE_NAME@ installation does not contain a ${@PACKAGE_PREFIX@_TARGET} library target!"
|
||||
" Try a different combination of @PACKAGE_PREFIX@_SHARED and @PACKAGE_PREFIX@_NOTHREADS.")
|
||||
endif ()
|
||||
|
||||
# add more convenient "${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@" import target
|
||||
if (NOT TARGET ${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@)
|
||||
if (@PACKAGE_PREFIX@_SHARED)
|
||||
add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ SHARED IMPORTED)
|
||||
else ()
|
||||
add_library (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ STATIC IMPORTED)
|
||||
endif ()
|
||||
# copy INTERFACE_* properties
|
||||
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
|
||||
COMPILE_DEFINITIONS
|
||||
COMPILE_FEATURES
|
||||
COMPILE_OPTIONS
|
||||
INCLUDE_DIRECTORIES
|
||||
LINK_LIBRARIES
|
||||
POSITION_INDEPENDENT_CODE
|
||||
)
|
||||
get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME})
|
||||
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
|
||||
INTERFACE_${_@PACKAGE_PREFIX@_PROPERTY_NAME} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
|
||||
)
|
||||
endif ()
|
||||
endforeach ()
|
||||
# copy IMPORTED_*_<CONFIG> properties
|
||||
get_target_property (_@PACKAGE_PREFIX@_CONFIGURATIONS ${@PACKAGE_PREFIX@_TARGET} IMPORTED_CONFIGURATIONS)
|
||||
set_target_properties (${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES IMPORTED_CONFIGURATIONS "${_@PACKAGE_PREFIX@_CONFIGURATIONS}")
|
||||
foreach (_@PACKAGE_PREFIX@_PROPERTY_NAME IN ITEMS
|
||||
IMPLIB
|
||||
LOCATION
|
||||
LINK_DEPENDENT_LIBRARIES
|
||||
LINK_INTERFACE_LIBRARIES
|
||||
LINK_INTERFACE_LANGUAGES
|
||||
LINK_INTERFACE_MULTIPLICITY
|
||||
NO_SONAME
|
||||
SONAME
|
||||
)
|
||||
foreach (_@PACKAGE_PREFIX@_CONFIG IN LISTS _@PACKAGE_PREFIX@_CONFIGURATIONS)
|
||||
get_target_property (_@PACKAGE_PREFIX@_PROPERTY_VALUE ${@PACKAGE_PREFIX@_TARGET} IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG})
|
||||
if (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
set_target_properties(${@PACKAGE_PREFIX@_TARGET_PREFIX}@PACKAGE_NAME@ PROPERTIES
|
||||
IMPORTED_${_@PACKAGE_PREFIX@_PROPERTY_NAME}_${_@PACKAGE_PREFIX@_CONFIG} "${_@PACKAGE_PREFIX@_PROPERTY_VALUE}"
|
||||
)
|
||||
endif ()
|
||||
endforeach ()
|
||||
endforeach ()
|
||||
unset (_@PACKAGE_PREFIX@_CONFIGURATIONS)
|
||||
unset (_@PACKAGE_PREFIX@_CONFIG)
|
||||
unset (_@PACKAGE_PREFIX@_PROPERTY_NAME)
|
||||
unset (_@PACKAGE_PREFIX@_PROPERTY_VALUE)
|
||||
endif ()
|
||||
|
||||
# alias for default import target to be compatible with older CMake package configurations
|
||||
set (@PACKAGE_PREFIX@_LIBRARIES "${@PACKAGE_PREFIX@_TARGET}")
|
||||
|
||||
# set @PACKAGE_NAME@_* variables for backwards compatibility
|
||||
if (NOT "^@PACKAGE_NAME@$" STREQUAL "^@PACKAGE_PREFIX@$")
|
||||
foreach (_@PACKAGE_PREFIX@_VARIABLE IN ITEMS
|
||||
VERSION_STRING
|
||||
VERSION_MAJOR
|
||||
VERSION_MINOR
|
||||
VERSION_PATCH
|
||||
INCLUDE_DIR
|
||||
LIBRARIES
|
||||
TARGET
|
||||
)
|
||||
set (@PACKAGE_NAME@_${_@PACKAGE_PREFIX@_VARIABLE} "${@PACKAGE_PREFIX@_${_@PACKAGE_PREFIX@_VARIABLE}}")
|
||||
endforeach ()
|
||||
unset (_@PACKAGE_PREFIX@_VARIABLE)
|
||||
endif ()
|
||||
|
||||
# unset private variables
|
||||
unset (@PACKAGE_NAME@_FIND_COMPONENT)
|
||||
unset (_INSTALL_PREFIX)
|
53
cmake/execute_test.cmake
Normal file
53
cmake/execute_test.cmake
Normal file
|
@ -0,0 +1,53 @@
|
|||
# ----------------------------------------------------------------------------
|
||||
# sanitize string stored in variable for use in regular expression.
|
||||
macro (sanitize_for_regex STRVAR)
|
||||
string (REGEX REPLACE "([.+*?^$()])" "\\\\\\1" ${STRVAR} "${${STRVAR}}")
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# script arguments
|
||||
if (NOT COMMAND)
|
||||
message (FATAL_ERROR "Test command not specified!")
|
||||
endif ()
|
||||
if (NOT DEFINED EXPECTED_RC)
|
||||
set (EXPECTED_RC 0)
|
||||
endif ()
|
||||
if (EXPECTED_OUTPUT)
|
||||
sanitize_for_regex(EXPECTED_OUTPUT)
|
||||
endif ()
|
||||
if (UNEXPECTED_OUTPUT)
|
||||
sanitize_for_regex(UNEXPECTED_OUTPUT)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# set a few environment variables (useful for --tryfromenv)
|
||||
set (ENV{FLAGS_undefok} "foo,bar")
|
||||
set (ENV{FLAGS_weirdo} "")
|
||||
set (ENV{FLAGS_version} "true")
|
||||
set (ENV{FLAGS_help} "false")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# execute test command
|
||||
execute_process(
|
||||
COMMAND ${COMMAND}
|
||||
RESULT_VARIABLE RC
|
||||
OUTPUT_VARIABLE OUTPUT
|
||||
ERROR_VARIABLE OUTPUT
|
||||
)
|
||||
|
||||
if (OUTPUT)
|
||||
message ("${OUTPUT}")
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# check test result
|
||||
if (NOT RC EQUAL EXPECTED_RC)
|
||||
string (REPLACE ";" " " COMMAND "${COMMAND}")
|
||||
message (FATAL_ERROR "Command:\n\t${COMMAND}\nExit status is ${RC}, expected ${EXPECTED_RC}")
|
||||
endif ()
|
||||
if (EXPECTED_OUTPUT AND NOT OUTPUT MATCHES "${EXPECTED_OUTPUT}")
|
||||
message (FATAL_ERROR "Test output does not match expected output: ${EXPECTED_OUTPUT}")
|
||||
endif ()
|
||||
if (UNEXPECTED_OUTPUT AND OUTPUT MATCHES "${UNEXPECTED_OUTPUT}")
|
||||
message (FATAL_ERROR "Test output matches unexpected output: ${UNEXPECTED_OUTPUT}")
|
||||
endif ()
|
49
cmake/package.cmake.in
Normal file
49
cmake/package.cmake.in
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Per-generator CPack configuration file. See CPACK_PROJECT_CONFIG_FILE documented at
|
||||
# http://www.cmake.org/cmake/help/v2.8.12/cpack.html#variable:CPACK_PROJECT_CONFIG_FILE
|
||||
#
|
||||
# All common CPACK_* variables are set in CMakeLists.txt already. This file only
|
||||
# overrides some of these to provide package generator specific settings.
|
||||
|
||||
# whether package contains all development files or only runtime files
|
||||
set (DEVEL @INSTALL_HEADERS@)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Mac OS X package
|
||||
if (CPACK_GENERATOR MATCHES "PackageMaker|DragNDrop")
|
||||
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
if (DEVEL)
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
|
||||
endif ()
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}")
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Debian package
|
||||
elseif (CPACK_GENERATOR MATCHES "DEB")
|
||||
|
||||
set (CPACK_PACKAGE_FILE_NAME "lib${CPACK_PACKAGE_NAME}")
|
||||
if (DEVEL)
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-dev")
|
||||
else ()
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}0")
|
||||
endif ()
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}_${CPACK_PACKAGE_VERSION}-1_${CPACK_PACKAGE_ARCHITECTURE}")
|
||||
|
||||
set (CPACK_DEBIAN_PACKAGE_DEPENDS)
|
||||
set (CPACK_DEBIAN_PACKAGE_SECTION "devel")
|
||||
set (CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "${CPACK_RPM_PACKAGE_URL}")
|
||||
set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
|
||||
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}")
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# RPM package
|
||||
elseif (CPACK_GENERATOR MATCHES "RPM")
|
||||
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}")
|
||||
if (DEVEL)
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-devel")
|
||||
endif ()
|
||||
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_VERSION}-1.${CPACK_PACKAGE_ARCHITECTURE}")
|
||||
|
||||
endif ()
|
14
cmake/package.pc.in
Normal file
14
cmake/package.pc.in
Normal file
|
@ -0,0 +1,14 @@
|
|||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
bindir=${exec_prefix}/@RUNTIME_INSTALL_DIR@
|
||||
libdir=${exec_prefix}/@LIBRARY_INSTALL_DIR@
|
||||
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
|
||||
|
||||
Name: @PACKAGE_NAME@
|
||||
Version: @PACKAGE_VERSION@
|
||||
Description: @PACKAGE_DESCRIPTION@
|
||||
URL: @PACKAGE_URL@
|
||||
Requires:
|
||||
Libs: -L${libdir} -lgflags
|
||||
Libs.private: -lpthread
|
||||
Cflags: -I${includedir}
|
207
cmake/utils.cmake
Normal file
207
cmake/utils.cmake
Normal file
|
@ -0,0 +1,207 @@
|
|||
## Utility CMake functions.
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Convert boolean value to 0 or 1
|
||||
macro (bool_to_int VAR)
|
||||
if (${VAR})
|
||||
set (${VAR} 1)
|
||||
else ()
|
||||
set (${VAR} 0)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Extract version numbers from version string
|
||||
function (version_numbers version major minor patch)
|
||||
if (version MATCHES "([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(rc[1-9][0-9]*|[a-z]+)?")
|
||||
if (CMAKE_MATCH_1)
|
||||
set (_major ${CMAKE_MATCH_1})
|
||||
else ()
|
||||
set (_major 0)
|
||||
endif ()
|
||||
if (CMAKE_MATCH_2)
|
||||
set (_minor ${CMAKE_MATCH_2})
|
||||
string (REGEX REPLACE "^\\." "" _minor "${_minor}")
|
||||
else ()
|
||||
set (_minor 0)
|
||||
endif ()
|
||||
if (CMAKE_MATCH_3)
|
||||
set (_patch ${CMAKE_MATCH_3})
|
||||
string (REGEX REPLACE "^\\." "" _patch "${_patch}")
|
||||
else ()
|
||||
set (_patch 0)
|
||||
endif ()
|
||||
else ()
|
||||
set (_major 0)
|
||||
set (_minor 0)
|
||||
set (_patch 0)
|
||||
endif ()
|
||||
set ("${major}" "${_major}" PARENT_SCOPE)
|
||||
set ("${minor}" "${_minor}" PARENT_SCOPE)
|
||||
set ("${patch}" "${_patch}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Determine if cache entry exists
|
||||
macro (gflags_is_cached retvar varname)
|
||||
if (DEFINED ${varname})
|
||||
get_property (${retvar} CACHE ${varname} PROPERTY TYPE SET)
|
||||
else ()
|
||||
set (${retvar} FALSE)
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Add gflags configuration variable
|
||||
#
|
||||
# The default value of the (cached) configuration value can be overridden either
|
||||
# on the CMake command-line or the super-project by setting the GFLAGS_<varname>
|
||||
# variable. When gflags is a subproject of another project (GFLAGS_IS_SUBPROJECT),
|
||||
# the variable is not added to the CMake cache. Otherwise it is cached.
|
||||
macro (gflags_define type varname docstring default)
|
||||
# note that ARGC must be expanded here, as it is not a "real" variable
|
||||
# (see the CMake documentation for the macro command)
|
||||
if ("${ARGC}" GREATER 5)
|
||||
message (FATAL_ERROR "gflags_variable: Too many macro arguments")
|
||||
endif ()
|
||||
if (NOT DEFINED GFLAGS_${varname})
|
||||
if (DEFINED ${varname})
|
||||
set (GFLAGS_${varname} "${${varname}}")
|
||||
else ()
|
||||
if (GFLAGS_IS_SUBPROJECT AND "${ARGC}" EQUAL 5)
|
||||
set (GFLAGS_${varname} "${ARGV4}")
|
||||
else ()
|
||||
set (GFLAGS_${varname} "${default}")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
if (GFLAGS_IS_SUBPROJECT)
|
||||
set (${varname} "${GFLAGS_${varname}}")
|
||||
else ()
|
||||
set (${varname} "${GFLAGS_${varname}}" CACHE ${type} "${docstring}")
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Set property of cached gflags configuration variable
|
||||
macro (gflags_property varname property value)
|
||||
gflags_is_cached (_cached ${varname})
|
||||
if (_cached)
|
||||
# note that property must be expanded here, as it is not a "real" variable
|
||||
# (see the CMake documentation for the macro command)
|
||||
if ("${property}" STREQUAL "ADVANCED")
|
||||
if (${value})
|
||||
mark_as_advanced (FORCE ${varname})
|
||||
else ()
|
||||
mark_as_advanced (CLEAR ${varname})
|
||||
endif ()
|
||||
else ()
|
||||
set_property (CACHE ${varname} PROPERTY "${property}" "${value}")
|
||||
endif ()
|
||||
endif ()
|
||||
unset (_cached)
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Modify value of gflags configuration variable
|
||||
macro (gflags_set varname value)
|
||||
gflags_is_cached (_cached ${varname})
|
||||
if (_cached)
|
||||
set_property (CACHE ${varname} PROPERTY VALUE "${value}")
|
||||
else ()
|
||||
set (${varname} "${value}")
|
||||
endif ()
|
||||
unset (_cached)
|
||||
endmacro ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Configure public header files
|
||||
function (configure_headers out)
|
||||
set (tmp)
|
||||
foreach (src IN LISTS ARGN)
|
||||
if (IS_ABSOLUTE "${src}")
|
||||
list (APPEND tmp "${src}")
|
||||
elseif (EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" @ONLY)
|
||||
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}")
|
||||
else ()
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/src/${src}" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" COPYONLY)
|
||||
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
set (${out} "${tmp}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Configure source files with .in suffix
|
||||
function (configure_sources out)
|
||||
set (tmp)
|
||||
foreach (src IN LISTS ARGN)
|
||||
if (src MATCHES ".h$" AND EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in")
|
||||
configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}" @ONLY)
|
||||
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_INCLUDE_DIR}/${src}")
|
||||
else ()
|
||||
list (APPEND tmp "${PROJECT_SOURCE_DIR}/src/${src}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
set (${out} "${tmp}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
## Add usage test
|
||||
#
|
||||
# Using PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION would
|
||||
# do as well, but CMake/CTest does not allow us to specify an
|
||||
# expected exit status. Moreover, the execute_test.cmake script
|
||||
# sets environment variables needed by the --fromenv/--tryfromenv tests.
|
||||
macro (add_gflags_test name expected_rc expected_output unexpected_output cmd)
|
||||
set (args "--test_tmpdir=${PROJECT_BINARY_DIR}/Testing/Temporary"
|
||||
"--srcdir=${PROJECT_SOURCE_DIR}/test")
|
||||
add_test (
|
||||
NAME ${name}
|
||||
COMMAND "${CMAKE_COMMAND}" "-DCOMMAND:STRING=$<TARGET_FILE:${cmd}>;${args};${ARGN}"
|
||||
"-DEXPECTED_RC:STRING=${expected_rc}"
|
||||
"-DEXPECTED_OUTPUT:STRING=${expected_output}"
|
||||
"-DUNEXPECTED_OUTPUT:STRING=${unexpected_output}"
|
||||
-P "${PROJECT_SOURCE_DIR}/cmake/execute_test.cmake"
|
||||
WORKING_DIRECTORY "${GFLAGS_FLAGFILES_DIR}"
|
||||
)
|
||||
endmacro ()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
## Register installed package with CMake
|
||||
#
|
||||
# This function adds an entry to the CMake registry for packages with the
|
||||
# path of the directory where the package configuration file of the installed
|
||||
# package is located in order to help CMake find the package in a custom
|
||||
# installation prefix. This differs from CMake's export(PACKAGE) command
|
||||
# which registers the build directory instead.
|
||||
function (register_gflags_package CONFIG_DIR)
|
||||
if (NOT IS_ABSOLUTE "${CONFIG_DIR}")
|
||||
set (CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${CONFIG_DIR}")
|
||||
endif ()
|
||||
string (MD5 REGISTRY_ENTRY "${CONFIG_DIR}")
|
||||
if (WIN32)
|
||||
install (CODE
|
||||
"execute_process (
|
||||
COMMAND reg add \"HKCU\\\\Software\\\\Kitware\\\\CMake\\\\Packages\\\\${PACKAGE_NAME}\" /v \"${REGISTRY_ENTRY}\" /d \"${CONFIG_DIR}\" /t REG_SZ /f
|
||||
RESULT_VARIABLE RT
|
||||
ERROR_VARIABLE ERR
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
if (RT EQUAL 0)
|
||||
message (STATUS \"Register: Added HKEY_CURRENT_USER\\\\Software\\\\Kitware\\\\CMake\\\\Packages\\\\${PACKAGE_NAME}\\\\${REGISTRY_ENTRY}\")
|
||||
else ()
|
||||
string (STRIP \"\${ERR}\" ERR)
|
||||
message (STATUS \"Register: Failed to add registry entry: \${ERR}\")
|
||||
endif ()"
|
||||
)
|
||||
elseif (IS_DIRECTORY "$ENV{HOME}")
|
||||
file (WRITE "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-registry-entry" "${CONFIG_DIR}")
|
||||
install (
|
||||
FILES "${PROJECT_BINARY_DIR}/${PACKAGE_NAME}-registry-entry"
|
||||
DESTINATION "$ENV{HOME}/.cmake/packages/${PACKAGE_NAME}"
|
||||
RENAME "${REGISTRY_ENTRY}"
|
||||
)
|
||||
endif ()
|
||||
endfunction ()
|
21
cmake/version.cmake.in
Normal file
21
cmake/version.cmake.in
Normal file
|
@ -0,0 +1,21 @@
|
|||
## gflags CMake configuration version file
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# library version
|
||||
set (PACKAGE_VERSION "@PACKAGE_VERSION@")
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# check compatibility
|
||||
|
||||
# Perform compatibility check here using the input CMake variables.
|
||||
# See example in http://www.cmake.org/Wiki/CMake_2.6_Notes.
|
||||
|
||||
set (PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
set (PACKAGE_VERSION_UNSUITABLE FALSE)
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@PACKAGE_VERSION_MAJOR@" AND
|
||||
"${PACKAGE_FIND_VERSION_MINOR}" EQUAL "@PACKAGE_VERSION_MINOR@")
|
||||
set (PACKAGE_VERSION_EXACT TRUE)
|
||||
else ()
|
||||
set (PACKAGE_VERSION_EXACT FALSE)
|
||||
endif ()
|
99
compile
99
compile
|
@ -1,99 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
# Wrapper for compilers which do not understand `-c -o'.
|
||||
|
||||
# Copyright 1999, 2000 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Usage:
|
||||
# compile PROGRAM [ARGS]...
|
||||
# `-o FOO.o' is removed from the args passed to the actual compile.
|
||||
|
||||
prog=$1
|
||||
shift
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
args=
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-o)
|
||||
# configure might choose to run compile as `compile cc -o foo foo.c'.
|
||||
# So we do something ugly here.
|
||||
ofile=$2
|
||||
shift
|
||||
case "$ofile" in
|
||||
*.o | *.obj)
|
||||
;;
|
||||
*)
|
||||
args="$args -o $ofile"
|
||||
ofile=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
args="$args $1"
|
||||
;;
|
||||
*)
|
||||
args="$args $1"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no `-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# `.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$prog" $args
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use `[/.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir $lockdir > /dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir $lockdir; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$prog" $args
|
||||
status=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
mv "$cofile" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir $lockdir
|
||||
exit $status
|
1466
config.guess
vendored
1466
config.guess
vendored
File diff suppressed because it is too large
Load diff
1579
config.sub
vendored
1579
config.sub
vendored
File diff suppressed because it is too large
Load diff
97
configure.ac
97
configure.ac
|
@ -1,97 +0,0 @@
|
|||
## Process this file with autoconf to produce configure.
|
||||
## In general, the safest way to proceed is to run ./autogen.sh
|
||||
|
||||
# make sure we're interpreted by some minimal autoconf
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
AC_INIT(gflags, 1.1, opensource@google.com)
|
||||
# The argument here is just something that should be in the current directory
|
||||
# (for sanity checking)
|
||||
AC_CONFIG_SRCDIR(README)
|
||||
AM_INIT_AUTOMAKE
|
||||
AM_CONFIG_HEADER(src/config.h)
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_CXX
|
||||
AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
# Populate $host_cpu, $host_os, etc.
|
||||
AC_CANONICAL_HOST
|
||||
case $host_os in
|
||||
*mingw*)
|
||||
# Disabling fast install keeps libtool from creating wrapper scripts
|
||||
# around the executables it builds. Such scripts have caused failures on
|
||||
# MinGW. Using this option means an extra link step is executed during
|
||||
# "make install".
|
||||
AC_DISABLE_FAST_INSTALL
|
||||
;;
|
||||
*)
|
||||
AC_ENABLE_FAST_INSTALL
|
||||
;;
|
||||
esac
|
||||
|
||||
# Uncomment this if you'll be exporting libraries (.so's)
|
||||
AC_PROG_LIBTOOL
|
||||
AC_SUBST(LIBTOOL_DEPS)
|
||||
|
||||
# Check whether some low-level functions/files are available
|
||||
AC_HEADER_STDC
|
||||
|
||||
# These are tested for by AC_HEADER_STDC, but I check again to set the var
|
||||
AC_CHECK_HEADER(stdint.h, ac_cv_have_stdint_h=1, ac_cv_have_stdint_h=0)
|
||||
AC_CHECK_HEADER(sys/types.h, ac_cv_have_systypes_h=1, ac_cv_have_systypes_h=0)
|
||||
AC_CHECK_HEADER(inttypes.h, ac_cv_have_inttypes_h=1, ac_cv_have_inttypes_h=0)
|
||||
AC_CHECK_HEADERS([fnmatch.h])
|
||||
|
||||
# These are the types I need. We look for them in either stdint.h,
|
||||
# sys/types.h, or inttypes.h, all of which are part of the default-includes.
|
||||
AC_CHECK_TYPE(uint16_t, ac_cv_have_uint16_t=1, ac_cv_have_uint16_t=0)
|
||||
AC_CHECK_TYPE(u_int16_t, ac_cv_have_u_int16_t=1, ac_cv_have_u_int16_t=0)
|
||||
AC_CHECK_TYPE(__int16, ac_cv_have___int16=1, ac_cv_have___int16=0)
|
||||
|
||||
AC_CHECK_FUNCS([strtoll strtoq])
|
||||
|
||||
AX_C___ATTRIBUTE__
|
||||
# We only care about __attribute__ ((unused))
|
||||
if test x"$ac_cv___attribute__" = x"yes"; then
|
||||
ac_cv___attribute__unused="__attribute__ ((unused))"
|
||||
else
|
||||
ac_cv___attribute__unused=
|
||||
fi
|
||||
|
||||
ACX_PTHREAD
|
||||
|
||||
# Find out what namespace 'normal' STL code lives in, and also what namespace
|
||||
# the user wants our classes to be defined in
|
||||
AC_CXX_STL_NAMESPACE
|
||||
AC_DEFINE_GOOGLE_NAMESPACE(google)
|
||||
|
||||
# Solaris 10 6/06 has a bug where /usr/sfw/lib/libstdc++.la is empty.
|
||||
# If so, we replace it with our own version.
|
||||
LIBSTDCXX_LA_LINKER_FLAG=
|
||||
if test -f /usr/sfw/lib/libstdc++.la && ! test -s /usr/sfw/lib/libstdc++.la
|
||||
then
|
||||
LIBSTDCXX_LA_LINKER_FLAG='-L$(top_srcdir)/src/solaris'
|
||||
fi
|
||||
AC_SUBST(LIBSTDCXX_LA_LINKER_FLAG)
|
||||
|
||||
# These are what's needed by gflags.h.in
|
||||
AC_SUBST(ac_google_start_namespace)
|
||||
AC_SUBST(ac_google_end_namespace)
|
||||
AC_SUBST(ac_google_namespace)
|
||||
AC_SUBST(ac_cv___attribute__unused)
|
||||
AC_SUBST(ac_cv_have_stdint_h)
|
||||
AC_SUBST(ac_cv_have_systypes_h)
|
||||
AC_SUBST(ac_cv_have_inttypes_h)
|
||||
AC_SUBST(ac_cv_have_uint16_t)
|
||||
AC_SUBST(ac_cv_have_u_int16_t)
|
||||
AC_SUBST(ac_cv_have___int16)
|
||||
|
||||
## Check out ../autoconf/ for other macros you can call to do useful stuff
|
||||
|
||||
# Write generated configuration file, and also .h files
|
||||
AC_CONFIG_FILES([Makefile src/gflags/gflags.h src/gflags/gflags_completions.h])
|
||||
AC_OUTPUT
|
530
depcomp
530
depcomp
|
@ -1,530 +0,0 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2005-07-09.11
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mecanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
4
doc/README.md
Normal file
4
doc/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
To update the GitHub Pages at http://gflags.github.io/gflags/, use command:
|
||||
```
|
||||
git subtree push --prefix=doc/ origin gh-pages
|
||||
```
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
<html>
|
||||
<head>
|
||||
<title>How To Use Google Commandline Flags</title>
|
||||
<title>How To Use Gflags (formerly Google Commandline Flags)</title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link href="http://www.google.com/favicon.ico" type="image/x-icon"
|
||||
rel="shortcut icon">
|
||||
<link href="designstyle.css" type="text/css" rel="stylesheet">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
|
@ -18,7 +16,7 @@
|
|||
color: #000;
|
||||
font-family: "Times Roman", times, serif;
|
||||
}
|
||||
ul.blacklist li {
|
||||
ul.blacklist li {
|
||||
color: #000;
|
||||
font-family: "Times Roman", times, serif;
|
||||
}
|
||||
|
@ -28,7 +26,7 @@
|
|||
|
||||
<body>
|
||||
|
||||
<h1>How To Use Google Commandline Flags (gflags)</h1>
|
||||
<h1>How To Use gflags (formerly Google Commandline Flags)</h1>
|
||||
<small>(as of
|
||||
<script type=text/javascript>
|
||||
var lm = new Date(document.lastModified);
|
||||
|
@ -37,6 +35,25 @@
|
|||
</small>
|
||||
<br>
|
||||
|
||||
<blockquote><dl>
|
||||
<dt> Table of contents </dt>
|
||||
<dd> <a href="#intro">Introduction</a> </dd>
|
||||
<dd> <a href="#download">Download and Installation</a> </dd>
|
||||
<dd> <a href="#cmake">Declare dependency on gflags with CMake</a></dd>
|
||||
<dd> <a href="#bazel">Declare dependency on gflags with Bazel</a></dd>
|
||||
<dd> <a href="#define">DEFINE: Defining Flags In Program</A> </dd>
|
||||
<dd> <a href="#using">Accessing the Flag</A> </dd>
|
||||
<dd> <a href="#declare">DECLARE: Using the Flag in a Different File</a> </dd>
|
||||
<dd> <a href="#validate">RegisterFlagValidator: Sanity-checking Flag Values</a> </dd>
|
||||
<dd> <a href="#together">Putting It Together: How to Set Up Flags</a> </dd>
|
||||
<dd> <a href="#commandline">Setting Flags on the Command Line</a> </dd>
|
||||
<dd> <a href="#default">Changing the Default Flag Value</a> </dd>
|
||||
<dd> <a href="#special">Special Flags</a> </dd>
|
||||
<dd> <a href="#api">The API</a> </dd>
|
||||
<dd> <a href="#misc">Miscellaneous Notes</a> </dd>
|
||||
<dd> <a href="#issues">Issues and Feature Requests</a> </dd>
|
||||
<dd> <br/> </dd>
|
||||
</dl></blockquote>
|
||||
|
||||
<h2> <A NAME=intro>Introduction, and Comparison to Other Commandline
|
||||
Flags Libraries</A> </h2>
|
||||
|
@ -57,13 +74,14 @@ string (in particular, a filename) as an argument. Users can use a
|
|||
library to help parse the commandline and store the flags in some data
|
||||
structure.</p>
|
||||
|
||||
<p>Google's commandline flags library differs from other libraries,
|
||||
<p>Gflags, the commandline flags library used within Google,
|
||||
differs from other libraries,
|
||||
such as <code>getopt()</code>, in that flag definitions can be
|
||||
scattered around the source code, and not just listed in one place
|
||||
such as <code>main()</code>. In practice, this means that a single
|
||||
source-code file will define and use flags that are meaningful to that
|
||||
file. Any application that links in that file will get the flags, and
|
||||
the google commandline flags library will automatically handle that
|
||||
the gflags library will automatically handle that
|
||||
flag appropriately.</p>
|
||||
|
||||
<p>There's significant gain in flexibility, and ease of code reuse,
|
||||
|
@ -76,6 +94,87 @@ library. It's a C++ library, so examples are in C++. However, there
|
|||
is a Python port with the same functionality, and this discussion
|
||||
translates directly to Python.</p>
|
||||
|
||||
<h2> <A NAME=download>Download and Installation</A> </h2>
|
||||
|
||||
<p>The gflags library can be downloaded from <A href="https://github.com/gflags/gflags">GitHub</A>.
|
||||
You can clone the project using the command:</p>
|
||||
<pre>
|
||||
git clone https://github.com/gflags/gflags.git
|
||||
</pre>
|
||||
<p>Build and installation instructions are provided in the
|
||||
<A href="https://github.com/gflags/gflags/blob/master/INSTALL.md">INSTALL</A> file.
|
||||
The installation of the gflags package includes configuration files for popular build systems
|
||||
such as <A href="https://www.freedesktop.org/wiki/Software/pkg-config/">pkg-config</A>,
|
||||
<A href="#cmake">CMake</A>, and <A href="#bazel">Bazel</A>.</p>
|
||||
|
||||
|
||||
<h2> <A name=cmake>Declare dependency on gflags with CMake</A></h2>
|
||||
|
||||
<p>Using gflags within a project which uses <A href="http://www.cmake.org">CMake</A> for its build system is easy.
|
||||
You can either require an external installation of the gflags package and find it using CMake's find_package
|
||||
command, or include the gflags project as subtree or submodule within your project's source tree and add the directory
|
||||
using CMake's add_subdirectory command.
|
||||
|
||||
<p>To use an external gflags installation, add the following CMake code to your <code>CMakeLists.txt</code> file.</p>
|
||||
|
||||
<p>Find gflags installation. The <code>gflags_DIR</code> variable must be set to the <prefix>/lib/cmake/gflags directory
|
||||
containing the gflags-config.cmake file if <prefix> is a non-standard location. Otherwise, CMake should find
|
||||
the gflags installation automatically.</p>
|
||||
<pre>
|
||||
find_package(gflags REQUIRED)
|
||||
</pre>
|
||||
<p>To request a particular imported gflags library target to link against, use the <code>COMPONENTS</code> option of
|
||||
the find_package command. For example, to force the use of the single-threaded static library, use the command</p>
|
||||
<pre>
|
||||
find_package(gflags COMPONENTS nothreads_static)
|
||||
</pre>
|
||||
<p>Note that this will raise a fatal error when the installed gflags package does not contain the requested library.
|
||||
It is therefore recommended to only specify the particular component to look for if a specific library must be used.
|
||||
Otherwise, the gflags-config.cmake module will choose a suitable and available library for you. By default, the
|
||||
multi-threaded gflags library with shared linkage is chosen if available.</p>
|
||||
|
||||
<p>When the source tree of the gflags project is included as subtree or submodule in the "gflags" directory of your project,
|
||||
replace the above find_package command by <code>add_subdirectory(gflags)</code>. See the top of the <code>gflags/CMakeLists.txt</code>
|
||||
file for a listing of available CMake variables that can be set before this command to configure the build of the
|
||||
gflags library. The default build settings are the build of a single-threaded static library which does not require
|
||||
any installation of the gflags subproject products.</p>
|
||||
|
||||
<p>Finally, add your executable build target which uses gflags to parse the command arguments with dependency on the
|
||||
imported gflags library target:</p>
|
||||
<pre>
|
||||
add_executable(foo main.cc)
|
||||
target_link_libraries(foo gflags::gflags)
|
||||
</pre>
|
||||
|
||||
<h2> <A name=bazel>Declare dependency on gflags with Bazel</A></h2>
|
||||
|
||||
<p>To use gflags within a project which uses <A href="https://bazel.build/">Bazel</A> as build tool,
|
||||
add the following lines to your <code>WORKSPACE</code> file
|
||||
(see also Bazel documentation of <A href="https://www.bazel.io/versions/master/docs/be/workspace.html#git_repository">git_repository</A>):
|
||||
|
||||
<pre>
|
||||
git_repository(
|
||||
name = "com_github_gflags_gflags",
|
||||
remote = "https://github.com/gflags/gflags.git",
|
||||
tag = "v2.2.2"
|
||||
)
|
||||
</pre>
|
||||
|
||||
<p>You can then add <code>@com_github_gflags_gflags//:gflags</code> to the <code>deps</code> section of a
|
||||
<code>cc_binary</code> or <code>cc_library</code> rule, and <code>#include "gflags/gflags.h"</code> to
|
||||
include it in your source code. This uses the shared gflags library with multi-threading enabled.
|
||||
In order to use the single-threaded shared gflags library, use the dependency
|
||||
<code>@com_github_gflags_gflags//:gflags_nothreads</code> instead.</p>
|
||||
|
||||
<p>For example, see the following <code>BUILD</code> rule of the gflags/example project:</p>
|
||||
|
||||
<pre>
|
||||
cc_binary(
|
||||
name = "foo",
|
||||
srcs = ["main.cc"],
|
||||
deps = ["@com_github_gflags_gflags//:gflags"],
|
||||
)
|
||||
</pre>
|
||||
|
||||
<h2> <A name=define>DEFINE: Defining Flags In Program</A> </h2>
|
||||
|
||||
|
@ -107,7 +206,7 @@ types supported:</p>
|
|||
flag in our example is a list of strings, but is defined of type
|
||||
"string", not "list_of_string" or similar. This is by design. We'd
|
||||
rather use only simple types for the flags, and allow for complex,
|
||||
arbitrary parsing routines to parse them, then to try to put the logic
|
||||
arbitrary parsing routines to parse them, than to try to put the logic
|
||||
inside the flags library proper.</p>
|
||||
|
||||
<p>All DEFINE macros take the same three arguments: the name of the
|
||||
|
@ -122,6 +221,15 @@ HREF="#declare">DECLARE</A> it in the others. Even better, DEFINE it
|
|||
in <code>foo.cc</code> and DECLARE it in <code>foo.h</code>; then
|
||||
everyone who <code>#includes foo.h</code> can use the flag.</p>
|
||||
|
||||
<p>
|
||||
Defining flags in libraries rather than in main() is powerful, but
|
||||
does have some costs. One is that a library might not have a good
|
||||
default value for its flags, for example if the flag holds a
|
||||
filename that might not exist in some environments. To mitigate such problems,
|
||||
you can use <a href="#validate">flag validators</a> to ensure prompt
|
||||
notification (in the form of a crash) of an invalid flag value.
|
||||
</p>
|
||||
|
||||
<p>Note that while most functions in this library are defined in the
|
||||
<code>google</code> namespace, <code>DEFINE_foo</code> (and
|
||||
<code>DECLARE_foo</code>, <A HREF="#declare">below</A>), should always
|
||||
|
@ -194,13 +302,13 @@ two files. This causes the flag to be a global variable.</p>
|
|||
|
||||
<p>After DEFINE-ing a flag, you may optionally register a validator
|
||||
function with the flag. If you do this, after the flag is parsed from
|
||||
the commandline, and whenever its value is changes via a call to
|
||||
the commandline, and whenever its value is changed via a call to
|
||||
<code>SetCommandLineOption()</code>, the validator function is called
|
||||
with the new value as an argument. The validator 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, InitGoogle will die.
|
||||
default value, ParseCommandLineFlags will die.
|
||||
|
||||
<p>Here is an example use of this functionality:</p>
|
||||
<pre>
|
||||
|
@ -211,17 +319,20 @@ static bool ValidatePort(const char* flagname, int32 value) {
|
|||
return false;
|
||||
}
|
||||
DEFINE_int32(port, 0, "What port to listen on");
|
||||
static const bool port_dummy = RegisterFlagValidator(&FLAGS_port, &ValidatePort);
|
||||
DEFINE_validator(port, &ValidatePort);
|
||||
</pre>
|
||||
|
||||
<p>By doing the registration at global initialization time (right
|
||||
after the DEFINE), we ensure that the registration happens before
|
||||
after the DEFINE_int32), we ensure that the registration happens before
|
||||
the commandline is parsed at the beginning of <code>main()</code>.</p>
|
||||
|
||||
<p><code>RegisterFlagValidator()</code> returns true if the
|
||||
registration is successful. It return false if the registration fails
|
||||
<p>The above used <code>DEFINE_validator</code> macro calls the
|
||||
<code>RegisterFlagValidator()</code> function which returns true if the
|
||||
registration is successful. It returns false if the registration fails
|
||||
because a) the first argument does not refer to a commandline flag, or
|
||||
b) a different validator has already been registered for this flag.</p>
|
||||
b) a different validator has already been registered for this flag.
|
||||
The return value is available as global static boolean variable named
|
||||
<code><flag>_validator_registered</code>.</p>
|
||||
|
||||
|
||||
<h2> <A name=together>Putting It Together: How to Set Up Flags</A> </h2>
|
||||
|
@ -234,7 +345,7 @@ the getopt library, but has much less overhead to use. In fact, it's
|
|||
just a single function call:</p>
|
||||
|
||||
<pre>
|
||||
google::ParseCommandLineFlags(&argc, &argv, true);
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
</pre>
|
||||
|
||||
<p>Usually, this code is at the beginning of <code>main()</code>.
|
||||
|
@ -317,16 +428,40 @@ HREF="#special"><code>--undefok</code></A> to suppress the error.</p>
|
|||
processing. So in <code>foo -f1 1 -- -f2 2</code>, <code>f1</code> is
|
||||
considered a flag, but <code>-f2</code> is not.</p>
|
||||
|
||||
<p>If a flag is specified more than once, only the last specification
|
||||
is used; the others are ignored.</p>
|
||||
|
||||
<p>Note that flags do not have single-letter synonyms, like they do in
|
||||
the getopt library, nor do we allow "combining" flags behind a
|
||||
single dash, as in <code>ls -la</code>.</p>
|
||||
|
||||
|
||||
<h2> <A name="special">Special Flags</code> </h2>
|
||||
|
||||
<h2> <A name=default>Changing the Default Flag Value</A> </h2>
|
||||
|
||||
<p>Sometimes a flag is defined in a library, and you want to change
|
||||
its default value in one application but not others. It's simple to
|
||||
do this: just assign a new value to the flag in <code>main()</code>,
|
||||
before calling <code>ParseCommandLineFlags()</code>:</p>
|
||||
<pre>
|
||||
DECLARE_bool(lib_verbose); // mylib has a lib_verbose flag, default is false
|
||||
int main(int argc, char** argv) {
|
||||
FLAGS_lib_verbose = true; // in my app, I want a verbose lib by default
|
||||
ParseCommandLineFlags(...);
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>For this application, users can still set the flag value on the
|
||||
commandline, but if they do not, the flag's value will default to
|
||||
true.</p>
|
||||
|
||||
|
||||
<h2> <A name="special">Special Flags</a> </h2>
|
||||
|
||||
<p>There are a few flags defined by the commandlineflags module
|
||||
itself, and are available to all applications. These fall into three
|
||||
categories. First are the 'reporting' flags that, when found, cause
|
||||
itself, and are available to all applications that use
|
||||
commandlineflags. These fall into
|
||||
three categories. First are the 'reporting' flags that, when found, cause
|
||||
the application to print some information about itself and exit.</p>
|
||||
|
||||
<table><tr valign=top>
|
||||
|
@ -334,12 +469,13 @@ the application to print some information about itself and exit.</p>
|
|||
<td>shows all flags from all files, sorted by file and then by name;
|
||||
shows the flagname, its default value, and its help string</td>
|
||||
</tr><tr valign=top>
|
||||
<td><code>--helpfull</code></td>
|
||||
<td><code>--helpful</code></td>
|
||||
<td>same as -help, but unambiguously asks for all flags
|
||||
(in case -help changes in the future)</td>
|
||||
</tr><tr valign=top>
|
||||
<td><code>--helpshort</code></td>
|
||||
<td>shows only flags for the file that includes <code>main()</code></td>
|
||||
<td>shows only flags for the file with the same name as the executable
|
||||
(usually the one containing <code>main()</code>)</td>
|
||||
</tr><tr valign=top>
|
||||
<td><code>--helpxml</code></td>
|
||||
<td>like --help, but output is in xml for easier parsing</td>
|
||||
|
@ -406,7 +542,7 @@ the application.</p>
|
|||
<p>Note it is still an error to say <code>--tryfromenv=foo</code> if
|
||||
<code>foo</code> is not DEFINED somewhere in the application.</p>
|
||||
|
||||
<h3> <code>--flagfile</code> </h3>
|
||||
<h3 id="flagfiles"> <code>--flagfile</code> </h3>
|
||||
|
||||
<p><code>--flagfile=f</code> tells the commandlineflags module to read
|
||||
the file <code>f</code>, and to run all the flag-assignments found in
|
||||
|
@ -414,7 +550,7 @@ that file as if these flags had been specified on the commandline.</p>
|
|||
|
||||
<p>In its simplest form, <code>f</code> should just be a list of flag
|
||||
assignments, one per line. Unlike on the commandline, the equals sign
|
||||
separating a flagname from its argument is <i>required</i> for
|
||||
separating a flagname from its argument is <i>required</i> for
|
||||
flagfiles. An example flagfile, <code>/tmp/myflags</code>:</p>
|
||||
<pre>
|
||||
--nobig_menus
|
||||
|
@ -457,7 +593,7 @@ and then processing continues with remaining flags from the command
|
|||
line.</p>
|
||||
|
||||
|
||||
<h2> <A name="api">The API</code> </h2>
|
||||
<h2> <A name="api">The API</a> </h2>
|
||||
|
||||
<p>In addition to accessing <code>FLAGS_foo</code> directly, it is
|
||||
possible to access the flags programmatically, through an API. It is
|
||||
|
@ -469,8 +605,8 @@ access parts of <code>argv</code> outside main, including the program
|
|||
name (<code>argv[0]</code>).</p>
|
||||
|
||||
<p>For more information about these routines, and other useful helper
|
||||
methods such as <code>google::SetUsageMessage</code>, see
|
||||
<code>gflags.h</code>.</p>
|
||||
methods such as <code>gflags::SetUsageMessage()</code> and
|
||||
<code>gflags::SetVersionString</code>, see <code>gflags.h</code>.</p>
|
||||
|
||||
|
||||
<h2> <A name="misc">Miscellaneous Notes</code> </h2>
|
||||
|
@ -484,10 +620,14 @@ methods such as <code>google::SetUsageMessage</code>, see
|
|||
reduce the size of the resulting binary somewhat, and may also be
|
||||
useful for security reasons.</p>
|
||||
|
||||
<h2> <A name="issues">Issues and Feature Requests</code> </h2>
|
||||
|
||||
<p>Please report any issues or ideas for additional features on <A href="https://github.com/gflags/gflags/issues">GitHub</A>.
|
||||
We would also like to encourage <A href="https://github.com/gflags/gflags/pulls">pull requests</A> for bug fixes and implementations of new features.</p>
|
||||
|
||||
<hr>
|
||||
<address>
|
||||
Craig Silverstein<br>
|
||||
Craig Silverstein, Andreas Schuh<br>
|
||||
<script type=text/javascript>
|
||||
var lm = new Date(document.lastModified);
|
||||
document.write(lm.toDateString());
|
323
install-sh
323
install-sh
|
@ -1,323 +0,0 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2005-05-14.22
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=
|
||||
chgrpcmd=
|
||||
stripcmd=
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dstarg=
|
||||
no_target_directory=
|
||||
|
||||
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
-c (ignored)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test -n "$1"; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t) dstarg=$2
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-T) no_target_directory=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
*) # When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
test -n "$dir_arg$dstarg" && break
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$1"; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src ;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
src=
|
||||
|
||||
if test -d "$dst"; then
|
||||
mkdircmd=:
|
||||
chmodcmd=
|
||||
else
|
||||
mkdircmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dstarg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dstarg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst ;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dstarg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst/`basename "$src"`
|
||||
fi
|
||||
fi
|
||||
|
||||
# This sed command emulates the dirname command.
|
||||
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if test ! -d "$dstdir"; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
shift
|
||||
IFS=$oIFS
|
||||
|
||||
pathcomp=
|
||||
|
||||
while test $# -ne 0 ; do
|
||||
pathcomp=$pathcomp$1
|
||||
shift
|
||||
if test ! -d "$pathcomp"; then
|
||||
$mkdirprog "$pathcomp"
|
||||
# mkdir can fail with a `File exist' error in case several
|
||||
# install-sh are creating the directory concurrently. This
|
||||
# is OK.
|
||||
test -d "$pathcomp" || exit
|
||||
fi
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
$doit $mkdircmd "$dst" \
|
||||
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
|
||||
|
||||
else
|
||||
dstfile=`basename "$dst"`
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
$doit $cpprog "$src" "$dsttmp" &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| {
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
if test -f "$dstdir/$dstfile"; then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|
||||
|| {
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
}
|
||||
}
|
||||
fi || { (exit 1); exit 1; }
|
||||
done
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
{
|
||||
(exit 0); exit 0
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
|
@ -1,16 +0,0 @@
|
|||
AC_DEFUN([AX_C___ATTRIBUTE__], [
|
||||
AC_MSG_CHECKING(for __attribute__)
|
||||
AC_CACHE_VAL(ac_cv___attribute__, [
|
||||
AC_TRY_COMPILE(
|
||||
[#include <stdlib.h>
|
||||
static void foo(void) __attribute__ ((unused));
|
||||
void foo(void) { exit(1); }],
|
||||
[],
|
||||
ac_cv___attribute__=yes,
|
||||
ac_cv___attribute__=no
|
||||
)])
|
||||
if test "$ac_cv___attribute__" = "yes"; then
|
||||
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv___attribute__)
|
||||
])
|
|
@ -1,363 +0,0 @@
|
|||
# This was retrieved from
|
||||
# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi
|
||||
# See also (perhaps for new versions?)
|
||||
# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi
|
||||
#
|
||||
# We've rewritten the inconsistency check code (from avahi), to work
|
||||
# more broadly. In particular, it no longer assumes ld accepts -zdefs.
|
||||
# This caused a restructing of the code, but the functionality has only
|
||||
# changed a little.
|
||||
|
||||
dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
|
||||
dnl
|
||||
dnl @summary figure out how to build C programs using POSIX threads
|
||||
dnl
|
||||
dnl This macro figures out how to build C programs using POSIX threads.
|
||||
dnl It sets the PTHREAD_LIBS output variable to the threads library and
|
||||
dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
|
||||
dnl C compiler flags that are needed. (The user can also force certain
|
||||
dnl compiler flags/libs to be tested by setting these environment
|
||||
dnl variables.)
|
||||
dnl
|
||||
dnl Also sets PTHREAD_CC to any special C compiler that is needed for
|
||||
dnl multi-threaded programs (defaults to the value of CC otherwise).
|
||||
dnl (This is necessary on AIX to use the special cc_r compiler alias.)
|
||||
dnl
|
||||
dnl NOTE: You are assumed to not only compile your program with these
|
||||
dnl flags, but also link it with them as well. e.g. you should link
|
||||
dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
|
||||
dnl $LIBS
|
||||
dnl
|
||||
dnl If you are only building threads programs, you may wish to use
|
||||
dnl these variables in your default LIBS, CFLAGS, and CC:
|
||||
dnl
|
||||
dnl LIBS="$PTHREAD_LIBS $LIBS"
|
||||
dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
dnl CC="$PTHREAD_CC"
|
||||
dnl
|
||||
dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
|
||||
dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
|
||||
dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
|
||||
dnl
|
||||
dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
|
||||
dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
|
||||
dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
|
||||
dnl default action will define HAVE_PTHREAD.
|
||||
dnl
|
||||
dnl Please let the authors know if this macro fails on any platform, or
|
||||
dnl if you have any other suggestions or comments. This macro was based
|
||||
dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
|
||||
dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
|
||||
dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
|
||||
dnl We are also grateful for the helpful feedback of numerous users.
|
||||
dnl
|
||||
dnl @category InstalledPackages
|
||||
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
|
||||
dnl @version 2006-05-29
|
||||
dnl @license GPLWithACException
|
||||
dnl
|
||||
dnl Checks for GCC shared/pthread inconsistency based on work by
|
||||
dnl Marcin Owsiany <marcin@owsiany.pl>
|
||||
|
||||
|
||||
AC_DEFUN([ACX_PTHREAD], [
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_C
|
||||
acx_pthread_ok=no
|
||||
|
||||
# We used to check for pthread.h first, but this fails if pthread.h
|
||||
# requires special compiler flags (e.g. on True64 or Sequent).
|
||||
# It gets checked for in the link test anyway.
|
||||
|
||||
# First of all, check if the user has set any of the PTHREAD_LIBS,
|
||||
# etcetera environment variables, and if threads linking works using
|
||||
# them:
|
||||
if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
|
||||
AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
fi
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
fi
|
||||
|
||||
# We must check for the threads library under a number of different
|
||||
# names; the ordering is very important because some systems
|
||||
# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
|
||||
# libraries is broken (non-POSIX).
|
||||
|
||||
# Create a list of thread flags to try. Items starting with a "-" are
|
||||
# C compiler flags, and other items are library names, except for "none"
|
||||
# which indicates that we try without any flags at all, and "pthread-config"
|
||||
# which is a program returning the flags for the Pth emulation library.
|
||||
|
||||
acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
|
||||
|
||||
# The ordering *is* (sometimes) important. Some notes on the
|
||||
# individual items follow:
|
||||
|
||||
# pthreads: AIX (must check this before -lpthread)
|
||||
# none: in case threads are in libc; should be tried before -Kthread and
|
||||
# other compiler flags to prevent continual compiler warnings
|
||||
# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
|
||||
# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
|
||||
# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
|
||||
# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
|
||||
# -pthreads: Solaris/gcc
|
||||
# -mthreads: Mingw32/gcc, Lynx/gcc
|
||||
# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
|
||||
# doesn't hurt to check since this sometimes defines pthreads too;
|
||||
# also defines -D_REENTRANT)
|
||||
# ... -mt is also the pthreads flag for HP/aCC
|
||||
# pthread: Linux, etcetera
|
||||
# --thread-safe: KAI C++
|
||||
# pthread-config: use pthread-config program (for GNU Pth library)
|
||||
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*solaris*)
|
||||
|
||||
# On Solaris (at least, for some versions), libc contains stubbed
|
||||
# (non-functional) versions of the pthreads routines, so link-based
|
||||
# tests will erroneously succeed. (We need to link with -pthreads/-mt/
|
||||
# -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
|
||||
# a function called by this macro, so we could check for that, but
|
||||
# who knows whether they'll stub that too in a future libc.) So,
|
||||
# we'll just look for -pthreads and -lpthread first:
|
||||
|
||||
acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test x"$acx_pthread_ok" = xno; then
|
||||
for flag in $acx_pthread_flags; do
|
||||
|
||||
case $flag in
|
||||
none)
|
||||
AC_MSG_CHECKING([whether pthreads work without any flags])
|
||||
;;
|
||||
|
||||
-*)
|
||||
AC_MSG_CHECKING([whether pthreads work with $flag])
|
||||
PTHREAD_CFLAGS="$flag"
|
||||
;;
|
||||
|
||||
pthread-config)
|
||||
AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
|
||||
if test x"$acx_pthread_config" = xno; then continue; fi
|
||||
PTHREAD_CFLAGS="`pthread-config --cflags`"
|
||||
PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
|
||||
;;
|
||||
|
||||
*)
|
||||
AC_MSG_CHECKING([for the pthreads library -l$flag])
|
||||
PTHREAD_LIBS="-l$flag"
|
||||
;;
|
||||
esac
|
||||
|
||||
save_LIBS="$LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Check for various functions. We must include pthread.h,
|
||||
# since some functions may be macros. (On the Sequent, we
|
||||
# need a special flag -Kthread to make this header compile.)
|
||||
# We check for pthread_join because it is in -lpthread on IRIX
|
||||
# while pthread_create is in libc. We check for pthread_attr_init
|
||||
# due to DEC craziness with -lpthreads. We check for
|
||||
# pthread_cleanup_push because it is one of the few pthread
|
||||
# functions on Solaris that doesn't have a non-functional libc stub.
|
||||
# We try pthread_create on general principles.
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[acx_pthread_ok=yes])
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
|
||||
AC_MSG_RESULT($acx_pthread_ok)
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
break;
|
||||
fi
|
||||
|
||||
PTHREAD_LIBS=""
|
||||
PTHREAD_CFLAGS=""
|
||||
done
|
||||
fi
|
||||
|
||||
# Various other checks:
|
||||
if test "x$acx_pthread_ok" = xyes; then
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
save_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
|
||||
|
||||
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
|
||||
AC_MSG_CHECKING([for joinable pthread attribute])
|
||||
attr_name=unknown
|
||||
for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
|
||||
AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
|
||||
[attr_name=$attr; break])
|
||||
done
|
||||
AC_MSG_RESULT($attr_name)
|
||||
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
|
||||
AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
|
||||
[Define to necessary symbol if this constant
|
||||
uses a non-standard name on your system.])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([if more special flags are required for pthreads])
|
||||
flag=no
|
||||
case "${host_cpu}-${host_os}" in
|
||||
*-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
|
||||
*solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
|
||||
esac
|
||||
AC_MSG_RESULT(${flag})
|
||||
if test "x$flag" != xno; then
|
||||
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
LIBS="$save_LIBS"
|
||||
CFLAGS="$save_CFLAGS"
|
||||
# More AIX lossage: must compile with xlc_r or cc_r
|
||||
if test x"$GCC" != xyes; then
|
||||
AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
|
||||
else
|
||||
PTHREAD_CC=$CC
|
||||
fi
|
||||
|
||||
# The next part tries to detect GCC inconsistency with -shared on some
|
||||
# architectures and systems. The problem is that in certain
|
||||
# configurations, when -shared is specified, GCC "forgets" to
|
||||
# internally use various flags which are still necessary.
|
||||
|
||||
#
|
||||
# Prepare the flags
|
||||
#
|
||||
save_CFLAGS="$CFLAGS"
|
||||
save_LIBS="$LIBS"
|
||||
save_CC="$CC"
|
||||
|
||||
# Try with the flags determined by the earlier checks.
|
||||
#
|
||||
# -Wl,-z,defs forces link-time symbol resolution, so that the
|
||||
# linking checks with -shared actually have any value
|
||||
#
|
||||
# FIXME: -fPIC is required for -shared on many architectures,
|
||||
# so we specify it here, but the right way would probably be to
|
||||
# properly detect whether it is actually required.
|
||||
CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $LIBS"
|
||||
CC="$PTHREAD_CC"
|
||||
|
||||
# In order not to create several levels of indentation, we test
|
||||
# the value of "$done" until we find the cure or run out of ideas.
|
||||
done="no"
|
||||
|
||||
# First, make sure the CFLAGS we added are actually accepted by our
|
||||
# compiler. If not (and OS X's ld, for instance, does not accept -z),
|
||||
# then we can't do this test.
|
||||
if test x"$done" = xno; then
|
||||
AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
|
||||
AC_TRY_LINK(,, , [done=yes])
|
||||
|
||||
if test "x$done" = xyes ; then
|
||||
AC_MSG_RESULT([no])
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
fi
|
||||
|
||||
if test x"$done" = xno; then
|
||||
AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[done=yes])
|
||||
|
||||
if test "x$done" = xyes; then
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Linux gcc on some architectures such as mips/mipsel forgets
|
||||
# about -lpthread
|
||||
#
|
||||
if test x"$done" = xno; then
|
||||
AC_MSG_CHECKING([whether -lpthread fixes that])
|
||||
LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[done=yes])
|
||||
|
||||
if test "x$done" = xyes; then
|
||||
AC_MSG_RESULT([yes])
|
||||
PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
fi
|
||||
#
|
||||
# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
|
||||
#
|
||||
if test x"$done" = xno; then
|
||||
AC_MSG_CHECKING([whether -lc_r fixes that])
|
||||
LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
|
||||
AC_TRY_LINK([#include <pthread.h>],
|
||||
[pthread_t th; pthread_join(th, 0);
|
||||
pthread_attr_init(0); pthread_cleanup_push(0, 0);
|
||||
pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
|
||||
[done=yes])
|
||||
|
||||
if test "x$done" = xyes; then
|
||||
AC_MSG_RESULT([yes])
|
||||
PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
fi
|
||||
if test x"$done" = xno; then
|
||||
# OK, we have run out of ideas
|
||||
AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
|
||||
|
||||
# so it's not safe to assume that we may use pthreads
|
||||
acx_pthread_ok=no
|
||||
fi
|
||||
|
||||
CFLAGS="$save_CFLAGS"
|
||||
LIBS="$save_LIBS"
|
||||
CC="$save_CC"
|
||||
else
|
||||
PTHREAD_CC="$CC"
|
||||
fi
|
||||
|
||||
AC_SUBST(PTHREAD_LIBS)
|
||||
AC_SUBST(PTHREAD_CFLAGS)
|
||||
AC_SUBST(PTHREAD_CC)
|
||||
|
||||
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
|
||||
if test x"$acx_pthread_ok" = xyes; then
|
||||
ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
|
||||
:
|
||||
else
|
||||
acx_pthread_ok=no
|
||||
$2
|
||||
fi
|
||||
AC_LANG_RESTORE
|
||||
])dnl ACX_PTHREAD
|
|
@ -1,42 +0,0 @@
|
|||
# Allow users to override the namespace we define our application's classes in
|
||||
# Arg $1 is the default namespace to use if --enable-namespace isn't present.
|
||||
|
||||
# In general, $1 should be 'google', so we put all our exported symbols in a
|
||||
# unique namespace that is not likely to conflict with anyone else. However,
|
||||
# when it makes sense -- for instance, when publishing stl-like code -- you
|
||||
# may want to go with a different default, like 'std'.
|
||||
|
||||
# We guarantee the invariant that GOOGLE_NAMESPACE starts with ::,
|
||||
# unless it's the empty string. Thus, it's always safe to do
|
||||
# GOOGLE_NAMESPACE::foo and be sure you're getting the foo that's
|
||||
# actually in the google namespace, and not some other namespace that
|
||||
# the namespace rules might kick in.
|
||||
|
||||
AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE],
|
||||
[google_namespace_default=[$1]
|
||||
AC_ARG_ENABLE(namespace, [ --enable-namespace=FOO to define these Google
|
||||
classes in the FOO namespace. --disable-namespace
|
||||
to define them in the global namespace. Default
|
||||
is to define them in namespace $1.],
|
||||
[case "$enableval" in
|
||||
yes) google_namespace="$google_namespace_default" ;;
|
||||
no) google_namespace="" ;;
|
||||
*) google_namespace="$enableval" ;;
|
||||
esac],
|
||||
[google_namespace="$google_namespace_default"])
|
||||
if test -n "$google_namespace"; then
|
||||
ac_google_namespace="::$google_namespace"
|
||||
ac_google_start_namespace="namespace $google_namespace {"
|
||||
ac_google_end_namespace="}"
|
||||
else
|
||||
ac_google_namespace=""
|
||||
ac_google_start_namespace=""
|
||||
ac_google_end_namespace=""
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(GOOGLE_NAMESPACE, $ac_google_namespace,
|
||||
Namespace for Google classes)
|
||||
AC_DEFINE_UNQUOTED(_START_GOOGLE_NAMESPACE_, $ac_google_start_namespace,
|
||||
Puts following code inside the Google namespace)
|
||||
AC_DEFINE_UNQUOTED(_END_GOOGLE_NAMESPACE_, $ac_google_end_namespace,
|
||||
Stops putting the code inside the Google namespace)
|
||||
])
|
|
@ -1,15 +0,0 @@
|
|||
# Checks whether the compiler implements namespaces
|
||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
||||
ac_cv_cxx_namespaces,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([namespace Outer {
|
||||
namespace Inner { int i = 0; }}],
|
||||
[using namespace Outer::Inner; return i;],
|
||||
ac_cv_cxx_namespaces=yes,
|
||||
ac_cv_cxx_namespaces=no)
|
||||
AC_LANG_RESTORE])
|
||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
||||
AC_DEFINE(HAVE_NAMESPACES, 1, [define if the compiler implements namespaces])
|
||||
fi])
|
|
@ -1,25 +0,0 @@
|
|||
# We check what namespace stl code like vector expects to be executed in
|
||||
|
||||
AC_DEFUN([AC_CXX_STL_NAMESPACE],
|
||||
[AC_CACHE_CHECK(
|
||||
what namespace STL code is in,
|
||||
ac_cv_cxx_stl_namespace,
|
||||
[AC_REQUIRE([AC_CXX_NAMESPACES])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([#include <vector>],
|
||||
[vector<int> t; return 0;],
|
||||
ac_cv_cxx_stl_namespace=none)
|
||||
AC_TRY_COMPILE([#include <vector>],
|
||||
[std::vector<int> t; return 0;],
|
||||
ac_cv_cxx_stl_namespace=std)
|
||||
AC_LANG_RESTORE])
|
||||
if test "$ac_cv_cxx_stl_namespace" = none; then
|
||||
AC_DEFINE(STL_NAMESPACE,,
|
||||
[the namespace where STL code like vector<> is defined])
|
||||
fi
|
||||
if test "$ac_cv_cxx_stl_namespace" = std; then
|
||||
AC_DEFINE(STL_NAMESPACE,std,
|
||||
[the namespace where STL code like vector<> is defined])
|
||||
fi
|
||||
])
|
360
missing
360
missing
|
@ -1,360 +0,0 @@
|
|||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2005-06-08.21
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
|
||||
# Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case "$1" in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
case "$1" in
|
||||
lex|yacc)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
|
||||
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
|
||||
fi
|
||||
if [ -f "$file" ]; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
158
mkinstalldirs
158
mkinstalldirs
|
@ -1,158 +0,0 @@
|
|||
#! /bin/sh
|
||||
# mkinstalldirs --- make directory hierarchy
|
||||
|
||||
scriptversion=2005-06-29.22
|
||||
|
||||
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
|
||||
# Created: 1993-05-16
|
||||
# Public domain.
|
||||
#
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
errstatus=0
|
||||
dirmode=
|
||||
|
||||
usage="\
|
||||
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
|
||||
|
||||
Create each directory DIR (with mode MODE, if specified), including all
|
||||
leading file name components.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>."
|
||||
|
||||
# process command line arguments
|
||||
while test $# -gt 0 ; do
|
||||
case $1 in
|
||||
-h | --help | --h*) # -h for help
|
||||
echo "$usage"
|
||||
exit $?
|
||||
;;
|
||||
-m) # -m PERM arg
|
||||
shift
|
||||
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
|
||||
dirmode=$1
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
echo "$0 $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
--) # stop option processing
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*) # unknown option
|
||||
echo "$usage" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
*) # first non-opt arg
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
for file
|
||||
do
|
||||
if test -d "$file"; then
|
||||
shift
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
case $# in
|
||||
0) exit 0 ;;
|
||||
esac
|
||||
|
||||
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
|
||||
# mkdir -p a/c at the same time, both will detect that a is missing,
|
||||
# one will create a, then the other will try to create a and die with
|
||||
# a "File exists" error. This is a problem when calling mkinstalldirs
|
||||
# from a parallel make. We use --version in the probe to restrict
|
||||
# ourselves to GNU mkdir, which is thread-safe.
|
||||
case $dirmode in
|
||||
'')
|
||||
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
|
||||
echo "mkdir -p -- $*"
|
||||
exec mkdir -p -- "$@"
|
||||
else
|
||||
# On NextStep and OpenStep, the `mkdir' command does not
|
||||
# recognize any option. It will interpret all options as
|
||||
# directories to create, and then abort because `.' already
|
||||
# exists.
|
||||
test -d ./-p && rmdir ./-p
|
||||
test -d ./--version && rmdir ./--version
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
|
||||
test ! -d ./--version; then
|
||||
echo "mkdir -m $dirmode -p -- $*"
|
||||
exec mkdir -m "$dirmode" -p -- "$@"
|
||||
else
|
||||
# Clean up after NextStep and OpenStep mkdir.
|
||||
for d in ./-m ./-p ./--version "./$dirmode";
|
||||
do
|
||||
test -d $d && rmdir $d
|
||||
done
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
for file
|
||||
do
|
||||
case $file in
|
||||
/*) pathcomp=/ ;;
|
||||
*) pathcomp= ;;
|
||||
esac
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
set fnord $file
|
||||
shift
|
||||
IFS=$oIFS
|
||||
|
||||
for d
|
||||
do
|
||||
test "x$d" = x && continue
|
||||
|
||||
pathcomp=$pathcomp$d
|
||||
case $pathcomp in
|
||||
-*) pathcomp=./$pathcomp ;;
|
||||
esac
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
echo "mkdir $pathcomp"
|
||||
|
||||
mkdir "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -d "$pathcomp"; then
|
||||
errstatus=$lasterr
|
||||
else
|
||||
if test ! -z "$dirmode"; then
|
||||
echo "chmod $dirmode $pathcomp"
|
||||
lasterr=
|
||||
chmod "$dirmode" "$pathcomp" || lasterr=$?
|
||||
|
||||
if test ! -z "$lasterr"; then
|
||||
errstatus=$lasterr
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
done
|
||||
|
||||
exit $errstatus
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
|
@ -1,74 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# This takes one commandline argument, the name of the package. If no
|
||||
# name is given, then we'll end up just using the name associated with
|
||||
# an arbitrary .tar.gz file in the rootdir. That's fine: there's probably
|
||||
# only one.
|
||||
#
|
||||
# Run this from the 'packages' directory, just under rootdir
|
||||
|
||||
## Set LIB to lib if exporting a library, empty-string else
|
||||
LIB=
|
||||
#LIB=lib
|
||||
|
||||
PACKAGE="$1"
|
||||
VERSION="$2"
|
||||
|
||||
# We can only build Debian packages, if the Debian build tools are installed
|
||||
if [ \! -x /usr/bin/debuild ]; then
|
||||
echo "Cannot find /usr/bin/debuild. Not building Debian packages." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Double-check we're in the packages directory, just under rootdir
|
||||
if [ \! -r ../Makefile -a \! -r ../INSTALL ]; then
|
||||
echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
|
||||
echo "Also, you must run \"make dist\" before running this script." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Find the top directory for this package
|
||||
topdir="${PWD%/*}"
|
||||
|
||||
# Find the tar archive built by "make dist"
|
||||
archive="${PACKAGE}-${VERSION}"
|
||||
archive_with_underscore="${PACKAGE}_${VERSION}"
|
||||
if [ -z "${archive}" ]; then
|
||||
echo "Cannot find ../$PACKAGE*.tar.gz. Run \"make dist\" first." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create a pristine directory for building the Debian package files
|
||||
trap 'rm -rf '`pwd`/tmp'; exit $?' EXIT SIGHUP SIGINT SIGTERM
|
||||
|
||||
rm -rf tmp
|
||||
mkdir -p tmp
|
||||
cd tmp
|
||||
|
||||
# Debian has very specific requirements about the naming of build
|
||||
# directories, and tar archives. It also wants to write all generated
|
||||
# packages to the parent of the source directory. We accommodate these
|
||||
# requirements by building directly from the tar file.
|
||||
ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive}.orig.tar.gz"
|
||||
# Some version of debuilder want foo.orig.tar.gz with _ between versions.
|
||||
ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive_with_underscore}.orig.tar.gz"
|
||||
tar zfx "${LIB}${archive}.orig.tar.gz"
|
||||
[ -n "${LIB}" ] && mv "${archive}" "${LIB}${archive}"
|
||||
cd "${LIB}${archive}"
|
||||
# This is one of those 'specific requirements': where the deb control files live
|
||||
cp -a "packages/deb" "debian"
|
||||
|
||||
# Now, we can call Debian's standard build tool
|
||||
debuild -uc -us
|
||||
cd ../.. # get back to the original top-level dir
|
||||
|
||||
# We'll put the result in a subdirectory that's named after the OS version
|
||||
# we've made this .deb file for.
|
||||
destdir="debian-$(cat /etc/debian_version 2>/dev/null || echo UNKNOWN)"
|
||||
|
||||
rm -rf "$destdir"
|
||||
mkdir -p "$destdir"
|
||||
mv $(find tmp -mindepth 1 -maxdepth 1 -type f) "$destdir"
|
||||
|
||||
echo
|
||||
echo "The Debian package files are located in $PWD/$destdir"
|
|
@ -1,87 +0,0 @@
|
|||
gflags (1.1-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
* Renamed package to gflags, from google-gflags, to match the package
|
||||
and library names used in the .rpm file, and in the tarball.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Tue, 14 Apr 2009 12:35:25 -0700
|
||||
|
||||
google-gflags (1.0-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Fri, 03 Oct 2008 15:16:46 -0700
|
||||
|
||||
google-gflags (1.0rc2-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Tue, 18 Sep 2008 12:58:05 -0700
|
||||
|
||||
google-gflags (1.0rc1-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Tue, 19 Aug 2008 16:15:48 -0700
|
||||
|
||||
google-gflags (0.9-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Mon, 21 Jul 2008 23:01:38 -0700
|
||||
|
||||
google-gflags (0.8-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Wed, 26 Mar 2008 15:20:18 -0700
|
||||
|
||||
google-gflags (0.7-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Thu, 18 Oct 2007 11:33:20 -0700
|
||||
|
||||
google-gflags (0.6-2) unstable; urgency=low
|
||||
|
||||
* Somehow 0.6-1 was missing the lib* control files, so the .deb produced
|
||||
was empty. Fix that to get an actual valid .deb file.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Wed, 15 Aug 2007 12:32:01 -0700
|
||||
|
||||
google-gflags (0.6-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Wed, 15 Aug 2007 07:35:51 -0700
|
||||
|
||||
google-gflags (0.5-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Tue, 12 Jun 2007 15:23:42 -0700
|
||||
|
||||
google-gflags (0.4-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Thu, 19 Apr 2007 15:18:43 -0700
|
||||
|
||||
google-gflags (0.3-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Mon, 22 Jan 2007 15:33:06 -0800
|
||||
|
||||
google-gflags (0.2-1) unstable; urgency=low
|
||||
|
||||
* New upstream release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Wed, 28 Mar 2007 12:15:56 -0700
|
||||
|
||||
google-gflags (0.1-1) unstable; urgency=low
|
||||
|
||||
* Initial release.
|
||||
|
||||
-- Google Inc. <opensource@google.com> Wed, 13 Dec 2006 11:33:30 -0800
|
||||
|
|
@ -1 +0,0 @@
|
|||
4
|
|
@ -1,25 +0,0 @@
|
|||
Source: gflags
|
||||
Priority: optional
|
||||
Maintainer: Google Inc. <opensource@google.com>
|
||||
Build-Depends: debhelper (>= 4.0.0), binutils
|
||||
Standards-Version: 3.6.1
|
||||
|
||||
Package: libgflags-dev
|
||||
Section: libdevel
|
||||
Architecture: any
|
||||
Depends: libgflags0 (= ${Source-Version})
|
||||
Description: 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.
|
||||
The devel package contains static and debug libraries and header files
|
||||
for developing applications that use the gflags package.
|
||||
|
||||
Package: libgflags0
|
||||
Section: libs
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}
|
||||
Description: 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.
|
|
@ -1,35 +0,0 @@
|
|||
This package was debianized by Google Inc. <opensource@google.com> on
|
||||
13 December 2006.
|
||||
|
||||
It was downloaded from http://code.google.com/
|
||||
|
||||
Upstream Author: opensource@google.com
|
||||
|
||||
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.
|
|
@ -1,8 +0,0 @@
|
|||
AUTHORS
|
||||
COPYING
|
||||
ChangeLog
|
||||
INSTALL
|
||||
NEWS
|
||||
README
|
||||
doc/designstyle.css
|
||||
doc/gflags.html
|
|
@ -1,4 +0,0 @@
|
|||
usr/lib
|
||||
usr/include
|
||||
usr/include/google
|
||||
usr/include/gflags
|
|
@ -1,10 +0,0 @@
|
|||
usr/include/google/*
|
||||
usr/include/gflags/*
|
||||
usr/lib/lib*.so
|
||||
usr/lib/lib*.a
|
||||
usr/lib/*.la
|
||||
debian/tmp/usr/include/google/*
|
||||
debian/tmp/usr/include/gflags/*
|
||||
debian/tmp/usr/lib/lib*.so
|
||||
debian/tmp/usr/lib/lib*.a
|
||||
debian/tmp/usr/lib/*.la
|
|
@ -1,2 +0,0 @@
|
|||
usr/lib
|
||||
usr/bin
|
|
@ -1,4 +0,0 @@
|
|||
usr/lib/lib*.so.*
|
||||
debian/tmp/usr/lib/lib*.so.*
|
||||
usr/bin/*
|
||||
debian/tmp/usr/bin/*
|
|
@ -1,117 +0,0 @@
|
|||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
# Sample debian/rules that uses debhelper.
|
||||
# This file was originally written by Joey Hess and Craig Small.
|
||||
# As a special exception, when this file is copied by dh-make into a
|
||||
# dh-make output file, you may use that output file without restriction.
|
||||
# This special exception was added by Craig Small in version 0.37 of dh-make.
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
|
||||
# These are used for cross-compiling and for saving the configure script
|
||||
# from having to guess our platform (since we know it already)
|
||||
DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
|
||||
|
||||
CFLAGS = -Wall -g
|
||||
|
||||
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
|
||||
CFLAGS += -O0
|
||||
else
|
||||
CFLAGS += -O2
|
||||
endif
|
||||
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
|
||||
INSTALL_PROGRAM += -s
|
||||
endif
|
||||
|
||||
# shared library versions, option 1
|
||||
#version=2.0.5
|
||||
#major=2
|
||||
# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
|
||||
version=`ls src/.libs/lib*.so.* | \
|
||||
awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
|
||||
major=`ls src/.libs/lib*.so.* | \
|
||||
awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
|
||||
|
||||
config.status: configure
|
||||
dh_testdir
|
||||
# Add here commands to configure the package.
|
||||
CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
|
||||
|
||||
|
||||
build: build-stamp
|
||||
build-stamp: config.status
|
||||
dh_testdir
|
||||
|
||||
# Add here commands to compile the package.
|
||||
$(MAKE)
|
||||
|
||||
touch build-stamp
|
||||
|
||||
clean:
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
rm -f build-stamp
|
||||
|
||||
# Add here commands to clean up after the build process.
|
||||
-$(MAKE) distclean
|
||||
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
|
||||
cp -f /usr/share/misc/config.sub config.sub
|
||||
endif
|
||||
ifneq "$(wildcard /usr/share/misc/config.guess)" ""
|
||||
cp -f /usr/share/misc/config.guess config.guess
|
||||
endif
|
||||
|
||||
|
||||
dh_clean
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_installdirs
|
||||
|
||||
# Add here commands to install the package into debian/tmp
|
||||
$(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
|
||||
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep: build install
|
||||
# We have nothing to do by default.
|
||||
|
||||
# Build architecture-dependent files here.
|
||||
binary-arch: build install
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs ChangeLog
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_install --sourcedir=debian/tmp
|
||||
# dh_installmenu
|
||||
# dh_installdebconf
|
||||
# dh_installlogrotate
|
||||
# dh_installemacsen
|
||||
# dh_installpam
|
||||
# dh_installmime
|
||||
# dh_installinit
|
||||
# dh_installcron
|
||||
# dh_installinfo
|
||||
dh_installman
|
||||
dh_link
|
||||
dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
# dh_perl
|
||||
# dh_python
|
||||
dh_makeshlibs
|
||||
dh_installdeb
|
||||
dh_shlibdeps
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-indep binary-arch
|
||||
.PHONY: build clean binary-indep binary-arch binary install
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# Run this from the 'packages' directory, just under rootdir
|
||||
|
||||
# We can only build rpm packages, if the rpm build tools are installed
|
||||
if [ \! -x /usr/bin/rpmbuild ]
|
||||
then
|
||||
echo "Cannot find /usr/bin/rpmbuild. Not building an rpm." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check the commandline flags
|
||||
PACKAGE="$1"
|
||||
VERSION="$2"
|
||||
fullname="${PACKAGE}-${VERSION}"
|
||||
archive=../$fullname.tar.gz
|
||||
|
||||
if [ -z "$1" -o -z "$2" ]
|
||||
then
|
||||
echo "Usage: $0 <package name> <package version>" 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Double-check we're in the packages directory, just under rootdir
|
||||
if [ \! -r ../Makefile -a \! -r ../INSTALL ]
|
||||
then
|
||||
echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
|
||||
echo "Also, you must run \"make dist\" before running this script." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ \! -r "$archive" ]
|
||||
then
|
||||
echo "Cannot find $archive. Run \"make dist\" first." 1>&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create the directory where the input lives, and where the output should live
|
||||
RPM_SOURCE_DIR="/tmp/rpmsource-$fullname"
|
||||
RPM_BUILD_DIR="/tmp/rpmbuild-$fullname"
|
||||
|
||||
trap 'rm -rf $RPM_SOURCE_DIR $RPM_BUILD_DIR; exit $?' EXIT SIGHUP SIGINT SIGTERM
|
||||
|
||||
rm -rf "$RPM_SOURCE_DIR" "$RPM_BUILD_DIR"
|
||||
mkdir "$RPM_SOURCE_DIR"
|
||||
mkdir "$RPM_BUILD_DIR"
|
||||
|
||||
cp "$archive" "$RPM_SOURCE_DIR"
|
||||
|
||||
rpmbuild -bb rpm/rpm.spec \
|
||||
--define "NAME $PACKAGE" \
|
||||
--define "VERSION $VERSION" \
|
||||
--define "_sourcedir $RPM_SOURCE_DIR" \
|
||||
--define "_builddir $RPM_BUILD_DIR" \
|
||||
--define "_rpmdir $RPM_SOURCE_DIR"
|
||||
|
||||
# We put the output in a directory based on what system we've built for
|
||||
destdir=rpm-unknown
|
||||
if [ -r /etc/issue ]
|
||||
then
|
||||
grep "Red Hat.*release 7" /etc/issue >/dev/null 2>&1 && destdir=rh7
|
||||
grep "Red Hat.*release 8" /etc/issue >/dev/null 2>&1 && destdir=rh8
|
||||
grep "Red Hat.*release 9" /etc/issue >/dev/null 2>&1 && destdir=rh9
|
||||
if grep Fedora /etc/issue >/dev/null; then
|
||||
destdir=fc`grep Fedora /etc/issue | cut -d' ' -f 4`;
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -rf "$destdir"
|
||||
mkdir -p "$destdir"
|
||||
# We want to get not only the main package but devel etc, hence the middle *
|
||||
mv "$RPM_SOURCE_DIR"/*/"${PACKAGE}"-*"${VERSION}"*.rpm "$destdir"
|
||||
|
||||
echo
|
||||
echo "The rpm package file(s) are located in $PWD/$destdir"
|
|
@ -1,79 +0,0 @@
|
|||
%define RELEASE 1
|
||||
%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
|
||||
%define prefix /usr
|
||||
|
||||
Name: %NAME
|
||||
Summary: A commandline flags library that allows for distributed flags
|
||||
Version: %VERSION
|
||||
Release: %rel
|
||||
Group: Development/Libraries
|
||||
URL: http://code.google.com/p/google-gflags
|
||||
License: BSD
|
||||
Vendor: Google
|
||||
Packager: Google Inc. <opensource@google.com>
|
||||
Source: http://%{NAME}.googlecode.com/files/%{NAME}-%{VERSION}.tar.gz
|
||||
Distribution: Redhat 7 and above.
|
||||
Buildroot: %{_tmppath}/%{name}-root
|
||||
Prefix: %prefix
|
||||
|
||||
%description
|
||||
The %name 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.
|
||||
|
||||
%package devel
|
||||
Summary: A commandline flags library that allows for distributed flags
|
||||
Group: Development/Libraries
|
||||
Requires: %{NAME} = %{VERSION}
|
||||
|
||||
%description devel
|
||||
The %name-devel package contains static and debug libraries and header
|
||||
files for developing applications that use the %name package.
|
||||
|
||||
%changelog
|
||||
* Tue Dec 13 2006 <opensource@google.com>
|
||||
- First draft
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%build
|
||||
./configure
|
||||
make prefix=%prefix
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make prefix=$RPM_BUILD_ROOT%{prefix} install
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
|
||||
## Mark all installed files within /usr/share/doc/{package name} as
|
||||
## documentation. This depends on the following two lines appearing in
|
||||
## Makefile.am:
|
||||
## docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
|
||||
## dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README
|
||||
%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
|
||||
%{prefix}/share/doc/%{NAME}-%{VERSION}/*
|
||||
|
||||
%{prefix}/lib/libgflags.so.0
|
||||
%{prefix}/lib/libgflags.so.0.0.0
|
||||
%{prefix}/lib/libgflags_nothreads.so.0
|
||||
%{prefix}/lib/libgflags_nothreads.so.0.0.0
|
||||
%{prefix}/bin/gflags_completions.sh
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
|
||||
%{prefix}/include/google
|
||||
%{prefix}/include/gflags
|
||||
%{prefix}/lib/libgflags.a
|
||||
%{prefix}/lib/libgflags.la
|
||||
%{prefix}/lib/libgflags.so
|
||||
%{prefix}/lib/libgflags_nothreads.a
|
||||
%{prefix}/lib/libgflags_nothreads.la
|
||||
%{prefix}/lib/libgflags_nothreads.so
|
2090
python/gflags.py
2090
python/gflags.py
File diff suppressed because it is too large
Load diff
|
@ -1,536 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2007, 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.
|
||||
|
||||
"""gflags2man runs a Google flags base program and generates a man page.
|
||||
|
||||
Run the program, parse the output, and then format that into a man
|
||||
page.
|
||||
|
||||
Usage:
|
||||
gflags2man <program> [program] ...
|
||||
"""
|
||||
|
||||
# TODO(csilvers): work with windows paths (\) as well as unix (/)
|
||||
|
||||
# This may seem a bit of an end run, but it: doesn't bloat flags, can
|
||||
# support python/java/C++, supports older executables, and can be
|
||||
# extended to other document formats.
|
||||
# Inspired by help2man.
|
||||
|
||||
__author__ = 'Dan Christian'
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import stat
|
||||
import time
|
||||
|
||||
import gflags
|
||||
|
||||
_VERSION = '0.1'
|
||||
|
||||
|
||||
def _GetDefaultDestDir():
|
||||
home = os.environ.get('HOME', '')
|
||||
homeman = os.path.join(home, 'man', 'man1')
|
||||
if home and os.path.exists(homeman):
|
||||
return homeman
|
||||
else:
|
||||
return os.environ.get('TMPDIR', '/tmp')
|
||||
|
||||
FLAGS = gflags.FLAGS
|
||||
gflags.DEFINE_string('dest_dir', _GetDefaultDestDir(),
|
||||
'Directory to write resulting manpage to.'
|
||||
' Specify \'-\' for stdout')
|
||||
gflags.DEFINE_string('help_flag', '--help',
|
||||
'Option to pass to target program in to get help')
|
||||
gflags.DEFINE_integer('v', 0, 'verbosity level to use for output')
|
||||
|
||||
_MIN_VALID_USAGE_MSG = 9 # if fewer lines than this, help is suspect
|
||||
|
||||
|
||||
class Logging:
|
||||
"""A super-simple logging class"""
|
||||
def error(self, msg): print >>sys.stderr, "ERROR: ", msg
|
||||
def warn(self, msg): print >>sys.stderr, "WARNING: ", msg
|
||||
def info(self, msg): print msg
|
||||
def debug(self, msg): self.vlog(1, msg)
|
||||
def vlog(self, level, msg):
|
||||
if FLAGS.v >= level: print msg
|
||||
logging = Logging()
|
||||
|
||||
|
||||
def GetRealPath(filename):
|
||||
"""Given an executable filename, find in the PATH or find absolute path.
|
||||
Args:
|
||||
filename An executable filename (string)
|
||||
Returns:
|
||||
Absolute version of filename.
|
||||
None if filename could not be found locally, absolutely, or in PATH
|
||||
"""
|
||||
if os.path.isabs(filename): # already absolute
|
||||
return filename
|
||||
|
||||
if filename.startswith('./') or filename.startswith('../'): # relative
|
||||
return os.path.abspath(filename)
|
||||
|
||||
path = os.getenv('PATH', '')
|
||||
for directory in path.split(':'):
|
||||
tryname = os.path.join(directory, filename)
|
||||
if os.path.exists(tryname):
|
||||
if not os.path.isabs(directory): # relative directory
|
||||
return os.path.abspath(tryname)
|
||||
return tryname
|
||||
if os.path.exists(filename):
|
||||
return os.path.abspath(filename)
|
||||
return None # could not determine
|
||||
|
||||
class Flag(object):
|
||||
"""The information about a single flag."""
|
||||
|
||||
def __init__(self, flag_desc, help):
|
||||
"""Create the flag object.
|
||||
Args:
|
||||
flag_desc The command line forms this could take. (string)
|
||||
help The help text (string)
|
||||
"""
|
||||
self.desc = flag_desc # the command line forms
|
||||
self.help = help # the help text
|
||||
self.default = '' # default value
|
||||
self.tips = '' # parsing/syntax tips
|
||||
|
||||
|
||||
class ProgramInfo(object):
|
||||
"""All the information gleaned from running a program with --help."""
|
||||
|
||||
# Match a module block start, for python scripts --help
|
||||
# "goopy.logging:"
|
||||
module_py_re = re.compile(r'(\S.+):$')
|
||||
# match the start of a flag listing
|
||||
# " -v,--verbosity: Logging verbosity"
|
||||
flag_py_re = re.compile(r'\s+(-\S+):\s+(.*)$')
|
||||
# " (default: '0')"
|
||||
flag_default_py_re = re.compile(r'\s+\(default:\s+\'(.*)\'\)$')
|
||||
# " (an integer)"
|
||||
flag_tips_py_re = re.compile(r'\s+\((.*)\)$')
|
||||
|
||||
# Match a module block start, for c++ programs --help
|
||||
# "google/base/commandlineflags"
|
||||
module_c_re = re.compile(r'\s+Flags from (\S.+):$')
|
||||
# match the start of a flag listing
|
||||
# " -v,--verbosity: Logging verbosity"
|
||||
flag_c_re = re.compile(r'\s+(-\S+)\s+(.*)$')
|
||||
|
||||
# Match a module block start, for java programs --help
|
||||
# "com.google.common.flags"
|
||||
module_java_re = re.compile(r'\s+Flags for (\S.+):$')
|
||||
# match the start of a flag listing
|
||||
# " -v,--verbosity: Logging verbosity"
|
||||
flag_java_re = re.compile(r'\s+(-\S+)\s+(.*)$')
|
||||
|
||||
def __init__(self, executable):
|
||||
"""Create object with executable.
|
||||
Args:
|
||||
executable Program to execute (string)
|
||||
"""
|
||||
self.long_name = executable
|
||||
self.name = os.path.basename(executable) # name
|
||||
# Get name without extension (PAR files)
|
||||
(self.short_name, self.ext) = os.path.splitext(self.name)
|
||||
self.executable = GetRealPath(executable) # name of the program
|
||||
self.output = [] # output from the program. List of lines.
|
||||
self.desc = [] # top level description. List of lines
|
||||
self.modules = {} # { section_name(string), [ flags ] }
|
||||
self.module_list = [] # list of module names in their original order
|
||||
self.date = time.localtime(time.time()) # default date info
|
||||
|
||||
def Run(self):
|
||||
"""Run it and collect output.
|
||||
|
||||
Returns:
|
||||
1 (true) If everything went well.
|
||||
0 (false) If there were problems.
|
||||
"""
|
||||
if not self.executable:
|
||||
logging.error('Could not locate "%s"' % self.long_name)
|
||||
return 0
|
||||
|
||||
finfo = os.stat(self.executable)
|
||||
self.date = time.localtime(finfo[stat.ST_MTIME])
|
||||
|
||||
logging.info('Running: %s %s </dev/null 2>&1'
|
||||
% (self.executable, FLAGS.help_flag))
|
||||
# --help output is often routed to stderr, so we combine with stdout.
|
||||
# Re-direct stdin to /dev/null to encourage programs that
|
||||
# don't understand --help to exit.
|
||||
(child_stdin, child_stdout_and_stderr) = os.popen4(
|
||||
[self.executable, FLAGS.help_flag])
|
||||
child_stdin.close() # '</dev/null'
|
||||
self.output = child_stdout_and_stderr.readlines()
|
||||
child_stdout_and_stderr.close()
|
||||
if len(self.output) < _MIN_VALID_USAGE_MSG:
|
||||
logging.error('Error: "%s %s" returned only %d lines: %s'
|
||||
% (self.name, FLAGS.help_flag,
|
||||
len(self.output), self.output))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
def Parse(self):
|
||||
"""Parse program output."""
|
||||
(start_line, lang) = self.ParseDesc()
|
||||
if start_line < 0:
|
||||
return
|
||||
if 'python' == lang:
|
||||
self.ParsePythonFlags(start_line)
|
||||
elif 'c' == lang:
|
||||
self.ParseCFlags(start_line)
|
||||
elif 'java' == lang:
|
||||
self.ParseJavaFlags(start_line)
|
||||
|
||||
def ParseDesc(self, start_line=0):
|
||||
"""Parse the initial description.
|
||||
|
||||
This could be Python or C++.
|
||||
|
||||
Returns:
|
||||
(start_line, lang_type)
|
||||
start_line Line to start parsing flags on (int)
|
||||
lang_type Either 'python' or 'c'
|
||||
(-1, '') if the flags start could not be found
|
||||
"""
|
||||
exec_mod_start = self.executable + ':'
|
||||
|
||||
after_blank = 0
|
||||
start_line = 0 # ignore the passed-in arg for now (?)
|
||||
for start_line in range(start_line, len(self.output)): # collect top description
|
||||
line = self.output[start_line].rstrip()
|
||||
# Python flags start with 'flags:\n'
|
||||
if ('flags:' == line
|
||||
and len(self.output) > start_line+1
|
||||
and '' == self.output[start_line+1].rstrip()):
|
||||
start_line += 2
|
||||
logging.debug('Flags start (python): %s' % line)
|
||||
return (start_line, 'python')
|
||||
# SWIG flags just have the module name followed by colon.
|
||||
if exec_mod_start == line:
|
||||
logging.debug('Flags start (swig): %s' % line)
|
||||
return (start_line, 'python')
|
||||
# C++ flags begin after a blank line and with a constant string
|
||||
if after_blank and line.startswith(' Flags from '):
|
||||
logging.debug('Flags start (c): %s' % line)
|
||||
return (start_line, 'c')
|
||||
# java flags begin with a constant string
|
||||
if line == 'where flags are':
|
||||
logging.debug('Flags start (java): %s' % line)
|
||||
start_line += 2 # skip "Standard flags:"
|
||||
return (start_line, 'java')
|
||||
|
||||
logging.debug('Desc: %s' % line)
|
||||
self.desc.append(line)
|
||||
after_blank = (line == '')
|
||||
else:
|
||||
logging.warn('Never found the start of the flags section for "%s"!'
|
||||
% self.long_name)
|
||||
return (-1, '')
|
||||
|
||||
def ParsePythonFlags(self, start_line=0):
|
||||
"""Parse python/swig style flags."""
|
||||
modname = None # name of current module
|
||||
modlist = []
|
||||
flag = None
|
||||
for line_num in range(start_line, len(self.output)): # collect flags
|
||||
line = self.output[line_num].rstrip()
|
||||
if not line: # blank
|
||||
continue
|
||||
|
||||
mobj = self.module_py_re.match(line)
|
||||
if mobj: # start of a new module
|
||||
modname = mobj.group(1)
|
||||
logging.debug('Module: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
self.module_list.append(modname)
|
||||
self.modules.setdefault(modname, [])
|
||||
modlist = self.modules[modname]
|
||||
flag = None
|
||||
continue
|
||||
|
||||
mobj = self.flag_py_re.match(line)
|
||||
if mobj: # start of a new flag
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
logging.debug('Flag: %s' % line)
|
||||
flag = Flag(mobj.group(1), mobj.group(2))
|
||||
continue
|
||||
|
||||
if not flag: # continuation of a flag
|
||||
logging.error('Flag info, but no current flag "%s"' % line)
|
||||
mobj = self.flag_default_py_re.match(line)
|
||||
if mobj: # (default: '...')
|
||||
flag.default = mobj.group(1)
|
||||
logging.debug('Fdef: %s' % line)
|
||||
continue
|
||||
mobj = self.flag_tips_py_re.match(line)
|
||||
if mobj: # (tips)
|
||||
flag.tips = mobj.group(1)
|
||||
logging.debug('Ftip: %s' % line)
|
||||
continue
|
||||
if flag and flag.help:
|
||||
flag.help += line # multiflags tack on an extra line
|
||||
else:
|
||||
logging.info('Extra: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
|
||||
def ParseCFlags(self, start_line=0):
|
||||
"""Parse C style flags."""
|
||||
modname = None # name of current module
|
||||
modlist = []
|
||||
flag = None
|
||||
for line_num in range(start_line, len(self.output)): # collect flags
|
||||
line = self.output[line_num].rstrip()
|
||||
if not line: # blank lines terminate flags
|
||||
if flag: # save last flag
|
||||
modlist.append(flag)
|
||||
flag = None
|
||||
continue
|
||||
|
||||
mobj = self.module_c_re.match(line)
|
||||
if mobj: # start of a new module
|
||||
modname = mobj.group(1)
|
||||
logging.debug('Module: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
self.module_list.append(modname)
|
||||
self.modules.setdefault(modname, [])
|
||||
modlist = self.modules[modname]
|
||||
flag = None
|
||||
continue
|
||||
|
||||
mobj = self.flag_c_re.match(line)
|
||||
if mobj: # start of a new flag
|
||||
if flag: # save last flag
|
||||
modlist.append(flag)
|
||||
logging.debug('Flag: %s' % line)
|
||||
flag = Flag(mobj.group(1), mobj.group(2))
|
||||
continue
|
||||
|
||||
# append to flag help. type and default are part of the main text
|
||||
if flag:
|
||||
flag.help += ' ' + line.strip()
|
||||
else:
|
||||
logging.info('Extra: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
|
||||
def ParseJavaFlags(self, start_line=0):
|
||||
"""Parse Java style flags (com.google.common.flags)."""
|
||||
# The java flags prints starts with a "Standard flags" "module"
|
||||
# that doesn't follow the standard module syntax.
|
||||
modname = 'Standard flags' # name of current module
|
||||
self.module_list.append(modname)
|
||||
self.modules.setdefault(modname, [])
|
||||
modlist = self.modules[modname]
|
||||
flag = None
|
||||
|
||||
for line_num in range(start_line, len(self.output)): # collect flags
|
||||
line = self.output[line_num].rstrip()
|
||||
logging.vlog(2, 'Line: "%s"' % line)
|
||||
if not line: # blank lines terminate module
|
||||
if flag: # save last flag
|
||||
modlist.append(flag)
|
||||
flag = None
|
||||
continue
|
||||
|
||||
mobj = self.module_java_re.match(line)
|
||||
if mobj: # start of a new module
|
||||
modname = mobj.group(1)
|
||||
logging.debug('Module: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
self.module_list.append(modname)
|
||||
self.modules.setdefault(modname, [])
|
||||
modlist = self.modules[modname]
|
||||
flag = None
|
||||
continue
|
||||
|
||||
mobj = self.flag_java_re.match(line)
|
||||
if mobj: # start of a new flag
|
||||
if flag: # save last flag
|
||||
modlist.append(flag)
|
||||
logging.debug('Flag: %s' % line)
|
||||
flag = Flag(mobj.group(1), mobj.group(2))
|
||||
continue
|
||||
|
||||
# append to flag help. type and default are part of the main text
|
||||
if flag:
|
||||
flag.help += ' ' + line.strip()
|
||||
else:
|
||||
logging.info('Extra: %s' % line)
|
||||
if flag:
|
||||
modlist.append(flag)
|
||||
|
||||
def Filter(self):
|
||||
"""Filter parsed data to create derived fields."""
|
||||
if not self.desc:
|
||||
self.short_desc = ''
|
||||
return
|
||||
|
||||
for i in range(len(self.desc)): # replace full path with name
|
||||
if self.desc[i].find(self.executable) >= 0:
|
||||
self.desc[i] = self.desc[i].replace(self.executable, self.name)
|
||||
|
||||
self.short_desc = self.desc[0]
|
||||
word_list = self.short_desc.split(' ')
|
||||
all_names = [ self.name, self.short_name, ]
|
||||
# Since the short_desc is always listed right after the name,
|
||||
# trim it from the short_desc
|
||||
while word_list and (word_list[0] in all_names
|
||||
or word_list[0].lower() in all_names):
|
||||
del word_list[0]
|
||||
self.short_desc = '' # signal need to reconstruct
|
||||
if not self.short_desc and word_list:
|
||||
self.short_desc = ' '.join(word_list)
|
||||
|
||||
|
||||
class GenerateDoc(object):
|
||||
"""Base class to output flags information."""
|
||||
|
||||
def __init__(self, proginfo, directory='.'):
|
||||
"""Create base object.
|
||||
Args:
|
||||
proginfo A ProgramInfo object
|
||||
directory Directory to write output into
|
||||
"""
|
||||
self.info = proginfo
|
||||
self.dirname = directory
|
||||
|
||||
def Output(self):
|
||||
"""Output all sections of the page."""
|
||||
self.Open()
|
||||
self.Header()
|
||||
self.Body()
|
||||
self.Footer()
|
||||
|
||||
def Open(self): raise NotImplementedError # define in subclass
|
||||
def Header(self): raise NotImplementedError # define in subclass
|
||||
def Body(self): raise NotImplementedError # define in subclass
|
||||
def Footer(self): raise NotImplementedError # define in subclass
|
||||
|
||||
|
||||
class GenerateMan(GenerateDoc):
|
||||
"""Output a man page."""
|
||||
|
||||
def __init__(self, proginfo, directory='.'):
|
||||
"""Create base object.
|
||||
Args:
|
||||
proginfo A ProgramInfo object
|
||||
directory Directory to write output into
|
||||
"""
|
||||
GenerateDoc.__init__(self, proginfo, directory)
|
||||
|
||||
def Open(self):
|
||||
if self.dirname == '-':
|
||||
logging.info('Writing to stdout')
|
||||
self.fp = sys.stdout
|
||||
else:
|
||||
self.file_path = '%s.1' % os.path.join(self.dirname, self.info.name)
|
||||
logging.info('Writing: %s' % self.file_path)
|
||||
self.fp = open(self.file_path, 'w')
|
||||
|
||||
def Header(self):
|
||||
self.fp.write(
|
||||
'.\\" DO NOT MODIFY THIS FILE! It was generated by gflags2man %s\n'
|
||||
% _VERSION)
|
||||
self.fp.write(
|
||||
'.TH %s "1" "%s" "%s" "User Commands"\n'
|
||||
% (self.info.name, time.strftime('%x', self.info.date), self.info.name))
|
||||
self.fp.write(
|
||||
'.SH NAME\n%s \\- %s\n' % (self.info.name, self.info.short_desc))
|
||||
self.fp.write(
|
||||
'.SH SYNOPSIS\n.B %s\n[\\fIFLAGS\\fR]...\n' % self.info.name)
|
||||
|
||||
def Body(self):
|
||||
self.fp.write(
|
||||
'.SH DESCRIPTION\n.\\" Add any additional description here\n.PP\n')
|
||||
for ln in self.info.desc:
|
||||
self.fp.write('%s\n' % ln)
|
||||
self.fp.write(
|
||||
'.SH OPTIONS\n')
|
||||
# This shows flags in the original order
|
||||
for modname in self.info.module_list:
|
||||
if modname.find(self.info.executable) >= 0:
|
||||
mod = modname.replace(self.info.executable, self.info.name)
|
||||
else:
|
||||
mod = modname
|
||||
self.fp.write('\n.P\n.I %s\n' % mod)
|
||||
for flag in self.info.modules[modname]:
|
||||
help_string = flag.help
|
||||
if flag.default or flag.tips:
|
||||
help_string += '\n.br\n'
|
||||
if flag.default:
|
||||
help_string += ' (default: \'%s\')' % flag.default
|
||||
if flag.tips:
|
||||
help_string += ' (%s)' % flag.tips
|
||||
self.fp.write(
|
||||
'.TP\n%s\n%s\n' % (flag.desc, help_string))
|
||||
|
||||
def Footer(self):
|
||||
self.fp.write(
|
||||
'.SH COPYRIGHT\nCopyright \(co %s Google.\n'
|
||||
% time.strftime('%Y', self.info.date))
|
||||
self.fp.write('Gflags2man created this page from "%s %s" output.\n'
|
||||
% (self.info.name, FLAGS.help_flag))
|
||||
self.fp.write('\nGflags2man was written by Dan Christian. '
|
||||
' Note that the date on this'
|
||||
' page is the modification date of %s.\n' % self.info.name)
|
||||
|
||||
|
||||
def main(argv):
|
||||
argv = FLAGS(argv) # handles help as well
|
||||
if len(argv) <= 1:
|
||||
print >>sys.stderr, __doc__
|
||||
print >>sys.stderr, "flags:"
|
||||
print >>sys.stderr, str(FLAGS)
|
||||
return 1
|
||||
|
||||
for arg in argv[1:]:
|
||||
prog = ProgramInfo(arg)
|
||||
if not prog.Run():
|
||||
continue
|
||||
prog.Parse()
|
||||
prog.Filter()
|
||||
doc = GenerateMan(prog, FLAGS.dest_dir)
|
||||
doc.Output()
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv)
|
File diff suppressed because it is too large
Load diff
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2007, 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.
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(name='gflags',
|
||||
version='0.8',
|
||||
description='Google Commandline Flags Module',
|
||||
license='BSD',
|
||||
author='Google Inc.',
|
||||
author_email='opensource@google.com',
|
||||
url='http://code.google.com/p/google-gflags',
|
||||
py_modules=["gflags"],
|
||||
data_files=[("bin", ["gflags2man.py"])])
|
|
@ -1,135 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2009, 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.
|
||||
|
||||
"""Auxiliary module for testing flags.py.
|
||||
|
||||
The purpose of this module is to define a few flags. We want to make
|
||||
sure the unit tests for flags.py involve more than one module.
|
||||
"""
|
||||
|
||||
__author__ = 'Alex Salcianu'
|
||||
|
||||
__pychecker__ = "no-local" # for unittest
|
||||
|
||||
# We use the name 'flags' internally in this test, for historical reasons.
|
||||
# Don't do this yourself! :-) Just do 'import gflags; FLAGS=gflags.FLAGS; etc'
|
||||
import gflags as flags
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
|
||||
def DefineFlags(flag_values=FLAGS):
|
||||
"""Defines some flags.
|
||||
|
||||
Args:
|
||||
flag_values: The FlagValues object we want to register the flags
|
||||
with.
|
||||
"""
|
||||
# The 'tmod_bar_' prefix (short for 'test_module_bar') ensures there
|
||||
# is no name clash with the existing flags.
|
||||
flags.DEFINE_boolean('tmod_bar_x', True, 'Boolean flag.',
|
||||
flag_values=flag_values)
|
||||
flags.DEFINE_string('tmod_bar_y', 'default', 'String flag.',
|
||||
flag_values=flag_values)
|
||||
flags.DEFINE_boolean('tmod_bar_z', False,
|
||||
'Another boolean flag from module bar.',
|
||||
flag_values=flag_values)
|
||||
flags.DEFINE_integer('tmod_bar_t', 4, 'Sample int flag.',
|
||||
flag_values=flag_values)
|
||||
flags.DEFINE_integer('tmod_bar_u', 5, 'Sample int flag.',
|
||||
flag_values=flag_values)
|
||||
flags.DEFINE_integer('tmod_bar_v', 6, 'Sample int flag.',
|
||||
flag_values=flag_values)
|
||||
|
||||
|
||||
def RemoveOneFlag(flag_name, flag_values=FLAGS):
|
||||
"""Removes the definition of one flag from flags.FLAGS.
|
||||
|
||||
Note: if the flag is not defined in flags.FLAGS, this function does
|
||||
not do anything (in particular, it does not raise any exception).
|
||||
|
||||
Motivation: We use this function for cleanup *after* a test: if
|
||||
there was a failure during a test and not all flags were declared,
|
||||
we do not want the cleanup code to crash.
|
||||
|
||||
Args:
|
||||
flag_name: A string, the name of the flag to delete.
|
||||
flag_values: The FlagValues object we remove the flag from.
|
||||
"""
|
||||
if flag_name in flag_values.FlagDict():
|
||||
flag_values.__delattr__(flag_name)
|
||||
|
||||
|
||||
def NamesOfDefinedFlags():
|
||||
"""Returns: List of names of the flags declared in this module."""
|
||||
return ['tmod_bar_x',
|
||||
'tmod_bar_y',
|
||||
'tmod_bar_z',
|
||||
'tmod_bar_t',
|
||||
'tmod_bar_u',
|
||||
'tmod_bar_v']
|
||||
|
||||
|
||||
def RemoveFlags(flag_values=FLAGS):
|
||||
"""Deletes the flag definitions done by the above DefineFlags().
|
||||
|
||||
Args:
|
||||
flag_values: The FlagValues object we remove the flags from.
|
||||
"""
|
||||
for flag_name in NamesOfDefinedFlags():
|
||||
RemoveOneFlag(flag_name, flag_values=flag_values)
|
||||
|
||||
|
||||
def GetModuleName():
|
||||
"""Uses flags._GetCallingModule() to return the name of this module.
|
||||
|
||||
For checking that _GetCallingModule works as expected.
|
||||
|
||||
Returns:
|
||||
A string, the name of this module.
|
||||
"""
|
||||
# Calling the protected _GetCallingModule generates a lint warning,
|
||||
# but we do not have any other alternative to test that function.
|
||||
return flags._GetCallingModule()
|
||||
|
||||
|
||||
def ExecuteCode(code, global_dict):
|
||||
"""Executes some code in a given global environment.
|
||||
|
||||
For testing of _GetCallingModule.
|
||||
|
||||
Args:
|
||||
code: A string, the code to be executed.
|
||||
global_dict: A dictionary, the global environment that code should
|
||||
be executed in.
|
||||
"""
|
||||
# Indeed, using exec generates a lint warning. But some user code
|
||||
# actually uses exec, and we have to test for it ...
|
||||
exec code in global_dict
|
|
@ -1,120 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2009, 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.
|
||||
|
||||
"""Auxiliary module for testing flags.py.
|
||||
|
||||
The purpose of this module is to define a few flags, and declare some
|
||||
other flags as being important. We want to make sure the unit tests
|
||||
for flags.py involve more than one module.
|
||||
"""
|
||||
|
||||
__author__ = 'Alex Salcianu'
|
||||
|
||||
__pychecker__ = "no-local" # for unittest
|
||||
|
||||
# We use the name 'flags' internally in this test, for historical reasons.
|
||||
# Don't do this yourself! :-) Just do 'import gflags; FLAGS=gflags.FLAGS; etc'
|
||||
import gflags as flags
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
# For historical reasons we use the name module_bar instead of test_module_bar.
|
||||
import test_module_bar as module_bar
|
||||
|
||||
DECLARED_KEY_FLAGS = ['tmod_bar_x', 'tmod_bar_z', 'tmod_bar_t']
|
||||
|
||||
|
||||
def DefineFlags():
|
||||
"""Defines a few flags."""
|
||||
module_bar.DefineFlags()
|
||||
# The 'tmod_foo_' prefix (short for 'test_module_foo') ensures that we
|
||||
# have no name clash with existing flags.
|
||||
flags.DEFINE_boolean('tmod_foo_bool', True, 'Boolean flag from module foo.')
|
||||
flags.DEFINE_string('tmod_foo_str', 'default', 'String flag.')
|
||||
flags.DEFINE_integer('tmod_foo_int', 3, 'Sample int flag.')
|
||||
|
||||
|
||||
def DeclareKeyFlags():
|
||||
"""Declares a few key flags."""
|
||||
for flag_name in DECLARED_KEY_FLAGS:
|
||||
flags.DECLARE_key_flag(flag_name)
|
||||
|
||||
|
||||
def DeclareExtraKeyFlags():
|
||||
"""Declares some extra key flags."""
|
||||
flags.ADOPT_module_key_flags(module_bar)
|
||||
|
||||
|
||||
def NamesOfDefinedFlags():
|
||||
"""Returns: list of names of flags defined by this module."""
|
||||
return ['tmod_foo_bool', 'tmod_foo_str', 'tmod_foo_int']
|
||||
|
||||
|
||||
def NamesOfDeclaredKeyFlags():
|
||||
"""Returns: list of names of key flags for this module."""
|
||||
return NamesOfDefinedFlags() + DECLARED_KEY_FLAGS
|
||||
|
||||
|
||||
def NamesOfDeclaredExtraKeyFlags():
|
||||
"""Returns the list of names of additional key flags for this module.
|
||||
|
||||
These are the flags that became key for this module only as a result
|
||||
of a call to DeclareExtraKeyFlags() above. I.e., the flags declared
|
||||
by module_bar, that were not already declared as key for this
|
||||
module.
|
||||
|
||||
Returns:
|
||||
The list of names of additional key flags for this module.
|
||||
"""
|
||||
names_of_extra_key_flags = list(module_bar.NamesOfDefinedFlags())
|
||||
for flag_name in NamesOfDeclaredKeyFlags():
|
||||
while flag_name in names_of_extra_key_flags:
|
||||
names_of_extra_key_flags.remove(flag_name)
|
||||
return names_of_extra_key_flags
|
||||
|
||||
|
||||
def RemoveFlags():
|
||||
"""Deletes the flag definitions done by the above DefineFlags()."""
|
||||
for flag_name in NamesOfDefinedFlags():
|
||||
module_bar.RemoveOneFlag(flag_name)
|
||||
module_bar.RemoveFlags()
|
||||
|
||||
|
||||
def GetModuleName():
|
||||
"""Uses flags._GetCallingModule() to return the name of this module.
|
||||
|
||||
For checking that _GetCallingModule works as expected.
|
||||
|
||||
Returns:
|
||||
A string, the name of this module.
|
||||
"""
|
||||
# Calling the protected _GetCallingModule generates a lint warning,
|
||||
# but we do not have any other alternative to test that function.
|
||||
return flags._GetCallingModule()
|
59
src/config.h
Normal file
59
src/config.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
// Note: This header file is only used internally. It is not part of public interface!
|
||||
|
||||
#ifndef GFLAGS_CONFIG_H_
|
||||
#define GFLAGS_CONFIG_H_
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// System checks
|
||||
|
||||
// CMake build configuration is written to defines.h file, unused by Bazel build
|
||||
#if !defined(GFLAGS_BAZEL_BUILD)
|
||||
# include "defines.h"
|
||||
#endif
|
||||
|
||||
// gcc requires this to get PRId64, etc.
|
||||
#if defined(HAVE_INTTYPES_H) && !defined(__STDC_FORMAT_MACROS)
|
||||
# define __STDC_FORMAT_MACROS 1
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Path separator
|
||||
#ifndef PATH_SEPARATOR
|
||||
# ifdef OS_WINDOWS
|
||||
# define PATH_SEPARATOR '\\'
|
||||
# else
|
||||
# define PATH_SEPARATOR '/'
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows
|
||||
|
||||
// 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)
|
||||
# elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define GFLAGS_DLL_DECL __attribute__((visibility("default")))
|
||||
# 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
|
||||
|
||||
|
||||
#endif // GFLAGS_CONFIG_H_
|
|
@ -1,89 +0,0 @@
|
|||
/* src/config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Namespace for Google classes */
|
||||
#undef GOOGLE_NAMESPACE
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <fnmatch.h> header file. */
|
||||
#undef HAVE_FNMATCH_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* define if the compiler implements namespaces */
|
||||
#undef HAVE_NAMESPACES
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strtoll' function. */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
/* Define to 1 if you have the `strtoq' function. */
|
||||
#undef HAVE_STRTOQ
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* define if your compiler has __attribute__ */
|
||||
#undef HAVE___ATTRIBUTE__
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
||||
your system. */
|
||||
#undef PTHREAD_CREATE_JOINABLE
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* the namespace where STL code like vector<> is defined */
|
||||
#undef STL_NAMESPACE
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
/* Stops putting the code inside the Google namespace */
|
||||
#undef _END_GOOGLE_NAMESPACE_
|
||||
|
||||
/* Puts following code inside the Google namespace */
|
||||
#undef _START_GOOGLE_NAMESPACE_
|
48
src/defines.h.in
Normal file
48
src/defines.h.in
Normal file
|
@ -0,0 +1,48 @@
|
|||
/* Generated from defines.h.in during build configuration using CMake. */
|
||||
|
||||
// Note: This header file is only used internally. It is not part of public interface!
|
||||
// Any cmakedefine is defined using the -D flag instead when Bazel is used.
|
||||
// For Bazel, this file is thus not used to avoid a private file in $(GENDIR).
|
||||
|
||||
#ifndef GFLAGS_DEFINES_H_
|
||||
#define GFLAGS_DEFINES_H_
|
||||
|
||||
|
||||
// Define if you build this library for a MS Windows OS.
|
||||
#cmakedefine OS_WINDOWS
|
||||
|
||||
// Define if you have the <stdint.h> header file.
|
||||
#cmakedefine HAVE_STDINT_H
|
||||
|
||||
// Define if you have the <sys/types.h> header file.
|
||||
#cmakedefine HAVE_SYS_TYPES_H
|
||||
|
||||
// Define if you have the <inttypes.h> header file.
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
|
||||
// Define if you have the <sys/stat.h> header file.
|
||||
#cmakedefine HAVE_SYS_STAT_H
|
||||
|
||||
// Define if you have the <unistd.h> header file.
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
|
||||
// Define if you have the <fnmatch.h> header file.
|
||||
#cmakedefine HAVE_FNMATCH_H
|
||||
|
||||
// Define if you have the <shlwapi.h> header file (Windows 2000/XP).
|
||||
#cmakedefine HAVE_SHLWAPI_H
|
||||
|
||||
// Define if you have the strtoll function.
|
||||
#cmakedefine HAVE_STRTOLL
|
||||
|
||||
// Define if you have the strtoq function.
|
||||
#cmakedefine HAVE_STRTOQ
|
||||
|
||||
// Define if you have the <pthread.h> header file.
|
||||
#cmakedefine HAVE_PTHREAD
|
||||
|
||||
// Define if your pthread library defines the type pthread_rwlock_t
|
||||
#cmakedefine HAVE_RWLOCK
|
||||
|
||||
|
||||
#endif // GFLAGS_DEFINES_H_
|
734
src/gflags.cc
734
src/gflags.cc
File diff suppressed because it is too large
Load diff
|
@ -28,7 +28,6 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
// Author: Ray Sidney
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This is the file that should be included by any file which declares
|
||||
|
@ -37,16 +36,23 @@
|
|||
// 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");
|
||||
// DECLARE_bool(verbose); // some other file has a DEFINE_bool(verbose, ...)
|
||||
//
|
||||
// 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
|
||||
// Then, at the command-line:
|
||||
// ./foo --noverbose --start=5 --end=100
|
||||
//
|
||||
// For more details, see
|
||||
// doc/gflags.html
|
||||
|
@ -69,60 +75,40 @@
|
|||
// other thread is writing to the variable or calling non-const
|
||||
// methods of this class.
|
||||
|
||||
#ifndef GOOGLE_GFLAGS_H_
|
||||
#define GOOGLE_GFLAGS_H_
|
||||
#ifndef GFLAGS_GFLAGS_H_
|
||||
#define GFLAGS_GFLAGS_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// We care a lot about number of bits things take up. Unfortunately,
|
||||
// systems define their bit-specific ints in a lot of different ways.
|
||||
// We use our own way, and have a typedef to get there.
|
||||
// Note: these commands below may look like "#if 1" or "#if 0", but
|
||||
// that's because they were constructed that way at ./configure time.
|
||||
// Look at gflags.h.in to see how they're calculated (based on your config).
|
||||
#if @ac_cv_have_stdint_h@
|
||||
#include <stdint.h> // the normal place uint16_t is defined
|
||||
#endif
|
||||
#if @ac_cv_have_systypes_h@
|
||||
#include <sys/types.h> // the normal place u_int16_t is defined
|
||||
#endif
|
||||
#if @ac_cv_have_inttypes_h@
|
||||
#include <inttypes.h> // a third place for uint16_t or u_int16_t
|
||||
#include "gflags/gflags_declare.h" // IWYU pragma: export
|
||||
|
||||
|
||||
// We always want to export variables defined in user code
|
||||
#ifndef GFLAGS_DLL_DEFINE_FLAG
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DEFINE_FLAG __declspec(dllexport)
|
||||
# else
|
||||
# define GFLAGS_DLL_DEFINE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ac_google_start_namespace@
|
||||
|
||||
#if @ac_cv_have_uint16_t@ // the C99 format
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#elif @ac_cv_have_u_int16_t@ // the BSD format
|
||||
typedef int32_t int32;
|
||||
typedef u_int32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef u_int64_t uint64;
|
||||
#elif @ac_cv_have___int16@ // the windows (vc7) format
|
||||
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 {
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// 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.
|
||||
// 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, InitGoogle will die.
|
||||
// default value, ParseCommandLineFlags() will die.
|
||||
//
|
||||
// This function is safe to call at global construct time (as in the
|
||||
// example below).
|
||||
|
@ -140,18 +126,18 @@ typedef unsigned __int64 uint64;
|
|||
// 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).
|
||||
bool RegisterFlagValidator(const bool* flag,
|
||||
bool (*validate_fn)(const char*, bool));
|
||||
bool RegisterFlagValidator(const int32* flag,
|
||||
bool (*validate_fn)(const char*, int32));
|
||||
bool RegisterFlagValidator(const int64* flag,
|
||||
bool (*validate_fn)(const char*, int64));
|
||||
bool RegisterFlagValidator(const uint64* flag,
|
||||
bool (*validate_fn)(const char*, uint64));
|
||||
bool RegisterFlagValidator(const double* flag,
|
||||
bool (*validate_fn)(const char*, double));
|
||||
bool RegisterFlagValidator(const std::string* flag,
|
||||
bool (*validate_fn)(const char*, const std::string&));
|
||||
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 uint32* flag, bool (*validate_fn)(const char*, uint32));
|
||||
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)
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -164,40 +150,56 @@ bool RegisterFlagValidator(const std::string* flag,
|
|||
// 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 flag
|
||||
bool is_default; // true if the flag has default value
|
||||
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)
|
||||
};
|
||||
|
||||
extern void GetAllFlags(std::vector<CommandLineFlagInfo>* OUTPUT);
|
||||
// These two are actually defined in commandlineflags_reporting.cc.
|
||||
extern void ShowUsageWithFlags(const char *argv0); // what --help does
|
||||
extern void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict);
|
||||
// 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 std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
||||
extern GFLAGS_DLL_DECL std::string DescribeOneFlag(const CommandLineFlagInfo& flag);
|
||||
|
||||
// Thread-hostile; meant to be called before any threads are spawned.
|
||||
extern void SetArgv(int argc, const char** argv);
|
||||
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 const std::vector<std::string>& GetArgvs(); // all of argv as a vector
|
||||
extern const char* GetArgv(); // all of argv as a string
|
||||
extern const char* GetArgv0(); // only argv0
|
||||
extern uint32 GetArgvSum(); // simple checksum of argv
|
||||
extern const char* ProgramInvocationName(); // argv0, or "UNKNOWN" if not set
|
||||
extern const char* ProgramInvocationShortName(); // basename(argv0)
|
||||
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 const char* ProgramUsage(); // string set by SetUsageMessage()
|
||||
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()
|
||||
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -210,17 +212,16 @@ extern const char* ProgramUsage(); // string set by SetUsageMessage()
|
|||
|
||||
// Return true iff the flagname was found.
|
||||
// OUTPUT is set to the flag's value, or unchanged if we return false.
|
||||
extern bool GetCommandLineOption(const char* name, std::string* OUTPUT);
|
||||
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 bool GetCommandLineFlagInfo(const char* name,
|
||||
CommandLineFlagInfo* OUTPUT);
|
||||
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 CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
||||
extern GFLAGS_DLL_DECL CommandLineFlagInfo GetCommandLineFlagInfoOrDie(const char* name);
|
||||
|
||||
enum FlagSettingMode {
|
||||
// update the flag's value (can call this multiple times).
|
||||
|
@ -242,9 +243,8 @@ enum FlagSettingMode {
|
|||
// non-empty else.
|
||||
|
||||
// SetCommandLineOption uses set_mode == SET_FLAGS_VALUE (the common case)
|
||||
extern std::string SetCommandLineOption(const char* name, const char* value);
|
||||
extern std::string SetCommandLineOptionWithMode(const char* name, const char* value,
|
||||
FlagSettingMode set_mode);
|
||||
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);
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -265,14 +265,17 @@ extern std::string SetCommandLineOptionWithMode(const char* name, const char* va
|
|||
// // without worrying about restoring the FLAG values.
|
||||
// }
|
||||
//
|
||||
// Note: This class is marked with __attribute__((unused)) because all the
|
||||
// work is done in the constructor and destructor, so in the standard
|
||||
// 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.
|
||||
// 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 FlagSaver {
|
||||
class GFLAGS_DLL_DECL FlagSaver {
|
||||
public:
|
||||
FlagSaver();
|
||||
~FlagSaver();
|
||||
|
@ -282,24 +285,23 @@ class FlagSaver {
|
|||
|
||||
FlagSaver(const FlagSaver&); // no copying!
|
||||
void operator=(const FlagSaver&);
|
||||
} @ac_cv___attribute__unused@;
|
||||
}@GFLAGS_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 std::string CommandlineFlagsIntoString();
|
||||
extern GFLAGS_DLL_DECL std::string CommandlineFlagsIntoString();
|
||||
// Usually where this is used, a FlagSaver should be used instead.
|
||||
extern bool ReadFlagsFromString(const std::string& flagfilecontents,
|
||||
const char* prog_name,
|
||||
bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
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 bool AppendFlagsIntoFile(const std::string& filename, const char* prog_name);
|
||||
extern bool SaveCommandFlags(); // actually defined in google.cc !
|
||||
extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name,
|
||||
bool errors_are_fatal); // uses SET_FLAGS_VALUE
|
||||
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
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -310,16 +312,17 @@ extern bool ReadFromFlagsFile(const std::string& filename, const char* prog_name
|
|||
// 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 bool BoolFromEnv(const char *varname, bool defval);
|
||||
extern int32 Int32FromEnv(const char *varname, int32 defval);
|
||||
extern int64 Int64FromEnv(const char *varname, int64 defval);
|
||||
extern uint64 Uint64FromEnv(const char *varname, uint64 defval);
|
||||
extern double DoubleFromEnv(const char *varname, double defval);
|
||||
extern const char *StringFromEnv(const char *varname, const char *defval);
|
||||
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 uint32 Uint32FromEnv(const char *varname, uint32 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 commandlineflags from main():
|
||||
// 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");
|
||||
|
@ -327,16 +330,22 @@ extern const char *StringFromEnv(const char *varname, const char *defval);
|
|||
// 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 void SetUsageMessage(const std::string& usage);
|
||||
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.
|
||||
// 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 uint32 ParseCommandLineFlags(int *argc, char*** argv,
|
||||
bool remove_flags);
|
||||
extern GFLAGS_DLL_DECL uint32 ParseCommandLineFlags(int *argc, char*** argv, bool remove_flags);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -346,29 +355,41 @@ extern uint32 ParseCommandLineFlags(int *argc, char*** argv,
|
|||
// 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.
|
||||
extern uint32 ParseCommandLineNonHelpFlags(int *argc, char*** argv,
|
||||
bool remove_flags);
|
||||
// This is actually defined in commandlineflags_reporting.cc.
|
||||
// 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 void HandleCommandLineHelpFlags(); // in commandlineflags_reporting.cc
|
||||
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 void AllowCommandLineReparsing();
|
||||
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.
|
||||
// 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 uint32 ReparseCommandLineNonHelpFlags();
|
||||
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();
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
@ -399,7 +420,7 @@ extern uint32 ReparseCommandLineNonHelpFlags();
|
|||
// 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 bool FLAGS_whatever;"
|
||||
// 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.
|
||||
|
@ -408,25 +429,56 @@ extern uint32 ReparseCommandLineNonHelpFlags();
|
|||
// people can't DECLARE_int32 something that they DEFINE_bool'd
|
||||
// elsewhere.
|
||||
|
||||
class FlagRegisterer {
|
||||
class GFLAGS_DLL_DECL FlagRegisterer {
|
||||
public:
|
||||
FlagRegisterer(const char* name, const char* type,
|
||||
// We instantiate this template ctor for all supported types,
|
||||
// so it is possible to place implementation of the FlagRegisterer ctor in
|
||||
// .cc file.
|
||||
// Calling this constructor with unsupported type will produce linker error.
|
||||
template <typename FlagType>
|
||||
FlagRegisterer(const char* name,
|
||||
const char* help, const char* filename,
|
||||
void* current_storage, void* defvalue_storage);
|
||||
FlagType* current_storage, FlagType* defvalue_storage);
|
||||
};
|
||||
|
||||
#ifndef SWIG // In swig, ignore the main flag declarations
|
||||
// Force compiler to not generate code for the given template specialization.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1800 // Visual Studio 2013 version 12.0
|
||||
#define GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(type)
|
||||
#else
|
||||
#define GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(type) \
|
||||
extern template GFLAGS_DLL_DECL FlagRegisterer::FlagRegisterer( \
|
||||
const char* name, const char* help, const char* filename, \
|
||||
type* current_storage, type* defvalue_storage)
|
||||
#endif
|
||||
|
||||
// Do this for all supported flag types.
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(bool);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int32);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint32);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(int64);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(uint64);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(double);
|
||||
GFLAGS_DECLARE_FLAG_REGISTERER_CTOR(std::string);
|
||||
|
||||
#undef GFLAGS_DECLARE_FLAG_REGISTERER_CTOR
|
||||
|
||||
// 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 const char kStrippedFlagHelp[];
|
||||
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) : kStrippedFlagHelp)
|
||||
#define MAYBE_STRIPPED_HELP(txt) \
|
||||
(false ? (txt) : GFLAGS_NAMESPACE::kStrippedFlagHelp)
|
||||
#else
|
||||
#define MAYBE_STRIPPED_HELP(txt) txt
|
||||
#endif
|
||||
|
@ -442,54 +494,62 @@ extern const char kStrippedFlagHelp[];
|
|||
// 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; \
|
||||
type FLAGS_##name = FLAGS_nono##name; \
|
||||
type FLAGS_no##name = FLAGS_nono##name; \
|
||||
static @ac_google_namespace@::FlagRegisterer o_##name( \
|
||||
#name, #type, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
||||
&FLAGS_##name, &FLAGS_no##name); \
|
||||
} \
|
||||
#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; \
|
||||
static type FLAGS_no##name = FLAGS_nono##name; \
|
||||
static GFLAGS_NAMESPACE::FlagRegisterer o_##name( \
|
||||
#name, MAYBE_STRIPPED_HELP(help), __FILE__, \
|
||||
&FLAGS_##name, &FLAGS_no##name); \
|
||||
} \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
#define DECLARE_VARIABLE(type, shorttype, name) \
|
||||
namespace fL##shorttype { \
|
||||
extern type FLAGS_##name; \
|
||||
} \
|
||||
using fL##shorttype::FLAGS_##name
|
||||
|
||||
// For boolean flags, we want to do the extra check that the passed-in
|
||||
// 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.
|
||||
// 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 {
|
||||
template<typename From> double IsBoolFlag(const From& from);
|
||||
bool IsBoolFlag(bool from);
|
||||
}
|
||||
extern bool FlagsTypeWarn(const char *name);
|
||||
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
|
||||
|
||||
#define DECLARE_bool(name) DECLARE_VARIABLE(bool,B, name)
|
||||
// We have extra code here to make sure 'val' is actually a boolean.
|
||||
#define DEFINE_bool(name,val,txt) namespace fLB { \
|
||||
const bool FLAGS_nonono##name = \
|
||||
(sizeof(@ac_google_namespace@::fLB::IsBoolFlag(val)) \
|
||||
== sizeof(double)) \
|
||||
? @ac_google_namespace@::FlagsTypeWarn(#name) : true; \
|
||||
} \
|
||||
DEFINE_VARIABLE(bool,B, name, val, txt)
|
||||
#define DECLARE_int32(name) DECLARE_VARIABLE(@ac_google_namespace@::int32,I, name)
|
||||
#define DEFINE_int32(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::int32,I, name, val, txt)
|
||||
// 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 DECLARE_int64(name) DECLARE_VARIABLE(@ac_google_namespace@::int64,I64, name)
|
||||
#define DEFINE_int64(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::int64,I64, name, val, txt)
|
||||
#define DEFINE_int32(name, val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::int32, I, \
|
||||
name, val, txt)
|
||||
|
||||
#define DECLARE_uint64(name) DECLARE_VARIABLE(@ac_google_namespace@::uint64,U64, name)
|
||||
#define DEFINE_uint64(name,val,txt) DEFINE_VARIABLE(@ac_google_namespace@::uint64,U64, name, val, txt)
|
||||
#define DEFINE_uint32(name,val, txt) \
|
||||
DEFINE_VARIABLE(GFLAGS_NAMESPACE::uint32, U, \
|
||||
name, val, txt)
|
||||
|
||||
#define DECLARE_double(name) DECLARE_VARIABLE(double,D, name)
|
||||
#define DEFINE_double(name,val,txt) DEFINE_VARIABLE(double,D, 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
|
||||
|
@ -497,8 +557,40 @@ extern bool FlagsTypeWarn(const char *name);
|
|||
// 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.
|
||||
#define DECLARE_string(name) namespace fLS { extern std::string& FLAGS_##name; } \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
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);
|
||||
|
||||
// Auxiliary class used to explicitly call destructor of string objects
|
||||
// allocated using placement new during static program deinitialization.
|
||||
// The destructor MUST be an inline function such that the explicit
|
||||
// destruction occurs in the same compilation unit as the placement new.
|
||||
class StringFlagDestructor {
|
||||
void *current_storage_;
|
||||
void *defvalue_storage_;
|
||||
|
||||
public:
|
||||
|
||||
StringFlagDestructor(void *current, void *defvalue)
|
||||
: current_storage_(current), defvalue_storage_(defvalue) {}
|
||||
|
||||
~StringFlagDestructor() {
|
||||
reinterpret_cast<clstring*>(current_storage_ )->~clstring();
|
||||
reinterpret_cast<clstring*>(defvalue_storage_)->~clstring();
|
||||
}
|
||||
};
|
||||
|
||||
} // 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
|
||||
|
@ -507,21 +599,28 @@ extern bool FlagsTypeWarn(const char *name);
|
|||
// 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 { \
|
||||
static union { void* align; char s[sizeof(std::string)]; } s_##name[2]; \
|
||||
const std::string* const FLAGS_no##name = new (s_##name[0].s) std::string(val); \
|
||||
static @ac_google_namespace@::FlagRegisterer o_##name( \
|
||||
#name, "string", MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
||||
s_##name[0].s, new (s_##name[1].s) std::string(*FLAGS_no##name)); \
|
||||
extern std::string& FLAGS_##name; \
|
||||
using fLS::FLAGS_##name; \
|
||||
std::string& FLAGS_##name = *(reinterpret_cast<std::string*>(s_##name[0].s)); \
|
||||
} \
|
||||
#define DEFINE_string(name, val, txt) \
|
||||
namespace fLS { \
|
||||
using ::fLS::clstring; \
|
||||
using ::fLS::StringFlagDestructor; \
|
||||
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, MAYBE_STRIPPED_HELP(txt), __FILE__, \
|
||||
FLAGS_no##name, new (s_##name[1].s) clstring(*FLAGS_no##name)); \
|
||||
static StringFlagDestructor d_##name(s_##name[0].s, s_##name[1].s); \
|
||||
extern GFLAGS_DLL_DEFINE_FLAG clstring& FLAGS_##name; \
|
||||
using fLS::FLAGS_##name; \
|
||||
clstring& FLAGS_##name = *FLAGS_no##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
#endif // SWIG
|
||||
|
||||
@ac_google_end_namespace@
|
||||
|
||||
#endif // GOOGLE_GFLAGS_H_
|
||||
@INCLUDE_GFLAGS_NS_H@
|
||||
|
||||
|
||||
#endif // GFLAGS_GFLAGS_H_
|
|
@ -28,8 +28,7 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---
|
||||
// Author: Dave Nicponski
|
||||
//
|
||||
|
||||
// Bash-style command line flag completion for C++ binaries
|
||||
//
|
||||
// This module implements bash-style completions. It achieves this
|
||||
|
@ -40,33 +39,31 @@
|
|||
// 2a) If there are no matching flags, do nothing.
|
||||
// 2b) If all matching flags share a common prefix longer than the
|
||||
// completion word, output just that matching prefix
|
||||
// 3) Categorize those flags to produce a rough ordering of relevence.
|
||||
// 3) Categorize those flags to produce a rough ordering of relevance.
|
||||
// 4) Potentially trim the set of flags returned to a smaller number
|
||||
// that bash is happier with
|
||||
// 5) Output the matching flags in groups ordered by relevence.
|
||||
// 5) Output the matching flags in groups ordered by relevance.
|
||||
// 5a) Force bash to place most-relevent groups at the top of the list
|
||||
// 5b) Trim most flag's descriptions to fit on a single terminal line
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h> // for strlen
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring> // for strlen
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "config.h"
|
||||
#include "gflags/gflags.h"
|
||||
#include "gflags/gflags_completions.h"
|
||||
#include "util.h"
|
||||
|
||||
using std::set;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
#ifndef PATH_SEPARATOR
|
||||
#define PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
DEFINE_string(tab_completion_word, "",
|
||||
"If non-empty, HandleCommandLineCompletions() will hijack the "
|
||||
|
@ -75,10 +72,11 @@ DEFINE_string(tab_completion_word, "",
|
|||
DEFINE_int32(tab_completion_columns, 80,
|
||||
"Number of columns to use in output for tab completion");
|
||||
|
||||
_START_GOOGLE_NAMESPACE_
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
// Function prototypes and Type forward declarations. Code may be
|
||||
// more easily understood if it is roughly ordered according to
|
||||
// control flow, rather than by C's "declare before use" ordering
|
||||
|
@ -121,7 +119,7 @@ static void CategorizeAllMatchingFlags(
|
|||
NotableFlags *notable_flags);
|
||||
|
||||
static void TryFindModuleAndPackageDir(
|
||||
const vector<CommandLineFlagInfo> all_flags,
|
||||
const vector<CommandLineFlagInfo> &all_flags,
|
||||
string *module,
|
||||
string *package_dir);
|
||||
|
||||
|
@ -172,7 +170,7 @@ static string GetLongFlagLine(
|
|||
// most likely to be useful first. If this is set, however, the user
|
||||
// really does want us to return every single flag as an option.
|
||||
// - force_no_update: Any time we output lines, all of which share a
|
||||
// common prefix, bash will 'helpfully' not even bother to show the
|
||||
// common prefix, bash will 'helpfuly' not even bother to show the
|
||||
// output, instead changing the current word to be that common prefix.
|
||||
// If it's clear this shouldn't happen, we'll set this boolean
|
||||
struct CompletionOptions {
|
||||
|
@ -181,11 +179,16 @@ struct CompletionOptions {
|
|||
bool flag_description_substring_search;
|
||||
bool return_all_matching_flags;
|
||||
bool force_no_update;
|
||||
CompletionOptions(): flag_name_substring_search(false),
|
||||
flag_location_substring_search(false),
|
||||
flag_description_substring_search(false),
|
||||
return_all_matching_flags(false),
|
||||
force_no_update(false) { }
|
||||
};
|
||||
|
||||
// Notable flags are flags that are special or preferred for some
|
||||
// reason. For example, flags that are defined in the binary's module
|
||||
// are expected to be much more relevent than flags defined in some
|
||||
// are expected to be much more relevant than flags defined in some
|
||||
// other random location. These sets are specified roughly in precedence
|
||||
// order. Once a flag is placed in one of these 'higher' sets, it won't
|
||||
// be placed in any of the 'lower' sets.
|
||||
|
@ -204,18 +207,18 @@ struct NotableFlags {
|
|||
static void PrintFlagCompletionInfo(void) {
|
||||
string cursor_word = FLAGS_tab_completion_word;
|
||||
string canonical_token;
|
||||
CompletionOptions options = { };
|
||||
CompletionOptions options = CompletionOptions();
|
||||
CanonicalizeCursorWordAndSearchOptions(
|
||||
cursor_word,
|
||||
&canonical_token,
|
||||
&options);
|
||||
|
||||
//VLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
|
||||
DVLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
|
||||
|
||||
vector<CommandLineFlagInfo> all_flags;
|
||||
set<const CommandLineFlagInfo *> matching_flags;
|
||||
GetAllFlags(&all_flags);
|
||||
//VLOG(2) << "Found " << all_flags.size() << " flags overall";
|
||||
DVLOG(2) << "Found " << all_flags.size() << " flags overall";
|
||||
|
||||
string longest_common_prefix;
|
||||
FindMatchingFlags(
|
||||
|
@ -224,28 +227,28 @@ static void PrintFlagCompletionInfo(void) {
|
|||
canonical_token,
|
||||
&matching_flags,
|
||||
&longest_common_prefix);
|
||||
//VLOG(1) << "Identified " << matching_flags.size() << " matching flags";
|
||||
//VLOG(1) << "Identified " << longest_common_prefix
|
||||
// << " as longest common prefix.";
|
||||
DVLOG(1) << "Identified " << matching_flags.size() << " matching flags";
|
||||
DVLOG(1) << "Identified " << longest_common_prefix
|
||||
<< " as longest common prefix.";
|
||||
if (longest_common_prefix.size() > canonical_token.size()) {
|
||||
// There's actually a shared common prefix to all matching flags,
|
||||
// so may as well output that and quit quickly.
|
||||
//VLOG(1) << "The common prefix '" << longest_common_prefix
|
||||
// << "' was longer than the token '" << canonical_token
|
||||
// << "'. Returning just this prefix for completion.";
|
||||
DVLOG(1) << "The common prefix '" << longest_common_prefix
|
||||
<< "' was longer than the token '" << canonical_token
|
||||
<< "'. Returning just this prefix for completion.";
|
||||
fprintf(stdout, "--%s", longest_common_prefix.c_str());
|
||||
return;
|
||||
}
|
||||
if (matching_flags.empty()) {
|
||||
//VLOG(1) << "There were no matching flags, returning nothing.";
|
||||
VLOG(1) << "There were no matching flags, returning nothing.";
|
||||
return;
|
||||
}
|
||||
|
||||
string module;
|
||||
string package_dir;
|
||||
TryFindModuleAndPackageDir(all_flags, &module, &package_dir);
|
||||
//VLOG(1) << "Identified module: '" << module << "'";
|
||||
//VLOG(1) << "Identified package_dir: '" << package_dir << "'";
|
||||
DVLOG(1) << "Identified module: '" << module << "'";
|
||||
DVLOG(1) << "Identified package_dir: '" << package_dir << "'";
|
||||
|
||||
NotableFlags notable_flags;
|
||||
CategorizeAllMatchingFlags(
|
||||
|
@ -254,12 +257,12 @@ static void PrintFlagCompletionInfo(void) {
|
|||
module,
|
||||
package_dir,
|
||||
¬able_flags);
|
||||
//VLOG(2) << "Categorized matching flags:";
|
||||
//VLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
|
||||
//VLOG(2) << " module: " << notable_flags.module_flags.size();
|
||||
//VLOG(2) << " package: " << notable_flags.package_flags.size();
|
||||
//VLOG(2) << " most common: " << notable_flags.most_common_flags.size();
|
||||
//VLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
|
||||
DVLOG(2) << "Categorized matching flags:";
|
||||
DVLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
|
||||
DVLOG(2) << " module: " << notable_flags.module_flags.size();
|
||||
DVLOG(2) << " package: " << notable_flags.package_flags.size();
|
||||
DVLOG(2) << " most common: " << notable_flags.most_common_flags.size();
|
||||
DVLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
|
||||
|
||||
vector<string> completions;
|
||||
FinalizeCompletionOutput(
|
||||
|
@ -271,13 +274,13 @@ static void PrintFlagCompletionInfo(void) {
|
|||
if (options.force_no_update)
|
||||
completions.push_back("~");
|
||||
|
||||
//VLOG(1) << "Finalized with " << completions.size()
|
||||
// << " chosen completions";
|
||||
DVLOG(1) << "Finalized with " << completions.size()
|
||||
<< " chosen completions";
|
||||
|
||||
for (vector<string>::const_iterator it = completions.begin();
|
||||
it != completions.end();
|
||||
++it) {
|
||||
//VLOG(9) << " Completion entry: '" << *it << "'";
|
||||
DVLOG(9) << " Completion entry: '" << *it << "'";
|
||||
fprintf(stdout, "%s\n", it->c_str());
|
||||
}
|
||||
}
|
||||
|
@ -322,12 +325,10 @@ static void CanonicalizeCursorWordAndSearchOptions(
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (found_question_marks) { // all fallthroughs
|
||||
case 3: options->flag_description_substring_search = true;
|
||||
case 2: options->flag_location_substring_search = true;
|
||||
case 1: options->flag_name_substring_search = true;
|
||||
};
|
||||
|
||||
if (found_question_marks > 2) options->flag_description_substring_search = true;
|
||||
if (found_question_marks > 1) options->flag_location_substring_search = true;
|
||||
if (found_question_marks > 0) options->flag_name_substring_search = true;
|
||||
|
||||
options->return_all_matching_flags = (found_plusses > 0);
|
||||
}
|
||||
|
@ -397,7 +398,7 @@ static bool DoesSingleFlagMatch(
|
|||
flag.filename.find(match_token) != string::npos)
|
||||
return true;
|
||||
|
||||
// TODO(daven): All searches should probably be case-insensitive
|
||||
// TODO(user): All searches should probably be case-insensitive
|
||||
// (especially this one...)
|
||||
if (options.flag_description_substring_search &&
|
||||
flag.description.find(match_token) != string::npos)
|
||||
|
@ -409,7 +410,7 @@ static bool DoesSingleFlagMatch(
|
|||
// 3) Categorize matches (and helper method)
|
||||
|
||||
// Given a set of matching flags, categorize them by
|
||||
// likely relevence to this specific binary
|
||||
// likely relevance to this specific binary
|
||||
static void CategorizeAllMatchingFlags(
|
||||
const set<const CommandLineFlagInfo *> &all_matches,
|
||||
const string &search_token,
|
||||
|
@ -426,8 +427,8 @@ static void CategorizeAllMatchingFlags(
|
|||
all_matches.begin();
|
||||
it != all_matches.end();
|
||||
++it) {
|
||||
//VLOG(2) << "Examining match '" << (*it)->name << "'";
|
||||
//VLOG(7) << " filename: '" << (*it)->filename << "'";
|
||||
DVLOG(2) << "Examining match '" << (*it)->name << "'";
|
||||
DVLOG(7) << " filename: '" << (*it)->filename << "'";
|
||||
string::size_type pos = string::npos;
|
||||
if (!package_dir.empty())
|
||||
pos = (*it)->filename.find(package_dir);
|
||||
|
@ -440,47 +441,41 @@ static void CategorizeAllMatchingFlags(
|
|||
if ((*it)->name == search_token) {
|
||||
// Exact match on some flag's name
|
||||
notable_flags->perfect_match_flag.insert(*it);
|
||||
//VLOG(3) << "Result: perfect match";
|
||||
DVLOG(3) << "Result: perfect match";
|
||||
} else if (!module.empty() && (*it)->filename == module) {
|
||||
// Exact match on module filename
|
||||
notable_flags->module_flags.insert(*it);
|
||||
//VLOG(3) << "Result: module match";
|
||||
DVLOG(3) << "Result: module match";
|
||||
} else if (!package_dir.empty() &&
|
||||
pos != string::npos && slash == string::npos) {
|
||||
// In the package, since there was no slash after the package portion
|
||||
notable_flags->package_flags.insert(*it);
|
||||
//VLOG(3) << "Result: package match";
|
||||
} else if (false) {
|
||||
// In the list of the XXX most commonly supplied flags overall
|
||||
// TODO(daven): Compile this list.
|
||||
//VLOG(3) << "Result: most-common match";
|
||||
DVLOG(3) << "Result: package match";
|
||||
} else if (!package_dir.empty() &&
|
||||
pos != string::npos && slash != string::npos) {
|
||||
// In a subdirectory of the package
|
||||
notable_flags->subpackage_flags.insert(*it);
|
||||
//VLOG(3) << "Result: subpackage match";
|
||||
DVLOG(3) << "Result: subpackage match";
|
||||
}
|
||||
|
||||
//VLOG(3) << "Result: not special match";
|
||||
DVLOG(3) << "Result: not special match";
|
||||
}
|
||||
}
|
||||
|
||||
static void PushNameWithSuffix(vector<string>* suffixes, const char* suffix) {
|
||||
string s("/");
|
||||
s += ProgramInvocationShortName();
|
||||
s += suffix;
|
||||
suffixes->push_back(s);
|
||||
suffixes->push_back(
|
||||
StringPrintf("/%s%s", ProgramInvocationShortName(), suffix));
|
||||
}
|
||||
|
||||
static void TryFindModuleAndPackageDir(
|
||||
const vector<CommandLineFlagInfo> all_flags,
|
||||
const vector<CommandLineFlagInfo> &all_flags,
|
||||
string *module,
|
||||
string *package_dir) {
|
||||
module->clear();
|
||||
package_dir->clear();
|
||||
|
||||
vector<string> suffixes;
|
||||
// TODO(daven): There's some inherant ambiguity here - multiple directories
|
||||
// TODO(user): There's some inherant ambiguity here - multiple directories
|
||||
// could share the same trailing folder and file structure (and even worse,
|
||||
// same file names), causing us to be unsure as to which of the two is the
|
||||
// actual package for this binary. In this case, we'll arbitrarily choose.
|
||||
|
@ -499,7 +494,7 @@ static void TryFindModuleAndPackageDir(
|
|||
for (vector<string>::const_iterator suffix = suffixes.begin();
|
||||
suffix != suffixes.end();
|
||||
++suffix) {
|
||||
// TODO(daven): Make sure the match is near the end of the string
|
||||
// TODO(user): Make sure the match is near the end of the string
|
||||
if (it->filename.find(*suffix) != string::npos) {
|
||||
*module = it->filename;
|
||||
string::size_type sep = it->filename.rfind(PATH_SEPARATOR);
|
||||
|
@ -549,8 +544,7 @@ static void FinalizeCompletionOutput(
|
|||
|
||||
vector<DisplayInfoGroup> output_groups;
|
||||
bool perfect_match_found = false;
|
||||
if (lines_so_far < max_desired_lines &&
|
||||
!notable_flags->perfect_match_flag.empty()) {
|
||||
if (!notable_flags->perfect_match_flag.empty()) {
|
||||
perfect_match_found = true;
|
||||
DisplayInfoGroup group =
|
||||
{ "",
|
||||
|
@ -696,12 +690,14 @@ static void OutputSingleGroupWithLimit(
|
|||
static string GetShortFlagLine(
|
||||
const string &line_indentation,
|
||||
const CommandLineFlagInfo &info) {
|
||||
string prefix =
|
||||
line_indentation + "--" + info.name + " [" +
|
||||
(info.type == "string" ?
|
||||
("'" + info.default_value + "'") :
|
||||
info.default_value)
|
||||
+ "] ";
|
||||
string prefix;
|
||||
bool is_string = (info.type == "string");
|
||||
SStringPrintf(&prefix, "%s--%s [%s%s%s] ",
|
||||
line_indentation.c_str(),
|
||||
info.name.c_str(),
|
||||
(is_string ? "'" : ""),
|
||||
info.default_value.c_str(),
|
||||
(is_string ? "'" : ""));
|
||||
int remainder =
|
||||
FLAGS_tab_completion_columns - static_cast<int>(prefix.size());
|
||||
string suffix;
|
||||
|
@ -731,8 +727,12 @@ static string GetLongFlagLine(
|
|||
static const char kNewlineWithIndent[] = "\n ";
|
||||
output.replace(output.find(" type:"), 1, string(kNewlineWithIndent));
|
||||
output.replace(output.find(" default:"), 1, string(kNewlineWithIndent));
|
||||
output = line_indentation + " Details for '--" + info.name + "':\n" +
|
||||
output + " defined: " + info.filename;
|
||||
output = StringPrintf("%s Details for '--%s':\n"
|
||||
"%s defined: %s",
|
||||
line_indentation.c_str(),
|
||||
info.name.c_str(),
|
||||
output.c_str(),
|
||||
info.filename.c_str());
|
||||
|
||||
// Eliminate any doubled newlines that crept in. Specifically, if
|
||||
// DescribeOneFlag() decided to break the line just before "type"
|
||||
|
@ -759,7 +759,8 @@ static string GetLongFlagLine(
|
|||
void HandleCommandLineCompletions(void) {
|
||||
if (FLAGS_tab_completion_word.empty()) return;
|
||||
PrintFlagCompletionInfo();
|
||||
exit(0);
|
||||
gflags_exitfunc(0);
|
||||
}
|
||||
|
||||
_END_GOOGLE_NAMESPACE_
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---
|
||||
// Author: Dave Nicponski
|
||||
|
||||
//
|
||||
// Implement helpful bash-style command line flag completions
|
||||
//
|
||||
|
@ -45,7 +45,7 @@
|
|||
// handling.
|
||||
//
|
||||
// ** Overview of Bash completions:
|
||||
// Bash can be told to programatically determine completions for the
|
||||
// Bash can be told to programmatically 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
|
||||
|
@ -63,7 +63,7 @@
|
|||
// 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
|
||||
// make bash order the output such that the most useful or relevant
|
||||
// flags are the most likely to be shown at the top.
|
||||
//
|
||||
// ** Additional features:
|
||||
|
@ -88,8 +88,8 @@
|
|||
// file would be (your path to gflags_completions.sh file may differ):
|
||||
|
||||
/*
|
||||
$ complete -o bashdefault -o default -o nospace -C \
|
||||
'/usr/local/bin/gflags_completions.sh --tab_completion_columns $COLUMNS' \
|
||||
$ 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 [...]
|
||||
*/
|
||||
|
||||
|
@ -109,13 +109,13 @@ $ complete -o bashdefault -o default -o nospace -C \
|
|||
// produce the expected completion output.
|
||||
|
||||
|
||||
#ifndef GOOGLE_GFLAGS_COMPLETIONS_H_
|
||||
#define GOOGLE_GFLAGS_COMPLETIONS_H_
|
||||
#ifndef GFLAGS_COMPLETIONS_H_
|
||||
#define GFLAGS_COMPLETIONS_H_
|
||||
|
||||
@ac_google_start_namespace@
|
||||
namespace @GFLAGS_NAMESPACE@ {
|
||||
|
||||
void HandleCommandLineCompletions(void);
|
||||
extern void HandleCommandLineCompletions(void);
|
||||
|
||||
@ac_google_end_namespace@
|
||||
}
|
||||
|
||||
#endif // GOOGLE_GFLAGS_COMPLETIONS_H_
|
||||
#endif // GFLAGS_COMPLETIONS_H_
|
|
@ -50,12 +50,12 @@
|
|||
completion_word_index="$(($# - 1))"
|
||||
completion_word="${!completion_word_index}"
|
||||
|
||||
# TODO(daven): Replace this once commandlineflags_completions.cc has
|
||||
# TODO(user): Replace this once gflags_completions.cc has
|
||||
# a bool parameter indicating unambiguously to hijack the process for
|
||||
# completion purposes.
|
||||
if [ -z "$completion_word" ]; then
|
||||
# Until an empty value for the completion word stops being misunderstood
|
||||
# by google3 binaries, don't actuall execute the binary or the process
|
||||
# by binaries, don't actually execute the binary or the process
|
||||
# won't be hijacked!
|
||||
exit 0
|
||||
fi
|
||||
|
@ -74,12 +74,10 @@ binary="${!binary_index}"
|
|||
# places this in the $COMP_LINE variable.
|
||||
if [ "$binary" == "time" ] || [ "$binary" == "env" ]; then
|
||||
# we'll assume that the first 'argument' is actually the
|
||||
# binary to be run, if we think it looks like a google3
|
||||
# binary
|
||||
|
||||
# TODO(daven): Decide what 'looks' like a google3 binary. =)
|
||||
|
||||
# TODO(daven): This is not perfect - the 'env' command, for instance,
|
||||
# TODO(user): This is not perfect - the 'env' command, for instance,
|
||||
# is allowed to have options between the 'env' and 'the command to
|
||||
# be executed'. For example, consider:
|
||||
# $ env FOO="bar" bin/do_something --help<TAB>
|
||||
|
@ -105,7 +103,7 @@ for ((i=1; i<=$(($# - 3)); ++i)); do
|
|||
done
|
||||
params="$params --tab_completion_word \"$completion_word\""
|
||||
|
||||
# TODO(daven): Perhaps stash the output in a temporary file somewhere
|
||||
# TODO(user): Perhaps stash the output in a temporary file somewhere
|
||||
# in /tmp, and only cat it to stdout if the command returned a success
|
||||
# code, to prevent false positives
|
||||
|
||||
|
|
156
src/gflags_declare.h.in
Normal file
156
src/gflags_declare.h.in
Normal file
|
@ -0,0 +1,156 @@
|
|||
// 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 @GFLAGS_NAMESPACE@
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Windows DLL import/export.
|
||||
|
||||
// Whether gflags library is a DLL.
|
||||
//
|
||||
// Set to 1 by default when the shared gflags library was built on Windows.
|
||||
// Must be overwritten when this header file is used with the optionally also
|
||||
// built static library instead; set by CMake's INTERFACE_COMPILE_DEFINITIONS.
|
||||
#ifndef GFLAGS_IS_A_DLL
|
||||
# define GFLAGS_IS_A_DLL @GFLAGS_IS_A_DLL@
|
||||
#endif
|
||||
|
||||
// We always want to import the symbols of the gflags library.
|
||||
#ifndef GFLAGS_DLL_DECL
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECL __declspec(dllimport)
|
||||
# elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define GFLAGS_DLL_DECL __attribute__((visibility("default")))
|
||||
# else
|
||||
# define GFLAGS_DLL_DECL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// We always want to import variables declared in user code.
|
||||
#ifndef GFLAGS_DLL_DECLARE_FLAG
|
||||
# if GFLAGS_IS_A_DLL && defined(_MSC_VER)
|
||||
# define GFLAGS_DLL_DECLARE_FLAG __declspec(dllimport)
|
||||
# elif defined(__GNUC__) && __GNUC__ >= 4
|
||||
# define GFLAGS_DLL_DECLARE_FLAG __attribute__((visibility("default")))
|
||||
# else
|
||||
# define GFLAGS_DLL_DECLARE_FLAG
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Flag types
|
||||
#include <string>
|
||||
#if @HAVE_STDINT_H@
|
||||
# include <stdint.h> // the normal place uint32_t is defined
|
||||
#elif @HAVE_SYS_TYPES_H@
|
||||
# include <sys/types.h> // the normal place u_int32_t is defined
|
||||
#elif @HAVE_INTTYPES_H@
|
||||
# include <inttypes.h> // a third place for uint32_t or u_int32_t
|
||||
#endif
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
#if @GFLAGS_INTTYPES_FORMAT_C99@ // C99
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#elif @GFLAGS_INTTYPES_FORMAT_BSD@ // BSD
|
||||
typedef int32_t int32;
|
||||
typedef u_int32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef u_int64_t uint64;
|
||||
#elif @GFLAGS_INTTYPES_FORMAT_VC7@ // 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_uint32(name) \
|
||||
DECLARE_VARIABLE(::GFLAGS_NAMESPACE::uint32, U, 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 { \
|
||||
extern GFLAGS_DLL_DECLARE_FLAG ::fLS::clstring& FLAGS_##name; \
|
||||
} \
|
||||
using fLS::FLAGS_##name
|
||||
|
||||
|
||||
#endif // GFLAGS_DECLARE_H_
|
102
src/gflags_ns.h.in
Normal file
102
src/gflags_ns.h.in
Normal file
|
@ -0,0 +1,102 @@
|
|||
// 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_@ns@.h may only be included by gflags.h
|
||||
#endif
|
||||
|
||||
#ifndef GFLAGS_NS_@NS@_H_
|
||||
#define GFLAGS_NS_@NS@_H_
|
||||
|
||||
|
||||
namespace @ns@ {
|
||||
|
||||
|
||||
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::Uint32FromEnv;
|
||||
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 @ns@
|
||||
|
||||
|
||||
#endif // GFLAGS_NS_@NS@_H_
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2006, Google Inc.
|
||||
// Copyright (c) 1999, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
|
@ -28,7 +28,7 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// ---
|
||||
// Author: Ray Sidney
|
||||
//
|
||||
// Revamped and reorganized by Craig Silverstein
|
||||
//
|
||||
// This file contains code for handling the 'reporting' flags. These
|
||||
|
@ -40,7 +40,7 @@
|
|||
// HandleCommandLineHelpFlags(). (Well, actually, ShowUsageWithFlags(),
|
||||
// ShowUsageWithFlagsRestrict(), and DescribeOneFlag() can be called
|
||||
// externally too, but there's little need for it.) These are all
|
||||
// declared in the main commandlineflags.h header file.
|
||||
// declared in the main gflags.h header file.
|
||||
//
|
||||
// HandleCommandLineHelpFlags() will check what 'reporting' flags have
|
||||
// been defined, if any -- the "help" part of the function name is a
|
||||
|
@ -48,48 +48,42 @@
|
|||
// called after all flag-values have been assigned, that is, after
|
||||
// parsing the command-line.
|
||||
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "config.h"
|
||||
#include "gflags/gflags.h"
|
||||
#include "gflags/gflags_completions.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
// The 'reporting' flags. They all call gflags_exitfunc().
|
||||
DEFINE_bool (help, false, "show help on all flags [tip: all flags can have two dashes]");
|
||||
DEFINE_bool (helpful, false, "show help on all flags -- same as -help");
|
||||
DEFINE_bool (helpshort, false, "show help on only the main module for this program");
|
||||
DEFINE_string(helpon, "", "show help on the modules named by this flag value");
|
||||
DEFINE_string(helpmatch, "", "show help on modules whose name contains the specified substr");
|
||||
DEFINE_bool (helppackage, false, "show help on all modules in the main package");
|
||||
DEFINE_bool (helpxml, false, "produce an xml version of help");
|
||||
DEFINE_bool (version, false, "show version and build info and exit");
|
||||
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
#ifndef PATH_SEPARATOR
|
||||
#define PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
// The 'reporting' flags. They all call exit().
|
||||
DEFINE_bool(help, false,
|
||||
"show help on all flags [tip: all flags can have two dashes]");
|
||||
DEFINE_bool(helpfull, false,
|
||||
"show help on all flags -- same as -help");
|
||||
DEFINE_bool(helpshort, false,
|
||||
"show help on only the main module for this program");
|
||||
DEFINE_string(helpon, "",
|
||||
"show help on the modules named by this flag value");
|
||||
DEFINE_string(helpmatch, "",
|
||||
"show help on modules whose name contains the specified substr");
|
||||
DEFINE_bool(helppackage, false,
|
||||
"show help on all modules in the main package");
|
||||
DEFINE_bool(helpxml, false,
|
||||
"produce an xml version of help");
|
||||
DEFINE_bool(version, false,
|
||||
"show version and build info and exit");
|
||||
|
||||
_START_GOOGLE_NAMESPACE_
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// DescribeOneFlag()
|
||||
// DescribeOneFlagInXML()
|
||||
// Routines that pretty-print info about a flag. These use
|
||||
// a CommandLineFlagInfo, which is the way the commandlineflags
|
||||
// a CommandLineFlagInfo, which is the way the gflags
|
||||
// API exposes static info about a flag.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
@ -109,17 +103,31 @@ static void AddString(const string& s,
|
|||
*chars_in_line += slen;
|
||||
}
|
||||
|
||||
static string PrintStringFlagsWithQuotes(const CommandLineFlagInfo& flag,
|
||||
const string& text, bool current) {
|
||||
const char* c_string = (current ? flag.current_value.c_str() :
|
||||
flag.default_value.c_str());
|
||||
if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings
|
||||
return StringPrintf("%s: \"%s\"", text.c_str(), c_string);
|
||||
} else {
|
||||
return StringPrintf("%s: %s", text.c_str(), c_string);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a descriptive string for a flag.
|
||||
// Goes to some trouble to make pretty line breaks.
|
||||
string DescribeOneFlag(const CommandLineFlagInfo& flag) {
|
||||
string main_part = (string(" -") + flag.name +
|
||||
" (" + flag.description + ')');
|
||||
string main_part;
|
||||
SStringPrintf(&main_part, " -%s (%s)",
|
||||
flag.name.c_str(),
|
||||
flag.description.c_str());
|
||||
const char* c_string = main_part.c_str();
|
||||
int chars_left = static_cast<int>(main_part.length());
|
||||
string final_string = "";
|
||||
string final_string;
|
||||
int chars_in_line = 0; // how many chars in current line so far?
|
||||
while (1) {
|
||||
assert(chars_left == strlen(c_string)); // Unless there's a \0 in there?
|
||||
assert(static_cast<size_t>(chars_left)
|
||||
== strlen(c_string)); // Unless there's a \0 in there?
|
||||
const char* newline = strchr(c_string, '\n');
|
||||
if (newline == NULL && chars_in_line+chars_left < kLineLength) {
|
||||
// The whole remainder of the string fits on this line
|
||||
|
@ -153,32 +161,24 @@ string DescribeOneFlag(const CommandLineFlagInfo& flag) {
|
|||
}
|
||||
if (*c_string == '\0')
|
||||
break;
|
||||
final_string += "\n ";
|
||||
StringAppendF(&final_string, "\n ");
|
||||
chars_in_line = 6;
|
||||
}
|
||||
|
||||
// Append data type
|
||||
AddString(string("type: ") + flag.type, &final_string, &chars_in_line);
|
||||
// Append the effective default value (i.e., the value that the flag
|
||||
// will have after the command line is parsed if the flag is not
|
||||
// specified on the command line), which may be different from the
|
||||
// stored default value. This would happen if the value of the flag
|
||||
// was modified before the command line was parsed. (Unless the
|
||||
// value was modified using SetCommandLineOptionWithMode() with mode
|
||||
// SET_FLAGS_DEFAULT.)
|
||||
// Note that we are assuming this code is being executed because a help
|
||||
// request was just parsed from the command line, in which case the
|
||||
// printed value is indeed the effective default, as long as no value
|
||||
// for the flag was parsed from the command line before "--help".
|
||||
if (strcmp(flag.type.c_str(), "string") == 0) { // add quotes for strings
|
||||
AddString(string("default: \"") + flag.current_value + string("\""),
|
||||
&final_string, &chars_in_line);
|
||||
} else {
|
||||
AddString(string("default: ") + flag.current_value,
|
||||
// The listed default value will be the actual default from the flag
|
||||
// definition in the originating source file, unless the value has
|
||||
// subsequently been modified using SetCommandLineOptionWithMode() with mode
|
||||
// SET_FLAGS_DEFAULT, or by setting FLAGS_foo = bar before ParseCommandLineFlags().
|
||||
AddString(PrintStringFlagsWithQuotes(flag, "default", false), &final_string,
|
||||
&chars_in_line);
|
||||
if (!flag.is_default) {
|
||||
AddString(PrintStringFlagsWithQuotes(flag, "currently", true),
|
||||
&final_string, &chars_in_line);
|
||||
}
|
||||
|
||||
final_string += '\n';
|
||||
StringAppendF(&final_string, "\n");
|
||||
return final_string;
|
||||
}
|
||||
|
||||
|
@ -193,15 +193,10 @@ static string XMLText(const string& txt) {
|
|||
}
|
||||
|
||||
static void AddXMLTag(string* r, const char* tag, const string& txt) {
|
||||
*r += ('<');
|
||||
*r += (tag);
|
||||
*r += ('>');
|
||||
*r += (XMLText(txt));
|
||||
*r += ("</");
|
||||
*r += (tag);
|
||||
*r += ('>');
|
||||
StringAppendF(r, "<%s>%s</%s>", tag, XMLText(txt).c_str(), tag);
|
||||
}
|
||||
|
||||
|
||||
static string DescribeOneFlagInXML(const CommandLineFlagInfo& flag) {
|
||||
// The file and flagname could have been attributes, but default
|
||||
// and meaning need to avoid attribute normalization. This way it
|
||||
|
@ -252,7 +247,7 @@ static bool FileMatchesSubstring(const string& filename,
|
|||
// the string to be at the beginning of a directory component.
|
||||
// That should match the first directory component as well, so
|
||||
// we allow '/foo' to match a filename of 'foo'.
|
||||
if (!target->empty() && (*target)[0] == '/' &&
|
||||
if (!target->empty() && (*target)[0] == PATH_SEPARATOR &&
|
||||
strncmp(filename.c_str(), target->c_str() + 1,
|
||||
strlen(target->c_str() + 1)) == 0)
|
||||
return true;
|
||||
|
@ -262,9 +257,9 @@ static bool FileMatchesSubstring(const string& filename,
|
|||
|
||||
// Show help for every filename which matches any of the target substrings.
|
||||
// If substrings is empty, shows help for every file. If a flag's help message
|
||||
// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1' before
|
||||
// including gflags/gflags.h), then this flag will not be displayed by
|
||||
// '--help' and its variants.
|
||||
// has been stripped (e.g. by adding '#define STRIP_FLAG_HELP 1'
|
||||
// before including gflags/gflags.h), then this flag will not be displayed
|
||||
// by '--help' and its variants.
|
||||
static void ShowUsageWithFlagsMatching(const char *argv0,
|
||||
const vector<string> &substrings) {
|
||||
fprintf(stdout, "%s: %s\n", Basename(argv0), ProgramUsage());
|
||||
|
@ -280,9 +275,9 @@ static void ShowUsageWithFlagsMatching(const char *argv0,
|
|||
++flag) {
|
||||
if (substrings.empty() ||
|
||||
FileMatchesSubstring(flag->filename, substrings)) {
|
||||
found_match = true; // this flag passed the match!
|
||||
// If the flag has been stripped, pretend that it doesn't exist.
|
||||
if (flag->description == kStrippedFlagHelp) continue;
|
||||
found_match = true; // this flag passed the match!
|
||||
if (flag->filename != last_filename) { // new file
|
||||
if (Dirname(flag->filename) != Dirname(last_filename)) { // new dir!
|
||||
if (!first_directory)
|
||||
|
@ -301,10 +296,10 @@ static void ShowUsageWithFlagsMatching(const char *argv0,
|
|||
}
|
||||
}
|
||||
|
||||
void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict) {
|
||||
void ShowUsageWithFlagsRestrict(const char *argv0, const char *restrict_) {
|
||||
vector<string> substrings;
|
||||
if (restrict != NULL && *restrict != '\0') {
|
||||
substrings.push_back(restrict);
|
||||
if (restrict_ != NULL && *restrict_ != '\0') {
|
||||
substrings.push_back(restrict_);
|
||||
}
|
||||
ShowUsageWithFlagsMatching(argv0, substrings);
|
||||
}
|
||||
|
@ -344,10 +339,13 @@ static void ShowXMLOfFlags(const char *prog_name) {
|
|||
// --------------------------------------------------------------------
|
||||
|
||||
static void ShowVersion() {
|
||||
fprintf(stdout, "%s\n", ProgramInvocationShortName());
|
||||
// TODO: add other stuff, like a timestamp, who built it, what
|
||||
// target they built, etc.
|
||||
|
||||
const char* version_string = VersionString();
|
||||
if (version_string && *version_string) {
|
||||
fprintf(stdout, "%s version %s\n",
|
||||
ProgramInvocationShortName(), version_string);
|
||||
} else {
|
||||
fprintf(stdout, "%s\n", ProgramInvocationShortName());
|
||||
}
|
||||
# if !defined(NDEBUG)
|
||||
fprintf(stdout, "Debug build (NDEBUG not #defined)\n");
|
||||
# endif
|
||||
|
@ -355,7 +353,8 @@ static void ShowVersion() {
|
|||
|
||||
static void AppendPrognameStrings(vector<string>* substrings,
|
||||
const char* progname) {
|
||||
string r("/");
|
||||
string r;
|
||||
r += PATH_SEPARATOR;
|
||||
r += progname;
|
||||
substrings->push_back(r + ".");
|
||||
substrings->push_back(r + "-main.");
|
||||
|
@ -372,7 +371,6 @@ static void AppendPrognameStrings(vector<string>* substrings,
|
|||
|
||||
void HandleCommandLineHelpFlags() {
|
||||
const char* progname = ProgramInvocationShortName();
|
||||
extern void (*commandlineflags_exitfunc)(int); // in gflags.cc
|
||||
|
||||
HandleCommandLineCompletions();
|
||||
|
||||
|
@ -383,21 +381,21 @@ void HandleCommandLineHelpFlags() {
|
|||
// show only flags related to this binary:
|
||||
// E.g. for fileutil.cc, want flags containing ... "/fileutil." cc
|
||||
ShowUsageWithFlagsMatching(progname, substrings);
|
||||
commandlineflags_exitfunc(1); // almost certainly exit()
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (FLAGS_help || FLAGS_helpfull) {
|
||||
} else if (FLAGS_help || FLAGS_helpful) {
|
||||
// show all options
|
||||
ShowUsageWithFlagsRestrict(progname, ""); // empty restrict
|
||||
commandlineflags_exitfunc(1);
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (!FLAGS_helpon.empty()) {
|
||||
string restrict = "/" + FLAGS_helpon + ".";
|
||||
ShowUsageWithFlagsRestrict(progname, restrict.c_str());
|
||||
commandlineflags_exitfunc(1);
|
||||
string restrict_ = PATH_SEPARATOR + FLAGS_helpon + ".";
|
||||
ShowUsageWithFlagsRestrict(progname, restrict_.c_str());
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (!FLAGS_helpmatch.empty()) {
|
||||
ShowUsageWithFlagsRestrict(progname, FLAGS_helpmatch.c_str());
|
||||
commandlineflags_exitfunc(1);
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (FLAGS_helppackage) {
|
||||
// Shows help for all files in the same directory as main(). We
|
||||
|
@ -413,31 +411,32 @@ void HandleCommandLineHelpFlags() {
|
|||
++flag) {
|
||||
if (!FileMatchesSubstring(flag->filename, substrings))
|
||||
continue;
|
||||
const string package = Dirname(flag->filename) + "/";
|
||||
const string package = Dirname(flag->filename) + PATH_SEPARATOR;
|
||||
if (package != last_package) {
|
||||
ShowUsageWithFlagsRestrict(progname, package.c_str());
|
||||
VLOG(7) << "Found package: " << package;
|
||||
if (!last_package.empty()) { // means this isn't our first pkg
|
||||
fprintf(stderr, "WARNING: Multiple packages contain a file=%s\n",
|
||||
progname);
|
||||
LOG(WARNING) << "Multiple packages contain a file=" << progname;
|
||||
}
|
||||
last_package = package;
|
||||
}
|
||||
}
|
||||
if (last_package.empty()) { // never found a package to print
|
||||
fprintf(stderr, "WARNING: Unable to find a package for file=%s\n",
|
||||
progname);
|
||||
LOG(WARNING) << "Unable to find a package for file=" << progname;
|
||||
}
|
||||
commandlineflags_exitfunc(1);
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (FLAGS_helpxml) {
|
||||
ShowXMLOfFlags(progname);
|
||||
commandlineflags_exitfunc(1);
|
||||
gflags_exitfunc(1);
|
||||
|
||||
} else if (FLAGS_version) {
|
||||
ShowVersion();
|
||||
// Unlike help, we may be asking for version in a script, so return 0
|
||||
commandlineflags_exitfunc(0);
|
||||
gflags_exitfunc(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_END_GOOGLE_NAMESPACE_
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
|
|
@ -1,230 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# 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.
|
||||
|
||||
# ---
|
||||
# Author: Craig Silverstein
|
||||
#
|
||||
# Just tries to run gflags_unittest with various flags defined in
|
||||
# gflags.cc, and make sure they give the appropriate exit
|
||||
# status and appropriate error message.
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "USAGE: $0 <unittest exe> [top_srcdir] [tmpdir]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXE="$1"
|
||||
SRCDIR="${2:-./}"
|
||||
TMPDIR="${3:-/tmp/gflags}"
|
||||
|
||||
# Executables built with the main source file suffixed with "-main" and "_main".
|
||||
EXE2="${EXE}2" # eg, gflags_unittest2
|
||||
EXE3="${EXE}3" # eg, gflags_unittest3
|
||||
|
||||
# $1: executable
|
||||
# $2: line-number $3: expected return code. $4: substring of expected output.
|
||||
# $5: a substring you *don't* expect to find in the output. $6+ flags
|
||||
ExpectExe() {
|
||||
local executable="$1"
|
||||
shift
|
||||
local line_number="$1"
|
||||
shift
|
||||
local expected_rc="$1"
|
||||
shift
|
||||
local expected_output="$1"
|
||||
shift
|
||||
local unexpected_output="$1"
|
||||
shift
|
||||
|
||||
# We always add --srcdir=$SRCDIR because it's needed for correctness
|
||||
"$executable" --srcdir="$SRCDIR" "$@" > "$TMPDIR/test.$line_number" 2>&1
|
||||
local actual_rc=$?
|
||||
if [ $actual_rc != $expected_rc ]; then
|
||||
echo "Test on line $line_number failed:" \
|
||||
"expected rc $expected_rc, got $actual_rc"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -n "$expected_output" ] &&
|
||||
! fgrep -e "$expected_output" "$TMPDIR/test.$line_number" >/dev/null; then
|
||||
echo "Test on line $line_number failed:" \
|
||||
"did not find expected substring '$expected_output'"
|
||||
exit 1;
|
||||
fi
|
||||
if [ -n "$unexpected_output" ] &&
|
||||
fgrep -e "$unexpected_output" "$TMPDIR/test.$line_number" >/dev/null; then
|
||||
echo "Test line $line_number failed:" \
|
||||
"found unexpected substring '$unexpected_output'"
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
# $1: line-number $2: expected return code. $3: substring of expected output.
|
||||
# $4: a substring you *don't* expect to find in the output. $5+ flags
|
||||
Expect() {
|
||||
ExpectExe "$EXE" "$@"
|
||||
}
|
||||
|
||||
rm -rf "$TMPDIR"
|
||||
mkdir "$TMPDIR" || exit 2
|
||||
|
||||
# Create a few flagfiles we can use later
|
||||
echo "--version" > "$TMPDIR/flagfile.1"
|
||||
echo "--foo=bar" > "$TMPDIR/flagfile.2"
|
||||
echo "--nounused_bool" >> "$TMPDIR/flagfile.2"
|
||||
echo "--flagfile=$TMPDIR/flagfile.2" > "$TMPDIR/flagfile.3"
|
||||
|
||||
# Set a few environment variables (useful for --tryfromenv)
|
||||
export FLAGS_undefok=foo,bar
|
||||
export FLAGS_weirdo=
|
||||
export FLAGS_version=true
|
||||
export FLAGS_help=false
|
||||
|
||||
# First, just make sure the unittest works as-is
|
||||
Expect $LINENO 0 "PASS" ""
|
||||
|
||||
# --help should show all flags, including flags from gflags_reporting.cc
|
||||
Expect $LINENO 1 "/gflags_reporting.cc" "" --help
|
||||
|
||||
# Make sure --help reflects flag changes made before flag-parsing
|
||||
Expect $LINENO 1 \
|
||||
"-changed_bool1 (changed) type: bool default: true" "" --help
|
||||
Expect $LINENO 1 \
|
||||
"-changed_bool2 (changed) type: bool default: true" "" --help
|
||||
|
||||
# --nohelp and --help=false should be as if we didn't say anything
|
||||
Expect $LINENO 0 "PASS" "" --nohelp
|
||||
Expect $LINENO 0 "PASS" "" --help=false
|
||||
|
||||
# --helpfull is the same as help
|
||||
Expect $LINENO 1 "/gflags_reporting.cc" "" -helpfull
|
||||
|
||||
# --helpshort should show only flags from the unittest itself
|
||||
Expect $LINENO 1 "/gflags_unittest.cc" "/gflags_reporting.cc" --helpshort
|
||||
|
||||
# --helpshort should show the tldflag we created in the unittest dir
|
||||
Expect $LINENO 1 "tldflag1" "/google.cc" --helpshort
|
||||
Expect $LINENO 1 "tldflag2" "/google.cc" --helpshort
|
||||
|
||||
# --helpshort should work if the main source file is suffixed with [_-]main
|
||||
ExpectExe "$EXE2" $LINENO 1 "/gflags_unittest-main.cc" "/gflags_reporting.cc" \
|
||||
--helpshort
|
||||
ExpectExe "$EXE3" $LINENO 1 "/gflags_unittest_main.cc" "/gflags_reporting.cc" \
|
||||
--helpshort
|
||||
|
||||
# --helpon needs an argument
|
||||
Expect $LINENO 1 \
|
||||
"'--helpon' is missing its argument; flag description: show help on" \
|
||||
"" --helpon
|
||||
|
||||
# --helpon argument indicates what file we'll show args from
|
||||
Expect $LINENO 1 "/gflags.cc" "/gflags_unittest.cc" --helpon=gflags
|
||||
|
||||
# another way of specifying the argument
|
||||
Expect $LINENO 1 "/gflags.cc" "/gflags_unittest.cc" --helpon gflags
|
||||
|
||||
# test another argument
|
||||
Expect $LINENO 1 "/gflags_unittest.cc" "/gflags.cc" \
|
||||
--helpon gflags_unittest
|
||||
|
||||
# helpmatch is like helpon but takes substrings
|
||||
Expect $LINENO 1 "/gflags_reporting.cc" "/gflags_unittest.cc" \
|
||||
-helpmatch reporting
|
||||
Expect $LINENO 1 "/gflags_unittest.cc" "/gflags.cc" \
|
||||
-helpmatch=unittest
|
||||
|
||||
# if no flags are found with helpmatch or helpon, suggest --help
|
||||
Expect $LINENO 1 "No modules matched" "/gflags_unittest.cc" \
|
||||
-helpmatch=nosuchsubstring
|
||||
Expect $LINENO 1 "No modules matched" "/gflags_unittest.cc" \
|
||||
-helpon=nosuchmodule
|
||||
|
||||
# helppackage shows all the flags in the same dir as this unittest
|
||||
# --help should show all flags, including flags from google.cc
|
||||
Expect $LINENO 1 "/gflags_reporting.cc" "" --helppackage
|
||||
|
||||
# xml!
|
||||
Expect $LINENO 1 "/gflags_unittest.cc</file>" \
|
||||
"/gflags_unittest.cc:" --helpxml
|
||||
|
||||
# just print the version info and exit
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" --version
|
||||
|
||||
# --undefok is a fun flag...
|
||||
Expect $LINENO 1 "unknown command line flag 'foo'" "" --undefok= --foo --unused_bool
|
||||
Expect $LINENO 0 "PASS" "" --undefok=foo --foo --unused_bool
|
||||
# If you say foo is ok to be undefined, we'll accept --nofoo as well
|
||||
Expect $LINENO 0 "PASS" "" --undefok=foo --nofoo --unused_bool
|
||||
# It's ok if the foo is in the middle
|
||||
Expect $LINENO 0 "PASS" "" --undefok=fee,fi,foo,fum --foo --unused_bool
|
||||
# But the spelling has to be just right...
|
||||
Expect $LINENO 1 "unknown command line flag 'foo'" "" --undefok=fo --foo --unused_bool
|
||||
Expect $LINENO 1 "unknown command line flag 'foo'" "" --undefok=foot --foo --unused_bool
|
||||
|
||||
# See if we can successfully load our flags from the flagfile
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" \
|
||||
--flagfile="$TMPDIR/flagfile.1"
|
||||
Expect $LINENO 0 "PASS" "" --flagfile="$TMPDIR/flagfile.2"
|
||||
Expect $LINENO 0 "PASS" "" --flagfile="$TMPDIR/flagfile.3"
|
||||
|
||||
# Also try to load flags from the environment
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" --fromenv=version
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" --tryfromenv=version
|
||||
Expect $LINENO 0 "PASS" "" --fromenv=help
|
||||
Expect $LINENO 0 "PASS" "" --tryfromenv=help
|
||||
Expect $LINENO 1 "helpfull not found in environment" "" --fromenv=helpfull
|
||||
Expect $LINENO 0 "PASS" "" --tryfromenv=helpfull
|
||||
Expect $LINENO 0 "PASS" "" --tryfromenv=undefok --foo
|
||||
Expect $LINENO 1 "unknown command line flag" "" --tryfromenv=weirdo
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" \
|
||||
--tryfromenv=test_bool,version,unused_bool
|
||||
Expect $LINENO 1 "not found in environment" "" --fromenv=test_bool
|
||||
Expect $LINENO 1 "unknown command line flag" "" --fromenv=test_bool,ok
|
||||
# Here, the --version overrides the fromenv
|
||||
Expect $LINENO 0 "gflags_unittest" "gflags_unittest.cc" \
|
||||
--fromenv=test_bool,version,ok
|
||||
|
||||
# Make sure -- by itself stops argv processing
|
||||
Expect $LINENO 0 "PASS" "" -- --help
|
||||
|
||||
# Make sure boolean flags gives warning when type of default value is not bool
|
||||
Expect $LINENO 0 "Flag test_bool_string is of type bool, but its default value is not a boolean." ""
|
||||
Expect $LINENO 0 "Flag test_bool_float is of type bool, but its default value is not a boolean." ""
|
||||
Expect $LINENO 0 "Flag test_bool_int is of type bool, but its default value is not a boolean." ""
|
||||
|
||||
# Make sure that boolean flags don't give warning when default value is bool
|
||||
Expect $LINENO 0 "" "Flag test_bool_bool is of type bool, but its default value is not a boolean."
|
||||
|
||||
# And we should die if the flag value doesn't pas the validator
|
||||
Expect $LINENO 1 "ERROR: failed validation of new value 'true' for flag 'always_fail'" "" --always_fail
|
||||
|
||||
echo "PASS"
|
||||
exit 0
|
109
src/mutex.h
109
src/mutex.h
|
@ -28,19 +28,16 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---
|
||||
// Author: Craig Silverstein.
|
||||
//
|
||||
// A simple mutex wrapper, supporting locks and read-write locks.
|
||||
// You should assume the locks are *not* re-entrant.
|
||||
//
|
||||
// To use: you should define the following macros in your configure.ac:
|
||||
// ACX_PTHREAD
|
||||
// AC_RWLOCK
|
||||
// The latter is defined in ../autoconf.
|
||||
//
|
||||
// This class is meant to be internal-only, so it's defined in the
|
||||
// global namespace. If you want to expose it, you'll want to move
|
||||
// it to the Google namespace.
|
||||
// This class is meant to be internal-only and should be wrapped by an
|
||||
// internal namespace. Before you use this module, please give the
|
||||
// name of your internal namespace for this module. Or, if you want
|
||||
// to expose it, you'll want to move it to the Google namespace. We
|
||||
// cannot put this class in global namespace because there can be some
|
||||
// problems when we have multiple versions of Mutex in each shared object.
|
||||
//
|
||||
// NOTE: by default, we have #ifdef'ed out the TryLock() method.
|
||||
// This is for two reasons:
|
||||
|
@ -95,16 +92,31 @@
|
|||
// colon-initializer) and set it to true via a function that always
|
||||
// evaluates to true, but that the compiler can't know always
|
||||
// evaluates to true. This should be good enough.
|
||||
//
|
||||
// A related issue is code that could try to access the mutex
|
||||
// after it's been destroyed in the global destructors (because
|
||||
// the Mutex global destructor runs before some other global
|
||||
// destructor, that tries to acquire the mutex). The way we
|
||||
// deal with this is by taking a constructor arg that global
|
||||
// mutexes should pass in, that causes the destructor to do no
|
||||
// work. We still depend on the compiler not doing anything
|
||||
// weird to a Mutex's memory after it is destroyed, but for a
|
||||
// static global variable, that's pretty safe.
|
||||
|
||||
#ifndef GOOGLE_MUTEX_H_
|
||||
#define GOOGLE_MUTEX_H_
|
||||
#ifndef GFLAGS_MUTEX_H_
|
||||
#define GFLAGS_MUTEX_H_
|
||||
|
||||
#include "config.h" // to figure out pthreads support
|
||||
#include "gflags/gflags_declare.h" // to figure out pthreads support
|
||||
|
||||
#if defined(NO_THREADS)
|
||||
typedef int MutexType; // to keep a lock-count
|
||||
#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
|
||||
# define WIN32_LEAN_AND_MEAN // We only need minimal includes
|
||||
typedef int MutexType; // to keep a lock-count
|
||||
#elif defined(OS_WINDOWS)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN // We only need minimal includes
|
||||
# endif
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX // Don't want windows to override min()/max()
|
||||
# endif
|
||||
# ifdef GMUTEX_TRYLOCK
|
||||
// We need Windows NT or later for TryEnterCriticalSection(). If you
|
||||
// don't need that functionality, you can remove these _WIN32_WINNT
|
||||
|
@ -121,7 +133,10 @@
|
|||
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
|
||||
// for locking there.)
|
||||
# ifdef __linux__
|
||||
# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
|
||||
# if _XOPEN_SOURCE < 500 // including not being defined at all
|
||||
# undef _XOPEN_SOURCE
|
||||
# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
|
||||
# endif
|
||||
# endif
|
||||
# include <pthread.h>
|
||||
typedef pthread_rwlock_t MutexType;
|
||||
|
@ -132,13 +147,26 @@
|
|||
# error Need to implement mutex.h for your architecture, or #define NO_THREADS
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h> // for abort()
|
||||
|
||||
#define MUTEX_NAMESPACE gflags_mutex_namespace
|
||||
|
||||
namespace MUTEX_NAMESPACE {
|
||||
|
||||
class Mutex {
|
||||
public:
|
||||
// This is used for the single-arg constructor
|
||||
enum LinkerInitialized { LINKER_INITIALIZED };
|
||||
|
||||
// Create a Mutex that is not held by anybody. This constructor is
|
||||
// typically used for Mutexes allocated on the heap or the stack.
|
||||
// See below for a recommendation for constructing global Mutex
|
||||
// objects.
|
||||
inline Mutex();
|
||||
// This constructor should be used for global, static Mutex objects.
|
||||
// It inhibits work being done by the destructor, which makes it
|
||||
// safer for code that tries to acqiure this mutex in their global
|
||||
// destructor.
|
||||
explicit inline Mutex(LinkerInitialized);
|
||||
|
||||
// Destructor
|
||||
inline ~Mutex();
|
||||
|
@ -163,11 +191,13 @@ class Mutex {
|
|||
// when we tell it to, and never makes assumptions is_safe_ is
|
||||
// always true. volatile is the most reliable way to do that.
|
||||
volatile bool is_safe_;
|
||||
// This indicates which constructor was called.
|
||||
bool destroy_;
|
||||
|
||||
inline void SetIsSafe() { is_safe_ = true; }
|
||||
|
||||
// Catch the error of writing Mutex when intending MutexLock.
|
||||
Mutex(Mutex* /*ignored*/) {}
|
||||
explicit Mutex(Mutex* /*ignored*/) {}
|
||||
// Disallow "evil" constructors
|
||||
Mutex(const Mutex&);
|
||||
void operator=(const Mutex&);
|
||||
|
@ -185,9 +215,9 @@ class Mutex {
|
|||
// In debug mode, we assert these invariants, while in non-debug mode
|
||||
// we do nothing, for efficiency. That's why everything is in an
|
||||
// assert.
|
||||
#include <assert.h>
|
||||
|
||||
Mutex::Mutex() : mutex_(0) { }
|
||||
Mutex::Mutex(Mutex::LinkerInitialized) : mutex_(0) { }
|
||||
Mutex::~Mutex() { assert(mutex_ == 0); }
|
||||
void Mutex::Lock() { assert(--mutex_ == -1); }
|
||||
void Mutex::Unlock() { assert(mutex_++ == -1); }
|
||||
|
@ -197,10 +227,17 @@ bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
|
|||
void Mutex::ReaderLock() { assert(++mutex_ > 0); }
|
||||
void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
|
||||
|
||||
#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
|
||||
#elif defined(OS_WINDOWS)
|
||||
|
||||
Mutex::Mutex() { InitializeCriticalSection(&mutex_); SetIsSafe(); }
|
||||
Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
|
||||
Mutex::Mutex() : destroy_(true) {
|
||||
InitializeCriticalSection(&mutex_);
|
||||
SetIsSafe();
|
||||
}
|
||||
Mutex::Mutex(LinkerInitialized) : destroy_(false) {
|
||||
InitializeCriticalSection(&mutex_);
|
||||
SetIsSafe();
|
||||
}
|
||||
Mutex::~Mutex() { if (destroy_) DeleteCriticalSection(&mutex_); }
|
||||
void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); }
|
||||
void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); }
|
||||
#ifdef GMUTEX_TRYLOCK
|
||||
|
@ -212,22 +249,24 @@ void Mutex::ReaderUnlock() { Unlock(); }
|
|||
|
||||
#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
|
||||
|
||||
#include <stdlib.h> // for abort()
|
||||
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
|
||||
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
|
||||
} while (0)
|
||||
|
||||
Mutex::Mutex() {
|
||||
Mutex::Mutex() : destroy_(true) {
|
||||
SetIsSafe();
|
||||
if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
|
||||
}
|
||||
Mutex::~Mutex() { SAFE_PTHREAD(pthread_rwlock_destroy); }
|
||||
Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) {
|
||||
SetIsSafe();
|
||||
if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
|
||||
}
|
||||
Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_rwlock_destroy); }
|
||||
void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock); }
|
||||
void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
|
||||
#ifdef GMUTEX_TRYLOCK
|
||||
bool Mutex::TryLock() { return is_safe_ ?
|
||||
pthread_rwlock_trywrlock(&mutex_) == 0 :
|
||||
true; }
|
||||
pthread_rwlock_trywrlock(&mutex_) == 0 : true; }
|
||||
#endif
|
||||
void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); }
|
||||
void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
|
||||
|
@ -235,16 +274,19 @@ void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
|
|||
|
||||
#elif defined(HAVE_PTHREAD)
|
||||
|
||||
#include <stdlib.h> // for abort()
|
||||
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
|
||||
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
|
||||
} while (0)
|
||||
|
||||
Mutex::Mutex() {
|
||||
Mutex::Mutex() : destroy_(true) {
|
||||
SetIsSafe();
|
||||
if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
|
||||
}
|
||||
Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy); }
|
||||
Mutex::Mutex(Mutex::LinkerInitialized) : destroy_(false) {
|
||||
SetIsSafe();
|
||||
if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
|
||||
}
|
||||
Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_mutex_destroy); }
|
||||
void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); }
|
||||
void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); }
|
||||
#ifdef GMUTEX_TRYLOCK
|
||||
|
@ -300,4 +342,7 @@ class WriterMutexLock {
|
|||
#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
|
||||
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
|
||||
|
||||
#endif /* #define GOOGLE_MUTEX_H__ */
|
||||
} // namespace MUTEX_NAMESPACE
|
||||
|
||||
|
||||
#endif /* #define GFLAGS_MUTEX_H__ */
|
||||
|
|
373
src/util.h
Normal file
373
src/util.h
Normal file
|
@ -0,0 +1,373 @@
|
|||
// Copyright (c) 2011, 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.
|
||||
// ---
|
||||
//
|
||||
// Some generically useful utility routines that in google-land would
|
||||
// be their own projects. We make a shortened version here.
|
||||
|
||||
#ifndef GFLAGS_UTIL_H_
|
||||
#define GFLAGS_UTIL_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <assert.h>
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#include <stdarg.h> // for va_*
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h> // for mkdir
|
||||
#endif
|
||||
|
||||
|
||||
namespace GFLAGS_NAMESPACE {
|
||||
|
||||
|
||||
// This is used for unittests for death-testing. It is defined in gflags.cc.
|
||||
extern GFLAGS_DLL_DECL void (*gflags_exitfunc)(int);
|
||||
|
||||
// Work properly if either strtoll or strtoq is on this system.
|
||||
#if defined(strtoll) || defined(HAVE_STRTOLL)
|
||||
# define strto64 strtoll
|
||||
# define strtou64 strtoull
|
||||
#elif defined(HAVE_STRTOQ)
|
||||
# define strto64 strtoq
|
||||
# define strtou64 strtouq
|
||||
// Neither strtoll nor strtoq are defined. I hope strtol works!
|
||||
#else
|
||||
# define strto64 strtol
|
||||
# define strtou64 strtoul
|
||||
#endif
|
||||
|
||||
// If we have inttypes.h, it will have defined PRId32/etc for us.
|
||||
// If not, take our best guess.
|
||||
#ifndef PRId32
|
||||
# define PRId32 "d"
|
||||
#endif
|
||||
#ifndef PRId64
|
||||
# define PRId64 "lld"
|
||||
#endif
|
||||
#ifndef PRIu64
|
||||
# define PRIu64 "llu"
|
||||
#endif
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
|
||||
// -- utility macros ---------------------------------------------------------
|
||||
|
||||
template <bool b> struct CompileAssert;
|
||||
template <> struct CompileAssert<true> {};
|
||||
#define COMPILE_ASSERT(expr, msg) \
|
||||
enum { assert_##msg = sizeof(CompileAssert<bool(expr)>) }
|
||||
|
||||
// Returns the number of elements in an array.
|
||||
#define arraysize(arr) (sizeof(arr)/sizeof(*(arr)))
|
||||
|
||||
|
||||
// -- logging and testing ---------------------------------------------------
|
||||
|
||||
// For now, we ignore the level for logging, and don't show *VLOG's at
|
||||
// all, except by hand-editing the lines below
|
||||
#define LOG(level) std::cerr
|
||||
#define VLOG(level) if (true) {} else std::cerr
|
||||
#define DVLOG(level) if (true) {} else std::cerr
|
||||
|
||||
// CHECK dies with a fatal error if condition is not true. It is *not*
|
||||
// controlled by NDEBUG, so the check will be executed regardless of
|
||||
// compilation mode. Therefore, it is safe to do things like:
|
||||
// CHECK(fp->Write(x) == 4)
|
||||
// We allow stream-like objects after this for debugging, but they're ignored.
|
||||
#define EXPECT_TRUE(condition) \
|
||||
if (true) { \
|
||||
if (!(condition)) { \
|
||||
fprintf(stderr, "Check failed: %s\n", #condition); \
|
||||
exit(1); \
|
||||
} \
|
||||
} else std::cerr << ""
|
||||
|
||||
#define EXPECT_OP(op, val1, val2) \
|
||||
if (true) { \
|
||||
if (!((val1) op (val2))) { \
|
||||
fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \
|
||||
exit(1); \
|
||||
} \
|
||||
} else std::cerr << ""
|
||||
|
||||
#define EXPECT_EQ(val1, val2) EXPECT_OP(==, val1, val2)
|
||||
#define EXPECT_NE(val1, val2) EXPECT_OP(!=, val1, val2)
|
||||
#define EXPECT_LE(val1, val2) EXPECT_OP(<=, val1, val2)
|
||||
#define EXPECT_LT(val1, val2) EXPECT_OP(< , val1, val2)
|
||||
#define EXPECT_GE(val1, val2) EXPECT_OP(>=, val1, val2)
|
||||
#define EXPECT_GT(val1, val2) EXPECT_OP(> , val1, val2)
|
||||
#define EXPECT_FALSE(cond) EXPECT_TRUE(!(cond))
|
||||
|
||||
// C99 declares isnan and isinf should be macros, so the #ifdef test
|
||||
// should be reliable everywhere. Of course, it's not, but these
|
||||
// are testing pertty marginal functionality anyway, so it's ok to
|
||||
// not-run them even in situations they might, with effort, be made to work.
|
||||
#ifdef isnan // Some compilers, like sun's for Solaris 10, don't define this
|
||||
#define EXPECT_NAN(arg) \
|
||||
do { \
|
||||
if (!isnan(arg)) { \
|
||||
fprintf(stderr, "Check failed: isnan(%s)\n", #arg); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define EXPECT_NAN(arg)
|
||||
#endif
|
||||
|
||||
#ifdef isinf // Some compilers, like sun's for Solaris 10, don't define this
|
||||
#define EXPECT_INF(arg) \
|
||||
do { \
|
||||
if (!isinf(arg)) { \
|
||||
fprintf(stderr, "Check failed: isinf(%s)\n", #arg); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define EXPECT_INF(arg)
|
||||
#endif
|
||||
|
||||
#define EXPECT_DOUBLE_EQ(val1, val2) \
|
||||
do { \
|
||||
if (((val1) < (val2) - 0.001 || (val1) > (val2) + 0.001)) { \
|
||||
fprintf(stderr, "Check failed: %s == %s\n", #val1, #val2); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define EXPECT_STREQ(val1, val2) \
|
||||
do { \
|
||||
if (strcmp((val1), (val2)) != 0) { \
|
||||
fprintf(stderr, "Check failed: streq(%s, %s)\n", #val1, #val2); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Call this in a .cc file where you will later call RUN_ALL_TESTS in main().
|
||||
#define TEST_INIT \
|
||||
static std::vector<void (*)()> g_testlist; /* the tests to run */ \
|
||||
static int RUN_ALL_TESTS() { \
|
||||
std::vector<void (*)()>::const_iterator it; \
|
||||
for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { \
|
||||
(*it)(); /* The test will error-exit if there's a problem. */ \
|
||||
} \
|
||||
fprintf(stderr, "\nPassed %d tests\n\nPASS\n", \
|
||||
static_cast<int>(g_testlist.size())); \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
// Note that this macro uses a FlagSaver to keep tests isolated.
|
||||
#define TEST(a, b) \
|
||||
struct Test_##a##_##b { \
|
||||
Test_##a##_##b() { g_testlist.push_back(&Run); } \
|
||||
static void Run() { \
|
||||
FlagSaver fs; \
|
||||
fprintf(stderr, "Running test %s/%s\n", #a, #b); \
|
||||
RunTest(); \
|
||||
} \
|
||||
static void RunTest(); \
|
||||
}; \
|
||||
static Test_##a##_##b g_test_##a##_##b; \
|
||||
void Test_##a##_##b::RunTest()
|
||||
|
||||
// This is a dummy class that eases the google->opensource transition.
|
||||
namespace testing {
|
||||
class Test {};
|
||||
}
|
||||
|
||||
// Call this in a .cc file where you will later call EXPECT_DEATH
|
||||
#define EXPECT_DEATH_INIT \
|
||||
static bool g_called_exit; \
|
||||
static void CalledExit(int) { g_called_exit = true; }
|
||||
|
||||
#define EXPECT_DEATH(fn, msg) \
|
||||
do { \
|
||||
g_called_exit = false; \
|
||||
gflags_exitfunc = &CalledExit; \
|
||||
fn; \
|
||||
gflags_exitfunc = &exit; /* set back to its default */ \
|
||||
if (!g_called_exit) { \
|
||||
fprintf(stderr, "Function didn't die (%s): %s\n", msg, #fn); \
|
||||
exit(1); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define GTEST_HAS_DEATH_TEST 1
|
||||
|
||||
// -- path routines ----------------------------------------------------------
|
||||
|
||||
// Tries to create the directory path as a temp-dir. If it fails,
|
||||
// changes path to some directory it *can* create.
|
||||
#if defined(__MINGW32__)
|
||||
#include <io.h>
|
||||
inline void MakeTmpdir(std::string* path) {
|
||||
if (!path->empty()) {
|
||||
path->append("/gflags_unittest_testdir");
|
||||
int err = mkdir(path->c_str());
|
||||
if (err == 0 || errno == EEXIST) return;
|
||||
}
|
||||
// I had trouble creating a directory in /tmp from mingw
|
||||
*path = "./gflags_unittest";
|
||||
mkdir(path->c_str());
|
||||
}
|
||||
#elif defined(_MSC_VER)
|
||||
#include <direct.h>
|
||||
inline void MakeTmpdir(std::string* path) {
|
||||
if (!path->empty()) {
|
||||
int err = _mkdir(path->c_str());
|
||||
if (err == 0 || errno == EEXIST) return;
|
||||
}
|
||||
char tmppath_buffer[1024];
|
||||
int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
|
||||
assert(tmppath_len > 0 && tmppath_len < sizeof(tmppath_buffer));
|
||||
assert(tmppath_buffer[tmppath_len - 1] == '\\'); // API guarantees it
|
||||
*path = std::string(tmppath_buffer) + "gflags_unittest";
|
||||
_mkdir(path->c_str());
|
||||
}
|
||||
#else
|
||||
inline void MakeTmpdir(std::string* path) {
|
||||
if (!path->empty()) {
|
||||
int err = mkdir(path->c_str(), 0755);
|
||||
if (err == 0 || errno == EEXIST) return;
|
||||
}
|
||||
mkdir("/tmp/gflags_unittest", 0755);
|
||||
}
|
||||
#endif
|
||||
|
||||
// -- string routines --------------------------------------------------------
|
||||
|
||||
inline void InternalStringPrintf(std::string* output, const char* format,
|
||||
va_list ap) {
|
||||
char space[128]; // try a small buffer and hope it fits
|
||||
|
||||
// It's possible for methods that use a va_list to invalidate
|
||||
// the data in it upon use. The fix is to make a copy
|
||||
// of the structure before using it and use that copy instead.
|
||||
va_list backup_ap;
|
||||
va_copy(backup_ap, ap);
|
||||
int bytes_written = vsnprintf(space, sizeof(space), format, backup_ap);
|
||||
va_end(backup_ap);
|
||||
|
||||
if ((bytes_written >= 0) && (static_cast<size_t>(bytes_written) < sizeof(space))) {
|
||||
output->append(space, bytes_written);
|
||||
return;
|
||||
}
|
||||
|
||||
// Repeatedly increase buffer size until it fits.
|
||||
int length = sizeof(space);
|
||||
while (true) {
|
||||
if (bytes_written < 0) {
|
||||
// Older snprintf() behavior. :-( Just try doubling the buffer size
|
||||
length *= 2;
|
||||
} else {
|
||||
// We need exactly "bytes_written+1" characters
|
||||
length = bytes_written+1;
|
||||
}
|
||||
char* buf = new char[length];
|
||||
|
||||
// Restore the va_list before we use it again
|
||||
va_copy(backup_ap, ap);
|
||||
bytes_written = vsnprintf(buf, length, format, backup_ap);
|
||||
va_end(backup_ap);
|
||||
|
||||
if ((bytes_written >= 0) && (bytes_written < length)) {
|
||||
output->append(buf, bytes_written);
|
||||
delete[] buf;
|
||||
return;
|
||||
}
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
|
||||
// Clears output before writing to it.
|
||||
inline void SStringPrintf(std::string* output, const char* format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
output->clear();
|
||||
InternalStringPrintf(output, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
inline void StringAppendF(std::string* output, const char* format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
InternalStringPrintf(output, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
inline std::string StringPrintf(const char* format, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
std::string output;
|
||||
InternalStringPrintf(&output, format, ap);
|
||||
va_end(ap);
|
||||
return output;
|
||||
}
|
||||
|
||||
inline bool SafeGetEnv(const char *varname, std::string &valstr)
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
char *val;
|
||||
size_t sz;
|
||||
if (_dupenv_s(&val, &sz, varname) != 0 || !val) return false;
|
||||
valstr = val;
|
||||
free(val);
|
||||
#else
|
||||
const char * const val = getenv(varname);
|
||||
if (!val) return false;
|
||||
valstr = val;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
inline int SafeFOpen(FILE **fp, const char* fname, const char *mode)
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
return fopen_s(fp, fname, mode);
|
||||
#else
|
||||
assert(fp != NULL);
|
||||
*fp = fopen(fname, mode);
|
||||
// errno only guaranteed to be set on failure
|
||||
return ((*fp == NULL) ? errno : 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
} // namespace GFLAGS_NAMESPACE
|
||||
|
||||
|
||||
#endif // GFLAGS_UTIL_H_
|
73
src/windows_port.cc
Normal file
73
src/windows_port.cc
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* Copyright (c) 2009, 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.
|
||||
*
|
||||
* ---
|
||||
* Author: Craig Silverstein
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
# error You should only be including windows/port.cc in a windows environment!
|
||||
#endif
|
||||
|
||||
#include <string.h> // for strlen(), memset(), memcmp()
|
||||
#include <assert.h>
|
||||
#include <stdarg.h> // for va_list, va_start, va_end
|
||||
#include <windows.h>
|
||||
|
||||
#include "windows_port.h"
|
||||
|
||||
// These call the windows _vsnprintf, but always NUL-terminate.
|
||||
#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */
|
||||
#if !(defined(_MSC_VER) && _MSC_VER >= 1900) /* msvc 2015 already defines */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4996) // ignore _vsnprintf security warning
|
||||
#endif
|
||||
int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
||||
if (size == 0) // not even room for a \0?
|
||||
return -1; // not what C99 says to do, but what windows does
|
||||
str[size-1] = '\0';
|
||||
return _vsnprintf(str, size-1, format, ap);
|
||||
}
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
int snprintf(char *str, size_t size, const char *format, ...) {
|
||||
int r;
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
r = vsnprintf(str, size, format, ap);
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* if !(defined(_MSC_VER) && _MSC_VER >= 1900) */
|
||||
#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
|
135
src/windows_port.h
Normal file
135
src/windows_port.h
Normal file
|
@ -0,0 +1,135 @@
|
|||
/* Copyright (c) 2009, 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.
|
||||
*
|
||||
* ---
|
||||
* Author: Craig Silverstein
|
||||
*
|
||||
* These are some portability typedefs and defines to make it a bit
|
||||
* easier to compile this code under VC++.
|
||||
*
|
||||
* Several of these are taken from glib:
|
||||
* http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html
|
||||
*/
|
||||
|
||||
#ifndef GFLAGS_WINDOWS_PORT_H_
|
||||
#define GFLAGS_WINDOWS_PORT_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
// This must be defined before the windows.h is included.
|
||||
// It's needed for mutex.h, to give access to the TryLock method.
|
||||
# if !defined(_WIN32_WINNT) && !(defined( __MINGW32__) || defined(__MINGW64__))
|
||||
# define _WIN32_WINNT 0x0400
|
||||
# endif
|
||||
// We always want minimal includes
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <direct.h> /* for mkdir */
|
||||
#include <stdlib.h> /* for _putenv, getenv */
|
||||
#include <stdio.h> /* need this to override stdio's snprintf, also defines _unlink used by unit tests */
|
||||
#include <stdarg.h> /* util.h uses va_copy */
|
||||
#include <string.h> /* for _stricmp and _strdup */
|
||||
|
||||
/* We can't just use _vsnprintf and _snprintf as drop-in-replacements,
|
||||
* because they don't always NUL-terminate. :-( We also can't use the
|
||||
* name vsnprintf, since windows defines that (but not snprintf (!)).
|
||||
*/
|
||||
#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */
|
||||
#if !(defined(_MSC_VER) && _MSC_VER >= 1900) /* msvc 2015 already defines */
|
||||
extern GFLAGS_DLL_DECL int snprintf(char *str, size_t size,
|
||||
const char *format, ...);
|
||||
extern int GFLAGS_DLL_DECL safe_vsnprintf(char *str, size_t size,
|
||||
const char *format, va_list ap);
|
||||
#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
|
||||
#define va_copy(dst, src) (dst) = (src)
|
||||
#endif
|
||||
#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4996) // ignore getenv security warning
|
||||
#endif
|
||||
#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 200112L
|
||||
inline void setenv(const char* name, const char* value, int) {
|
||||
// In windows, it's impossible to set a variable to the empty string.
|
||||
// We handle this by setting it to "0" and the NUL-ing out the \0.
|
||||
// That is, we putenv("FOO=0") and then find out where in memory the
|
||||
// putenv wrote "FOO=0", and change it in-place to "FOO=\0".
|
||||
// c.f. http://svn.apache.org/viewvc/stdcxx/trunk/tests/src/environ.cpp?r1=611451&r2=637508&pathrev=637508
|
||||
static const char* const kFakeZero = "0";
|
||||
if (*value == '\0')
|
||||
value = kFakeZero;
|
||||
// Apparently the semantics of putenv() is that the input
|
||||
// must live forever, so we leak memory here. :-(
|
||||
const size_t nameval_len = strlen(name) + 1 + strlen(value) + 1;
|
||||
char* nameval = reinterpret_cast<char*>(malloc(nameval_len));
|
||||
snprintf(nameval, nameval_len, "%s=%s", name, value);
|
||||
_putenv(nameval);
|
||||
if (value == kFakeZero) {
|
||||
nameval[nameval_len - 2] = '\0'; // works when putenv() makes no copy
|
||||
if (*getenv(name) != '\0')
|
||||
*getenv(name) = '\0'; // works when putenv() copies nameval
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
#define strdup _strdup
|
||||
#define unlink _unlink
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1800
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
#define PRId32 "d"
|
||||
#define PRIu32 "u"
|
||||
#define PRId64 "I64d"
|
||||
#define PRIu64 "I64u"
|
||||
#endif
|
||||
|
||||
#if !defined(__MINGW32__) && !defined(__MINGW64__)
|
||||
#define strtoq _strtoi64
|
||||
#define strtouq _strtoui64
|
||||
#define strtoll _strtoi64
|
||||
#define strtoull _strtoui64
|
||||
#define atoll _atoi64
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#endif /* GFLAGS_WINDOWS_PORT_H_ */
|
227
test/CMakeLists.txt
Normal file
227
test/CMakeLists.txt
Normal file
|
@ -0,0 +1,227 @@
|
|||
## gflags tests
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# output directories
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
|
||||
# set working directory of test commands
|
||||
set (GFLAGS_FLAGFILES_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# common include directories and link libraries
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
include_directories ("${gflags_SOURCE_DIR}/src")
|
||||
include_directories ("${gflags_BINARY_DIR}/include")
|
||||
include_directories ("${gflags_BINARY_DIR}/include/gflags")
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
set (type shared)
|
||||
if (GFLAGS_IS_A_DLL)
|
||||
add_definitions(-DGFLAGS_IS_A_DLL)
|
||||
endif ()
|
||||
else ()
|
||||
set (type static)
|
||||
endif ()
|
||||
if (BUILD_gflags_LIB)
|
||||
link_libraries (gflags_${type})
|
||||
else ()
|
||||
link_libraries (gflags_nothreads_${type})
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# STRIP_FLAG_HELP
|
||||
add_executable (gflags_strip_flags_test gflags_strip_flags_test.cc)
|
||||
# Make sure the --help output doesn't print the stripped text.
|
||||
add_gflags_test (strip_flags_help 1 "" "This text should be stripped out" gflags_strip_flags_test --help)
|
||||
# Make sure the stripped text isn't in the binary at all.
|
||||
add_test (
|
||||
NAME strip_flags_binary
|
||||
COMMAND "${CMAKE_COMMAND}" "-DBINARY=$<TARGET_FILE:gflags_strip_flags_test>"
|
||||
-P "${CMAKE_CURRENT_SOURCE_DIR}/gflags_strip_flags_test.cmake"
|
||||
CONFIGURATIONS Release MinSizeRel
|
||||
)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# unit tests
|
||||
configure_file (gflags_unittest.cc gflags_unittest-main.cc COPYONLY)
|
||||
configure_file (gflags_unittest.cc gflags_unittest_main.cc COPYONLY)
|
||||
|
||||
add_executable (gflags_unittest gflags_unittest.cc)
|
||||
add_executable (gflags_unittest-main gflags_unittest-main.cc)
|
||||
add_executable (gflags_unittest_main gflags_unittest_main.cc)
|
||||
|
||||
if (OS_WINDOWS)
|
||||
set (SLASH "\\\\")
|
||||
else ()
|
||||
set (SLASH "/")
|
||||
endif ()
|
||||
|
||||
# First, just make sure the gflags_unittest works as-is
|
||||
add_gflags_test(unittest 0 "" "" gflags_unittest)
|
||||
|
||||
# --help should show all flags, including flags from gflags_reporting
|
||||
add_gflags_test(help-reporting 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --help)
|
||||
|
||||
# Make sure that --help prints even very long helpstrings.
|
||||
add_gflags_test(long-helpstring 1 "end of a long helpstring" "" gflags_unittest --help)
|
||||
|
||||
# Make sure --help reflects flag changes made before flag-parsing
|
||||
add_gflags_test(changed_bool1 1 "-changed_bool1 (changed) type: bool default: true" "" gflags_unittest --help)
|
||||
add_gflags_test(changed_bool2 1 "-changed_bool2 (changed) type: bool default: false currently: true" "" gflags_unittest --help)
|
||||
# And on the command-line, too
|
||||
add_gflags_test(changeable_string_var 1 "-changeable_string_var () type: string default: \"1\" currently: \"2\"" "" gflags_unittest --changeable_string_var 2 --help)
|
||||
|
||||
# --nohelp and --help=false should be as if we didn't say anything
|
||||
add_gflags_test(nohelp 0 "PASS" "" gflags_unittest --nohelp)
|
||||
add_gflags_test(help=false 0 "PASS" "" gflags_unittest --help=false)
|
||||
|
||||
# --helpful is the same as help
|
||||
add_gflags_test(helpful 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helpful)
|
||||
|
||||
# --helpshort should show only flags from the gflags_unittest itself
|
||||
add_gflags_test(helpshort 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest --helpshort)
|
||||
|
||||
# --helpshort should show the tldflag we created in the gflags_unittest dir
|
||||
add_gflags_test(helpshort-tldflag1 1 "tldflag1" "${SLASH}google.cc:" gflags_unittest --helpshort)
|
||||
add_gflags_test(helpshort-tldflag2 1 "tldflag2" "${SLASH}google.cc:" gflags_unittest --helpshort)
|
||||
|
||||
# --helpshort should work if the main source file is suffixed with [_-]main
|
||||
add_gflags_test(helpshort-main 1 "${SLASH}gflags_unittest-main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest-main --helpshort)
|
||||
add_gflags_test(helpshort_main 1 "${SLASH}gflags_unittest_main.cc:" "${SLASH}gflags_reporting.cc:" gflags_unittest_main --helpshort)
|
||||
|
||||
# --helpon needs an argument
|
||||
add_gflags_test(helpon 1 "'--helpon' is missing its argument; flag description: show help on" "" gflags_unittest --helpon)
|
||||
# --helpon argument indicates what file we'll show args from
|
||||
add_gflags_test(helpon=gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon=gflags)
|
||||
# another way of specifying the argument
|
||||
add_gflags_test(helpon_gflags 1 "${SLASH}gflags.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpon gflags)
|
||||
# test another argument
|
||||
add_gflags_test(helpon=gflags_unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest --helpon=gflags_unittest)
|
||||
|
||||
# helpmatch is like helpon but takes substrings
|
||||
add_gflags_test(helpmatch_reporting 1 "${SLASH}gflags_reporting.cc:" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch reporting)
|
||||
add_gflags_test(helpmatch=unittest 1 "${SLASH}gflags_unittest.cc:" "${SLASH}gflags.cc:" gflags_unittest -helpmatch=unittest)
|
||||
|
||||
# if no flags are found with helpmatch or helpon, suggest --help
|
||||
add_gflags_test(helpmatch=nosuchsubstring 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpmatch=nosuchsubstring)
|
||||
add_gflags_test(helpon=nosuchmodule 1 "No modules matched" "${SLASH}gflags_unittest.cc:" gflags_unittest -helpon=nosuchmodule)
|
||||
|
||||
# helppackage shows all the flags in the same dir as this unittest
|
||||
# --help should show all flags, including flags from google.cc
|
||||
add_gflags_test(helppackage 1 "${SLASH}gflags_reporting.cc:" "" gflags_unittest --helppackage)
|
||||
|
||||
# xml!
|
||||
add_gflags_test(helpxml 1 "${SLASH}gflags_unittest.cc</file>" "${SLASH}gflags_unittest.cc:" gflags_unittest --helpxml)
|
||||
|
||||
# just print the version info and exit
|
||||
add_gflags_test(version-1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --version)
|
||||
add_gflags_test(version-2 0 "version test_version" "${SLASH}gflags_unittest.cc:" gflags_unittest --version)
|
||||
|
||||
# --undefok is a fun flag...
|
||||
add_gflags_test(undefok-1 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok= --foo --unused_bool)
|
||||
add_gflags_test(undefok-2 0 "PASS" "" gflags_unittest --undefok=foo --foo --unused_bool)
|
||||
# If you say foo is ok to be undefined, we'll accept --nofoo as well
|
||||
add_gflags_test(undefok-3 0 "PASS" "" gflags_unittest --undefok=foo --nofoo --unused_bool)
|
||||
# It's ok if the foo is in the middle
|
||||
add_gflags_test(undefok-4 0 "PASS" "" gflags_unittest --undefok=fee,fi,foo,fum --foo --unused_bool)
|
||||
# But the spelling has to be just right...
|
||||
add_gflags_test(undefok-5 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=fo --foo --unused_bool)
|
||||
add_gflags_test(undefok-6 1 "unknown command line flag 'foo'" "" gflags_unittest --undefok=foot --foo --unused_bool)
|
||||
|
||||
# See if we can successfully load our flags from the flagfile
|
||||
add_gflags_test(flagfile.1 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest "--flagfile=flagfile.1")
|
||||
add_gflags_test(flagfile.2 0 "PASS" "" gflags_unittest "--flagfile=flagfile.2")
|
||||
add_gflags_test(flagfile.3 0 "PASS" "" gflags_unittest "--flagfile=flagfile.3")
|
||||
|
||||
# Also try to load flags from the environment
|
||||
add_gflags_test(fromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=version)
|
||||
add_gflags_test(tryfromenv=version 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=version)
|
||||
add_gflags_test(fromenv=help 0 "PASS" "" gflags_unittest --fromenv=help)
|
||||
add_gflags_test(tryfromenv=help 0 "PASS" "" gflags_unittest --tryfromenv=help)
|
||||
add_gflags_test(fromenv=helpful 1 "helpful not found in environment" "" gflags_unittest --fromenv=helpful)
|
||||
add_gflags_test(tryfromenv=helpful 0 "PASS" "" gflags_unittest --tryfromenv=helpful)
|
||||
add_gflags_test(tryfromenv=undefok 0 "PASS" "" gflags_unittest --tryfromenv=undefok --foo)
|
||||
add_gflags_test(tryfromenv=weirdo 1 "unknown command line flag" "" gflags_unittest --tryfromenv=weirdo)
|
||||
add_gflags_test(tryfromenv-multiple 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --tryfromenv=test_bool,version,unused_bool)
|
||||
add_gflags_test(fromenv=test_bool 1 "not found in environment" "" gflags_unittest --fromenv=test_bool)
|
||||
add_gflags_test(fromenv=test_bool-ok 1 "unknown command line flag" "" gflags_unittest --fromenv=test_bool,ok)
|
||||
# Here, the --version overrides the fromenv
|
||||
add_gflags_test(version-overrides-fromenv 0 "gflags_unittest" "${SLASH}gflags_unittest.cc:" gflags_unittest --fromenv=test_bool,version,ok)
|
||||
|
||||
# Make sure -- by itself stops argv processing
|
||||
add_gflags_test(dashdash 0 "PASS" "" gflags_unittest -- --help)
|
||||
|
||||
# And we should die if the flag value doesn't pass the validator
|
||||
add_gflags_test(always_fail 1 "ERROR: failed validation of new value 'true' for flag 'always_fail'" "" gflags_unittest --always_fail)
|
||||
|
||||
# And if locking in validators fails
|
||||
# TODO(andreas): Worked on Windows 7 Release configuration, but causes
|
||||
# debugger abort() intervention in case of Debug configuration.
|
||||
#add_gflags_test(deadlock_if_cant_lock 0 "PASS" "" gflags_unittest --deadlock_if_cant_lock)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# use gflags_declare.h
|
||||
add_executable (gflags_declare_test gflags_declare_test.cc gflags_declare_flags.cc)
|
||||
|
||||
add_test(NAME gflags_declare COMMAND gflags_declare_test --message "Hello gflags!")
|
||||
set_tests_properties(gflags_declare PROPERTIES PASS_REGULAR_EXPRESSION "Hello gflags!")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# qnx specific test installation (ctest not compatible)
|
||||
if (QNX)
|
||||
install (
|
||||
DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
|
||||
DESTINATION ${RUNTIME_INSTALL_DIR}/gflags_tests
|
||||
)
|
||||
install (
|
||||
DIRECTORY ${PROJECT_SOURCE_DIR}/test/
|
||||
DESTINATION ${RUNTIME_INSTALL_DIR}/gflags_tests
|
||||
FILES_MATCHING
|
||||
PATTERN "flagfile.*"
|
||||
PATTERN "gflags_unittest_flagfile"
|
||||
PATTERN "config" EXCLUDE
|
||||
PATTERN "nc" EXCLUDE
|
||||
)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# configure Python script which configures and builds a test project
|
||||
if (BUILD_NC_TESTS OR BUILD_CONFIG_TESTS)
|
||||
find_package (PythonInterp)
|
||||
if (NOT PYTHON_EXECUTABLE)
|
||||
message (FATAL_ERROR "No Python installation found! It is required by the (negative) compilation tests."
|
||||
" Either install Python or set BUILD_NC_TESTS and BUILD_CONFIG_TESTS to FALSE.")
|
||||
endif ()
|
||||
set (TMPDIR "${PROJECT_BINARY_DIR}/Testing/Temporary")
|
||||
configure_file (gflags_build.py.in "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/build.py" @ONLY)
|
||||
function (add_gflags_build_test name srcdir expect_fail)
|
||||
set (srcdir "${CMAKE_CURRENT_SOURCE_DIR}/${srcdir}")
|
||||
add_test (
|
||||
NAME "${name}"
|
||||
COMMAND "${PYTHON_EXECUTABLE}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/build.py"
|
||||
${name} ${srcdir} ${expect_fail}
|
||||
)
|
||||
endfunction ()
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# negative compilation tests
|
||||
option (BUILD_NC_TESTS "Request addition of negative compilation tests." OFF)
|
||||
mark_as_advanced (BUILD_NC_TESTS)
|
||||
if (BUILD_NC_TESTS)
|
||||
add_gflags_build_test (nc_sanity nc 0)
|
||||
add_gflags_build_test (nc_swapped_args nc 1)
|
||||
add_gflags_build_test (nc_int_instead_of_bool nc 1)
|
||||
add_gflags_build_test (nc_bool_in_quotes nc 1)
|
||||
add_gflags_build_test (nc_define_string_with_0 nc 1)
|
||||
endif ()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# build configuration test
|
||||
option (BUILD_CONFIG_TESTS "Request addition of package configuration tests." OFF)
|
||||
mark_as_advanced (BUILD_CONFIG_TESTS)
|
||||
if (BUILD_CONFIG_TESTS)
|
||||
add_gflags_build_test (cmake_config config 0)
|
||||
endif ()
|
10
test/config/CMakeLists.txt
Normal file
10
test/config/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
## gflags package configuration tests
|
||||
|
||||
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
project (gflags_${TEST_NAME})
|
||||
|
||||
find_package (gflags REQUIRED)
|
||||
|
||||
add_executable (foo main.cc)
|
||||
target_link_libraries (foo gflags::gflags)
|
20
test/config/main.cc
Normal file
20
test/config/main.cc
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <iostream>
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
DEFINE_string(message, "Hello World!", "The message to print");
|
||||
|
||||
static bool ValidateMessage(const char* flagname, const std::string &message)
|
||||
{
|
||||
return !message.empty();
|
||||
}
|
||||
DEFINE_validator(message, ValidateMessage);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gflags::SetUsageMessage("Test CMake configuration of gflags library (gflags-config.cmake)");
|
||||
gflags::SetVersionString("0.1");
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
std::cout << FLAGS_message << std::endl;
|
||||
gflags::ShutDownCommandLineFlags();
|
||||
return 0;
|
||||
}
|
1
test/flagfile.1
Normal file
1
test/flagfile.1
Normal file
|
@ -0,0 +1 @@
|
|||
--version
|
2
test/flagfile.2
Normal file
2
test/flagfile.2
Normal file
|
@ -0,0 +1,2 @@
|
|||
--foo=bar
|
||||
--nounused_bool
|
1
test/flagfile.3
Normal file
1
test/flagfile.3
Normal file
|
@ -0,0 +1 @@
|
|||
--flagfile=flagfile.2
|
43
test/gflags_build.py.in
Normal file
43
test/gflags_build.py.in
Normal file
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import shutil
|
||||
|
||||
CMAKE = '@CMAKE_COMMAND@'
|
||||
CMAKE_BUILD_TYPE = '@CMAKE_BUILD_TYPE@'
|
||||
TMPDIR = '@TMPDIR@'
|
||||
SRCDIR = '@SRCDIR@'
|
||||
GFLAGS_DIR = '@gflags_BINARY_DIR@'
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 4:
|
||||
sys.stderr.write(' '.join(['usage:', sys.argv[0], '<test_name> <srcdir> <expect_fail:0|1>\n']))
|
||||
sys.exit(1)
|
||||
test_name = sys.argv[1]
|
||||
srcdir = sys.argv[2]
|
||||
expect_fail = (sys.argv[3].lower() in ['true', 'yes', 'on', '1'])
|
||||
bindir = os.path.join(TMPDIR, test_name)
|
||||
if TMPDIR == '':
|
||||
sys.stderr.write('Temporary directory not set!\n')
|
||||
sys.exit(1)
|
||||
# create build directory
|
||||
if os.path.isdir(bindir): shutil.rmtree(bindir)
|
||||
os.makedirs(bindir)
|
||||
# configure the build tree
|
||||
if subprocess.call([CMAKE, '-DCMAKE_BUILD_TYPE:STRING='+CMAKE_BUILD_TYPE,
|
||||
'-Dgflags_DIR:PATH='+GFLAGS_DIR,
|
||||
'-DTEST_NAME:STRING='+test_name, srcdir], cwd=bindir) != 0:
|
||||
sys.stderr.write('Failed to configure the build tree!\n')
|
||||
sys.exit(1)
|
||||
# build the test project
|
||||
exit_code = subprocess.call([CMAKE, '--build', bindir, '--config', CMAKE_BUILD_TYPE], cwd=bindir)
|
||||
if expect_fail == True:
|
||||
if exit_code == 0:
|
||||
sys.stderr.write('Build expected to fail, but it succeeded!\n')
|
||||
sys.exit(1)
|
||||
else:
|
||||
sys.stderr.write('Build failed as expected\n')
|
||||
exit_code = 0
|
||||
sys.exit(exit_code)
|
14
test/gflags_declare_flags.cc
Executable file
14
test/gflags_declare_flags.cc
Executable file
|
@ -0,0 +1,14 @@
|
|||
// The macro can already be defined when using Unity builds.
|
||||
#undef GFLAGS_DLL_DECLARE_FLAG
|
||||
#define GFLAGS_DLL_DECLARE_FLAG
|
||||
|
||||
#include <iostream>
|
||||
#include <gflags/gflags_declare.h>
|
||||
|
||||
DECLARE_string(message); // in gflags_delcare_test.cc
|
||||
|
||||
void print_message();
|
||||
void print_message()
|
||||
{
|
||||
std::cout << FLAGS_message << std::endl;
|
||||
}
|
12
test/gflags_declare_test.cc
Normal file
12
test/gflags_declare_test.cc
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <gflags/gflags.h>
|
||||
|
||||
DEFINE_string(message, "", "The message to print");
|
||||
void print_message(); // in gflags_declare_flags.cc
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GFLAGS_NAMESPACE::SetUsageMessage("Test compilation and use of gflags_declare.h");
|
||||
GFLAGS_NAMESPACE::ParseCommandLineFlags(&argc, &argv, true);
|
||||
print_message();
|
||||
return 0;
|
||||
}
|
36
src/google/gflags_completions.h → test/gflags_strip_flags_test.cc
Normal file → Executable file
36
src/google/gflags_completions.h → test/gflags_strip_flags_test.cc
Normal file → Executable file
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2008, Google Inc.
|
||||
// Copyright (c) 2011, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,9 +26,35 @@
|
|||
// 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.
|
||||
//
|
||||
// ---
|
||||
// Author: csilvers@google.com (Craig Silverstein)
|
||||
//
|
||||
// A simple program that uses STRIP_FLAG_HELP. We'll have a shell
|
||||
// script that runs 'strings' over this program and makes sure
|
||||
// that the help string is not in there.
|
||||
|
||||
// Header files have moved from the google directory to the gflags
|
||||
// directory. This forwarding file is provided only for backwards
|
||||
// compatibility. Use gflags/gflags_completions.h in all new code.
|
||||
#define STRIP_FLAG_HELP 1
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#include <gflags/gflags_completions.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using GFLAGS_NAMESPACE::SetUsageMessage;
|
||||
using GFLAGS_NAMESPACE::ParseCommandLineFlags;
|
||||
|
||||
|
||||
DEFINE_bool(test, true, "This text should be stripped out");
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
SetUsageMessage("Usage message");
|
||||
ParseCommandLineFlags(&argc, &argv, false);
|
||||
|
||||
// Unfortunately, for us, libtool can replace executables with a shell
|
||||
// script that does some work before calling the 'real' executable
|
||||
// under a different name. We need the 'real' executable name to run
|
||||
// 'strings' on it, so we construct this binary to print the real
|
||||
// name (argv[0]) on stdout when run.
|
||||
puts(argv[0]);
|
||||
|
||||
return 0;
|
||||
}
|
7
test/gflags_strip_flags_test.cmake
Normal file
7
test/gflags_strip_flags_test.cmake
Normal file
|
@ -0,0 +1,7 @@
|
|||
if (NOT BINARY)
|
||||
message (FATAL_ERROR "BINARY file to check not specified!")
|
||||
endif ()
|
||||
file (STRINGS "${BINARY}" strings REGEX "This text should be stripped out")
|
||||
if (strings)
|
||||
message (FATAL_ERROR "Text not stripped from binary like it should be: ${BINARY}")
|
||||
endif ()
|
579
src/gflags_unittest.cc → test/gflags_unittest.cc
Normal file → Executable file
579
src/gflags_unittest.cc → test/gflags_unittest.cc
Normal file → Executable file
File diff suppressed because it is too large
Load diff
16
test/nc/CMakeLists.txt
Normal file
16
test/nc/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
## gflags negative compilation tests
|
||||
|
||||
cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
if (NOT TEST_NAME)
|
||||
message (FATAL_ERROR "Missing TEST_NAME CMake flag")
|
||||
endif ()
|
||||
string (TOUPPER ${TEST_NAME} TEST_NAME_UPPER)
|
||||
|
||||
project (gflags_${TEST_NAME})
|
||||
|
||||
find_package (gflags REQUIRED)
|
||||
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
add_definitions (-DTEST_${TEST_NAME_UPPER})
|
||||
add_executable (gflags_${TEST_NAME} gflags_nc.cc)
|
||||
target_link_libraries(gflags_${TEST_NAME} gflags)
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2006, Google Inc.
|
||||
// Copyright (c) 2009, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
|
@ -27,8 +27,47 @@
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
// Header files have moved from the google directory to the gflags
|
||||
// directory. This forwarding file is provided only for backwards
|
||||
// compatibility. Use gflags/gflags.h in all new code.
|
||||
// ---
|
||||
//
|
||||
// A negative comiple test for gflags.
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
|
||||
#if defined(TEST_NC_SWAPPED_ARGS)
|
||||
|
||||
DEFINE_bool(some_bool_flag,
|
||||
"the default value should go here, not the description",
|
||||
false);
|
||||
|
||||
|
||||
#elif defined(TEST_NC_INT_INSTEAD_OF_BOOL)
|
||||
|
||||
DEFINE_bool(some_bool_flag_2,
|
||||
0,
|
||||
"should have been an int32 flag but mistakenly used bool instead");
|
||||
|
||||
#elif defined(TEST_NC_BOOL_IN_QUOTES)
|
||||
|
||||
|
||||
DEFINE_bool(some_bool_flag_3,
|
||||
"false",
|
||||
"false in in quotes, which is wrong");
|
||||
|
||||
#elif defined(TEST_NC_SANITY)
|
||||
|
||||
DEFINE_bool(some_bool_flag_4,
|
||||
true,
|
||||
"this is the correct usage of DEFINE_bool");
|
||||
|
||||
#elif defined(TEST_NC_DEFINE_STRING_WITH_0)
|
||||
|
||||
DEFINE_string(some_string_flag,
|
||||
0,
|
||||
"Trying to construct a string by passing 0 would cause a crash.");
|
||||
|
||||
#endif
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue