Compare commits
488 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f007d9621 | ||
|
|
7fcf58afa6 | ||
|
|
ca390c4718 | ||
|
|
575fb19092 | ||
|
|
6c5c692c8e | ||
|
|
1f0f3d6829 | ||
|
|
2075ae813b | ||
|
|
de309c08c0 | ||
|
|
be06647ac2 | ||
|
|
b3b9eb987f | ||
|
|
2714c2a258 | ||
|
|
6d92a2e5a1 | ||
|
|
6703865b78 | ||
|
|
175b54d4fa | ||
|
|
65896fe00d | ||
|
|
570c7e4e1d | ||
|
|
45f99f5e1a | ||
|
|
2bd06dbe36 | ||
|
|
409e19881d | ||
|
|
0c10a02229 | ||
|
|
9ca8073cb2 | ||
|
|
c4b63c7a4e | ||
|
|
5cf7a9afd3 | ||
|
|
d49e700897 | ||
|
|
44c2e9d9ad | ||
|
|
df683bbc81 | ||
|
|
0bad9688a0 | ||
|
|
1cd4d78817 | ||
|
|
30c9ed3687 | ||
|
|
645acfe606 | ||
|
|
cfe648e9c5 | ||
|
|
cc0de6c200 | ||
|
|
7b134a5c82 | ||
|
|
d76999015c | ||
|
|
4c50627c38 | ||
|
|
6e6a817a44 | ||
|
|
cd4ef77d58 | ||
|
|
c0813f90bb | ||
|
|
442c6fcbf1 | ||
|
|
2b36dfe444 | ||
|
|
eecd37e7eb | ||
|
|
f73750564e | ||
|
|
46e4721fb6 | ||
|
|
fd15ff9a54 | ||
|
|
31429d85b8 | ||
|
|
ea0748d8df | ||
|
|
5a7856ab96 | ||
|
|
8a1c086d39 | ||
|
|
a189fc3d7d | ||
|
|
34b8da6496 | ||
|
|
7a807f3805 | ||
|
|
b24e4d9445 | ||
|
|
de77d0b97b | ||
|
|
68b6ce38eb | ||
|
|
9b34110745 | ||
|
|
ac12a9e794 | ||
|
|
7e6fca90e8 | ||
|
|
8d13b3bb0c | ||
|
|
2293c6fc5a | ||
|
|
ec455f2cc1 | ||
|
|
2b5a53c880 | ||
|
|
dd77d0fd38 | ||
|
|
941c66fbcb | ||
|
|
9377254062 | ||
|
|
c469cc23a1 | ||
|
|
7af231e6bf | ||
|
|
aaefca72b3 | ||
|
|
734ab3463f | ||
|
|
42a185cd88 | ||
|
|
1f9ac49c7d | ||
|
|
489d35eb13 | ||
|
|
1ef1ab37e7 | ||
|
|
2c735b8dfb | ||
|
|
25a349f7ae | ||
|
|
eb72e4c181 | ||
|
|
f88544adf5 | ||
|
|
89f5977468 | ||
|
|
fe46778bd3 | ||
|
|
6d23649fef | ||
|
|
b172be9564 | ||
|
|
8fbad2cb9c | ||
|
|
8dd7abfdec | ||
|
|
f3bee1b15b | ||
|
|
c8950c6b17 | ||
|
|
8775a454c1 | ||
|
|
dfce35c97c | ||
|
|
e1f424a7e2 | ||
|
|
39df0545e7 | ||
|
|
cafba580ec | ||
|
|
54b2c17172 | ||
|
|
51e7a439dc | ||
|
|
bdd14b6ab1 | ||
|
|
70285fddc7 | ||
|
|
4244cec140 | ||
|
|
0032896711 | ||
|
|
645d0a5d5f | ||
|
|
45d7978daf | ||
|
|
b1bc8e75cb | ||
|
|
8ff1a7db04 | ||
|
|
ac8f8dae2c | ||
|
|
d29d02e8af | ||
|
|
93549f3600 | ||
|
|
e3f5398aa1 | ||
|
|
80d7fa3863 | ||
|
|
aeee0ef452 | ||
|
|
546906f467 | ||
|
|
43792b8a13 | ||
|
|
3c052d90f8 | ||
|
|
ab2a1a8519 | ||
|
|
e92ab7df52 | ||
|
|
e26e342623 | ||
|
|
dfb7703542 | ||
|
|
b7686b6995 | ||
|
|
72b8a7956f | ||
|
|
65cc31ab16 | ||
|
|
d937c2e1b8 | ||
|
|
716be9edc7 | ||
|
|
6607b369d0 | ||
|
|
3fcf77a691 | ||
|
|
3731c120c0 | ||
|
|
a9eecd7f9a | ||
|
|
7d973f9b4e | ||
|
|
36ccb159f4 | ||
|
|
58ac48fe20 | ||
|
|
b6082e5088 | ||
|
|
931323df21 | ||
|
|
b45f5b4c82 | ||
|
|
da9753409b | ||
|
|
b58718f37c | ||
|
|
aebdfd6051 | ||
|
|
e19e598302 | ||
|
|
fe476db256 | ||
|
|
b8a251c091 | ||
|
|
4dbc26af72 | ||
|
|
615966eb6d | ||
|
|
6a7be64131 | ||
|
|
9a5e72136b | ||
|
|
5d4fa3d774 | ||
|
|
4a75a9df7c | ||
|
|
e17f932eec | ||
|
|
f6e4d960e9 | ||
|
|
1dffb4eb29 | ||
|
|
747b8a0774 | ||
|
|
857df01007 | ||
|
|
319a0dfba4 | ||
|
|
e567cfc442 | ||
|
|
7ba2f7bc02 | ||
|
|
27bf2b2fd3 | ||
|
|
fab3b5eac4 | ||
|
|
b90799c277 | ||
|
|
3411d58669 | ||
|
|
64827572c0 | ||
|
|
6fbc93a7e4 | ||
|
|
3a0d4d22c5 | ||
|
|
22491eb123 | ||
|
|
4945347d07 | ||
|
|
888f93947b | ||
|
|
4ffdf0dc78 | ||
|
|
7a62819e43 | ||
|
|
aca9a23c83 | ||
|
|
6742834201 | ||
|
|
35f4efbb0a | ||
|
|
9c3d6d0e71 | ||
|
|
a13d03babc | ||
|
|
846c3fe55b | ||
|
|
1b59cb0905 | ||
|
|
af8344bbbe | ||
|
|
88e2cd4eef | ||
|
|
4ffb2f3c40 | ||
|
|
4056374800 | ||
|
|
f545ff5e7d | ||
|
|
2115d9b590 | ||
|
|
c18db3903b | ||
|
|
05fbc65278 | ||
|
|
9ad08ac6cc | ||
|
|
b70ea80433 | ||
|
|
bfee415a1d | ||
|
|
acc60d0c38 | ||
|
|
6d5b384507 | ||
|
|
1fb4cc1958 | ||
|
|
a1b6164ef1 | ||
|
|
278ed96891 | ||
|
|
6ed0c9e58b | ||
|
|
a34226ca94 | ||
|
|
c515e1ae2f | ||
|
|
79d692c645 | ||
|
|
086ce224d2 | ||
|
|
b33e3bad4c | ||
|
|
54b8bcbbf1 | ||
|
|
864ef64920 | ||
|
|
c640c2f7c1 | ||
|
|
5addeedc0a | ||
|
|
d153e294b8 | ||
|
|
c4ca519a86 | ||
|
|
a8e0007e96 | ||
|
|
553ddaea85 | ||
|
|
6d3f70a405 | ||
|
|
612a7d28c1 | ||
|
|
180b700ddc | ||
|
|
b38ed9d08a | ||
|
|
9f0b7d3bfe | ||
|
|
aa94e6b9ab | ||
|
|
17269d649d | ||
|
|
bc1fada1cf | ||
|
|
18836106d1 | ||
|
|
b0174b3dda | ||
|
|
6969412183 | ||
|
|
6434410145 | ||
|
|
a8cfbe0c0c | ||
|
|
b3abfaa123 | ||
|
|
43fc3bf91c | ||
|
|
42d509b1c3 | ||
|
|
224f66bb63 | ||
|
|
4ffa98388f | ||
|
|
087ad5bf32 | ||
|
|
9dc1107f88 | ||
|
|
dfb9ffc324 | ||
|
|
c575116051 | ||
|
|
d09b999f34 | ||
|
|
baa7006e63 | ||
|
|
660352f02b | ||
|
|
52354b2adc | ||
|
|
ccbda2dfd5 | ||
|
|
ef36f800ed | ||
|
|
ee6faf13b2 | ||
|
|
6e9b2f16f5 | ||
|
|
f4dd77ae6b | ||
|
|
503e3dec8d | ||
|
|
5316599845 | ||
|
|
cd8fbd5fbf | ||
|
|
c8a7f5abee | ||
|
|
f47582361a | ||
|
|
f773eb9b6f | ||
|
|
f42fd3b154 | ||
|
|
cb7c19d36b | ||
|
|
cf4c4699bc | ||
|
|
5a3bd74cfa | ||
|
|
1da31df93c | ||
|
|
6bd5acfb66 | ||
|
|
8121c07551 | ||
|
|
8b872216ea | ||
|
|
11f08e7bb1 | ||
|
|
65199ed0b8 | ||
|
|
b79e18b78b | ||
|
|
4399e56647 | ||
|
|
9206460cd3 | ||
|
|
64b4e327ff | ||
|
|
4df5ae7463 | ||
|
|
ab5e109298 | ||
|
|
32522a5f65 | ||
|
|
d581807e33 | ||
|
|
6c9f5b2ec4 | ||
|
|
0798a37bb0 | ||
|
|
33696664cb | ||
|
|
68964b8db6 | ||
|
|
17e7679fd9 | ||
|
|
c27c3a803b | ||
|
|
e8e40f76db | ||
|
|
3362cc6c79 | ||
|
|
9cf0eb7c98 | ||
|
|
1398762db8 | ||
|
|
ce3533613b | ||
|
|
06e665108a | ||
|
|
56d3faceea | ||
|
|
4a55b11580 | ||
|
|
3965584721 | ||
|
|
acda903486 | ||
|
|
8474b7854b | ||
|
|
831a6f8232 | ||
|
|
c34dbe9873 | ||
|
|
56523194b3 | ||
|
|
f7407d4d27 | ||
|
|
2412db3158 | ||
|
|
3b6b05d70b | ||
|
|
de81bb0aac | ||
|
|
9733727be4 | ||
|
|
ffb40018a5 | ||
|
|
6f9e32a79e | ||
|
|
df95749e83 | ||
|
|
35983c895c | ||
|
|
9fce37c464 | ||
|
|
a063a04ecf | ||
|
|
92cb3c449b | ||
|
|
f8c8e99fdf | ||
|
|
98e0e8c65d | ||
|
|
0b83bb203d | ||
|
|
370cb741bb | ||
|
|
3ce6090d04 | ||
|
|
36bcd28c61 | ||
|
|
dfe573088c | ||
|
|
717f569835 | ||
|
|
eca3ddef81 | ||
|
|
4a4331f2f2 | ||
|
|
a01d739ea3 | ||
|
|
8d3ce1c29a | ||
|
|
c39fcf6e8a | ||
|
|
47ad26d5c6 | ||
|
|
5bf7fdea16 | ||
|
|
42ce901f28 | ||
|
|
a1374c4200 | ||
|
|
6e46c125e3 | ||
|
|
a415556858 | ||
|
|
a1fa841f33 | ||
|
|
a4a725d547 | ||
|
|
44331dc245 | ||
|
|
f0bac8852a | ||
|
|
764162569a | ||
|
|
d25a1b7bc0 | ||
|
|
9c1a25b931 | ||
|
|
c1499f64a8 | ||
|
|
03f2b3861a | ||
|
|
86fea1ab25 | ||
|
|
fef48c17e2 | ||
|
|
d2fed749a5 | ||
|
|
0b3d4cb471 | ||
|
|
81e0d616ed | ||
|
|
d5c04eec9e | ||
|
|
8f9ccfe770 | ||
|
|
36fee386f5 | ||
|
|
8d40d7564d | ||
|
|
a23e96f04f | ||
|
|
0efaa59a75 | ||
|
|
230da316c5 | ||
|
|
bda40ec006 | ||
|
|
762a2a7ee1 | ||
|
|
7d4eeb14f4 | ||
|
|
0cbc235297 | ||
|
|
c7656c3ec1 | ||
|
|
663bb26960 | ||
|
|
7ec73b5099 | ||
|
|
efc341d768 | ||
|
|
a79416bab7 | ||
|
|
63ec71b58d | ||
|
|
39e83581de | ||
|
|
635a078180 | ||
|
|
e51790bf33 | ||
|
|
36e6ed910a | ||
|
|
7d60d6e04b | ||
|
|
1041a221b8 | ||
|
|
82320a8a88 | ||
|
|
bf183f44f2 | ||
|
|
9ee010d853 | ||
|
|
4fca1b9673 | ||
|
|
30bb9086d2 | ||
|
|
d66e593188 | ||
|
|
d5fdcfefcd | ||
|
|
7f8a48b3bf | ||
|
|
5abed00e3c | ||
|
|
bf3e5a80ae | ||
|
|
01f3e543e3 | ||
|
|
2f7d608a92 | ||
|
|
3f4df6aee9 | ||
|
|
7a6e743eb6 | ||
|
|
e27f141194 | ||
|
|
0b3c27d042 | ||
|
|
5c57edfbc8 | ||
|
|
20984f9730 | ||
|
|
3533c22d21 | ||
|
|
be25d94c21 | ||
|
|
45fdc922de | ||
|
|
c30896d3d5 | ||
|
|
b442ef8070 | ||
|
|
d4e8ebab7e | ||
|
|
0863ad797c | ||
|
|
ce50c57b9e | ||
|
|
d824eae3cd | ||
|
|
df3ce126d6 | ||
|
|
246e49ac48 | ||
|
|
9881ea5969 | ||
|
|
4cef723320 | ||
|
|
544b4a4f50 | ||
|
|
b9be6bb5db | ||
|
|
6d14ac3efe | ||
|
|
795384957d | ||
|
|
e370cd5166 | ||
|
|
3b21da69ea | ||
|
|
4fa737b62a | ||
|
|
4f09bed0b4 | ||
|
|
7bba6030c2 | ||
|
|
7a8b66aa17 | ||
|
|
6d5da21549 | ||
|
|
15d51a17cc | ||
|
|
fe1287dd5d | ||
|
|
431d74c802 | ||
|
|
c8f8135a57 | ||
|
|
d82641f709 | ||
|
|
cec37e1cf5 | ||
|
|
b55437ac10 | ||
|
|
c5dcae8306 | ||
|
|
b30a009faa | ||
|
|
b539557b36 | ||
|
|
d516278b1c | ||
|
|
6c0a5fcb53 | ||
|
|
f28ae960c3 | ||
|
|
fa0d50f9fc | ||
|
|
fcc9da24a6 | ||
|
|
40ab822812 | ||
|
|
4c5a60c3c3 | ||
|
|
8ee2bb5b31 | ||
|
|
024b095d7e | ||
|
|
d442460690 | ||
|
|
5bc1e1177c | ||
|
|
af4df08e5b | ||
|
|
7258189847 | ||
|
|
c652590d84 | ||
|
|
e5ef2728bd | ||
|
|
909069ea82 | ||
|
|
64650ef2ed | ||
|
|
0a2e5931bd | ||
|
|
0a12a96cee | ||
|
|
d8998fe4f6 | ||
|
|
2e87f98fe4 | ||
|
|
7001ab9ecb | ||
|
|
4a82a856d2 | ||
|
|
3ba8976592 | ||
|
|
ceb7163880 | ||
|
|
28321d8959 | ||
|
|
5b4fb63d27 | ||
|
|
7da49d48a3 | ||
|
|
940335d82f | ||
|
|
dfc0e441c5 | ||
|
|
eb13e4f67c | ||
|
|
195d416e3b | ||
|
|
74076bebc3 | ||
|
|
130a3e10de | ||
|
|
445af7ef7e | ||
|
|
a35e612c55 | ||
|
|
36fa99ba2c | ||
|
|
0a6704b439 | ||
|
|
7764e4a8b4 | ||
|
|
3b5f2807f4 | ||
|
|
1b7d541431 | ||
|
|
95a3655796 | ||
|
|
c0d2ceade6 | ||
|
|
925858d996 | ||
|
|
20919b325e | ||
|
|
7f732529da | ||
|
|
1863b4228c | ||
|
|
c0463b17b6 | ||
|
|
9a43cfb8d2 | ||
|
|
19570c69c9 | ||
|
|
58d7f873dc | ||
|
|
0bf00f95aa | ||
|
|
0f4975a68d | ||
|
|
5ef521d4ad | ||
|
|
e58e596f13 | ||
|
|
f811ae9ed1 | ||
|
|
3ee89c86d6 | ||
|
|
4d6aff4184 | ||
|
|
742fe94f22 | ||
|
|
9630e0e848 | ||
|
|
fd3dc2c633 | ||
|
|
eec1435d52 | ||
|
|
e227697b0b | ||
|
|
82d0860b76 | ||
|
|
e0a2521e3d | ||
|
|
a6f7be14c6 | ||
|
|
15fb5ca5b6 | ||
|
|
5792d60d68 | ||
|
|
44f6079fad | ||
|
|
242130d305 | ||
|
|
1a4c47a749 | ||
|
|
f17d11aa8c | ||
|
|
1227cf4dab | ||
|
|
0f83e53c43 | ||
|
|
e558d50b0a | ||
|
|
30f7f3ee93 | ||
|
|
6f5699a236 | ||
|
|
e24276a35e | ||
|
|
1d762fa5b0 | ||
|
|
1655f4f910 | ||
|
|
10498b485f | ||
|
|
1e6b9f3291 | ||
|
|
4cc89c9e2b | ||
|
|
a8fad525e5 | ||
|
|
00cb9f4e6f | ||
|
|
ba8a9f6952 | ||
|
|
0d0c254317 | ||
|
|
6ca3d3cf58 | ||
|
|
834dd780bf | ||
|
|
94a54120de | ||
|
|
41a6a7880e | ||
|
|
a606c3187b | ||
|
|
d064ab8d0a | ||
|
|
4764ca65f5 | ||
|
|
f581614a78 | ||
|
|
47af307fa6 | ||
|
|
d68736bc1d |
@ -1,17 +1,62 @@
|
|||||||
---
|
---
|
||||||
platforms:
|
tasks:
|
||||||
ubuntu1404:
|
ubuntu1804:
|
||||||
|
name: "Ubuntu 22.04"
|
||||||
|
platform: ubuntu2204
|
||||||
|
build_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=-Werror"
|
||||||
build_targets:
|
build_targets:
|
||||||
- "..."
|
- "//..."
|
||||||
|
test_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=-Werror"
|
||||||
test_targets:
|
test_targets:
|
||||||
- "..."
|
- "//..."
|
||||||
ubuntu1604:
|
|
||||||
build_targets:
|
|
||||||
- "..."
|
|
||||||
test_targets:
|
|
||||||
- "..."
|
|
||||||
macos:
|
macos:
|
||||||
|
name: "macOS: latest Xcode"
|
||||||
|
platform: macos
|
||||||
|
build_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=-Werror"
|
||||||
build_targets:
|
build_targets:
|
||||||
- "..."
|
- "//..."
|
||||||
|
test_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=-Werror"
|
||||||
test_targets:
|
test_targets:
|
||||||
- "..."
|
- "//..."
|
||||||
|
windows-msvc:
|
||||||
|
name: "Windows: MSVC 2017"
|
||||||
|
platform: windows
|
||||||
|
environment:
|
||||||
|
BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
|
||||||
|
build_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=/WX"
|
||||||
|
build_targets:
|
||||||
|
- "//..."
|
||||||
|
test_flags:
|
||||||
|
- "--features=layering_check"
|
||||||
|
- "--copt=/WX"
|
||||||
|
test_targets:
|
||||||
|
- "//..."
|
||||||
|
windows-clang-cl:
|
||||||
|
name: "Windows: Clang"
|
||||||
|
platform: windows
|
||||||
|
environment:
|
||||||
|
BAZEL_VC: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC"
|
||||||
|
build_flags:
|
||||||
|
- "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl"
|
||||||
|
- "--extra_execution_platforms=//:x64_windows-clang-cl"
|
||||||
|
- "--compiler=clang-cl"
|
||||||
|
- "--features=layering_check"
|
||||||
|
build_targets:
|
||||||
|
- "//..."
|
||||||
|
test_flags:
|
||||||
|
- "--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl"
|
||||||
|
- "--extra_execution_platforms=//:x64_windows-clang-cl"
|
||||||
|
- "--compiler=clang-cl"
|
||||||
|
- "--features=layering_check"
|
||||||
|
test_targets:
|
||||||
|
- "//..."
|
||||||
|
|||||||
168
.clang-format
Normal file
168
.clang-format
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: Google
|
||||||
|
AccessModifierOffset: -1
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: false
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: true
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: true
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 80
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^<ext/.*\.h>'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '^<.*\.h>'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '^<.*'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: AfterHash
|
||||||
|
IndentWidth: 2
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Never
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
RawStringFormats:
|
||||||
|
- Language: Cpp
|
||||||
|
Delimiters:
|
||||||
|
- cc
|
||||||
|
- CC
|
||||||
|
- cpp
|
||||||
|
- Cpp
|
||||||
|
- CPP
|
||||||
|
- 'c++'
|
||||||
|
- 'C++'
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
- Language: TextProto
|
||||||
|
Delimiters:
|
||||||
|
- pb
|
||||||
|
- PB
|
||||||
|
- proto
|
||||||
|
- PROTO
|
||||||
|
EnclosingFunctions:
|
||||||
|
- EqualsProto
|
||||||
|
- EquivToProto
|
||||||
|
- PARSE_PARTIAL_TEXT_PROTO
|
||||||
|
- PARSE_TEST_PROTO
|
||||||
|
- PARSE_TEXT_PROTO
|
||||||
|
- ParseTextOrDie
|
||||||
|
- ParseTextProtoOrDie
|
||||||
|
CanonicalDelimiter: ''
|
||||||
|
BasedOnStyle: google
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 2
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
Standard: c++14
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
...
|
||||||
|
|
||||||
58
.clang-tidy
Normal file
58
.clang-tidy
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
---
|
||||||
|
Checks: 'clang-diagnostic-*,clang-analyzer-*,google-*,modernize-*,-modernize-use-trailing-return-type,readability-*,portability-*,performance-*,bugprone-*,android-*,darwin-*,clang-analyzer-*'
|
||||||
|
WarningsAsErrors: ''
|
||||||
|
HeaderFilterRegex: ''
|
||||||
|
FormatStyle: file
|
||||||
|
CheckOptions:
|
||||||
|
- key: cert-dcl16-c.NewSuffixes
|
||||||
|
value: 'L;LL;LU;LLU'
|
||||||
|
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
|
||||||
|
value: '0'
|
||||||
|
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
|
||||||
|
value: '1'
|
||||||
|
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||||
|
value: '1'
|
||||||
|
- key: google-build-namespaces.HeaderFileExtensions
|
||||||
|
value: ',h,hh,hpp,hxx'
|
||||||
|
- key: google-global-names-in-headers.HeaderFileExtensions
|
||||||
|
value: ',h,hh,hpp,hxx'
|
||||||
|
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||||
|
value: '1'
|
||||||
|
- key: google-readability-function-size.BranchThreshold
|
||||||
|
value: '4294967295'
|
||||||
|
- key: google-readability-function-size.LineThreshold
|
||||||
|
value: '4294967295'
|
||||||
|
- key: google-readability-function-size.NestingThreshold
|
||||||
|
value: '4294967295'
|
||||||
|
- key: google-readability-function-size.ParameterThreshold
|
||||||
|
value: '4294967295'
|
||||||
|
- key: google-readability-function-size.StatementThreshold
|
||||||
|
value: '800'
|
||||||
|
- key: google-readability-function-size.VariableThreshold
|
||||||
|
value: '4294967295'
|
||||||
|
- key: google-readability-namespace-comments.ShortNamespaceLines
|
||||||
|
value: '10'
|
||||||
|
- key: google-readability-namespace-comments.SpacesBeforeComments
|
||||||
|
value: '2'
|
||||||
|
- key: google-runtime-int.SignedTypePrefix
|
||||||
|
value: int
|
||||||
|
- key: google-runtime-int.TypeSuffix
|
||||||
|
value: ''
|
||||||
|
- key: google-runtime-int.UnsignedTypePrefix
|
||||||
|
value: uint
|
||||||
|
- key: google-runtime-references.WhiteListTypes
|
||||||
|
value: ''
|
||||||
|
- key: modernize-loop-convert.MaxCopySize
|
||||||
|
value: '16'
|
||||||
|
- key: modernize-loop-convert.MinConfidence
|
||||||
|
value: reasonable
|
||||||
|
- key: modernize-loop-convert.NamingStyle
|
||||||
|
value: CamelCase
|
||||||
|
- key: modernize-pass-by-value.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-use-nullptr.NullMacros
|
||||||
|
value: 'NULL'
|
||||||
|
...
|
||||||
|
|
||||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.h linguist-language=C++
|
||||||
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Set update schedule for GitHub Actions
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
# Check for updates to GitHub Actions every week
|
||||||
|
interval: "weekly"
|
||||||
69
.github/workflows/android.yml
vendored
Normal file
69
.github/workflows/android.yml
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
name: Android
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-android:
|
||||||
|
name: NDK-C++${{matrix.std}}-${{matrix.abi}}-${{matrix.build_type}}
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
NDK_VERSION: 26.0.10792818
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
std: [14, 17, 20]
|
||||||
|
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]
|
||||||
|
build_type: [Debug, Release]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- name: Setup Dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
|
||||||
|
cmake \
|
||||||
|
ninja-build
|
||||||
|
|
||||||
|
- name: Setup NDK
|
||||||
|
env:
|
||||||
|
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
|
||||||
|
run: |
|
||||||
|
echo 'y' | ${{env.ANDROID_SDK_ROOT}}/cmdline-tools/latest/bin/sdkmanager --install 'ndk;${{env.NDK_VERSION}}'
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.abi}} \
|
||||||
|
-DCMAKE_ANDROID_API=28 \
|
||||||
|
-DCMAKE_ANDROID_ARCH_ABI=${{matrix.abi}} \
|
||||||
|
-DCMAKE_ANDROID_NDK=/usr/local/lib/android/sdk/ndk/${{env.NDK_VERSION}} \
|
||||||
|
-DCMAKE_ANDROID_STL_TYPE=c++_shared \
|
||||||
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
|
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-DCMAKE_SYSTEM_NAME=Android \
|
||||||
|
-G Ninja \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.abi}} \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
26
.github/workflows/cifuzz.yml
vendored
Normal file
26
.github/workflows/cifuzz.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
name: CIFuzz
|
||||||
|
on: [pull_request]
|
||||||
|
jobs:
|
||||||
|
Fuzzing:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Build Fuzzers
|
||||||
|
id: build
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'glog'
|
||||||
|
dry-run: false
|
||||||
|
language: c++
|
||||||
|
- name: Run Fuzzers
|
||||||
|
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
|
||||||
|
with:
|
||||||
|
oss-fuzz-project-name: 'glog'
|
||||||
|
fuzz-seconds: 60
|
||||||
|
dry-run: false
|
||||||
|
language: c++
|
||||||
|
- name: Upload Crash
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: failure() && steps.build.outcome == 'success'
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: ./out/artifacts
|
||||||
57
.github/workflows/emscripten.yml
vendored
Normal file
57
.github/workflows/emscripten.yml
vendored
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
name: Emscripten
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
name: Emscripten-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
container: emscripten/emsdk
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
build_type: [Release, Debug]
|
||||||
|
lib: [static]
|
||||||
|
std: [14, 17, 20, 23]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- name: Setup Dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y \
|
||||||
|
cmake \
|
||||||
|
ninja-build
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -Wno-error=wasm-exception-spec ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
emcmake cmake -S . -B build_${{matrix.build_type}} \
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
|
||||||
|
-G Ninja \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
120
.github/workflows/linux.yml
vendored
Normal file
120
.github/workflows/linux.yml
vendored
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
name: Linux
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-linux:
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
name: GCC-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
build_type: [Release, Debug]
|
||||||
|
lib: [shared, static]
|
||||||
|
std: [14, 17, 20, 23]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- name: Setup Dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-suggests --no-install-recommends \
|
||||||
|
g++ \
|
||||||
|
cmake \
|
||||||
|
gcovr \
|
||||||
|
libgflags-dev \
|
||||||
|
libgmock-dev \
|
||||||
|
libgtest-dev \
|
||||||
|
libunwind-dev \
|
||||||
|
ninja-build
|
||||||
|
|
||||||
|
- name: Setup Environment
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.build_type}} \
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install \
|
||||||
|
-G Ninja \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}} \
|
||||||
|
--target install
|
||||||
|
|
||||||
|
cmake build_${{matrix.build_type}} \
|
||||||
|
-DCMAKE_INSTALL_INCLUDEDIR=${{runner.workspace}}/foo/include \
|
||||||
|
-DCMAKE_INSTALL_LIBDIR=${{runner.workspace}}/foo/lib \
|
||||||
|
-DCMAKE_INSTALL_DATAROOTDIR=${{runner.workspace}}/foo/share
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}} \
|
||||||
|
--target install
|
||||||
|
|
||||||
|
- name: Test CMake Package (relative GNUInstallDirs)
|
||||||
|
run: |
|
||||||
|
cmake -S src/package_config_unittest/working_config \
|
||||||
|
-B build_${{matrix.build_type}}_package \
|
||||||
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
|
-DCMAKE_PREFIX_PATH=${{github.workspace}}/install \
|
||||||
|
-G Ninja
|
||||||
|
cmake --build build_${{matrix.build_type}}_package \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Test CMake Package (absolute GNUInstallDirs)
|
||||||
|
run: |
|
||||||
|
cmake -S src/package_config_unittest/working_config \
|
||||||
|
-B build_${{matrix.build_type}}_package_foo \
|
||||||
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
|
-DCMAKE_PREFIX_PATH=${{runner.workspace}}/foo \
|
||||||
|
-G Ninja
|
||||||
|
cmake --build build_${{matrix.build_type}}_package_foo \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
ctest --test-dir build_${{matrix.build_type}} -j$(nproc) --output-on-failure
|
||||||
|
|
||||||
|
- name: Generate Coverage
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
cd build_${{matrix.build_type}}
|
||||||
|
gcovr -r .. . -s --xml coverage.xml
|
||||||
|
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
files: build_${{matrix.build_type}}/coverage.xml
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
76
.github/workflows/macos.yml
vendored
Normal file
76
.github/workflows/macos.yml
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
name: macOS
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-macos:
|
||||||
|
name: AppleClang-C++${{matrix.std}}-${{matrix.build_type}}
|
||||||
|
runs-on: macos-12
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
std: [14, 17, 20, 23]
|
||||||
|
include:
|
||||||
|
- generator: Xcode
|
||||||
|
- build_type: Debug
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Dependencies
|
||||||
|
run: |
|
||||||
|
brew install ninja
|
||||||
|
|
||||||
|
- name: Setup Coverage Dependencies
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
brew install gcovr
|
||||||
|
|
||||||
|
- name: Setup Environment
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
echo 'CXXFLAGS=--coverage' >> $GITHUB_ENV
|
||||||
|
echo 'LDFLAGS=--coverage' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror -pedantic-errors ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.build_type}} \
|
||||||
|
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-G "${{matrix.generator}}" \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}} \
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
ctest --test-dir build_${{matrix.build_type}} \
|
||||||
|
--build-config ${{matrix.build_type}} \
|
||||||
|
--output-on-failure
|
||||||
|
|
||||||
|
- name: Generate Coverage
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
cd build_${{matrix.build_type}}
|
||||||
|
rm -r Tests/
|
||||||
|
gcovr -r .. . -s --cobertura coverage.xml
|
||||||
|
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
files: build_${{matrix.build_type}}/coverage.xml
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
245
.github/workflows/windows.yml
vendored
Normal file
245
.github/workflows/windows.yml
vendored
Normal file
@ -0,0 +1,245 @@
|
|||||||
|
name: Windows
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-msvc:
|
||||||
|
name: ${{matrix.msvc}}-${{matrix.arch}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||||
|
runs-on: ${{matrix.os}}
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: powershell
|
||||||
|
env:
|
||||||
|
CL: /MP
|
||||||
|
CXXFLAGS: /WX /permissive-
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
arch: [Win32, x64]
|
||||||
|
build_type: [Debug, Release]
|
||||||
|
lib: [shared, static]
|
||||||
|
msvc: [VS-16-2019, VS-17-2022]
|
||||||
|
std: [14, 17, 20, 23]
|
||||||
|
include:
|
||||||
|
- msvc: VS-16-2019
|
||||||
|
os: windows-2019
|
||||||
|
generator: 'Visual Studio 16 2019'
|
||||||
|
- msvc: VS-17-2022
|
||||||
|
os: windows-2022
|
||||||
|
generator: 'Visual Studio 17 2022'
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- name: Cache GTest
|
||||||
|
id: cache-gtest
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: gtest/
|
||||||
|
key: ${{runner.os}}-gtest-1.14-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Download GTest
|
||||||
|
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile("https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip", "v1.14.0.zip")
|
||||||
|
Expand-Archive v1.14.0.zip .
|
||||||
|
|
||||||
|
- name: Build GTest
|
||||||
|
if: steps.cache-gtest.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
cmake -S googletest-1.14.0 -B build-googletest `
|
||||||
|
-A ${{matrix.arch}} `
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||||
|
-Dgtest_force_shared_crt=ON `
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gtest
|
||||||
|
cmake --build build-googletest `
|
||||||
|
--config ${{matrix.build_type}} `
|
||||||
|
--target install
|
||||||
|
|
||||||
|
- name: Cache gflags
|
||||||
|
id: cache-gflags
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: gflags/
|
||||||
|
key: ${{runner.os}}-gflags-2.2.2-${{matrix.lib}}-${{matrix.arch}}-${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Download gflags
|
||||||
|
if: steps.cache-gflags.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
(New-Object System.Net.WebClient).DownloadFile("https://github.com/gflags/gflags/archive/refs/tags/v2.2.2.zip", "v2.2.2.zip")
|
||||||
|
Expand-Archive v2.2.2.zip .
|
||||||
|
|
||||||
|
- name: Build gflags
|
||||||
|
if: steps.cache-gflags.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
cmake -S gflags-2.2.2 -B build-gflags `
|
||||||
|
-A ${{matrix.arch}} `
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||||
|
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/gflags
|
||||||
|
cmake --build build-gflags `
|
||||||
|
--config ${{matrix.build_type}} `
|
||||||
|
--target install
|
||||||
|
|
||||||
|
- name: Setup Environment
|
||||||
|
run: |
|
||||||
|
echo "GTest_ROOT=$((Get-Item .).FullName)/gtest" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
echo "gflags_ROOT=$((Get-Item .).FullName)/gflags" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
echo "${{github.workspace}}/gtest/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
echo "${{github.workspace}}/gflags/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: Setup Release Environment
|
||||||
|
if: matrix.build_type != 'Debug'
|
||||||
|
run: |
|
||||||
|
echo "CXXFLAGS=/Zi ${{env.CXXFLAGS}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.build_type}} `
|
||||||
|
-A ${{matrix.arch}} `
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
|
||||||
|
-DCMAKE_CXX_EXTENSIONS=OFF `
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} `
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON `
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS='/NOIMPLIB' `
|
||||||
|
-DCMAKE_EXE_LINKER_FLAGS_RELEASE='/INCREMENTAL:NO /DEBUG' `
|
||||||
|
-DCMAKE_INSTALL_PREFIX:PATH=./install `
|
||||||
|
-DCMAKE_MSVC_RUNTIME_LIBRARY='MultiThreaded$<$<CONFIG:Debug>:Debug>DLL' `
|
||||||
|
-G "${{matrix.generator}}" `
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: cmake --build build_${{matrix.build_type}} `
|
||||||
|
--config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
env:
|
||||||
|
CTEST_OUTPUT_ON_FAILURE: 1
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}}/ `
|
||||||
|
--config ${{matrix.build_type}} `
|
||||||
|
--target RUN_TESTS
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}}/ `
|
||||||
|
--config ${{matrix.build_type}} `
|
||||||
|
--target install
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
|
with:
|
||||||
|
category: language:cpp
|
||||||
|
|
||||||
|
build-mingw:
|
||||||
|
name: ${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}
|
||||||
|
runs-on: windows-2022
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
env:
|
||||||
|
BUILDDIR: 'build_${{matrix.sys}}-${{matrix.env}}-C++${{matrix.std}}-${{matrix.build_type}}-${{matrix.lib}}'
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: msys2 {0}
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
build_type: [Debug]
|
||||||
|
lib: [shared, static]
|
||||||
|
std: [14, 17, 20, 23]
|
||||||
|
sys: [mingw32, mingw64]
|
||||||
|
include:
|
||||||
|
- sys: mingw32
|
||||||
|
env: i686
|
||||||
|
- sys: mingw64
|
||||||
|
env: x86_64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v3
|
||||||
|
with:
|
||||||
|
languages: cpp
|
||||||
|
|
||||||
|
- uses: msys2/setup-msys2@v2
|
||||||
|
with:
|
||||||
|
msystem: ${{matrix.sys}}
|
||||||
|
install: >-
|
||||||
|
mingw-w64-${{matrix.env}}-cmake
|
||||||
|
mingw-w64-${{matrix.env}}-gcc
|
||||||
|
mingw-w64-${{matrix.env}}-gflags
|
||||||
|
mingw-w64-${{matrix.env}}-ninja
|
||||||
|
mingw-w64-${{matrix.env}}-python-jinja
|
||||||
|
mingw-w64-${{matrix.env}}-python-lxml
|
||||||
|
mingw-w64-${{matrix.env}}-python-pip
|
||||||
|
mingw-w64-${{matrix.env}}-python-pygments
|
||||||
|
|
||||||
|
- name: Setup Coverage Dependencies
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
pip install 'gcovr==7.0'
|
||||||
|
|
||||||
|
- name: Setup Environment
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
echo 'CXXFLAGS=--coverage ${{env.CXXFLAGS}}' >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Configure
|
||||||
|
env:
|
||||||
|
CXXFLAGS: -Wall -Wextra -Wpedantic -Wsign-conversion -Wtautological-compare -Wformat-nonliteral -Wundef -Werror ${{env.CXXFLAGS}}
|
||||||
|
run: |
|
||||||
|
cmake -S . -B build_${{matrix.build_type}}/ \
|
||||||
|
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \
|
||||||
|
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
|
||||||
|
-DCMAKE_CXX_EXTENSIONS=OFF \
|
||||||
|
-DCMAKE_CXX_STANDARD=${{matrix.std}} \
|
||||||
|
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
|
||||||
|
-DCMAKE_INSTALL_PREFIX:PATH=./install \
|
||||||
|
-G Ninja \
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}}
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
env:
|
||||||
|
CTEST_OUTPUT_ON_FAILURE: 1
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}}/ --config ${{matrix.build_type}} \
|
||||||
|
--target test
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
cmake --build build_${{matrix.build_type}}/ \
|
||||||
|
--config ${{matrix.build_type}} \
|
||||||
|
--target install
|
||||||
|
|
||||||
|
- name: Generate Coverage
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
run: |
|
||||||
|
cd build_${{matrix.build_type}}
|
||||||
|
gcovr -r .. . -s --cobertura coverage.xml
|
||||||
|
|
||||||
|
- name: Upload Coverage to Codecov
|
||||||
|
if: matrix.build_type == 'Debug'
|
||||||
|
uses: codecov/codecov-action@v5
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
files: build_${{matrix.build_type}}/coverage.xml
|
||||||
|
fail_ci_if_error: true
|
||||||
|
verbose: true
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v3
|
||||||
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,12 +1,6 @@
|
|||||||
autom4te.cache
|
*.orig
|
||||||
glog-*.tar.gz
|
/build*/
|
||||||
packages/rpm-unknown
|
/site/
|
||||||
packages/debian-*
|
|
||||||
CMakeCache.txt
|
|
||||||
CMakeFiles/
|
|
||||||
*.cmake
|
|
||||||
config.h
|
|
||||||
*.sln
|
|
||||||
*.vcxproj
|
|
||||||
*.filters
|
|
||||||
bazel-*
|
bazel-*
|
||||||
|
# Bzlmod lockfile
|
||||||
|
/MODULE.bazel.lock
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
set -x
|
|
||||||
|
|
||||||
uname -a
|
|
||||||
|
|
||||||
cmake -H. -B_build_${TOOLCHAIN} -DCMAKE_TOOLCHAIN_FILE="${PWD}/toolchains/${TOOLCHAIN}.cmake"
|
|
||||||
cmake --build _build_${TOOLCHAIN} -- -j4
|
|
||||||
|
|
||||||
if [ "$RUN_TESTS" = true ]; then
|
|
||||||
case "$TOOLCHAIN" in linux-mingw*)
|
|
||||||
echo "copy runtime libraries needed for tests into build directory"
|
|
||||||
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32/{libstdc++-6.dll,libgcc_s_seh-1.dll} _build_${TOOLCHAIN}
|
|
||||||
esac
|
|
||||||
CTEST_OUTPUT_ON_FAILURE=1 cmake --build _build_${TOOLCHAIN} --target test
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
119
.travis.yml
119
.travis.yml
@ -1,119 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
language: bash
|
|
||||||
services:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
# define the build matrix
|
|
||||||
env:
|
|
||||||
global:
|
|
||||||
- PROJECT_DIR: .
|
|
||||||
- TOOLCHAIN: gcc-cxx11
|
|
||||||
- BUILD_PACKAGES: cmake
|
|
||||||
- RUN_TESTS: true
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
# Linux {
|
|
||||||
|
|
||||||
# Ubuntu 14.04
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=trusty
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
BUILD_PACKAGES=cmake3
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=trusty
|
|
||||||
BUILD_ARCH=i386
|
|
||||||
BUILD_PACKAGES=cmake3
|
|
||||||
# Ubuntu 16.04
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=xenial
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=xenial
|
|
||||||
BUILD_ARCH=i386
|
|
||||||
# Ubuntu 18.04
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=gcc-cxx98
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=gcc-gnuxx11
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=gcc-cxx17
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=clang-cxx17
|
|
||||||
BUILD_PACKAGES="cmake clang"
|
|
||||||
# } // end Linux
|
|
||||||
|
|
||||||
# Windows build with mingw-w64 on Ubuntu 18.04
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=linux-mingw-w64-cxx11
|
|
||||||
BUILD_PACKAGES="cmake mingw-w64 wine-stable"
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=linux-mingw-w64-gnuxx11
|
|
||||||
BUILD_PACKAGES="cmake mingw-w64 wine-stable"
|
|
||||||
- os: linux
|
|
||||||
env: >
|
|
||||||
BUILD_FLAVOR=ubuntu
|
|
||||||
BUILD_RELEASE=bionic
|
|
||||||
BUILD_ARCH=amd64
|
|
||||||
TOOLCHAIN=linux-mingw-w64-cxx17
|
|
||||||
BUILD_PACKAGES="cmake mingw-w64 wine-stable"
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
# use the Dockerfile.<distro>.template file for building the image with sed magic
|
|
||||||
- |
|
|
||||||
sed \
|
|
||||||
-e "s/@BUILD_FLAVOR@/${BUILD_FLAVOR}/g" \
|
|
||||||
-e "s/@BUILD_RELEASE@/${BUILD_RELEASE}/g" \
|
|
||||||
-e "s/@BUILD_ARCH@/${BUILD_ARCH}/g" \
|
|
||||||
-e "s/@BUILD_PACKAGES@/${BUILD_PACKAGES}/g" \
|
|
||||||
Dockerfile.$BUILD_FLAVOR.template | tee Dockerfile.$BUILD_FLAVOR.$BUILD_RELEASE.$BUILD_ARCH
|
|
||||||
- docker build -f Dockerfile.$BUILD_FLAVOR.$BUILD_RELEASE.$BUILD_ARCH -t glog-devel .
|
|
||||||
|
|
||||||
script: |
|
|
||||||
# run the respective .travis.<distro>.sh script
|
|
||||||
docker run \
|
|
||||||
-e BUILD_FLAVOR="$BUILD_FLAVOR" \
|
|
||||||
-e BUILD_RELEASE="$BUILD_RELEASE" \
|
|
||||||
-e BUILD_ARCH="$BUILD_ARCH" \
|
|
||||||
-e PROJECT_DIR="$PROJECT_DIR" \
|
|
||||||
-e TOOLCHAIN="$TOOLCHAIN" \
|
|
||||||
-e RUN_TESTS="$RUN_TESTS" \
|
|
||||||
-it glog-devel ./.travis.$BUILD_FLAVOR.sh
|
|
||||||
|
|
||||||
5
AUTHORS
5
AUTHORS
@ -13,8 +13,11 @@ Abhishek Parmar <abhishek@orng.net>
|
|||||||
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
|
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
|
||||||
Andy Ying <andy@trailofbits.com>
|
Andy Ying <andy@trailofbits.com>
|
||||||
Brian Silverman <bsilver16384@gmail.com>
|
Brian Silverman <bsilver16384@gmail.com>
|
||||||
|
Dmitriy Arbitman <d.arbitman@gmail.com>
|
||||||
Google Inc.
|
Google Inc.
|
||||||
Guillaume Dumont <dumont.guillaume@gmail.com>
|
Guillaume Dumont <dumont.guillaume@gmail.com>
|
||||||
|
LingBin <lingbinlb@gmail.com>
|
||||||
|
Marco Wang <m.aesophor@gmail.com>
|
||||||
Michael Tanner <michael@tannertaxpro.com>
|
Michael Tanner <michael@tannertaxpro.com>
|
||||||
MiniLight <MiniLightAR@Gmail.com>
|
MiniLight <MiniLightAR@Gmail.com>
|
||||||
romange <romange@users.noreply.github.com>
|
romange <romange@users.noreply.github.com>
|
||||||
@ -22,4 +25,6 @@ Roman Perepelitsa <roman.perepelitsa@gmail.com>
|
|||||||
Sergiu Deitsch <sergiu.deitsch@gmail.com>
|
Sergiu Deitsch <sergiu.deitsch@gmail.com>
|
||||||
tbennun <tbennun@gmail.com>
|
tbennun <tbennun@gmail.com>
|
||||||
Teddy Reed <teddy@prosauce.org>
|
Teddy Reed <teddy@prosauce.org>
|
||||||
|
Vijaymahantesh Sattigeri <vijaymahantesh016@gmail.com>
|
||||||
Zhongming Qu <qzmfranklin@gmail.com>
|
Zhongming Qu <qzmfranklin@gmail.com>
|
||||||
|
Zhuoran Shen <cmsflash99@gmail.com>
|
||||||
|
|||||||
5
BUILD
5
BUILD
@ -1,5 +0,0 @@
|
|||||||
licenses(['notice'])
|
|
||||||
|
|
||||||
load(':bazel/glog.bzl', 'glog_library')
|
|
||||||
|
|
||||||
glog_library()
|
|
||||||
22
BUILD.bazel
Normal file
22
BUILD.bazel
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
licenses(["notice"])
|
||||||
|
|
||||||
|
exports_files(["COPYING"])
|
||||||
|
|
||||||
|
load(":bazel/glog.bzl", "glog_library")
|
||||||
|
|
||||||
|
glog_library()
|
||||||
|
|
||||||
|
# platform() to build with clang-cl on Bazel CI. This is enabled with
|
||||||
|
# the flags in .bazelci/presubmit.yml:
|
||||||
|
#
|
||||||
|
# --incompatible_enable_cc_toolchain_resolution
|
||||||
|
# --extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl
|
||||||
|
# --extra_execution_platforms=//:x64_windows-clang-cl
|
||||||
|
platform(
|
||||||
|
name = "x64_windows-clang-cl",
|
||||||
|
constraint_values = [
|
||||||
|
"@platforms//cpu:x86_64",
|
||||||
|
"@platforms//os:windows",
|
||||||
|
"@rules_cc//cc/private/toolchain:clang-cl",
|
||||||
|
],
|
||||||
|
)
|
||||||
1323
CMakeLists.txt
1323
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
@ -1,58 +0,0 @@
|
|||||||
# How to contribute #
|
|
||||||
|
|
||||||
We'd love to accept your patches and contributions to this project. There are
|
|
||||||
a just a few small guidelines you need to follow.
|
|
||||||
|
|
||||||
|
|
||||||
## Contributor License Agreement ##
|
|
||||||
|
|
||||||
Contributions to any Google project must be accompanied by a Contributor
|
|
||||||
License Agreement. This is not a copyright **assignment**, it simply gives
|
|
||||||
Google permission to use and redistribute your contributions as part of the
|
|
||||||
project.
|
|
||||||
|
|
||||||
* If you are an individual writing original source code and you're sure you
|
|
||||||
own the intellectual property, then you'll need to sign an [individual
|
|
||||||
CLA][].
|
|
||||||
|
|
||||||
* If you work for a company that wants to allow you to contribute your work,
|
|
||||||
then you'll need to sign a [corporate CLA][].
|
|
||||||
|
|
||||||
You generally only need to submit a CLA once, so if you've already submitted
|
|
||||||
one (even if it was for a different project), you probably don't need to do it
|
|
||||||
again.
|
|
||||||
|
|
||||||
[individual CLA]: https://developers.google.com/open-source/cla/individual
|
|
||||||
[corporate CLA]: https://developers.google.com/open-source/cla/corporate
|
|
||||||
|
|
||||||
Once your CLA is submitted (or if you already submitted one for
|
|
||||||
another Google project), make a commit adding yourself to the
|
|
||||||
[AUTHORS][] and [CONTRIBUTORS][] files. This commit can be part
|
|
||||||
of your first [pull request][].
|
|
||||||
|
|
||||||
[AUTHORS]: AUTHORS
|
|
||||||
[CONTRIBUTORS]: CONTRIBUTORS
|
|
||||||
|
|
||||||
|
|
||||||
## Submitting a patch ##
|
|
||||||
|
|
||||||
1. It's generally best to start by opening a new issue describing the bug or
|
|
||||||
feature you're intending to fix. Even if you think it's relatively minor,
|
|
||||||
it's helpful to know what people are working on. Mention in the initial
|
|
||||||
issue that you are planning to work on that bug or feature so that it can
|
|
||||||
be assigned to you.
|
|
||||||
|
|
||||||
1. Follow the normal process of [forking][] the project, and setup a new
|
|
||||||
branch to work in. It's important that each group of changes be done in
|
|
||||||
separate branches in order to ensure that a pull request only includes the
|
|
||||||
commits related to that bug or feature.
|
|
||||||
|
|
||||||
1. Do your best to have [well-formed commit messages][] for each change.
|
|
||||||
This provides consistency throughout the project, and ensures that commit
|
|
||||||
messages are able to be formatted properly by various git tools.
|
|
||||||
|
|
||||||
1. Finally, push the commits to your fork and submit a [pull request][].
|
|
||||||
|
|
||||||
[forking]: https://help.github.com/articles/fork-a-repo
|
|
||||||
[well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
|
||||||
[pull request]: https://help.github.com/articles/creating-a-pull-request
|
|
||||||
@ -26,12 +26,19 @@ Abhishek Dasgupta <abhi2743@gmail.com>
|
|||||||
Abhishek Parmar <abhishek@orng.net>
|
Abhishek Parmar <abhishek@orng.net>
|
||||||
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
|
Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
|
||||||
Andy Ying <andy@trailofbits.com>
|
Andy Ying <andy@trailofbits.com>
|
||||||
|
Bret McKee <bretmckee@google.com>
|
||||||
Brian Silverman <bsilver16384@gmail.com>
|
Brian Silverman <bsilver16384@gmail.com>
|
||||||
|
Dmitriy Arbitman <d.arbitman@gmail.com>
|
||||||
|
Eric Kilmer <eric.d.kilmer@gmail.com>
|
||||||
Fumitoshi Ukai <ukai@google.com>
|
Fumitoshi Ukai <ukai@google.com>
|
||||||
Guillaume Dumont <dumont.guillaume@gmail.com>
|
Guillaume Dumont <dumont.guillaume@gmail.com>
|
||||||
Håkan L. S. Younes <hyounes@google.com>
|
Håkan L. S. Younes <hyounes@google.com>
|
||||||
Ivan Penkov <ivanpe@google.com>
|
Ivan Penkov <ivanpe@google.com>
|
||||||
|
Jacob Trimble <modmaker@google.com>
|
||||||
Jim Ray <jimray@google.com>
|
Jim Ray <jimray@google.com>
|
||||||
|
LingBin <lingbinlb@gmail.com>
|
||||||
|
Marco Wang <m.aesophor@gmail.com>
|
||||||
|
Michael Darr <mdarr@matician.com>
|
||||||
Michael Tanner <michael@tannertaxpro.com>
|
Michael Tanner <michael@tannertaxpro.com>
|
||||||
MiniLight <MiniLightAR@Gmail.com>
|
MiniLight <MiniLightAR@Gmail.com>
|
||||||
Peter Collingbourne <pcc@google.com>
|
Peter Collingbourne <pcc@google.com>
|
||||||
@ -42,4 +49,6 @@ Sergiu Deitsch <sergiu.deitsch@gmail.com>
|
|||||||
Shinichiro Hamaji <hamaji@google.com>
|
Shinichiro Hamaji <hamaji@google.com>
|
||||||
tbennun <tbennun@gmail.com>
|
tbennun <tbennun@gmail.com>
|
||||||
Teddy Reed <teddy@prosauce.org>
|
Teddy Reed <teddy@prosauce.org>
|
||||||
|
Vijaymahantesh Sattigeri <vijaymahantesh016@gmail.com>
|
||||||
Zhongming Qu <qzmfranklin@gmail.com>
|
Zhongming Qu <qzmfranklin@gmail.com>
|
||||||
|
Zhuoran Shen <cmsflash99@gmail.com>
|
||||||
|
|||||||
65
COPYING
65
COPYING
@ -1,65 +0,0 @@
|
|||||||
Copyright (c) 2008, Google Inc.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above
|
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
|
||||||
in the documentation and/or other materials provided with the
|
|
||||||
distribution.
|
|
||||||
* Neither the name of Google Inc. nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
A function gettimeofday in utilities.cc is based on
|
|
||||||
|
|
||||||
http://www.google.com/codesearch/p?hl=en#dR3YEbitojA/COPYING&q=GetSystemTimeAsFileTime%20license:bsd
|
|
||||||
|
|
||||||
The license of this code is:
|
|
||||||
|
|
||||||
Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi> and contributors
|
|
||||||
All Rights Reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are
|
|
||||||
met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
2. 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.
|
|
||||||
|
|
||||||
3. Neither the name(s) of the above-listed copyright holder(s) 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.
|
|
||||||
20
ChangeLog
20
ChangeLog
@ -1,3 +1,23 @@
|
|||||||
|
2024-06-08 Google Inc. <opensource@google.com>
|
||||||
|
|
||||||
|
* google-glog: version 0.7.1.
|
||||||
|
* See git log for the details.
|
||||||
|
|
||||||
|
2024-02-17 Google Inc. <opensource@google.com>
|
||||||
|
|
||||||
|
* google-glog: version 0.7.0.
|
||||||
|
* See git log for the details.
|
||||||
|
|
||||||
|
2022-04-05 Google Inc. <opensource@google.com>
|
||||||
|
|
||||||
|
* google-glog: version 0.6.0.
|
||||||
|
* See git log for the details.
|
||||||
|
|
||||||
|
2021-05-08 Google Inc. <opensource@google.com>
|
||||||
|
|
||||||
|
* google-glog: version 0.5.0.
|
||||||
|
* See git log for the details.
|
||||||
|
|
||||||
2019-01-22 Google Inc. <opensource@google.com>
|
2019-01-22 Google Inc. <opensource@google.com>
|
||||||
|
|
||||||
* google-glog: version 0.4.0.
|
* google-glog: version 0.4.0.
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
# Build Ubuntu image
|
|
||||||
FROM @BUILD_ARCH@/@BUILD_FLAVOR@:@BUILD_RELEASE@
|
|
||||||
|
|
||||||
# see https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#/run
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
@BUILD_PACKAGES@ \
|
|
||||||
build-essential \
|
|
||||||
g++
|
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app
|
|
||||||
WORKDIR /usr/src/app
|
|
||||||
|
|
||||||
COPY . /usr/src/app
|
|
||||||
297
INSTALL
297
INSTALL
@ -1,297 +0,0 @@
|
|||||||
Installation Instructions
|
|
||||||
*************************
|
|
||||||
|
|
||||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
|
||||||
2006, 2007 Free Software Foundation, Inc.
|
|
||||||
|
|
||||||
This file is free documentation; the Free Software Foundation gives
|
|
||||||
unlimited permission to copy, distribute and modify it.
|
|
||||||
|
|
||||||
Glog-Specific Install Notes
|
|
||||||
================================
|
|
||||||
|
|
||||||
*** NOTE FOR 64-BIT LINUX SYSTEMS
|
|
||||||
|
|
||||||
The glibc built-in stack-unwinder on 64-bit systems has some problems
|
|
||||||
with the glog libraries. (In particular, if you are using
|
|
||||||
InstallFailureSignalHandler(), the signal may be raised in the middle
|
|
||||||
of malloc, holding some malloc-related locks when they invoke the
|
|
||||||
stack unwinder. The built-in stack unwinder may call malloc
|
|
||||||
recursively, which may require the thread to acquire a lock it already
|
|
||||||
holds: deadlock.)
|
|
||||||
|
|
||||||
For that reason, if you use a 64-bit system and you need
|
|
||||||
InstallFailureSignalHandler(), we strongly recommend you install
|
|
||||||
libunwind before trying to configure or install google glog.
|
|
||||||
libunwind can be found at
|
|
||||||
|
|
||||||
http://download.savannah.nongnu.org/releases/libunwind/libunwind-snap-070410.tar.gz
|
|
||||||
|
|
||||||
Even if you already have libunwind installed, you will probably still
|
|
||||||
need to install from the snapshot to get the latest version.
|
|
||||||
|
|
||||||
CAUTION: if you install libunwind from the URL above, be aware that
|
|
||||||
you may have trouble if you try to statically link your binary with
|
|
||||||
glog: that is, if you link with 'gcc -static -lgcc_eh ...'. This
|
|
||||||
is because both libunwind and libgcc implement the same C++ exception
|
|
||||||
handling APIs, but they implement them differently on some platforms.
|
|
||||||
This is not likely to be a problem on ia64, but may be on x86-64.
|
|
||||||
|
|
||||||
Also, if you link binaries statically, make sure that you add
|
|
||||||
-Wl,--eh-frame-hdr to your linker options. This is required so that
|
|
||||||
libunwind can find the information generated by the compiler required
|
|
||||||
for stack unwinding.
|
|
||||||
|
|
||||||
Using -static is rare, though, so unless you know this will affect you
|
|
||||||
it probably won't.
|
|
||||||
|
|
||||||
If you cannot or do not wish to install libunwind, you can still try
|
|
||||||
to use two kinds of stack-unwinder: 1. glibc built-in stack-unwinder
|
|
||||||
and 2. frame pointer based stack-unwinder.
|
|
||||||
|
|
||||||
1. As we already mentioned, glibc's unwinder has a deadlock issue.
|
|
||||||
However, if you don't use InstallFailureSignalHandler() or you don't
|
|
||||||
worry about the rare possibilities of deadlocks, you can use this
|
|
||||||
stack-unwinder. If you specify no options and libunwind isn't
|
|
||||||
detected on your system, the configure script chooses this unwinder by
|
|
||||||
default.
|
|
||||||
|
|
||||||
2. The frame pointer based stack unwinder requires that your
|
|
||||||
application, the glog library, and system libraries like libc, all be
|
|
||||||
compiled with a frame pointer. This is *not* the default for x86-64.
|
|
||||||
|
|
||||||
If you are on x86-64 system, know that you have a set of system
|
|
||||||
libraries with frame-pointers enabled, and compile all your
|
|
||||||
applications with -fno-omit-frame-pointer, then you can enable the
|
|
||||||
frame pointer based stack unwinder by passing the
|
|
||||||
--enable-frame-pointers flag to configure.
|
|
||||||
|
|
||||||
|
|
||||||
Basic Installation
|
|
||||||
==================
|
|
||||||
|
|
||||||
Briefly, the shell commands `./configure; make; make install' should
|
|
||||||
configure, build, and install this package. The following
|
|
||||||
more-detailed instructions are generic; see the `README.md' file for
|
|
||||||
instructions specific to this package.
|
|
||||||
|
|
||||||
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.md' 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 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.
|
|
||||||
|
|
||||||
Running `configure' might take a while. 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.
|
|
||||||
|
|
||||||
6. Often, you can also type `make uninstall' to remove the installed
|
|
||||||
files again.
|
|
||||||
|
|
||||||
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=c99 CFLAGS=-g 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 can use 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 `..'.
|
|
||||||
|
|
||||||
With a non-GNU `make', it is safer 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.md' 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).
|
|
||||||
|
|
||||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
|
||||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
|
||||||
|
|
||||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/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.
|
|
||||||
|
|
||||||
@ -1,26 +1,18 @@
|
|||||||
This package was debianized by Google Inc. <opensource@google.com> on
|
Copyright © 2024, Google Inc.
|
||||||
13 June 2008.
|
|
||||||
|
|
||||||
It was downloaded from https://github.com/google/glog
|
|
||||||
|
|
||||||
Upstream Author: opensource@google.com
|
|
||||||
|
|
||||||
Copyright (c) 2008, Google Inc.
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
||||||
met:
|
met:
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
notice, this list of conditions and the following disclaimer.
|
list of conditions and the following disclaimer.
|
||||||
* Redistributions in binary form must reproduce the above
|
* Redistributions in binary form must reproduce the above copyright notice, this
|
||||||
copyright notice, this list of conditions and the following disclaimer
|
list of conditions and the following disclaimer in the documentation and/or
|
||||||
in the documentation and/or other materials provided with the
|
other materials provided with the distribution.
|
||||||
distribution.
|
* Neither the name of Google Inc. nor the names of its contributors may be used
|
||||||
* Neither the name of Google Inc. nor the names of its
|
to endorse or promote products derived from this software without specific
|
||||||
contributors may be used to endorse or promote products derived from
|
prior written permission.
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
13
MODULE.bazel
Normal file
13
MODULE.bazel
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module(
|
||||||
|
name = "glog",
|
||||||
|
compatibility_level = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(name = "gflags", version = "2.2.2")
|
||||||
|
bazel_dep(name = "googletest", version = "1.14.0", dev_dependency = True)
|
||||||
|
bazel_dep(name = "platforms", version = "0.0.10")
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.12")
|
||||||
|
|
||||||
|
# Required for Windows clang-cl build: --extra_toolchains=@local_config_cc//:cc-toolchain-arm64_windows
|
||||||
|
cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
|
||||||
|
use_repo(cc_configure, "local_config_cc")
|
||||||
260
Makefile.am
260
Makefile.am
@ -1,260 +0,0 @@
|
|||||||
## Process this file with automake to produce Makefile.in
|
|
||||||
|
|
||||||
AUTOMAKE_OPTIONS = subdir-objects foreign
|
|
||||||
|
|
||||||
# Make sure that when we re-make ./configure, we get the macros we need
|
|
||||||
ACLOCAL_AMFLAGS = -I m4
|
|
||||||
|
|
||||||
# This is so we can #include <glog/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
|
|
||||||
|
|
||||||
# These are x86-specific, having to do with frame-pointers
|
|
||||||
if X86_64
|
|
||||||
if ENABLE_FRAME_POINTERS
|
|
||||||
AM_CXXFLAGS += -fno-omit-frame-pointer
|
|
||||||
else
|
|
||||||
# TODO(csilvers): check if -fomit-frame-pointer might be in $(CXXFLAGS),
|
|
||||||
# before setting this.
|
|
||||||
AM_CXXFLAGS += -DNO_FRAME_POINTER
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if DISABLE_RTTI
|
|
||||||
AM_CXXFLAGS += -fno-rtti
|
|
||||||
endif
|
|
||||||
|
|
||||||
glogincludedir = $(includedir)/glog
|
|
||||||
## The .h files you want to install (that is, .h files that people
|
|
||||||
## who install this package can include in their own applications.)
|
|
||||||
## We have to include both the .h and .h.in forms. The latter we
|
|
||||||
## put in noinst_HEADERS.
|
|
||||||
gloginclude_HEADERS = src/glog/log_severity.h
|
|
||||||
nodist_gloginclude_HEADERS = src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h
|
|
||||||
noinst_HEADERS = src/glog/logging.h.in src/glog/raw_logging.h.in src/glog/vlog_is_on.h.in src/glog/stl_logging.h.in
|
|
||||||
|
|
||||||
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 README.md README.windows \
|
|
||||||
doc/designstyle.css doc/glog.html
|
|
||||||
|
|
||||||
## The libraries (.so's) you want to install
|
|
||||||
lib_LTLIBRARIES =
|
|
||||||
|
|
||||||
# The libraries libglog depends on.
|
|
||||||
COMMON_LIBS = $(PTHREAD_LIBS) $(GFLAGS_LIBS) $(UNWIND_LIBS)
|
|
||||||
# Compile switches for our unittest.
|
|
||||||
TEST_CFLAGS = $(GTEST_CFLAGS) $(GMOCK_CFLAGS) $(GFLAGS_CFLAGS) \
|
|
||||||
$(MINGW_CFLAGS) $(AM_CXXFLAGS)
|
|
||||||
# Libraries for our unittest.
|
|
||||||
TEST_LIBS = $(GTEST_LIBS) $(GMOCK_LIBS) $(GFLAGS_LIBS)
|
|
||||||
|
|
||||||
## 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 =
|
|
||||||
# Set a small stack size so that (at least on Linux) PIEs are mapped at a lower
|
|
||||||
# address than DSOs. This is used by symbolize_pie_unittest to check that we can
|
|
||||||
# successfully symbolize PIEs loaded at low addresses.
|
|
||||||
TESTS_ENVIRONMENT = ulimit -s 8192;
|
|
||||||
check_SCRIPTS =
|
|
||||||
# Every time you add a unittest to check_SCRIPTS, add it here too
|
|
||||||
noinst_SCRIPTS =
|
|
||||||
# Binaries used for script-based unittests.
|
|
||||||
TEST_BINARIES =
|
|
||||||
|
|
||||||
TESTS += logging_unittest
|
|
||||||
logging_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/logging_unittest.cc \
|
|
||||||
src/config_for_unittests.h \
|
|
||||||
src/mock-log.h
|
|
||||||
nodist_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
check_SCRIPTS += logging_striplog_test_sh
|
|
||||||
noinst_SCRIPTS += src/logging_striplog_test.sh
|
|
||||||
logging_striplog_test_sh: logging_striptest0 logging_striptest2 logging_striptest10
|
|
||||||
$(top_srcdir)/src/logging_striplog_test.sh
|
|
||||||
|
|
||||||
check_SCRIPTS += demangle_unittest_sh
|
|
||||||
noinst_SCRIPTS += src/demangle_unittest.sh
|
|
||||||
demangle_unittest_sh: demangle_unittest
|
|
||||||
$(builddir)/demangle_unittest # force to create lt-demangle_unittest
|
|
||||||
$(top_srcdir)/src/demangle_unittest.sh
|
|
||||||
|
|
||||||
check_SCRIPTS += signalhandler_unittest_sh
|
|
||||||
noinst_SCRIPTS += src/signalhandler_unittest.sh
|
|
||||||
signalhandler_unittest_sh: signalhandler_unittest
|
|
||||||
$(builddir)/signalhandler_unittest # force to create lt-signalhandler_unittest
|
|
||||||
$(top_srcdir)/src/signalhandler_unittest.sh
|
|
||||||
|
|
||||||
TEST_BINARIES += logging_striptest0
|
|
||||||
logging_striptest0_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/logging_striptest_main.cc
|
|
||||||
nodist_logging_striptest0_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
logging_striptest0_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
logging_striptest0_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
logging_striptest0_LDADD = libglog.la $(COMMON_LIBS)
|
|
||||||
|
|
||||||
TEST_BINARIES += logging_striptest2
|
|
||||||
logging_striptest2_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/logging_striptest2.cc
|
|
||||||
nodist_logging_striptest2_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
logging_striptest2_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
logging_striptest2_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
logging_striptest2_LDADD = libglog.la $(COMMON_LIBS)
|
|
||||||
|
|
||||||
TEST_BINARIES += logging_striptest10
|
|
||||||
logging_striptest10_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/logging_striptest10.cc
|
|
||||||
nodist_logging_striptest10_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
logging_striptest10_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
logging_striptest10_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
logging_striptest10_LDADD = libglog.la $(COMMON_LIBS)
|
|
||||||
|
|
||||||
TESTS += demangle_unittest
|
|
||||||
demangle_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/demangle_unittest.cc
|
|
||||||
nodist_demangle_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
demangle_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
demangle_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
demangle_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
TESTS += stacktrace_unittest
|
|
||||||
stacktrace_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/stacktrace_unittest.cc
|
|
||||||
nodist_stacktrace_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
stacktrace_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
stacktrace_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
stacktrace_unittest_LDADD = libglog.la $(COMMON_LIBS)
|
|
||||||
|
|
||||||
TESTS += symbolize_unittest
|
|
||||||
symbolize_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/symbolize_unittest.cc
|
|
||||||
nodist_symbolize_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
symbolize_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
symbolize_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
symbolize_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
TESTS += symbolize_pie_unittest
|
|
||||||
symbolize_pie_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/symbolize_unittest.cc
|
|
||||||
nodist_symbolize_pie_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
symbolize_pie_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS) -fPIE
|
|
||||||
symbolize_pie_unittest_LDFLAGS = $(PTHREAD_CFLAGS) -pie
|
|
||||||
symbolize_pie_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
TESTS += stl_logging_unittest
|
|
||||||
stl_logging_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/stl_logging_unittest.cc
|
|
||||||
nodist_stl_logging_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
stl_logging_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
stl_logging_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
stl_logging_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
TEST_BINARIES += signalhandler_unittest
|
|
||||||
signalhandler_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/signalhandler_unittest.cc
|
|
||||||
nodist_signalhandler_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
signalhandler_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
signalhandler_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
signalhandler_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
TESTS += utilities_unittest
|
|
||||||
utilities_unittest_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/utilities_unittest.cc
|
|
||||||
nodist_utilities_unittest_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
utilities_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
utilities_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
utilities_unittest_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
|
|
||||||
if HAVE_GMOCK
|
|
||||||
TESTS += mock_log_test
|
|
||||||
mock_log_test_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/mock-log_test.cc
|
|
||||||
nodist_mock_log_test_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
mock_log_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(TEST_CFLAGS)
|
|
||||||
mock_log_test_LDFLAGS = $(PTHREAD_CFLAGS)
|
|
||||||
mock_log_test_LDADD = libglog.la $(COMMON_LIBS) $(TEST_LIBS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
|
|
||||||
|
|
||||||
lib_LTLIBRARIES += libglog.la
|
|
||||||
libglog_la_SOURCES = $(gloginclude_HEADERS) \
|
|
||||||
src/logging.cc src/raw_logging.cc src/vlog_is_on.cc \
|
|
||||||
src/utilities.cc src/utilities.h \
|
|
||||||
src/demangle.cc src/demangle.h \
|
|
||||||
src/stacktrace.h \
|
|
||||||
src/stacktrace_generic-inl.h \
|
|
||||||
src/stacktrace_libunwind-inl.h \
|
|
||||||
src/stacktrace_powerpc-inl.h \
|
|
||||||
src/stacktrace_x86-inl.h \
|
|
||||||
src/stacktrace_x86_64-inl.h \
|
|
||||||
src/symbolize.cc src/symbolize.h \
|
|
||||||
src/signalhandler.cc \
|
|
||||||
src/base/mutex.h src/base/googleinit.h \
|
|
||||||
src/base/commandlineflags.h src/googletest.h
|
|
||||||
nodist_libglog_la_SOURCES = $(nodist_gloginclude_HEADERS)
|
|
||||||
|
|
||||||
libglog_la_CXXFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_CFLAGS) $(MINGW_CFLAGS) \
|
|
||||||
$(AM_CXXFLAGS) -DNDEBUG
|
|
||||||
libglog_la_LDFLAGS = $(PTRHEAD_CFLAGS) $(GFLAGS_LDFLAGS)
|
|
||||||
libglog_la_LIBADD = $(COMMON_LIBS)
|
|
||||||
|
|
||||||
## The location of the windows project file for each binary we make
|
|
||||||
WINDOWS_PROJECTS = google-glog.sln
|
|
||||||
WINDOWS_PROJECTS += vsprojects/libglog/libglog.vcproj
|
|
||||||
WINDOWS_PROJECTS += vsprojects/logging_unittest/logging_unittest.vcproj
|
|
||||||
WINDOWS_PROJECTS += vsprojects/libglog_static/libglog_static.vcproj
|
|
||||||
WINDOWS_PROJECTS += vsprojects/logging_unittest_static/logging_unittest_static.vcproj
|
|
||||||
|
|
||||||
## ^^^^ 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) $(TEST_BINARIES)
|
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
# Windows wants write permission to .vcproj files and maybe even sln files.
|
|
||||||
dist-hook:
|
|
||||||
test -e "$(distdir)/vsprojects" \
|
|
||||||
&& chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
|
|
||||||
|
|
||||||
libtool: $(LIBTOOL_DEPS)
|
|
||||||
$(SHELL) ./config.status --recheck
|
|
||||||
|
|
||||||
EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec \
|
|
||||||
packages/deb.sh packages/deb/* \
|
|
||||||
$(SCRIPTS) src/logging_unittest.err src/demangle_unittest.txt \
|
|
||||||
src/windows/config.h src/windows/port.h src/windows/port.cc \
|
|
||||||
src/windows/preprocess.sh \
|
|
||||||
src/windows/glog/log_severity.h src/windows/glog/logging.h \
|
|
||||||
src/windows/glog/raw_logging.h src/windows/glog/stl_logging.h \
|
|
||||||
src/windows/glog/vlog_is_on.h \
|
|
||||||
$(WINDOWS_PROJECTS)
|
|
||||||
|
|
||||||
CLEANFILES = core demangle.dm demangle.nm signalhandler.out* \
|
|
||||||
signalhandler_unittest.*.log.INFO.*
|
|
||||||
|
|
||||||
# Add pkgconfig file
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
|
||||||
pkgconfig_DATA = libglog.pc
|
|
||||||
10
README.md
10
README.md
@ -1,10 +0,0 @@
|
|||||||
[](https://travis-ci.org/google/glog/builds)
|
|
||||||
[](https://ci.appveyor.com/project/google-admin/glog/history)
|
|
||||||
|
|
||||||
This repository contains a C++ implementation of the Google logging
|
|
||||||
module. Documentation for the implementation is in doc/.
|
|
||||||
|
|
||||||
See INSTALL for (generic) installation instructions for C++: basically
|
|
||||||
```sh
|
|
||||||
./autogen.sh && ./configure && make && make install
|
|
||||||
```
|
|
||||||
23
README.rst
Normal file
23
README.rst
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Google Logging Library
|
||||||
|
======================
|
||||||
|
|
||||||
|
|Linux Github actions| |Windows Github actions| |macOS Github actions| |Codecov|
|
||||||
|
|
||||||
|
Google Logging (glog) is a C++14 library that implements application-level
|
||||||
|
logging. The library provides logging APIs based on C++-style streams and
|
||||||
|
various helper macros.
|
||||||
|
|
||||||
|
Getting Started
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Please refer to project's `documentation <https://google.github.io/glog/>`_.
|
||||||
|
|
||||||
|
|
||||||
|
.. |Linux Github actions| image:: https://github.com/google/glog/actions/workflows/linux.yml/badge.svg
|
||||||
|
:target: https://github.com/google/glog/actions
|
||||||
|
.. |Windows Github actions| image:: https://github.com/google/glog/actions/workflows/windows.yml/badge.svg
|
||||||
|
:target: https://github.com/google/glog/actions
|
||||||
|
.. |macOS Github actions| image:: https://github.com/google/glog/actions/workflows/macos.yml/badge.svg
|
||||||
|
:target: https://github.com/google/glog/actions
|
||||||
|
.. |Codecov| image:: https://codecov.io/gh/google/glog/branch/master/graph/badge.svg?token=8an420vNju
|
||||||
|
:target: https://codecov.io/gh/google/glog
|
||||||
@ -1,17 +0,0 @@
|
|||||||
This project has been ported to Windows, including stack tracing, signal
|
|
||||||
handling, and unit tests.
|
|
||||||
|
|
||||||
A Visual Studio solution file is explicitly not provided because it is not
|
|
||||||
maintainable. Instead, a CMake build system exists to generate the correct
|
|
||||||
solution for your version of Visual Studio.
|
|
||||||
|
|
||||||
In short,
|
|
||||||
(1) Install CMake from: https://cmake.org/download/
|
|
||||||
(2) With CMake on your PATH, run `cmake .` to generate the build files
|
|
||||||
(3) Either use `cmake --build`, or open the generated solution
|
|
||||||
|
|
||||||
CMake provides different generators, and by default will pick the most relevant
|
|
||||||
one to your environment. If you need a specific version of Visual Studio, use
|
|
||||||
`cmake . -G <generator-name>`, and see `cmake --help` for the available
|
|
||||||
generators. Also see `-T <toolset-name>`, which can used to request the native
|
|
||||||
x64 toolchain with `-T host=x64`.
|
|
||||||
10
WORKSPACE
10
WORKSPACE
@ -1,10 +0,0 @@
|
|||||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
||||||
|
|
||||||
http_archive(
|
|
||||||
name = "com_github_gflags_gflags",
|
|
||||||
strip_prefix = "gflags-2.2.2",
|
|
||||||
urls = [
|
|
||||||
"https://mirror.bazel.build/github.com/gflags/gflags/archive/v2.2.2.tar.gz",
|
|
||||||
"https://github.com/gflags/gflags/archive/v2.2.2.tar.gz",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
1
WORKSPACE.bazel
Normal file
1
WORKSPACE.bazel
Normal file
@ -0,0 +1 @@
|
|||||||
|
# WORKSPACE marker file needed by Bazel
|
||||||
71
appveyor.yml
71
appveyor.yml
@ -1,71 +0,0 @@
|
|||||||
# global environment variables
|
|
||||||
environment:
|
|
||||||
global:
|
|
||||||
# path to source directory of project to be built
|
|
||||||
PROJECT_DIR: .
|
|
||||||
# output test results for failing tests
|
|
||||||
CTEST_OUTPUT_ON_FAILURE: 1
|
|
||||||
|
|
||||||
# test matrix
|
|
||||||
matrix:
|
|
||||||
|
|
||||||
- TOOLCHAIN: "vs-14-2015-sdk-8-1"
|
|
||||||
GENERATOR: "Visual Studio 14 2015 Win64"
|
|
||||||
TEST_TARGET: RUN_TESTS
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "vs-14-2015-win64"
|
|
||||||
GENERATOR: "Visual Studio 14 2015 Win64"
|
|
||||||
TEST_TARGET: RUN_TESTS
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "vs-15-2017-win64"
|
|
||||||
GENERATOR: "Visual Studio 15 2017 Win64"
|
|
||||||
TEST_TARGET: RUN_TESTS
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "vs-15-2017-win64-cxx17"
|
|
||||||
GENERATOR: "Visual Studio 15 2017 Win64"
|
|
||||||
TEST_TARGET: RUN_TESTS
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "mingw-cxx11"
|
|
||||||
GENERATOR: "MinGW Makefiles"
|
|
||||||
MINGW_PATH: "C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin"
|
|
||||||
TEST_TARGET: test
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "mingw-gnuxx11"
|
|
||||||
GENERATOR: "MinGW Makefiles"
|
|
||||||
MINGW_PATH: "C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin"
|
|
||||||
TEST_TARGET: test
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
- TOOLCHAIN: "mingw-cxx17"
|
|
||||||
GENERATOR: "MinGW Makefiles"
|
|
||||||
MINGW_PATH: "C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin"
|
|
||||||
TEST_TARGET: test
|
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
|
||||||
|
|
||||||
install:
|
|
||||||
# Remove entry with sh.exe from PATH to fix error with MinGW toolchain
|
|
||||||
# (For MinGW make to work correctly sh.exe must NOT be in your path)
|
|
||||||
# * http://stackoverflow.com/a/3870338/2288008
|
|
||||||
- cmd: set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
|
|
||||||
|
|
||||||
# set MINGW path
|
|
||||||
- cmd: IF DEFINED MINGW_PATH set PATH=%MINGW_PATH%;%PATH%
|
|
||||||
|
|
||||||
# Visual Studio 15 2017: Mimic behavior of older versions
|
|
||||||
- cmd: set VS150COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools
|
|
||||||
|
|
||||||
build_script:
|
|
||||||
- cmd: cmake -H. -B_build_%TOOLCHAIN%_Debug -G "%GENERATOR%" -DCMAKE_TOOLCHAIN_FILE="%cd%\toolchains\%TOOLCHAIN%.cmake"
|
|
||||||
- cmd: cmake --build _build_%TOOLCHAIN%_Debug --config Debug
|
|
||||||
#- cmd: cmake -H. -B_build_%TOOLCHAIN%_Release -G "%GENERATOR%" -DCMAKE_TOOLCHAIN_FILE="%cd%\toolchains\%TOOLCHAIN%.cmake"
|
|
||||||
#- cmd: cmake --build _build_%TOOLCHAIN%_Release --config Release
|
|
||||||
# add git back to PATH for `diff` command in case of error
|
|
||||||
- cmd: set PATH=C:\Program Files\Git\usr\bin;%PATH%
|
|
||||||
- cmd: IF DEFINED TEST_TARGET cmake --build _build_%TOOLCHAIN%_Debug --target %TEST_TARGET%
|
|
||||||
#- cmd: IF DEFINED TEST_TARGET cmake --build _build_%TOOLCHAIN%_Release --target %TEST_TARGET%
|
|
||||||
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
autoreconf -i
|
|
||||||
@ -4,5 +4,6 @@ cc_test(
|
|||||||
srcs = ["main.cc"],
|
srcs = ["main.cc"],
|
||||||
deps = [
|
deps = [
|
||||||
"//:glog",
|
"//:glog",
|
||||||
|
"@gflags//:gflags",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
393
bazel/glog.bzl
393
bazel/glog.bzl
@ -1,4 +1,4 @@
|
|||||||
# Implement a macro glog_library() that the BUILD file can load.
|
# Implement a macro glog_library() that the BUILD.bazel file can load.
|
||||||
|
|
||||||
# By default, glog is built with gflags support. You can change this behavior
|
# By default, glog is built with gflags support. You can change this behavior
|
||||||
# by using glog_library(with_gflags=0)
|
# by using glog_library(with_gflags=0)
|
||||||
@ -6,134 +6,285 @@
|
|||||||
# This file is inspired by the following sample BUILD files:
|
# This file is inspired by the following sample BUILD files:
|
||||||
# https://github.com/google/glog/issues/61
|
# https://github.com/google/glog/issues/61
|
||||||
# https://github.com/google/glog/files/393474/BUILD.txt
|
# https://github.com/google/glog/files/393474/BUILD.txt
|
||||||
|
#
|
||||||
|
# Known issue: the namespace parameter is not supported on Win32.
|
||||||
|
|
||||||
def glog_library(namespace='google', with_gflags=1, **kwargs):
|
def expand_template_impl(ctx):
|
||||||
if native.repository_name() != '@':
|
ctx.actions.expand_template(
|
||||||
gendir = '$(GENDIR)/external/' + native.repository_name().lstrip('@')
|
template = ctx.file.template,
|
||||||
|
output = ctx.outputs.out,
|
||||||
|
substitutions = ctx.attr.substitutions,
|
||||||
|
)
|
||||||
|
|
||||||
|
expand_template = rule(
|
||||||
|
implementation = expand_template_impl,
|
||||||
|
attrs = {
|
||||||
|
"template": attr.label(mandatory = True, allow_single_file = True),
|
||||||
|
"substitutions": attr.string_dict(mandatory = True),
|
||||||
|
"out": attr.output(mandatory = True),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
def glog_library(with_gflags = 1, **kwargs):
|
||||||
|
if native.repository_name() != "@":
|
||||||
|
repo_name = native.repository_name()[1:] # Strip the first leading @
|
||||||
|
gendir = "$(GENDIR)/external/" + repo_name
|
||||||
|
src_windows = "external/%s/src/windows" % repo_name
|
||||||
else:
|
else:
|
||||||
gendir = '$(GENDIR)'
|
gendir = "$(GENDIR)"
|
||||||
|
src_windows = "src/windows"
|
||||||
|
|
||||||
|
# Config setting for WebAssembly target.
|
||||||
|
native.config_setting(
|
||||||
|
name = "wasm",
|
||||||
|
values = {"cpu": "wasm"},
|
||||||
|
)
|
||||||
|
|
||||||
|
# Detect when building with clang-cl on Windows.
|
||||||
|
native.config_setting(
|
||||||
|
name = "clang-cl",
|
||||||
|
values = {"compiler": "clang-cl"},
|
||||||
|
)
|
||||||
|
|
||||||
|
common_copts = [
|
||||||
|
"-std=c++14",
|
||||||
|
"-I%s/glog_internal" % gendir,
|
||||||
|
] + (["-DGLOG_USE_GFLAGS"] if with_gflags else [])
|
||||||
|
|
||||||
|
wasm_copts = [
|
||||||
|
# Disable warnings that exists in glog.
|
||||||
|
"-Wno-sign-compare",
|
||||||
|
"-Wno-unused-function",
|
||||||
|
"-Wno-unused-local-typedefs",
|
||||||
|
"-Wno-unused-variable",
|
||||||
|
# Allows src/logging.cc to determine the host name.
|
||||||
|
"-DHAVE_SYS_UTSNAME_H",
|
||||||
|
# For src/utilities.cc.
|
||||||
|
"-DHAVE_SYS_TIME_H",
|
||||||
|
# NOTE: users could optionally patch -DHAVE_UNWIND off if
|
||||||
|
# stacktrace dumping is not needed
|
||||||
|
"-DHAVE_UNWIND",
|
||||||
|
# Enable dumping stacktrace upon sigaction.
|
||||||
|
"-DHAVE_SIGACTION",
|
||||||
|
# For logging.cc.
|
||||||
|
"-DHAVE_PREAD",
|
||||||
|
# -DHAVE_MODE_T prevent repeated typedef mode_t leading
|
||||||
|
# to emcc compilation failure
|
||||||
|
"-DHAVE_MODE_T",
|
||||||
|
"-DHAVE_UNISTD_H",
|
||||||
|
]
|
||||||
|
|
||||||
|
linux_or_darwin_copts = wasm_copts + [
|
||||||
|
"-DGLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
|
||||||
|
"-DGLOG_NO_EXPORT=__attribute__((visibility(\\\"default\\\")))",
|
||||||
|
"-DHAVE_POSIX_FADVISE",
|
||||||
|
"-DHAVE_SSIZE_T",
|
||||||
|
"-DHAVE_SYS_TYPES_H",
|
||||||
|
# For src/utilities.cc.
|
||||||
|
"-DHAVE_SYS_SYSCALL_H",
|
||||||
|
# For src/logging.cc to create symlinks.
|
||||||
|
"-fvisibility-inlines-hidden",
|
||||||
|
"-fvisibility=hidden",
|
||||||
|
]
|
||||||
|
|
||||||
|
freebsd_only_copts = [
|
||||||
|
# Enable declaration of _Unwind_Backtrace
|
||||||
|
"-D_GNU_SOURCE",
|
||||||
|
"-DHAVE_LINK_H",
|
||||||
|
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
|
||||||
|
]
|
||||||
|
|
||||||
|
linux_only_copts = [
|
||||||
|
# For utilities.h.
|
||||||
|
"-DHAVE_EXECINFO_H",
|
||||||
|
"-DHAVE_LINK_H",
|
||||||
|
"-DHAVE_SYMBOLIZE", # Supported by <link.h>
|
||||||
|
]
|
||||||
|
|
||||||
|
darwin_only_copts = [
|
||||||
|
# For stacktrace.
|
||||||
|
"-DHAVE_DLADDR",
|
||||||
|
]
|
||||||
|
|
||||||
|
windows_only_copts = [
|
||||||
|
# Override -DGLOG_EXPORT= from the cc_library's defines.
|
||||||
|
"-DGLOG_EXPORT=__declspec(dllexport)",
|
||||||
|
"-DGLOG_NO_ABBREVIATED_SEVERITIES",
|
||||||
|
"-DGLOG_NO_EXPORT=",
|
||||||
|
"-DGLOG_USE_WINDOWS_PORT",
|
||||||
|
"-DHAVE__CHSIZE_S",
|
||||||
|
"-DHAVE_DBGHELP",
|
||||||
|
"-I" + src_windows,
|
||||||
|
]
|
||||||
|
|
||||||
|
clang_cl_only_copts = [
|
||||||
|
# Allow the override of -DGLOG_EXPORT.
|
||||||
|
"-Wno-macro-redefined",
|
||||||
|
]
|
||||||
|
|
||||||
|
windows_only_srcs = [
|
||||||
|
"src/windows/dirent.h",
|
||||||
|
"src/windows/port.cc",
|
||||||
|
"src/windows/port.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
gflags_deps = ["@gflags//:gflags"] if with_gflags else []
|
||||||
|
|
||||||
|
final_lib_defines = select({
|
||||||
|
# GLOG_EXPORT is normally set by export.h, but that's not
|
||||||
|
# generated for Bazel.
|
||||||
|
"@bazel_tools//src/conditions:windows": [
|
||||||
|
"GLOG_DEPRECATED=__declspec(deprecated)",
|
||||||
|
"GLOG_EXPORT=",
|
||||||
|
"GLOG_NO_ABBREVIATED_SEVERITIES",
|
||||||
|
"GLOG_NO_EXPORT=",
|
||||||
|
],
|
||||||
|
"//conditions:default": [
|
||||||
|
"GLOG_DEPRECATED=__attribute__((deprecated))",
|
||||||
|
"GLOG_EXPORT=__attribute__((visibility(\\\"default\\\")))",
|
||||||
|
"GLOG_NO_EXPORT=__attribute__((visibility(\\\"default\\\")))",
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
final_lib_copts = select({
|
||||||
|
"@bazel_tools//src/conditions:windows": common_copts + windows_only_copts,
|
||||||
|
"@bazel_tools//src/conditions:darwin": common_copts + linux_or_darwin_copts + darwin_only_copts,
|
||||||
|
"@bazel_tools//src/conditions:freebsd": common_copts + linux_or_darwin_copts + freebsd_only_copts,
|
||||||
|
":wasm": common_copts + wasm_copts,
|
||||||
|
"//conditions:default": common_copts + linux_or_darwin_copts + linux_only_copts,
|
||||||
|
}) + select({
|
||||||
|
":clang-cl": clang_cl_only_copts,
|
||||||
|
"//conditions:default": [],
|
||||||
|
})
|
||||||
|
|
||||||
|
# Needed to use these headers in `glog` and the test targets without exposing them as public targets in `glog`
|
||||||
|
native.filegroup(
|
||||||
|
name = "shared_headers",
|
||||||
|
srcs = [
|
||||||
|
"src/base/commandlineflags.h",
|
||||||
|
"src/stacktrace.h",
|
||||||
|
"src/utilities.h",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
native.cc_library(
|
native.cc_library(
|
||||||
name = 'glog',
|
name = "glog",
|
||||||
visibility = [ '//visibility:public' ],
|
visibility = ["//visibility:public"],
|
||||||
srcs = [
|
srcs = [
|
||||||
':config_h',
|
":config_h",
|
||||||
'src/base/commandlineflags.h',
|
":shared_headers",
|
||||||
'src/base/googleinit.h',
|
"src/base/googleinit.h",
|
||||||
'src/base/mutex.h',
|
"src/demangle.cc",
|
||||||
'src/demangle.cc',
|
"src/demangle.h",
|
||||||
'src/demangle.h',
|
"src/flags.cc",
|
||||||
'src/logging.cc',
|
"src/logging.cc",
|
||||||
'src/raw_logging.cc',
|
"src/raw_logging.cc",
|
||||||
'src/signalhandler.cc',
|
"src/signalhandler.cc",
|
||||||
'src/stacktrace.h',
|
"src/stacktrace.cc",
|
||||||
'src/stacktrace_generic-inl.h',
|
"src/stacktrace.h",
|
||||||
'src/stacktrace_libunwind-inl.h',
|
"src/stacktrace_generic-inl.h",
|
||||||
'src/stacktrace_powerpc-inl.h',
|
"src/stacktrace_libunwind-inl.h",
|
||||||
'src/stacktrace_windows-inl.h',
|
"src/stacktrace_powerpc-inl.h",
|
||||||
'src/stacktrace_x86-inl.h',
|
"src/stacktrace_unwind-inl.h",
|
||||||
'src/stacktrace_x86_64-inl.h',
|
"src/stacktrace_windows-inl.h",
|
||||||
'src/symbolize.cc',
|
"src/stacktrace_x86-inl.h",
|
||||||
'src/symbolize.h',
|
"src/symbolize.cc",
|
||||||
'src/utilities.cc',
|
"src/symbolize.h",
|
||||||
'src/utilities.h',
|
"src/utilities.cc",
|
||||||
'src/vlog_is_on.cc',
|
"src/utilities.h",
|
||||||
],
|
"src/vlog_is_on.cc",
|
||||||
|
] + select({
|
||||||
|
"@bazel_tools//src/conditions:windows": windows_only_srcs,
|
||||||
|
"//conditions:default": [],
|
||||||
|
}),
|
||||||
hdrs = [
|
hdrs = [
|
||||||
':logging_h',
|
"src/glog/flags.h",
|
||||||
':raw_logging_h',
|
"src/glog/log_severity.h",
|
||||||
':stl_logging_h',
|
"src/glog/logging.h",
|
||||||
':vlog_is_on_h',
|
"src/glog/platform.h",
|
||||||
'src/glog/log_severity.h',
|
"src/glog/raw_logging.h",
|
||||||
|
"src/glog/stl_logging.h",
|
||||||
|
"src/glog/types.h",
|
||||||
|
"src/glog/vlog_is_on.h",
|
||||||
],
|
],
|
||||||
strip_include_prefix = 'src',
|
# https://github.com/google/glog/issues/837: Replacing
|
||||||
copts = [
|
# `strip_include_prefix` with `includes` would avoid spamming
|
||||||
# Disable warnings that exists in glog.
|
# downstream projects with compiler warnings, but would also leak
|
||||||
'-Wno-sign-compare',
|
# private headers like stacktrace.h, because strip_include_prefix's
|
||||||
'-Wno-unused-function',
|
# implementation only creates symlinks for the public hdrs. I suspect
|
||||||
'-Wno-unused-local-typedefs',
|
# the only way to avoid this is to refactor the project including the
|
||||||
'-Wno-unused-variable',
|
# CMake build, so that the private headers are in a glog_internal
|
||||||
"-DGLOG_BAZEL_BUILD",
|
# subdirectory.
|
||||||
# Inject a C++ namespace.
|
strip_include_prefix = "src",
|
||||||
"-DGOOGLE_NAMESPACE='%s'" % namespace,
|
defines = final_lib_defines,
|
||||||
# Allows src/base/mutex.h to include pthread.h.
|
copts = final_lib_copts,
|
||||||
'-DHAVE_PTHREAD',
|
deps = gflags_deps + select({
|
||||||
# Allows src/logging.cc to determine the host name.
|
"@bazel_tools//src/conditions:windows": [":strip_include_prefix_hack"],
|
||||||
'-DHAVE_SYS_UTSNAME_H',
|
"//conditions:default": [],
|
||||||
# For src/utilities.cc.
|
}),
|
||||||
'-DHAVE_SYS_SYSCALL_H',
|
linkopts = select({
|
||||||
'-DHAVE_SYS_TIME_H',
|
"@bazel_tools//src/conditions:windows": ["dbghelp.lib"],
|
||||||
'-DHAVE_STDINT_H',
|
"//conditions:default": [],
|
||||||
'-DHAVE_STRING_H',
|
}),
|
||||||
# Enable dumping stacktrace upon sigaction.
|
|
||||||
'-DHAVE_SIGACTION',
|
|
||||||
# For logging.cc.
|
|
||||||
'-DHAVE_PREAD',
|
|
||||||
'-DHAVE___ATTRIBUTE__',
|
|
||||||
|
|
||||||
# Include generated header files.
|
|
||||||
'-I%s/glog_internal' % gendir,
|
|
||||||
] + ([
|
|
||||||
# Use gflags to parse CLI arguments.
|
|
||||||
'-DHAVE_LIB_GFLAGS',
|
|
||||||
] if with_gflags else []),
|
|
||||||
deps = [
|
|
||||||
'@com_github_gflags_gflags//:gflags',
|
|
||||||
] if with_gflags else [],
|
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
native.genrule(
|
test_list = [
|
||||||
name = 'gen_sh',
|
"cleanup_immediately",
|
||||||
outs = [
|
"cleanup_with_absolute_prefix",
|
||||||
'gen.sh',
|
"cleanup_with_relative_prefix",
|
||||||
],
|
# "demangle", # Broken
|
||||||
cmd = r'''\
|
# "logging", # Broken
|
||||||
#!/bin/sh
|
# "mock-log", # Broken
|
||||||
cat > $@ <<"EOF"
|
# "signalhandler", # Pointless
|
||||||
sed -e 's/@ac_cv_cxx_using_operator@/1/g' \
|
"stacktrace",
|
||||||
-e 's/@ac_cv_have_unistd_h@/1/g' \
|
"stl_logging",
|
||||||
-e 's/@ac_cv_have_stdint_h@/1/g' \
|
# "symbolize", # Broken
|
||||||
-e 's/@ac_cv_have_systypes_h@/1/g' \
|
"utilities",
|
||||||
-e 's/@ac_cv_have_libgflags@/{}/g' \
|
|
||||||
-e 's/@ac_cv_have_uint16_t@/1/g' \
|
|
||||||
-e 's/@ac_cv_have___builtin_expect@/1/g' \
|
|
||||||
-e 's/@ac_cv_have_.*@/0/g' \
|
|
||||||
-e 's/@ac_google_start_namespace@/namespace google {{/g' \
|
|
||||||
-e 's/@ac_google_end_namespace@/}}/g' \
|
|
||||||
-e 's/@ac_google_namespace@/google/g' \
|
|
||||||
-e 's/@ac_cv___attribute___noinline@/__attribute__((noinline))/g' \
|
|
||||||
-e 's/@ac_cv___attribute___noreturn@/__attribute__((noreturn))/g' \
|
|
||||||
-e 's/@ac_cv___attribute___printf_4_5@/__attribute__((__format__ (__printf__, 4, 5)))/g'
|
|
||||||
EOF
|
|
||||||
'''.format(int(with_gflags)),
|
|
||||||
)
|
|
||||||
|
|
||||||
native.genrule(
|
|
||||||
name = 'config_h',
|
|
||||||
srcs = [
|
|
||||||
'src/config.h.cmake.in',
|
|
||||||
],
|
|
||||||
outs = [
|
|
||||||
'glog_internal/config.h',
|
|
||||||
],
|
|
||||||
cmd = "awk '{ gsub(/^#cmakedefine/, \"//cmakedefine\"); print; }' $< > $@",
|
|
||||||
)
|
|
||||||
|
|
||||||
[native.genrule(
|
|
||||||
name = '%s_h' % f,
|
|
||||||
srcs = [
|
|
||||||
'src/glog/%s.h.in' % f,
|
|
||||||
],
|
|
||||||
outs = [
|
|
||||||
'src/glog/%s.h' % f,
|
|
||||||
],
|
|
||||||
cmd = '$(location :gen_sh) < $< > $@',
|
|
||||||
tools = [':gen_sh'],
|
|
||||||
) for f in [
|
|
||||||
'vlog_is_on',
|
|
||||||
'stl_logging',
|
|
||||||
'raw_logging',
|
|
||||||
'logging',
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
test_only_copts = [
|
||||||
|
"-DTEST_SRC_DIR=\\\"%s/tests\\\"" % gendir,
|
||||||
|
]
|
||||||
|
|
||||||
|
for test_name in test_list:
|
||||||
|
native.cc_test(
|
||||||
|
name = test_name + "_test",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
srcs = [
|
||||||
|
":config_h",
|
||||||
|
":shared_headers",
|
||||||
|
"src/googletest.h",
|
||||||
|
"src/" + test_name + "_unittest.cc",
|
||||||
|
],
|
||||||
|
defines = final_lib_defines,
|
||||||
|
copts = final_lib_copts + test_only_copts,
|
||||||
|
deps = gflags_deps + [
|
||||||
|
":glog",
|
||||||
|
"@googletest//:gtest",
|
||||||
|
],
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
# Workaround https://github.com/bazelbuild/bazel/issues/6337 by declaring
|
||||||
|
# the dependencies without strip_include_prefix.
|
||||||
|
native.cc_library(
|
||||||
|
name = "strip_include_prefix_hack",
|
||||||
|
hdrs = [
|
||||||
|
"src/glog/flags.h",
|
||||||
|
"src/glog/log_severity.h",
|
||||||
|
"src/glog/logging.h",
|
||||||
|
"src/glog/platform.h",
|
||||||
|
"src/glog/raw_logging.h",
|
||||||
|
"src/glog/stl_logging.h",
|
||||||
|
"src/glog/types.h",
|
||||||
|
"src/glog/vlog_is_on.h",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
expand_template(
|
||||||
|
name = "config_h",
|
||||||
|
template = "src/config.h.cmake.in",
|
||||||
|
out = "glog_internal/config.h",
|
||||||
|
substitutions = {"#cmakedefine": "//cmakedefine"},
|
||||||
|
)
|
||||||
|
|||||||
0
cmake/DetermineGflagsNamespace.cmake
Executable file → Normal file
0
cmake/DetermineGflagsNamespace.cmake
Executable file → Normal file
61
cmake/FindUnwind.cmake
Normal file
61
cmake/FindUnwind.cmake
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# - Try to find libunwind
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# Unwind_FOUND - system has libunwind
|
||||||
|
# unwind::unwind - cmake target for libunwind
|
||||||
|
|
||||||
|
include (FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
|
find_path (Unwind_INCLUDE_DIR NAMES unwind.h libunwind.h DOC "unwind include directory")
|
||||||
|
find_library (Unwind_LIBRARY NAMES unwind DOC "unwind library")
|
||||||
|
|
||||||
|
mark_as_advanced (Unwind_INCLUDE_DIR Unwind_LIBRARY)
|
||||||
|
|
||||||
|
# Extract version information
|
||||||
|
if (Unwind_LIBRARY)
|
||||||
|
set (_Unwind_VERSION_HEADER ${Unwind_INCLUDE_DIR}/libunwind-common.h)
|
||||||
|
|
||||||
|
if (EXISTS ${_Unwind_VERSION_HEADER})
|
||||||
|
file (READ ${_Unwind_VERSION_HEADER} _Unwind_VERSION_CONTENTS)
|
||||||
|
|
||||||
|
string (REGEX REPLACE ".*#define UNW_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
|
||||||
|
Unwind_VERSION_MAJOR "${_Unwind_VERSION_CONTENTS}")
|
||||||
|
string (REGEX REPLACE ".*#define UNW_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
|
||||||
|
Unwind_VERSION_MINOR "${_Unwind_VERSION_CONTENTS}")
|
||||||
|
string (REGEX REPLACE ".*#define UNW_VERSION_EXTRA[ \t]+([0-9]+).*" "\\1"
|
||||||
|
Unwind_VERSION_PATCH "${_Unwind_VERSION_CONTENTS}")
|
||||||
|
|
||||||
|
set (Unwind_VERSION ${Unwind_VERSION_MAJOR}.${Unwind_VERSION_MINOR})
|
||||||
|
|
||||||
|
if (CMAKE_MATCH_0)
|
||||||
|
# Third version component may be empty
|
||||||
|
set (Unwind_VERSION ${Unwind_VERSION}.${Unwind_VERSION_PATCH})
|
||||||
|
set (Unwind_VERSION_COMPONENTS 3)
|
||||||
|
else (CMAKE_MATCH_0)
|
||||||
|
set (Unwind_VERSION_COMPONENTS 2)
|
||||||
|
endif (CMAKE_MATCH_0)
|
||||||
|
endif (EXISTS ${_Unwind_VERSION_HEADER})
|
||||||
|
endif (Unwind_LIBRARY)
|
||||||
|
|
||||||
|
# handle the QUIETLY and REQUIRED arguments and set Unwind_FOUND to TRUE
|
||||||
|
# if all listed variables are TRUE
|
||||||
|
find_package_handle_standard_args (Unwind
|
||||||
|
REQUIRED_VARS Unwind_INCLUDE_DIR Unwind_LIBRARY
|
||||||
|
VERSION_VAR Unwind_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
if (Unwind_FOUND)
|
||||||
|
if (NOT TARGET unwind::unwind)
|
||||||
|
add_library (unwind::unwind INTERFACE IMPORTED)
|
||||||
|
|
||||||
|
set_property (TARGET unwind::unwind PROPERTY
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES ${Unwind_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
set_property (TARGET unwind::unwind PROPERTY
|
||||||
|
INTERFACE_LINK_LIBRARIES ${Unwind_LIBRARY}
|
||||||
|
)
|
||||||
|
set_property (TARGET unwind::unwind PROPERTY
|
||||||
|
IMPORTED_CONFIGURATIONS RELEASE
|
||||||
|
)
|
||||||
|
endif (NOT TARGET unwind::unwind)
|
||||||
|
endif (Unwind_FOUND)
|
||||||
70
cmake/GetCacheVariables.cmake
Normal file
70
cmake/GetCacheVariables.cmake
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
cmake_policy (PUSH)
|
||||||
|
cmake_policy (VERSION 3.16...3.27)
|
||||||
|
|
||||||
|
include (CMakeParseArguments)
|
||||||
|
|
||||||
|
function (get_cache_variables _CACHEVARS)
|
||||||
|
set (_SINGLE)
|
||||||
|
set (_MULTI EXCLUDE)
|
||||||
|
set (_OPTIONS)
|
||||||
|
|
||||||
|
cmake_parse_arguments (_ARGS "${_OPTIONS}" "${_SINGLE}" "${_MULTI}" ${ARGS} ${ARGN})
|
||||||
|
|
||||||
|
get_cmake_property (_VARIABLES VARIABLES)
|
||||||
|
|
||||||
|
set (CACHEVARS)
|
||||||
|
|
||||||
|
foreach (_VAR ${_VARIABLES})
|
||||||
|
if (DEFINED _ARGS_EXCLUDE)
|
||||||
|
if ("${_VAR}" IN_LIST _ARGS_EXCLUDE)
|
||||||
|
continue ()
|
||||||
|
endif ("${_VAR}" IN_LIST _ARGS_EXCLUDE)
|
||||||
|
endif (DEFINED _ARGS_EXCLUDE)
|
||||||
|
|
||||||
|
get_property (_CACHEVARTYPE CACHE ${_VAR} PROPERTY TYPE)
|
||||||
|
|
||||||
|
if ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR
|
||||||
|
"${_CACHEVARTYPE}" STREQUAL STATIC OR
|
||||||
|
"${_CACHEVARTYPE}" STREQUAL UNINITIALIZED)
|
||||||
|
continue ()
|
||||||
|
endif ("${_CACHEVARTYPE}" STREQUAL INTERNAL OR
|
||||||
|
"${_CACHEVARTYPE}" STREQUAL STATIC OR
|
||||||
|
"${_CACHEVARTYPE}" STREQUAL UNINITIALIZED)
|
||||||
|
|
||||||
|
get_property (_CACHEVARVAL CACHE ${_VAR} PROPERTY VALUE)
|
||||||
|
|
||||||
|
if ("${_CACHEVARVAL}" STREQUAL "")
|
||||||
|
continue ()
|
||||||
|
endif ("${_CACHEVARVAL}" STREQUAL "")
|
||||||
|
|
||||||
|
get_property (_CACHEVARDOC CACHE ${_VAR} PROPERTY HELPSTRING)
|
||||||
|
|
||||||
|
# Escape " in values
|
||||||
|
string (REPLACE "\"" "\\\"" _CACHEVARVAL "${_CACHEVARVAL}")
|
||||||
|
# Escape " in help strings
|
||||||
|
string (REPLACE "\"" "\\\"" _CACHEVARDOC "${_CACHEVARDOC}")
|
||||||
|
# Escape ; in values
|
||||||
|
string (REPLACE ";" "\\\;" _CACHEVARVAL "${_CACHEVARVAL}")
|
||||||
|
# Escape ; in help strings
|
||||||
|
string (REPLACE ";" "\\\;" _CACHEVARDOC "${_CACHEVARDOC}")
|
||||||
|
# Escape backslashes in values except those that are followed by a
|
||||||
|
# quote.
|
||||||
|
string (REGEX REPLACE "\\\\([^\"])" "\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")
|
||||||
|
# Escape backslashes in values that are followed by a letter to avoid
|
||||||
|
# invalid escape sequence errors.
|
||||||
|
string (REGEX REPLACE "\\\\([a-zA-Z])" "\\\\\\\\1" _CACHEVARVAL "${_CACHEVARVAL}")
|
||||||
|
string (REPLACE "\\\\" "\\\\\\\\" _CACHEVARDOC "${_CACHEVARDOC}")
|
||||||
|
|
||||||
|
if (NOT "${_CACHEVARTYPE}" STREQUAL BOOL)
|
||||||
|
set (_CACHEVARVAL "\"${_CACHEVARVAL}\"")
|
||||||
|
endif (NOT "${_CACHEVARTYPE}" STREQUAL BOOL)
|
||||||
|
|
||||||
|
if (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "")
|
||||||
|
set (CACHEVARS "${CACHEVARS}set (${_VAR} ${_CACHEVARVAL} CACHE ${_CACHEVARTYPE} \"${_CACHEVARDOC}\")\n")
|
||||||
|
endif (NOT "${_CACHEVARTYPE}" STREQUAL "" AND NOT "${_CACHEVARVAL}" STREQUAL "")
|
||||||
|
endforeach (_VAR)
|
||||||
|
|
||||||
|
set (${_CACHEVARS} ${CACHEVARS} PARENT_SCOPE)
|
||||||
|
endfunction (get_cache_variables)
|
||||||
|
|
||||||
|
cmake_policy (POP)
|
||||||
@ -1,81 +0,0 @@
|
|||||||
# Glog - CMake Support
|
|
||||||
|
|
||||||
Glog comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt)) that can be used on a wide range of platforms.
|
|
||||||
If you don't have CMake installed already, you can download it for free from <http://www.cmake.org/>.
|
|
||||||
|
|
||||||
CMake works by generating native makefiles or build projects that can be used in the compiler environment of your choice.
|
|
||||||
You can either build Glog with CMake as a standalone project or it can be incorporated into an existing CMake build for another project.
|
|
||||||
|
|
||||||
## Table of Contents
|
|
||||||
|
|
||||||
- [Building Glog with CMake](#building-glog-with-cmake)
|
|
||||||
- [Consuming Glog in a CMake Project](#consuming-glog-in-a-cmake-project)
|
|
||||||
- [Incorporating Glog into a CMake Project](#incorporating-glog-into-a-cmake-project)
|
|
||||||
|
|
||||||
## Building Glog with CMake
|
|
||||||
|
|
||||||
When building Glog as a standalone project, on Unix-like systems with GNU Make as build tool, the typical workflow is:
|
|
||||||
|
|
||||||
1. Get the source code and change to it.
|
|
||||||
e.g. cloning with git:
|
|
||||||
```bash
|
|
||||||
git clone git@github.com:google/glog.git
|
|
||||||
cd glog
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Run CMake to configure the build tree.
|
|
||||||
```bash
|
|
||||||
cmake -H. -Bbuild -G "Unix Makefiles"
|
|
||||||
```
|
|
||||||
note: To get the list of available generators (e.g. Visual Studio), use `-G ""`
|
|
||||||
|
|
||||||
3. Afterwards, generated files can be used to compile the project.
|
|
||||||
```bash
|
|
||||||
cmake --build build
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Test the build software (optional).
|
|
||||||
```bash
|
|
||||||
cmake --build build --target test
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Install the built files (optional).
|
|
||||||
```bash
|
|
||||||
cmake --build build --target install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Consuming Glog in a CMake Project
|
|
||||||
|
|
||||||
If you have Glog installed in your system, you can use the CMake command
|
|
||||||
`find_package()` to include it in your CMake Project.
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
cmake_minimum_required(VERSION 3.0.2)
|
|
||||||
project(myproj VERSION 1.0)
|
|
||||||
|
|
||||||
find_package(glog 0.4.0 REQUIRED)
|
|
||||||
|
|
||||||
add_executable(myapp main.cpp)
|
|
||||||
target_link_libraries(myapp glog::glog)
|
|
||||||
```
|
|
||||||
|
|
||||||
Compile definitions and options will be added automatically to your target as
|
|
||||||
needed.
|
|
||||||
|
|
||||||
## Incorporating Glog into a CMake Project
|
|
||||||
|
|
||||||
You can also use the CMake command `add_subdirectory()` to include Glog directly from a subdirectory of your project.
|
|
||||||
The **glog::glog** target is in this case an ALIAS library target for the **glog** library target.
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
cmake_minimum_required(VERSION 3.0.2)
|
|
||||||
project(myproj VERSION 1.0)
|
|
||||||
|
|
||||||
add_subdirectory(glog)
|
|
||||||
|
|
||||||
add_executable(myapp main.cpp)
|
|
||||||
target_link_libraries(myapp glog::glog)
|
|
||||||
```
|
|
||||||
|
|
||||||
Again, compile definitions and options will be added automatically to your target as
|
|
||||||
needed.
|
|
||||||
26
cmake/RunCleanerTest1.cmake
Normal file
26
cmake/RunCleanerTest1.cmake
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
set (RUNS 3)
|
||||||
|
|
||||||
|
foreach (iter RANGE 1 ${RUNS})
|
||||||
|
set (ENV{GOOGLE_LOG_DIR} ${TEST_DIR})
|
||||||
|
execute_process (COMMAND ${LOGCLEANUP} RESULT_VARIABLE _RESULT)
|
||||||
|
|
||||||
|
if (NOT _RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
|
||||||
|
endif (NOT _RESULT EQUAL 0)
|
||||||
|
endforeach (iter)
|
||||||
|
|
||||||
|
file (GLOB LOG_FILES ${TEST_DIR}/*.foobar)
|
||||||
|
list (LENGTH LOG_FILES NUM_FILES)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# On Windows open files cannot be removed and will result in a permission
|
||||||
|
# denied error while unlinking such file. Therefore, the last file will be
|
||||||
|
# retained.
|
||||||
|
set (_expected 1)
|
||||||
|
else (WIN32)
|
||||||
|
set (_expected 0)
|
||||||
|
endif (WIN32)
|
||||||
|
|
||||||
|
if (NOT NUM_FILES EQUAL _expected)
|
||||||
|
message (SEND_ERROR "Expected ${_expected} log file in log directory but found ${NUM_FILES}")
|
||||||
|
endif (NOT NUM_FILES EQUAL _expected)
|
||||||
26
cmake/RunCleanerTest2.cmake
Normal file
26
cmake/RunCleanerTest2.cmake
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
set (RUNS 3)
|
||||||
|
|
||||||
|
foreach (iter RANGE 1 ${RUNS})
|
||||||
|
execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR}
|
||||||
|
RESULT_VARIABLE _RESULT)
|
||||||
|
|
||||||
|
if (NOT _RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
|
||||||
|
endif (NOT _RESULT EQUAL 0)
|
||||||
|
endforeach (iter)
|
||||||
|
|
||||||
|
file (GLOB LOG_FILES ${TEST_DIR}/test_cleanup_*.barfoo)
|
||||||
|
list (LENGTH LOG_FILES NUM_FILES)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# On Windows open files cannot be removed and will result in a permission
|
||||||
|
# denied error while unlinking such file. Therefore, the last file will be
|
||||||
|
# retained.
|
||||||
|
set (_expected 1)
|
||||||
|
else (WIN32)
|
||||||
|
set (_expected 0)
|
||||||
|
endif (WIN32)
|
||||||
|
|
||||||
|
if (NOT NUM_FILES EQUAL _expected)
|
||||||
|
message (SEND_ERROR "Expected ${_expected} log file in log directory but found ${NUM_FILES}")
|
||||||
|
endif (NOT NUM_FILES EQUAL _expected)
|
||||||
32
cmake/RunCleanerTest3.cmake
Normal file
32
cmake/RunCleanerTest3.cmake
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
set (RUNS 3)
|
||||||
|
|
||||||
|
# Create the subdirectory required by this unit test.
|
||||||
|
file (MAKE_DIRECTORY ${TEST_DIR}/${TEST_SUBDIR})
|
||||||
|
|
||||||
|
foreach (iter RANGE 1 ${RUNS})
|
||||||
|
execute_process (COMMAND ${LOGCLEANUP} -log_dir=${TEST_DIR}
|
||||||
|
RESULT_VARIABLE _RESULT)
|
||||||
|
|
||||||
|
if (NOT _RESULT EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to run logcleanup_unittest (error: ${_RESULT})")
|
||||||
|
endif (NOT _RESULT EQUAL 0)
|
||||||
|
endforeach (iter)
|
||||||
|
|
||||||
|
file (GLOB LOG_FILES ${TEST_DIR}/${TEST_SUBDIR}/test_cleanup_*.relativefoo)
|
||||||
|
list (LENGTH LOG_FILES NUM_FILES)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
# On Windows open files cannot be removed and will result in a permission
|
||||||
|
# denied error while unlinking such file. Therefore, the last file will be
|
||||||
|
# retained.
|
||||||
|
set (_expected 1)
|
||||||
|
else (WIN32)
|
||||||
|
set (_expected 0)
|
||||||
|
endif (WIN32)
|
||||||
|
|
||||||
|
if (NOT NUM_FILES EQUAL _expected)
|
||||||
|
message (SEND_ERROR "Expected ${_expected} log file in build directory ${TEST_DIR}${TEST_SUBDIR} but found ${NUM_FILES}")
|
||||||
|
endif (NOT NUM_FILES EQUAL _expected)
|
||||||
|
|
||||||
|
# Remove the subdirectory required by this unit test.
|
||||||
|
file (REMOVE_RECURSE ${TEST_DIR}/${TEST_SUBDIR})
|
||||||
11
cmake/TestInitPackageConfig.cmake
Normal file
11
cmake/TestInitPackageConfig.cmake
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Create the build directory
|
||||||
|
execute_process (
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
|
||||||
|
RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to create build directory")
|
||||||
|
endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
|
||||||
|
|
||||||
|
file (WRITE ${INITIAL_CACHE} "${CACHEVARS}")
|
||||||
30
cmake/TestPackageConfig.cmake
Normal file
30
cmake/TestPackageConfig.cmake
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
if (GENERATOR_TOOLSET)
|
||||||
|
list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET})
|
||||||
|
endif (GENERATOR_TOOLSET)
|
||||||
|
|
||||||
|
if (GENERATOR_PLATFORM)
|
||||||
|
list (APPEND _ADDITIONAL_ARGS -A ${GENERATOR_PLATFORM})
|
||||||
|
endif (GENERATOR_PLATFORM)
|
||||||
|
|
||||||
|
# Run CMake
|
||||||
|
execute_process (
|
||||||
|
# Capture the PATH environment variable content set during project generation
|
||||||
|
# stage. This is required because later during the build stage the PATH is
|
||||||
|
# modified again (e.g., for MinGW AppVeyor CI builds) by adding back the
|
||||||
|
# directory containing git.exe. Incidentally, the Git installation directory
|
||||||
|
# also contains sh.exe which causes MinGW Makefile generation to fail.
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH}
|
||||||
|
${CMAKE_COMMAND} -C ${INITIAL_CACHE}
|
||||||
|
-G ${GENERATOR}
|
||||||
|
${_ADDITIONAL_ARGS}
|
||||||
|
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
|
||||||
|
-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
|
||||||
|
-Dglog_ROOT=${PACKAGE_DIR}
|
||||||
|
-S ${SOURCE_DIR}
|
||||||
|
-B ${TEST_BINARY_DIR}
|
||||||
|
RESULT_VARIABLE _GENERATE_SUCCEEDED
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT _GENERATE_SUCCEEDED EQUAL 0)
|
||||||
|
message (FATAL_ERROR "Failed to generate project files using CMake")
|
||||||
|
endif (NOT _GENERATE_SUCCEEDED EQUAL 0)
|
||||||
11
codecov.yml
Normal file
11
codecov.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
comment:
|
||||||
|
layout: "diff, flags, files"
|
||||||
|
behavior: default
|
||||||
|
require_changes: false
|
||||||
|
require_base: false
|
||||||
|
require_head: true
|
||||||
|
ignore:
|
||||||
|
- "**/*_unittest.cc"
|
||||||
|
- "src/*_unittest/**"
|
||||||
|
- "src/googletest.h"
|
||||||
|
- "src/mock-log.h"
|
||||||
246
configure.ac
246
configure.ac
@ -1,246 +0,0 @@
|
|||||||
## Process this file with autoconf to produce configure.
|
|
||||||
## In general, the safest way to proceed is to run the following:
|
|
||||||
## % aclocal -I . -I `pwd`/../autoconf && autoheader && autoconf && automake
|
|
||||||
|
|
||||||
# make sure we're interpreted by some minimal autoconf
|
|
||||||
AC_PREREQ(2.57)
|
|
||||||
|
|
||||||
AC_INIT(glog, 0.4.0, opensource@google.com)
|
|
||||||
# The argument here is just something that should be in the current directory
|
|
||||||
# (for sanity checking)
|
|
||||||
AC_CONFIG_SRCDIR(README.md)
|
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
|
||||||
AM_INIT_AUTOMAKE
|
|
||||||
AM_CONFIG_HEADER(src/config.h)
|
|
||||||
|
|
||||||
AC_LANG(C++)
|
|
||||||
|
|
||||||
# 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_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_HEADER(pwd.h, ac_cv_have_pwd_h=1, ac_cv_have_pwd_h=0)
|
|
||||||
AC_CHECK_HEADERS(unistd.h, ac_cv_have_unistd_h=1, ac_cv_have_unistd_h=0)
|
|
||||||
AC_CHECK_HEADERS(syscall.h)
|
|
||||||
AC_CHECK_HEADERS(sys/syscall.h)
|
|
||||||
# For backtrace with glibc.
|
|
||||||
AC_CHECK_HEADERS(execinfo.h)
|
|
||||||
# For backtrace with libunwind.
|
|
||||||
AC_CHECK_HEADERS(libunwind.h, ac_cv_have_libunwind_h=1, ac_cv_have_libunwind_h=0)
|
|
||||||
AC_CHECK_HEADERS(ucontext.h)
|
|
||||||
AC_CHECK_HEADERS(sys/utsname.h)
|
|
||||||
AC_CHECK_HEADERS(pwd.h)
|
|
||||||
AC_CHECK_HEADERS(syslog.h)
|
|
||||||
AC_CHECK_HEADERS(sys/time.h)
|
|
||||||
AC_CHECK_HEADERS(glob.h)
|
|
||||||
# For backtrace with gcc.
|
|
||||||
AC_CHECK_HEADERS(unwind.h)
|
|
||||||
|
|
||||||
AC_CHECK_HEADER(windows.h, ac_cv_have_windows_h=1, ac_cv_have_windows_h=0)
|
|
||||||
if test x"$ac_cv_have_windows_h" = x"1"; then
|
|
||||||
MINGW_CFLAGS=-Isrc/windows
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CHECK_SIZEOF(void *)
|
|
||||||
|
|
||||||
# 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(__uint16, ac_cv_have___uint16=1, ac_cv_have___uint16=0)
|
|
||||||
|
|
||||||
AC_CHECK_FUNC(sigaltstack,
|
|
||||||
AC_DEFINE(HAVE_SIGALTSTACK, 1,
|
|
||||||
[Define if you have the `sigaltstack' function]))
|
|
||||||
AC_CHECK_FUNC(sigaction,
|
|
||||||
AC_DEFINE(HAVE_SIGACTION, 1,
|
|
||||||
[Define if you have the 'sigaction' function]))
|
|
||||||
AC_CHECK_FUNC(dladdr,
|
|
||||||
AC_DEFINE(HAVE_DLADDR, 1,
|
|
||||||
[Define if you have the `dladdr' function]))
|
|
||||||
AC_CHECK_FUNC(fcntl,
|
|
||||||
AC_DEFINE(HAVE_FCNTL, 1,
|
|
||||||
[Define if you have the `fcntl' function]))
|
|
||||||
AC_CHECK_FUNC(pread,
|
|
||||||
AC_DEFINE(HAVE_PREAD, 1,
|
|
||||||
[Define if you have the 'pread' function]))
|
|
||||||
AC_CHECK_FUNC(pwrite,
|
|
||||||
AC_DEFINE(HAVE_PWRITE, 1,
|
|
||||||
[Define if you have the 'pwrite' function]))
|
|
||||||
|
|
||||||
AX_C___ATTRIBUTE__
|
|
||||||
# We only care about these two attributes.
|
|
||||||
if test x"$ac_cv___attribute__" = x"yes"; then
|
|
||||||
ac_cv___attribute___noreturn="__attribute__ ((noreturn))"
|
|
||||||
ac_cv___attribute___noinline="__attribute__ ((noinline))"
|
|
||||||
ac_cv___attribute___printf_4_5="__attribute__((__format__ (__printf__, 4, 5)))"
|
|
||||||
else
|
|
||||||
ac_cv___attribute___noreturn=
|
|
||||||
ac_cv___attribute___noinline=
|
|
||||||
ac_cv___attribute___printf_4_5=
|
|
||||||
fi
|
|
||||||
|
|
||||||
AX_C___BUILTIN_EXPECT
|
|
||||||
if test x"$ac_cv___builtin_expect" = x"yes"; then
|
|
||||||
ac_cv_have___builtin_expect=1
|
|
||||||
else
|
|
||||||
ac_cv_have___builtin_expect=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
AX_C___SYNC_VAL_COMPARE_AND_SWAP
|
|
||||||
|
|
||||||
# On x86_64, instead of libunwind, we can choose to compile with frame-pointers
|
|
||||||
# (This isn't needed on i386, where -fno-omit-frame-pointer is the default).
|
|
||||||
AC_ARG_ENABLE(frame_pointers,
|
|
||||||
AS_HELP_STRING([--enable-frame-pointers],
|
|
||||||
[On x86_64 systems, compile with -fno-omit-frame-pointer (see INSTALL)]),,
|
|
||||||
enable_frame_pointers=no)
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [return __x86_64__ == 1 ? 0 : 1])],
|
|
||||||
[is_x86_64=yes], [is_x86_64=no])
|
|
||||||
AM_CONDITIONAL(ENABLE_FRAME_POINTERS, test "$enable_frame_pointers" = yes)
|
|
||||||
AM_CONDITIONAL(X86_64, test "$is_x86_64" = yes)
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(rtti,
|
|
||||||
AS_HELP_STRING([--disable-rtti],
|
|
||||||
[Disable RTTI in glog]))
|
|
||||||
AM_CONDITIONAL(DISABLE_RTTI, test x"$enable_rtti" = x"no")
|
|
||||||
if test x"$enable_rtti" = x"no"; then
|
|
||||||
AC_DEFINE(DISABLE_RTTI, 1, [define if glog doesn't use RTTI])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Some of the code in this directory depends on pthreads
|
|
||||||
ACX_PTHREAD
|
|
||||||
if test x"$acx_pthread_ok" = x"yes"; then
|
|
||||||
# To make libglog depend on libpthread on Linux, we need to add
|
|
||||||
# -lpthread in addition to -pthread.
|
|
||||||
AC_CHECK_LIB(pthread, pthread_self)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if there is google-gflags library installed.
|
|
||||||
SAVE_CFLAGS="$CFLAGS"
|
|
||||||
SAVE_LIBS="$LIBS"
|
|
||||||
AC_ARG_WITH(gflags, AS_HELP_STRING[--with-gflags=GFLAGS_DIR],
|
|
||||||
GFLAGS_CFLAGS="-I${with_gflags}/include"
|
|
||||||
GFLAGS_LIBS="-L${with_gflags}/lib -lgflags"
|
|
||||||
CFLAGS="$CFLAGS $GFLAGS_CFLAGS"
|
|
||||||
LIBS="$LIBS $GFLAGS_LIBS"
|
|
||||||
)
|
|
||||||
AC_CHECK_LIB(gflags, main, ac_cv_have_libgflags=1, ac_cv_have_libgflags=0)
|
|
||||||
if test x"$ac_cv_have_libgflags" = x"1"; then
|
|
||||||
AC_DEFINE(HAVE_LIB_GFLAGS, 1, [define if you have google gflags library])
|
|
||||||
if test x"$GFLAGS_LIBS" = x""; then
|
|
||||||
GFLAGS_LIBS="-lgflags"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
GFLAGS_CFLAGS=
|
|
||||||
GFLAGS_LIBS=
|
|
||||||
fi
|
|
||||||
CFLAGS="$SAVE_CFLAGS"
|
|
||||||
LIBS="$SAVE_LIBS"
|
|
||||||
|
|
||||||
# TODO(hamaji): Use official m4 macros provided by testing libraries
|
|
||||||
# once the m4 macro of Google Mocking becomes ready.
|
|
||||||
# Check if there is Google Test library installed.
|
|
||||||
AC_CHECK_PROG(GTEST_CONFIG, gtest-config, "yes")
|
|
||||||
AC_CHECK_LIB(gtest, main, have_gtest_lib="yes")
|
|
||||||
if test x"$GTEST_CONFIG" = "xyes" -a x"$have_gtest_lib" = "xyes"; then
|
|
||||||
GTEST_CFLAGS=`gtest-config --cppflags --cxxflags`
|
|
||||||
GTEST_LIBS=`gtest-config --ldflags --libs`
|
|
||||||
AC_DEFINE(HAVE_LIB_GTEST, 1, [define if you have google gtest library])
|
|
||||||
|
|
||||||
# Check if there is Google Mocking library installed.
|
|
||||||
AC_CHECK_PROG(GMOCK_CONFIG, gmock-config, "yes")
|
|
||||||
if test x"$GMOCK_CONFIG" = "xyes"; then
|
|
||||||
GMOCK_CFLAGS=`gmock-config --cppflags --cxxflags`
|
|
||||||
GMOCK_LIBS=`gmock-config --ldflags --libs`
|
|
||||||
AC_DEFINE(HAVE_LIB_GMOCK, 1, [define if you have google gmock library])
|
|
||||||
else
|
|
||||||
# We don't run test cases which use Google Mocking framework.
|
|
||||||
GMOCK_CFLAGS=
|
|
||||||
GMOCK_LIBS=
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# We'll use src/googletest.h for our unittests.
|
|
||||||
GTEST_CFLAGS=
|
|
||||||
GTEST_LIBS=
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL(HAVE_GMOCK, test x"$GMOCK_CONFIG" = "xyes")
|
|
||||||
|
|
||||||
# We want to link in libunwind if it exists
|
|
||||||
UNWIND_LIBS=
|
|
||||||
# Unfortunately, we need to check the header file in addition to the
|
|
||||||
# lib file to check if libunwind is available since libunwind-0.98
|
|
||||||
# doesn't install all necessary header files.
|
|
||||||
if test x"$ac_cv_have_libunwind_h" = x"1"; then
|
|
||||||
AC_CHECK_LIB(unwind, backtrace, UNWIND_LIBS=-lunwind)
|
|
||||||
fi
|
|
||||||
AC_SUBST(UNWIND_LIBS)
|
|
||||||
if test x"$UNWIND_LIBS" != x""; then
|
|
||||||
AC_DEFINE(HAVE_LIB_UNWIND, 1, [define if you have libunwind])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# We'd like to use read/write locks in several places in the code.
|
|
||||||
# See if our pthreads support extends to that. Note: for linux, it
|
|
||||||
# does as long as you define _XOPEN_SOURCE appropriately.
|
|
||||||
AC_RWLOCK
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
|
|
||||||
AC_CXX_USING_OPERATOR
|
|
||||||
|
|
||||||
AC_PC_FROM_UCONTEXT(AC_MSG_WARN(Could not find the PC. Will not output failed addresses...))
|
|
||||||
|
|
||||||
AC_DEFINE_UNQUOTED(TEST_SRC_DIR, "$srcdir", [location of source code])
|
|
||||||
|
|
||||||
AC_ARG_ENABLE(unsymbolized-traces,
|
|
||||||
AS_HELP_STRING([--enable-unsymbolized-traces],
|
|
||||||
[Print raw pc values when symbolization is failed.]),
|
|
||||||
enable_unsymbolized_traces=yes)
|
|
||||||
if test x"$enable_unsymbolized_traces" = x"yes"; then
|
|
||||||
AC_DEFINE(PRINT_UNSYMBOLIZED_STACK_TRACES, 1,
|
|
||||||
[define if we should print raw pc values on symbolization failure.])
|
|
||||||
fi
|
|
||||||
|
|
||||||
# These are what's needed by logging.h.in and raw_logging.h.in
|
|
||||||
AC_SUBST(ac_google_start_namespace)
|
|
||||||
AC_SUBST(ac_google_end_namespace)
|
|
||||||
AC_SUBST(ac_google_namespace)
|
|
||||||
AC_SUBST(ac_cv_cxx_using_operator)
|
|
||||||
AC_SUBST(ac_cv___attribute___noreturn)
|
|
||||||
AC_SUBST(ac_cv___attribute___noinline)
|
|
||||||
AC_SUBST(ac_cv___attribute___printf_4_5)
|
|
||||||
AC_SUBST(ac_cv_have___builtin_expect)
|
|
||||||
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_unistd_h)
|
|
||||||
AC_SUBST(ac_cv_have_uint16_t)
|
|
||||||
AC_SUBST(ac_cv_have_u_int16_t)
|
|
||||||
AC_SUBST(ac_cv_have___uint16)
|
|
||||||
AC_SUBST(ac_cv_have_libgflags)
|
|
||||||
AC_SUBST(GFLAGS_CFLAGS)
|
|
||||||
AC_SUBST(GTEST_CFLAGS)
|
|
||||||
AC_SUBST(GMOCK_CFLAGS)
|
|
||||||
AC_SUBST(MINGW_CFLAGS)
|
|
||||||
AC_SUBST(GFLAGS_LIBS)
|
|
||||||
AC_SUBST(GTEST_LIBS)
|
|
||||||
AC_SUBST(GMOCK_LIBS)
|
|
||||||
|
|
||||||
# Write generated configuration file
|
|
||||||
AC_CONFIG_FILES([Makefile src/glog/logging.h src/glog/raw_logging.h src/glog/vlog_is_on.h src/glog/stl_logging.h])
|
|
||||||
AC_OUTPUT(libglog.pc)
|
|
||||||
@ -1,115 +0,0 @@
|
|||||||
body {
|
|
||||||
background-color: #ffffff;
|
|
||||||
color: black;
|
|
||||||
margin-right: 1in;
|
|
||||||
margin-left: 1in;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
color: #3366ff;
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
/* Darker version for printing */
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
color: #000080;
|
|
||||||
font-family: helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
text-align: center;
|
|
||||||
font-size: 18pt;
|
|
||||||
}
|
|
||||||
h2 {
|
|
||||||
margin-left: -0.5in;
|
|
||||||
}
|
|
||||||
h3 {
|
|
||||||
margin-left: -0.25in;
|
|
||||||
}
|
|
||||||
h4 {
|
|
||||||
margin-left: -0.125in;
|
|
||||||
}
|
|
||||||
hr {
|
|
||||||
margin-left: -1in;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Definition lists: definition term bold */
|
|
||||||
dt {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
address {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
/* Use the <code> tag for bits of code and <var> for variables and objects. */
|
|
||||||
code,pre,samp,var {
|
|
||||||
color: #006000;
|
|
||||||
}
|
|
||||||
/* Use the <file> tag for file and directory paths and names. */
|
|
||||||
file {
|
|
||||||
color: #905050;
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
|
||||||
/* Use the <kbd> tag for stuff the user should type. */
|
|
||||||
kbd {
|
|
||||||
color: #600000;
|
|
||||||
}
|
|
||||||
div.note p {
|
|
||||||
float: right;
|
|
||||||
width: 3in;
|
|
||||||
margin-right: 0%;
|
|
||||||
padding: 1px;
|
|
||||||
border: 2px solid #6060a0;
|
|
||||||
background-color: #fffff0;
|
|
||||||
}
|
|
||||||
|
|
||||||
UL.nobullets {
|
|
||||||
list-style-type: none;
|
|
||||||
list-style-image: none;
|
|
||||||
margin-left: -1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
body:after {
|
|
||||||
content: "Google Confidential";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* pretty printing styles. See prettify.js */
|
|
||||||
.str { color: #080; }
|
|
||||||
.kwd { color: #008; }
|
|
||||||
.com { color: #800; }
|
|
||||||
.typ { color: #606; }
|
|
||||||
.lit { color: #066; }
|
|
||||||
.pun { color: #660; }
|
|
||||||
.pln { color: #000; }
|
|
||||||
.tag { color: #008; }
|
|
||||||
.atn { color: #606; }
|
|
||||||
.atv { color: #080; }
|
|
||||||
pre.prettyprint { padding: 2px; border: 1px solid #888; }
|
|
||||||
|
|
||||||
.embsrc { background: #eee; }
|
|
||||||
|
|
||||||
@media print {
|
|
||||||
.str { color: #060; }
|
|
||||||
.kwd { color: #006; font-weight: bold; }
|
|
||||||
.com { color: #600; font-style: italic; }
|
|
||||||
.typ { color: #404; font-weight: bold; }
|
|
||||||
.lit { color: #044; }
|
|
||||||
.pun { color: #440; }
|
|
||||||
.pln { color: #000; }
|
|
||||||
.tag { color: #006; font-weight: bold; }
|
|
||||||
.atn { color: #404; }
|
|
||||||
.atv { color: #060; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Table Column Headers */
|
|
||||||
.hdr {
|
|
||||||
color: #006;
|
|
||||||
font-weight: bold;
|
|
||||||
background-color: #dddddd; }
|
|
||||||
.hdr2 {
|
|
||||||
color: #006;
|
|
||||||
background-color: #eeeeee; }
|
|
||||||
613
doc/glog.html
613
doc/glog.html
@ -1,613 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>How To Use Google Logging Library (glog)</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">
|
|
||||||
<!--
|
|
||||||
ol.bluelist li {
|
|
||||||
color: #3366ff;
|
|
||||||
font-family: sans-serif;
|
|
||||||
}
|
|
||||||
ol.bluelist li p {
|
|
||||||
color: #000;
|
|
||||||
font-family: "Times Roman", times, serif;
|
|
||||||
}
|
|
||||||
ul.blacklist li {
|
|
||||||
color: #000;
|
|
||||||
font-family: "Times Roman", times, serif;
|
|
||||||
}
|
|
||||||
//-->
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>How To Use Google Logging Library (glog)</h1>
|
|
||||||
<small>(as of
|
|
||||||
<script type=text/javascript>
|
|
||||||
var lm = new Date(document.lastModified);
|
|
||||||
document.write(lm.toDateString());
|
|
||||||
</script>)
|
|
||||||
</small>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<h2> <A NAME=intro>Introduction</A> </h2>
|
|
||||||
|
|
||||||
<p><b>Google glog</b> is a library that implements application-level
|
|
||||||
logging. This library provides logging APIs based on C++-style
|
|
||||||
streams and various helper macros.
|
|
||||||
You can log a message by simply streaming things to LOG(<a
|
|
||||||
particular <a href="#severity">severity level</a>>), e.g.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
#include <glog/logging.h>
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
// Initialize Google's logging library.
|
|
||||||
google::InitGoogleLogging(argv[0]);
|
|
||||||
|
|
||||||
// ...
|
|
||||||
LOG(INFO) << "Found " << num_cookies << " cookies";
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Google glog defines a series of macros that simplify many common logging
|
|
||||||
tasks. You can log messages by severity level, control logging
|
|
||||||
behavior from the command line, log based on conditionals, abort the
|
|
||||||
program when expected conditions are not met, introduce your own
|
|
||||||
verbose logging levels, and more. This document describes the
|
|
||||||
functionality supported by glog. Please note that this document
|
|
||||||
doesn't describe all features in this library, but the most useful
|
|
||||||
ones. If you want to find less common features, please check
|
|
||||||
header files under <code>src/glog</code> directory.
|
|
||||||
|
|
||||||
<h2> <A NAME=severity>Severity Level</A> </h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
You can specify one of the following severity levels (in
|
|
||||||
increasing order of severity): <code>INFO</code>, <code>WARNING</code>,
|
|
||||||
<code>ERROR</code>, and <code>FATAL</code>.
|
|
||||||
Logging a <code>FATAL</code> message terminates the program (after the
|
|
||||||
message is logged).
|
|
||||||
Note that messages of a given severity are logged not only in the
|
|
||||||
logfile for that severity, but also in all logfiles of lower severity.
|
|
||||||
E.g., a message of severity <code>FATAL</code> will be logged to the
|
|
||||||
logfiles of severity <code>FATAL</code>, <code>ERROR</code>,
|
|
||||||
<code>WARNING</code>, and <code>INFO</code>.
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The <code>DFATAL</code> severity logs a <code>FATAL</code> error in
|
|
||||||
debug mode (i.e., there is no <code>NDEBUG</code> macro defined), but
|
|
||||||
avoids halting the program in production by automatically reducing the
|
|
||||||
severity to <code>ERROR</code>.
|
|
||||||
|
|
||||||
<p>Unless otherwise specified, glog writes to the filename
|
|
||||||
"/tmp/<program name>.<hostname>.<user name>.log.<severity level>.<date>.<time>.<pid>"
|
|
||||||
(e.g., "/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474").
|
|
||||||
By default, glog copies the log messages of severity level
|
|
||||||
<code>ERROR</code> or <code>FATAL</code> to standard error (stderr)
|
|
||||||
in addition to log files.
|
|
||||||
|
|
||||||
<h2><A NAME=flags>Setting Flags</A></h2>
|
|
||||||
|
|
||||||
<p>Several flags influence glog's output behavior.
|
|
||||||
If the <a href="https://github.com/gflags/gflags">Google
|
|
||||||
gflags library</a> is installed on your machine, the
|
|
||||||
<code>configure</code> script (see the INSTALL file in the package for
|
|
||||||
detail of this script) will automatically detect and use it,
|
|
||||||
allowing you to pass flags on the command line. For example, if you
|
|
||||||
want to turn the flag <code>--logtostderr</code> on, you can start
|
|
||||||
your application with the following command line:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
./your_application --logtostderr=1
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
If the Google gflags library isn't installed, you set flags via
|
|
||||||
environment variables, prefixing the flag name with "GLOG_", e.g.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
GLOG_logtostderr=1 ./your_application
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<!-- TODO(hamaji): Fill the version number
|
|
||||||
<p>By glog version 0.x.x, you can use GLOG_* environment variables
|
|
||||||
even if you have gflags. If both an environment variable and a flag
|
|
||||||
are specified, the value specified by a flag wins. E.g., if GLOG_v=0
|
|
||||||
and --v=1, the verbosity will be 1, not 0.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<p>The following flags are most commonly used:
|
|
||||||
|
|
||||||
<dl>
|
|
||||||
<dt><code>logtostderr</code> (<code>bool</code>, default=<code>false</code>)
|
|
||||||
<dd>Log messages to stderr instead of logfiles.<br>
|
|
||||||
Note: you can set binary flags to <code>true</code> by specifying
|
|
||||||
<code>1</code>, <code>true</code>, or <code>yes</code> (case
|
|
||||||
insensitive).
|
|
||||||
Also, you can set binary flags to <code>false</code> by specifying
|
|
||||||
<code>0</code>, <code>false</code>, or <code>no</code> (again, case
|
|
||||||
insensitive).
|
|
||||||
<dt><code>stderrthreshold</code> (<code>int</code>, default=2, which
|
|
||||||
is <code>ERROR</code>)
|
|
||||||
<dd>Copy log messages at or above this level to stderr in
|
|
||||||
addition to logfiles. The numbers of severity levels
|
|
||||||
<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>, and
|
|
||||||
<code>FATAL</code> are 0, 1, 2, and 3, respectively.
|
|
||||||
<dt><code>minloglevel</code> (<code>int</code>, default=0, which
|
|
||||||
is <code>INFO</code>)
|
|
||||||
<dd>Log messages at or above this level. Again, the numbers of
|
|
||||||
severity levels <code>INFO</code>, <code>WARNING</code>,
|
|
||||||
<code>ERROR</code>, and <code>FATAL</code> are 0, 1, 2, and 3,
|
|
||||||
respectively.
|
|
||||||
<dt><code>log_dir</code> (<code>string</code>, default="")
|
|
||||||
<dd>If specified, logfiles are written into this directory instead
|
|
||||||
of the default logging directory.
|
|
||||||
<dt><code>v</code> (<code>int</code>, default=0)
|
|
||||||
<dd>Show all <code>VLOG(m)</code> messages for <code>m</code> less or
|
|
||||||
equal the value of this flag. Overridable by --vmodule.
|
|
||||||
See <a href="#verbose">the section about verbose logging</a> for more
|
|
||||||
detail.
|
|
||||||
<dt><code>vmodule</code> (<code>string</code>, default="")
|
|
||||||
<dd>Per-module verbose level. The argument has to contain a
|
|
||||||
comma-separated list of <module name>=<log level>.
|
|
||||||
<module name>
|
|
||||||
is a glob pattern (e.g., <code>gfs*</code> for all modules whose name
|
|
||||||
starts with "gfs"), matched against the filename base
|
|
||||||
(that is, name ignoring .cc/.h./-inl.h).
|
|
||||||
<log level> overrides any value given by --v.
|
|
||||||
See also <a href="#verbose">the section about verbose logging</a>.
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<p>There are some other flags defined in logging.cc. Please grep the
|
|
||||||
source code for "DEFINE_" to see a complete list of all flags.
|
|
||||||
|
|
||||||
<p>You can also modify flag values in your program by modifying global
|
|
||||||
variables <code>FLAGS_*</code> . Most settings start working
|
|
||||||
immediately after you update <code>FLAGS_*</code> . The exceptions are
|
|
||||||
the flags related to destination files. For example, you might want to
|
|
||||||
set <code>FLAGS_log_dir</code> before
|
|
||||||
calling <code>google::InitGoogleLogging</code> . Here is an example:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
LOG(INFO) << "file";
|
|
||||||
// Most flags work immediately after updating values.
|
|
||||||
FLAGS_logtostderr = 1;
|
|
||||||
LOG(INFO) << "stderr";
|
|
||||||
FLAGS_logtostderr = 0;
|
|
||||||
// This won't change the log destination. If you want to set this
|
|
||||||
// value, you should do this before google::InitGoogleLogging .
|
|
||||||
FLAGS_log_dir = "/some/log/directory";
|
|
||||||
LOG(INFO) << "the same file";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h2><A NAME=conditional>Conditional / Occasional Logging</A></h2>
|
|
||||||
|
|
||||||
<p>Sometimes, you may only want to log a message under certain
|
|
||||||
conditions. You can use the following macros to perform conditional
|
|
||||||
logging:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
The "Got lots of cookies" message is logged only when the variable
|
|
||||||
<code>num_cookies</code> exceeds 10.
|
|
||||||
|
|
||||||
If a line of code is executed many times, it may be useful to only log
|
|
||||||
a message at certain intervals. This kind of logging is most useful
|
|
||||||
for informational messages.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>The above line outputs a log messages on the 1st, 11th,
|
|
||||||
21st, ... times it is executed. Note that the special
|
|
||||||
<code>google::COUNTER</code> value is used to identify which repetition is
|
|
||||||
happening.
|
|
||||||
|
|
||||||
<p>You can combine conditional and occasional logging with the
|
|
||||||
following macro.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
|
|
||||||
<< "th big cookie";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Instead of outputting a message every nth time, you can also limit
|
|
||||||
the output to the first n occurrences:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Outputs log messages for the first 20 times it is executed. Again,
|
|
||||||
the <code>google::COUNTER</code> identifier indicates which repetition is
|
|
||||||
happening.
|
|
||||||
|
|
||||||
<h2><A NAME=debug>Debug Mode Support</A></h2>
|
|
||||||
|
|
||||||
<p>Special "debug mode" logging macros only have an effect in debug
|
|
||||||
mode and are compiled away to nothing for non-debug mode
|
|
||||||
compiles. Use these macros to avoid slowing down your production
|
|
||||||
application due to excessive logging.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
DLOG(INFO) << "Found cookies";
|
|
||||||
|
|
||||||
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
|
||||||
|
|
||||||
DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h2><A NAME=check>CHECK Macros</A></h2>
|
|
||||||
|
|
||||||
<p>It is a good practice to check expected conditions in your program
|
|
||||||
frequently to detect errors as early as possible. The
|
|
||||||
<code>CHECK</code> macro provides the ability to abort the application
|
|
||||||
when a condition is not met, similar to the <code>assert</code> macro
|
|
||||||
defined in the standard C library.
|
|
||||||
|
|
||||||
<p><code>CHECK</code> aborts the application if a condition is not
|
|
||||||
true. Unlike <code>assert</code>, it is *not* controlled by
|
|
||||||
<code>NDEBUG</code>, so the check will be executed regardless of
|
|
||||||
compilation mode. Therefore, <code>fp->Write(x)</code> in the
|
|
||||||
following example is always executed:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK(fp->Write(x) == 4) << "Write failed!";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>There are various helper macros for
|
|
||||||
equality/inequality checks - <code>CHECK_EQ</code>,
|
|
||||||
<code>CHECK_NE</code>, <code>CHECK_LE</code>, <code>CHECK_LT</code>,
|
|
||||||
<code>CHECK_GE</code>, and <code>CHECK_GT</code>.
|
|
||||||
They compare two values, and log a
|
|
||||||
<code>FATAL</code> message including the two values when the result is
|
|
||||||
not as expected. The values must have <code>operator<<(ostream,
|
|
||||||
...)</code> defined.
|
|
||||||
|
|
||||||
<p>You may append to the error message like so:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK_NE(1, 2) << ": The world must be ending!";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>We are very careful to ensure that each argument is evaluated exactly
|
|
||||||
once, and that anything which is legal to pass as a function argument is
|
|
||||||
legal here. In particular, the arguments may be temporary expressions
|
|
||||||
which will end up being destroyed at the end of the apparent statement,
|
|
||||||
for example:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK_EQ(string("abc")[1], 'b');
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>The compiler reports an error if one of the arguments is a
|
|
||||||
pointer and the other is NULL. To work around this, simply static_cast
|
|
||||||
NULL to the type of the desired pointer.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK_EQ(some_ptr, static_cast<SomeType*>(NULL));
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Better yet, use the CHECK_NOTNULL macro:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK_NOTNULL(some_ptr);
|
|
||||||
some_ptr->DoSomething();
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Since this macro returns the given pointer, this is very useful in
|
|
||||||
constructor initializer lists.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
struct S {
|
|
||||||
S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
|
|
||||||
Something* ptr_;
|
|
||||||
};
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Note that you cannot use this macro as a C++ stream due to this
|
|
||||||
feature. Please use <code>CHECK_EQ</code> described above to log a
|
|
||||||
custom message before aborting the application.
|
|
||||||
|
|
||||||
<p>If you are comparing C strings (char *), a handy set of macros
|
|
||||||
performs case sensitive as well as case insensitive comparisons -
|
|
||||||
<code>CHECK_STREQ</code>, <code>CHECK_STRNE</code>,
|
|
||||||
<code>CHECK_STRCASEEQ</code>, and <code>CHECK_STRCASENE</code>. The
|
|
||||||
CASE versions are case-insensitive. You can safely pass <code>NULL</code>
|
|
||||||
pointers for this macro. They treat <code>NULL</code> and any
|
|
||||||
non-<code>NULL</code> string as not equal. Two <code>NULL</code>s are
|
|
||||||
equal.
|
|
||||||
|
|
||||||
<p>Note that both arguments may be temporary strings which are
|
|
||||||
destructed at the end of the current "full expression"
|
|
||||||
(e.g., <code>CHECK_STREQ(Foo().c_str(), Bar().c_str())</code> where
|
|
||||||
<code>Foo</code> and <code>Bar</code> return C++'s
|
|
||||||
<code>std::string</code>).
|
|
||||||
|
|
||||||
<p>The <code>CHECK_DOUBLE_EQ</code> macro checks the equality of two
|
|
||||||
floating point values, accepting a small error margin.
|
|
||||||
<code>CHECK_NEAR</code> accepts a third floating point argument, which
|
|
||||||
specifies the acceptable error margin.
|
|
||||||
|
|
||||||
<h2><A NAME=verbose>Verbose Logging</A></h2>
|
|
||||||
|
|
||||||
<p>When you are chasing difficult bugs, thorough log messages are very
|
|
||||||
useful. However, you may want to ignore too verbose messages in usual
|
|
||||||
development. For such verbose logging, glog provides the
|
|
||||||
<code>VLOG</code> macro, which allows you to define your own numeric
|
|
||||||
logging levels. The <code>--v</code> command line option controls
|
|
||||||
which verbose messages are logged:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
VLOG(1) << "I'm printed when you run the program with --v=1 or higher";
|
|
||||||
VLOG(2) << "I'm printed when you run the program with --v=2 or higher";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>With <code>VLOG</code>, the lower the verbose level, the more
|
|
||||||
likely messages are to be logged. For example, if
|
|
||||||
<code>--v==1</code>, <code>VLOG(1)</code> will log, but
|
|
||||||
<code>VLOG(2)</code> will not log. This is opposite of the severity
|
|
||||||
level, where <code>INFO</code> is 0, and <code>ERROR</code> is 2.
|
|
||||||
<code>--minloglevel</code> of 1 will log <code>WARNING</code> and
|
|
||||||
above. Though you can specify any integers for both <code>VLOG</code>
|
|
||||||
macro and <code>--v</code> flag, the common values for them are small
|
|
||||||
positive integers. For example, if you write <code>VLOG(0)</code>,
|
|
||||||
you should specify <code>--v=-1</code> or lower to silence it. This
|
|
||||||
is less useful since we may not want verbose logs by default in most
|
|
||||||
cases. The <code>VLOG</code> macros always log at the
|
|
||||||
<code>INFO</code> log level (when they log at all).
|
|
||||||
|
|
||||||
<p>Verbose logging can be controlled from the command line on a
|
|
||||||
per-module basis:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
--vmodule=mapreduce=2,file=1,gfs*=3 --v=0
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>will:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>a. Print VLOG(2) and lower messages from mapreduce.{h,cc}
|
|
||||||
<li>b. Print VLOG(1) and lower messages from file.{h,cc}
|
|
||||||
<li>c. Print VLOG(3) and lower messages from files prefixed with "gfs"
|
|
||||||
<li>d. Print VLOG(0) and lower messages from elsewhere
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>The wildcarding functionality shown by (c) supports both '*'
|
|
||||||
(matches 0 or more characters) and '?' (matches any single character)
|
|
||||||
wildcards. Please also check the section about <a
|
|
||||||
href="#flags">command line flags</a>.
|
|
||||||
|
|
||||||
<p>There's also <code>VLOG_IS_ON(n)</code> "verbose level" condition
|
|
||||||
macro. This macro returns true when the <code>--v</code> is equal or
|
|
||||||
greater than <code>n</code>. To be used as
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
if (VLOG_IS_ON(2)) {
|
|
||||||
// do some logging preparation and logging
|
|
||||||
// that can't be accomplished with just VLOG(2) << ...;
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Verbose level condition macros <code>VLOG_IF</code>,
|
|
||||||
<code>VLOG_EVERY_N</code> and <code>VLOG_IF_EVERY_N</code> behave
|
|
||||||
analogous to <code>LOG_IF</code>, <code>LOG_EVERY_N</code>,
|
|
||||||
<code>LOF_IF_EVERY</code>, but accept a numeric verbosity level as
|
|
||||||
opposed to a severity level.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
VLOG_IF(1, (size > 1024))
|
|
||||||
<< "I'm printed when size is more than 1024 and when you run the "
|
|
||||||
"program with --v=1 or more";
|
|
||||||
VLOG_EVERY_N(1, 10)
|
|
||||||
<< "I'm printed every 10th occurrence, and when you run the program "
|
|
||||||
"with --v=1 or more. Present occurence is " << google::COUNTER;
|
|
||||||
VLOG_IF_EVERY_N(1, (size > 1024), 10)
|
|
||||||
<< "I'm printed on every 10th occurence of case when size is more "
|
|
||||||
" than 1024, when you run the program with --v=1 or more. ";
|
|
||||||
"Present occurence is " << google::COUNTER;
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h2> <A name="signal">Failure Signal Handler</A> </h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
The library provides a convenient signal handler that will dump useful
|
|
||||||
information when the program crashes on certain signals such as SIGSEGV.
|
|
||||||
The signal handler can be installed by
|
|
||||||
google::InstallFailureSignalHandler(). The following is an example of output
|
|
||||||
from the signal handler.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
*** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date ***
|
|
||||||
*** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: ***
|
|
||||||
PC: @ 0x412eb1 TestWaitingLogSink::send()
|
|
||||||
@ 0x7f892fb417d0 (unknown)
|
|
||||||
@ 0x412eb1 TestWaitingLogSink::send()
|
|
||||||
@ 0x7f89304f7f06 google::LogMessage::SendToLog()
|
|
||||||
@ 0x7f89304f35af google::LogMessage::Flush()
|
|
||||||
@ 0x7f89304f3739 google::LogMessage::~LogMessage()
|
|
||||||
@ 0x408cf4 TestLogSinkWaitTillSent()
|
|
||||||
@ 0x4115de main
|
|
||||||
@ 0x7f892f7ef1c4 (unknown)
|
|
||||||
@ 0x4046f9 (unknown)
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
By default, the signal handler writes the failure dump to the standard
|
|
||||||
error. You can customize the destination by InstallFailureWriter().
|
|
||||||
|
|
||||||
<h2> <A name="misc">Miscellaneous Notes</A> </h2>
|
|
||||||
|
|
||||||
<h3><A NAME=message>Performance of Messages</A></h3>
|
|
||||||
|
|
||||||
<p>The conditional logging macros provided by glog (e.g.,
|
|
||||||
<code>CHECK</code>, <code>LOG_IF</code>, <code>VLOG</code>, ...) are
|
|
||||||
carefully implemented and don't execute the right hand side
|
|
||||||
expressions when the conditions are false. So, the following check
|
|
||||||
may not sacrifice the performance of your application.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3><A NAME=failure>User-defined Failure Function</A></h3>
|
|
||||||
|
|
||||||
<p><code>FATAL</code> severity level messages or unsatisfied
|
|
||||||
<code>CHECK</code> condition terminate your program. You can change
|
|
||||||
the behavior of the termination by
|
|
||||||
<code>InstallFailureFunction</code>.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
void YourFailureFunction() {
|
|
||||||
// Reports something...
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
google::InstallFailureFunction(&YourFailureFunction);
|
|
||||||
}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>By default, glog tries to dump stacktrace and makes the program
|
|
||||||
exit with status 1. The stacktrace is produced only when you run the
|
|
||||||
program on an architecture for which glog supports stack tracing (as
|
|
||||||
of September 2008, glog supports stack tracing for x86 and x86_64).
|
|
||||||
|
|
||||||
<h3><A NAME=raw>Raw Logging</A></h3>
|
|
||||||
|
|
||||||
<p>The header file <code><glog/raw_logging.h></code> can be
|
|
||||||
used for thread-safe logging, which does not allocate any memory or
|
|
||||||
acquire any locks. Therefore, the macros defined in this
|
|
||||||
header file can be used by low-level memory allocation and
|
|
||||||
synchronization code.
|
|
||||||
Please check <code>src/glog/raw_logging.h.in</code> for detail.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3><A NAME=plog>Google Style perror()</A></h3>
|
|
||||||
|
|
||||||
<p><code>PLOG()</code> and <code>PLOG_IF()</code> and
|
|
||||||
<code>PCHECK()</code> behave exactly like their <code>LOG*</code> and
|
|
||||||
<code>CHECK</code> equivalents with the addition that they append a
|
|
||||||
description of the current state of errno to their output lines.
|
|
||||||
E.g.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
PCHECK(write(1, NULL, 2) >= 0) << "Write NULL failed";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>This check fails with the following error message.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
F0825 185142 test.cc:22] Check failed: write(1, NULL, 2) >= 0 Write NULL failed: Bad address [14]
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<h3><A NAME=syslog>Syslog</A></h3>
|
|
||||||
|
|
||||||
<p><code>SYSLOG</code>, <code>SYSLOG_IF</code>, and
|
|
||||||
<code>SYSLOG_EVERY_N</code> macros are available.
|
|
||||||
These log to syslog in addition to the normal logs. Be aware that
|
|
||||||
logging to syslog can drastically impact performance, especially if
|
|
||||||
syslog is configured for remote logging! Make sure you understand the
|
|
||||||
implications of outputting to syslog before you use these macros. In
|
|
||||||
general, it's wise to use these macros sparingly.
|
|
||||||
|
|
||||||
<h3><A NAME=strip>Strip Logging Messages</A></h3>
|
|
||||||
|
|
||||||
<p>Strings used in log messages can increase the size of your binary
|
|
||||||
and present a privacy concern. You can therefore instruct glog to
|
|
||||||
remove all strings which fall below a certain severity level by using
|
|
||||||
the GOOGLE_STRIP_LOG macro:
|
|
||||||
|
|
||||||
<p>If your application has code like this:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
#define GOOGLE_STRIP_LOG 1 // this must go before the #include!
|
|
||||||
#include <glog/logging.h>
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>The compiler will remove the log messages whose severities are less
|
|
||||||
than the specified integer value. Since
|
|
||||||
<code>VLOG</code> logs at the severity level <code>INFO</code>
|
|
||||||
(numeric value <code>0</code>),
|
|
||||||
setting <code>GOOGLE_STRIP_LOG</code> to 1 or greater removes
|
|
||||||
all log messages associated with <code>VLOG</code>s as well as
|
|
||||||
<code>INFO</code> log statements.
|
|
||||||
|
|
||||||
<h3><A NAME=windows>Notes for Windows users</A></h3>
|
|
||||||
|
|
||||||
<p>Google glog defines a severity level <code>ERROR</code>, which is
|
|
||||||
also defined in <code>windows.h</code> . You can make glog not define
|
|
||||||
<code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
|
|
||||||
and <code>FATAL</code> by defining
|
|
||||||
<code>GLOG_NO_ABBREVIATED_SEVERITIES</code> before
|
|
||||||
including <code>glog/logging.h</code> . Even with this macro, you can
|
|
||||||
still use the iostream like logging facilities:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
|
||||||
#include <windows.h>
|
|
||||||
#include <glog/logging.h>
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
LOG(ERROR) << "This should work";
|
|
||||||
LOG_IF(ERROR, x > y) << "This should be also OK";
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
However, you cannot
|
|
||||||
use <code>INFO</code>, <code>WARNING</code>, <code>ERROR</code>,
|
|
||||||
and <code>FATAL</code> anymore for functions defined
|
|
||||||
in <code>glog/logging.h</code> .
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
|
||||||
#include <windows.h>
|
|
||||||
#include <glog/logging.h>
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// This won't work.
|
|
||||||
// google::FlushLogFiles(google::ERROR);
|
|
||||||
|
|
||||||
// Use this instead.
|
|
||||||
google::FlushLogFiles(google::GLOG_ERROR);
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
If you don't need <code>ERROR</code> defined
|
|
||||||
by <code>windows.h</code>, there are a couple of more workarounds
|
|
||||||
which sometimes don't work:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>#define <code>WIN32_LEAN_AND_MEAN</code> or <code>NOGDI</code>
|
|
||||||
<strong>before</strong> you #include <code>windows.h</code> .
|
|
||||||
<li>#undef <code>ERROR</code> <strong>after</strong> you #include
|
|
||||||
<code>windows.h</code> .
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>See <a href="http://code.google.com/p/google-glog/issues/detail?id=33">
|
|
||||||
this issue</a> for more detail.
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
<address>
|
|
||||||
Shinichiro Hamaji<br>
|
|
||||||
Gregor Hohpe<br>
|
|
||||||
<script type=text/javascript>
|
|
||||||
var lm = new Date(document.lastModified);
|
|
||||||
document.write(lm.toDateString());
|
|
||||||
</script>
|
|
||||||
</address>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
66
docs/build.md
Normal file
66
docs/build.md
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
# Building from Source
|
||||||
|
|
||||||
|
## Bazel
|
||||||
|
|
||||||
|
To use glog within a project which uses the [Bazel](https://bazel.build/) build
|
||||||
|
tool, add the following lines to your `MODULE.bazel` file:
|
||||||
|
|
||||||
|
``` bazel title="MODULE.bazel"
|
||||||
|
bazel_dep(name = "glog")
|
||||||
|
|
||||||
|
archive_override(
|
||||||
|
module_name = "glog",
|
||||||
|
urls = "https://github.com/google/glog/archive/cc0de6c200375b33d907ee7632eee2f173b33a09.tar.gz",
|
||||||
|
strip_prefix = "glog-cc0de6c200375b33d907ee7632eee2f173b33a09", # Latest commit as of 2024-06-08.
|
||||||
|
integrity = "sha256-rUrv4EBkdc+4Wbhfxp+KoRstlj2Iw842/OpLfDq0ivg=",
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
You can then add `@glog//:glog` to
|
||||||
|
the deps section of a `cc_binary` or
|
||||||
|
`cc_library` rule, and `#!cpp #include <glog/logging.h>` to
|
||||||
|
include it in your source code.
|
||||||
|
|
||||||
|
!!! example "Using glog in a Bazel project"
|
||||||
|
``` bazel
|
||||||
|
cc_binary(
|
||||||
|
name = "main",
|
||||||
|
srcs = ["main.cc"],
|
||||||
|
deps = ["@glog//:glog"],
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## CMake
|
||||||
|
|
||||||
|
glog can be compiled using [CMake](http://www.cmake.org) on a wide range of
|
||||||
|
platforms. The typical workflow for building glog on a Unix-like system with GNU
|
||||||
|
Make as build tool is as follows:
|
||||||
|
|
||||||
|
1. Clone the repository and change into source directory.
|
||||||
|
``` bash
|
||||||
|
git clone https://github.com/google/glog.git
|
||||||
|
cd glog
|
||||||
|
```
|
||||||
|
2. Run CMake to configure the build tree.
|
||||||
|
``` bash
|
||||||
|
cmake -S . -B build -G "Unix Makefiles"
|
||||||
|
```
|
||||||
|
CMake provides different generators, and by default will pick the most
|
||||||
|
relevant one to your environment. If you need a specific version of Visual
|
||||||
|
Studio, use `#!bash cmake . -G <generator-name>`, and see `#!bash cmake
|
||||||
|
--help` for the available generators. Also see `-T <toolset-name>`, which can
|
||||||
|
be used to request the native x64 toolchain with `-T host=x64`.
|
||||||
|
3. Afterwards, generated files can be used to compile the project.
|
||||||
|
``` bash
|
||||||
|
cmake --build build
|
||||||
|
```
|
||||||
|
4. Test the build software (optional).
|
||||||
|
``` bash
|
||||||
|
cmake --build build --target test
|
||||||
|
```
|
||||||
|
5. Install the built files (optional).
|
||||||
|
``` bash
|
||||||
|
cmake --build build --target install
|
||||||
|
```
|
||||||
|
|
||||||
|
Once successfully built, glog can be [integrated into own projects](usage.md).
|
||||||
50
docs/contribute.md
Normal file
50
docs/contribute.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# How to Contribute
|
||||||
|
|
||||||
|
We'd love to accept your patches and contributions to this project.
|
||||||
|
There are a just a few small guidelines you need to follow.
|
||||||
|
|
||||||
|
## Contributor License Agreement (CLA)
|
||||||
|
|
||||||
|
Contributions to any Google project must be accompanied by a Contributor
|
||||||
|
License Agreement. This is not a copyright **assignment**, it simply
|
||||||
|
gives Google permission to use and redistribute your contributions as
|
||||||
|
part of the project.
|
||||||
|
|
||||||
|
- If you are an individual writing original source code and you're
|
||||||
|
sure you own the intellectual property, then you'll need to sign an
|
||||||
|
[individual
|
||||||
|
CLA](https://developers.google.com/open-source/cla/individual).
|
||||||
|
- If you work for a company that wants to allow you to contribute your
|
||||||
|
work, then you'll need to sign a [corporate
|
||||||
|
CLA](https://developers.google.com/open-source/cla/corporate).
|
||||||
|
|
||||||
|
You generally only need to submit a CLA once, so if you've already
|
||||||
|
submitted one (even if it was for a different project), you probably
|
||||||
|
don't need to do it again.
|
||||||
|
|
||||||
|
Once your CLA is submitted (or if you already submitted one for another Google
|
||||||
|
project), make a commit adding yourself to the
|
||||||
|
[AUTHORS](https://github.com/google/glog/blob/master/AUTHORS) and
|
||||||
|
[CONTRIBUTORS](https://github.com/google/glog/blob/master/CONTRIBUTORS) files.
|
||||||
|
This commit can be part of your first [pull
|
||||||
|
request](https://help.github.com/articles/creating-a-pull-request).
|
||||||
|
|
||||||
|
## Submitting a Patch
|
||||||
|
|
||||||
|
1. It's generally best to start by opening a new issue describing the
|
||||||
|
bug or feature you're intending to fix. Even if you think it's
|
||||||
|
relatively minor, it's helpful to know what people are working on.
|
||||||
|
Mention in the initial issue that you are planning to work on that
|
||||||
|
bug or feature so that it can be assigned to you.
|
||||||
|
2. Follow the normal process of
|
||||||
|
[forking](https://help.github.com/articles/fork-a-repo) the project,
|
||||||
|
and setup a new branch to work in. It's important that each group of
|
||||||
|
changes be done in separate branches in order to ensure that a pull
|
||||||
|
request only includes the commits related to that bug or feature.
|
||||||
|
3. Do your best to have [well-formed commit
|
||||||
|
messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||||
|
for each change. This provides consistency throughout the project,
|
||||||
|
and ensures that commit messages are able to be formatted properly
|
||||||
|
by various git tools.
|
||||||
|
4. Finally, push the commits to your fork and submit a [pull
|
||||||
|
request](https://help.github.com/articles/creating-a-pull-request).
|
||||||
73
docs/failures.md
Normal file
73
docs/failures.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# Failure Signal Handler
|
||||||
|
|
||||||
|
## Stacktrace as Default Failure Handler
|
||||||
|
|
||||||
|
The library provides a convenient signal handler that will dump useful
|
||||||
|
information when the program crashes on certain signals such as `SIGSEGV`. The
|
||||||
|
signal handler can be installed by `#!cpp
|
||||||
|
google::InstallFailureSignalHandler()`. The following is an example of output
|
||||||
|
from the signal handler.
|
||||||
|
|
||||||
|
*** Aborted at 1225095260 (unix time) try "date -d @1225095260" if you are using GNU date ***
|
||||||
|
*** SIGSEGV (@0x0) received by PID 17711 (TID 0x7f893090a6f0) from PID 0; stack trace: ***
|
||||||
|
PC: @ 0x412eb1 TestWaitingLogSink::send()
|
||||||
|
@ 0x7f892fb417d0 (unknown)
|
||||||
|
@ 0x412eb1 TestWaitingLogSink::send()
|
||||||
|
@ 0x7f89304f7f06 google::LogMessage::SendToLog()
|
||||||
|
@ 0x7f89304f35af google::LogMessage::Flush()
|
||||||
|
@ 0x7f89304f3739 google::LogMessage::~LogMessage()
|
||||||
|
@ 0x408cf4 TestLogSinkWaitTillSent()
|
||||||
|
@ 0x4115de main
|
||||||
|
@ 0x7f892f7ef1c4 (unknown)
|
||||||
|
@ 0x4046f9 (unknown)
|
||||||
|
|
||||||
|
|
||||||
|
## Customizing Handler Output
|
||||||
|
|
||||||
|
By default, the signal handler writes the failure dump to the standard error.
|
||||||
|
However, it is possible to customize the destination by installing a callback
|
||||||
|
using the `#!cpp google::InstallFailureWriter()` function. The function expects
|
||||||
|
a pointer to a function with the following signature:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
void YourFailureWriter(const char* message/* (1)! */, std::size_t length/* (2)! */);
|
||||||
|
```
|
||||||
|
|
||||||
|
1. The pointer references the start of the failure message.
|
||||||
|
|
||||||
|
!!! danger
|
||||||
|
The string is **not null-terminated**.
|
||||||
|
|
||||||
|
2. The message length in characters.
|
||||||
|
|
||||||
|
!!! warning "Possible overflow errors"
|
||||||
|
Users should not expect the `message` string to be null-terminated.
|
||||||
|
|
||||||
|
## User-defined Failure Function
|
||||||
|
|
||||||
|
`FATAL` severity level messages or unsatisfied `CHECK` condition
|
||||||
|
terminate your program. You can change the behavior of the termination
|
||||||
|
by `google::InstallFailureFunction`.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
void YourFailureFunction() {
|
||||||
|
// Reports something...
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
google::InstallFailureFunction(&YourFailureFunction);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, glog tries to dump the stacktrace and calls `#!cpp std::abort`. The
|
||||||
|
stacktrace is generated only when running the application on a system
|
||||||
|
supported[^1] by glog.
|
||||||
|
|
||||||
|
[^1]: To extract the stack trace, glog currently supports the following targets:
|
||||||
|
|
||||||
|
* x86, x86_64,
|
||||||
|
* PowerPC architectures,
|
||||||
|
* `libunwind`,
|
||||||
|
* and the Debug Help Library (`dbghelp`) on Windows.
|
||||||
|
|
||||||
93
docs/flags.md
Normal file
93
docs/flags.md
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
# Adjusting Output
|
||||||
|
|
||||||
|
Several flags influence glog's output behavior.
|
||||||
|
|
||||||
|
## Using Command-line Parameters and Environment Variables
|
||||||
|
|
||||||
|
If the [Google gflags
|
||||||
|
library](https://github.com/gflags/gflags) is installed on your machine,
|
||||||
|
the build system will automatically detect and use it, allowing you to
|
||||||
|
pass flags on the command line.
|
||||||
|
|
||||||
|
!!! example "Activate `--logtostderr` in an application from the command line"
|
||||||
|
A binary `you_application` that uses glog can be started using
|
||||||
|
``` bash
|
||||||
|
./your_application --logtostderr=1
|
||||||
|
```
|
||||||
|
to log to `stderr` instead of writing the output to a log file.
|
||||||
|
|
||||||
|
!!! tip
|
||||||
|
You can set boolean flags to `true` by specifying `1`, `true`, or `yes`. To
|
||||||
|
set boolean flags to `false`, specify `0`, `false`, or `no`. In either case
|
||||||
|
the spelling is case-insensitive.
|
||||||
|
|
||||||
|
|
||||||
|
If the Google gflags library isn't installed, you set flags via
|
||||||
|
environment variables, prefixing the flag name with `GLOG_`, e.g.,
|
||||||
|
|
||||||
|
!!! example "Activate `logtostderr` without gflags"
|
||||||
|
``` bash
|
||||||
|
GLOG_logtostderr=1 ./your_application
|
||||||
|
```
|
||||||
|
|
||||||
|
The following flags are most commonly used:
|
||||||
|
|
||||||
|
`logtostderr` (`bool`, default=`false`)
|
||||||
|
|
||||||
|
: Log messages to `stderr` instead of logfiles.
|
||||||
|
|
||||||
|
`stderrthreshold` (`int`, default=2, which is `ERROR`)
|
||||||
|
|
||||||
|
: Copy log messages at or above this level to `stderr` in addition to
|
||||||
|
logfiles. The numbers of severity levels `INFO`, `WARNING`, `ERROR`,
|
||||||
|
and `FATAL` are 0, 1, 2, and 3, respectively.
|
||||||
|
|
||||||
|
`minloglevel` (`int`, default=0, which is `INFO`)
|
||||||
|
|
||||||
|
: Log messages at or above this level. Again, the numbers of severity
|
||||||
|
levels `INFO`, `WARNING`, `ERROR`, and `FATAL` are 0, 1, 2, and 3,
|
||||||
|
respectively.
|
||||||
|
|
||||||
|
`log_dir` (`string`, default="")
|
||||||
|
|
||||||
|
: If specified, logfiles are written into this directory instead of
|
||||||
|
the default logging directory.
|
||||||
|
|
||||||
|
`v` (`int`, default=0)
|
||||||
|
|
||||||
|
: Show all `#!cpp VLOG(m)` messages for `m` less or equal the value of this
|
||||||
|
flag. Overridable by `#!bash --vmodule`. Refer to [verbose
|
||||||
|
logging](logging.md#verbose-logging) for more detail.
|
||||||
|
|
||||||
|
`vmodule` (`string`, default="")
|
||||||
|
|
||||||
|
: Per-module verbose level. The argument has to contain a
|
||||||
|
comma-separated list of `<module name>=<log level>`. `<module name>` is a
|
||||||
|
glob pattern (e.g., `gfs*` for all modules whose name starts with "gfs"),
|
||||||
|
matched against the filename base (that is, name ignoring .cc/.h./-inl.h).
|
||||||
|
`<log level>` overrides any value given by `--v`. See also [verbose
|
||||||
|
logging](logging.md#verbose-logging) for more details.
|
||||||
|
|
||||||
|
Additional flags are defined in
|
||||||
|
[flags.cc](https://github.com/google/glog/blob/master/src/flags.cc). Please see
|
||||||
|
the source for their complete list.
|
||||||
|
|
||||||
|
## Modifying Flags Programmatically
|
||||||
|
|
||||||
|
You can also modify flag values in your program by modifying global variables
|
||||||
|
`FLAGS_*`. Most settings start working immediately after you update `FLAGS_*`.
|
||||||
|
The exceptions are the flags related to destination files. For instance, you
|
||||||
|
might want to set `FLAGS_log_dir` before calling `google::InitGoogleLogging`.
|
||||||
|
|
||||||
|
!!! example "Setting `log_dir` at runtime"
|
||||||
|
``` cpp
|
||||||
|
LOG(INFO) << "file";
|
||||||
|
// Most flags work immediately after updating values.
|
||||||
|
FLAGS_logtostderr = 1;
|
||||||
|
LOG(INFO) << "stderr";
|
||||||
|
FLAGS_logtostderr = 0;
|
||||||
|
// This won’t change the log destination. If you want to set this
|
||||||
|
// value, you should do this before google::InitGoogleLogging .
|
||||||
|
FLAGS_log_dir = "/some/log/directory";
|
||||||
|
LOG(INFO) << "the same file";
|
||||||
|
```
|
||||||
30
docs/index.md
Normal file
30
docs/index.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Google Logging Library
|
||||||
|
|
||||||
|
Google Logging (glog) is a C++14 library that implements application-level
|
||||||
|
logging. The library provides logging APIs based on C++-style streams and
|
||||||
|
various helper macros.
|
||||||
|
|
||||||
|
# How to Use
|
||||||
|
|
||||||
|
You can log a message by simply streaming things to `LOG`(<a particular
|
||||||
|
[severity level](logging.md#severity-levels)\>), e.g.,
|
||||||
|
|
||||||
|
``` cpp title="main.cpp"
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
google::InitGoogleLogging(argv[0]); // (1)!
|
||||||
|
LOG(INFO) << "Found " << num_cookies << " cookies"; // (2)!
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Initialize the Google Logging Library
|
||||||
|
2. Log a message with informational severity
|
||||||
|
|
||||||
|
The library can be installed using various [package managers](packages.md) or
|
||||||
|
compiled [from source](build.md). For a detailed overview of glog features and
|
||||||
|
their usage, please refer to the [user guide](logging.md).
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
The above example requires further [Bazel](build.md#bazel) or
|
||||||
|
[CMake](usage.md) setup for use in own projects.
|
||||||
3
docs/license.md
Normal file
3
docs/license.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# The 3-Clause BSD License
|
||||||
|
|
||||||
|
--8<-- "LICENSE.md"
|
||||||
24
docs/log_cleaner.md
Normal file
24
docs/log_cleaner.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Automatically Remove Old Logs
|
||||||
|
|
||||||
|
To enable the log cleaner:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
google::EnableLogCleaner(24h * 3); // keep your logs for 3 days
|
||||||
|
```
|
||||||
|
|
||||||
|
In C++20 (and later) this can be shortened to:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
google::EnableLogCleaner(3d); // keep your logs for 3 days
|
||||||
|
```
|
||||||
|
|
||||||
|
And then glog will check if there are overdue logs whenever a flush is
|
||||||
|
performed. In this example, any log file from your project whose last
|
||||||
|
modified time is greater than 3 days will be `unlink`()ed.
|
||||||
|
|
||||||
|
This feature can be disabled at any time (if it has been enabled) using
|
||||||
|
``` cpp
|
||||||
|
google::DisableLogCleaner();
|
||||||
|
```
|
||||||
20
docs/log_stripping.md
Normal file
20
docs/log_stripping.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Strip Logging Messages
|
||||||
|
|
||||||
|
Strings used in log messages can increase the size of your binary and
|
||||||
|
present a privacy concern. You can therefore instruct glog to remove all
|
||||||
|
strings which fall below a certain severity level by using the
|
||||||
|
`GOOGLE_STRIP_LOG` macro:
|
||||||
|
|
||||||
|
If your application has code like this:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
#define GOOGLE_STRIP_LOG 1 // this must go before the #include!
|
||||||
|
#include <glog/logging.h>
|
||||||
|
```
|
||||||
|
|
||||||
|
The compiler will remove the log messages whose severities are less than
|
||||||
|
the specified integer value. Since `VLOG` logs at the severity level
|
||||||
|
`INFO` (numeric value `0`), setting `GOOGLE_STRIP_LOG` to 1 or greater
|
||||||
|
removes all log messages associated with `VLOG`s as well as `INFO` log
|
||||||
|
statements.
|
||||||
|
|
||||||
424
docs/logging.md
Normal file
424
docs/logging.md
Normal file
@ -0,0 +1,424 @@
|
|||||||
|
# Logging
|
||||||
|
|
||||||
|
glog defines a series of macros that simplify many common logging tasks. You can
|
||||||
|
log messages by [severity level](#severity-levels), [control logging](flags.md)
|
||||||
|
behavior from the command line, log based on
|
||||||
|
[conditionals](#conditional-occasional-logging), abort the program when
|
||||||
|
[expected conditions](#runtime-checks) are not met, introduce your [own logging
|
||||||
|
levels](#verbose-logging), [customize the prefix](#format-customization)
|
||||||
|
attached to log messages, and more.
|
||||||
|
|
||||||
|
|
||||||
|
## Severity Levels
|
||||||
|
|
||||||
|
You can specify one of the following severity levels (in increasing order of
|
||||||
|
severity):
|
||||||
|
|
||||||
|
1. `INFO`,
|
||||||
|
2. `WARNING`,
|
||||||
|
3. `ERROR`, and
|
||||||
|
4. `FATAL`.
|
||||||
|
|
||||||
|
Logging a `FATAL` message terminates the program (after the message is logged).
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Messages of a given severity are logged not only to corresponding severity
|
||||||
|
logfile but also to other logfiles of lower severity. For instance, a
|
||||||
|
message of severity `FATAL` will be logged to logfiles of severity `FATAL`,
|
||||||
|
`ERROR`, `WARNING`, and `INFO`.
|
||||||
|
|
||||||
|
The `DFATAL` severity logs a `FATAL` error in [debug mode](#debugging-support)
|
||||||
|
(i.e., there is no `NDEBUG` macro defined), but avoids halting the program in
|
||||||
|
production by automatically reducing the severity to `ERROR`.
|
||||||
|
|
||||||
|
## Log Files
|
||||||
|
|
||||||
|
Unless otherwise specified, glog uses the format
|
||||||
|
|
||||||
|
<tmp>/<program name>.<hostname>.<user name>.log.<severity level>.<date>-<time>.<pid>
|
||||||
|
|
||||||
|
for log filenames written to a directory designated as `<tmp>` and
|
||||||
|
determined according to the following rules.
|
||||||
|
|
||||||
|
**Windows**
|
||||||
|
|
||||||
|
: glog uses the
|
||||||
|
[GetTempPathA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppatha)
|
||||||
|
API function to retrieve the directory for temporary files with a
|
||||||
|
fallback to
|
||||||
|
|
||||||
|
1. `C:\TMP\`
|
||||||
|
2. `C:\TEMP\`
|
||||||
|
|
||||||
|
(in the order given.)
|
||||||
|
|
||||||
|
**non-Windows**
|
||||||
|
|
||||||
|
: The directory is determined by referencing the environment variables
|
||||||
|
|
||||||
|
1. `TMPDIR`
|
||||||
|
2. `TMP`
|
||||||
|
|
||||||
|
if set with a fallback to `/tmp/`.
|
||||||
|
|
||||||
|
The default path to a log file on Linux, for instance, could be
|
||||||
|
|
||||||
|
/tmp/hello_world.example.com.hamaji.log.INFO.20080709-222411.10474
|
||||||
|
|
||||||
|
By default, glog echos `ERROR` and `FATAL` messages to standard error in
|
||||||
|
addition to log files.
|
||||||
|
|
||||||
|
## Log Line Prefix Format
|
||||||
|
|
||||||
|
Log lines have this form:
|
||||||
|
|
||||||
|
Lyyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg...
|
||||||
|
|
||||||
|
where the fields are defined as follows:
|
||||||
|
|
||||||
|
| Placeholder | Meaning |
|
||||||
|
| ------------------- | ----------------------------------------------------------------------|
|
||||||
|
| `L` | A single character, representing the log level (e.g., `I` for `INFO`) |
|
||||||
|
| `yyyy` | The year |
|
||||||
|
| `mm` | The month (zero padded; i.e., May is `05`) |
|
||||||
|
| `dd` | The day (zero padded) |
|
||||||
|
| `hh:mm:ss.uuuuuu` | Time in hours, minutes and fractional seconds |
|
||||||
|
| `threadid` | The space-padded thread ID |
|
||||||
|
| `file` | The file name |
|
||||||
|
| `line` | The line number |
|
||||||
|
| `msg` | The user-supplied message |
|
||||||
|
|
||||||
|
!!! example "Default log line prefix format"
|
||||||
|
|
||||||
|
```
|
||||||
|
I1103 11:57:31.739339 24395 google.cc:2341] Command line: ./some_prog
|
||||||
|
I1103 11:57:31.739403 24395 google.cc:2342] Process id 24395
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Although microseconds are useful for comparing events on a single machine,
|
||||||
|
clocks on different machines may not be well synchronized. Hence, use with
|
||||||
|
caution when comparing the low bits of timestamps from different machines.
|
||||||
|
|
||||||
|
### Format Customization
|
||||||
|
|
||||||
|
The predefined log line prefix can be replaced using a user-provided callback
|
||||||
|
that formats the corresponding output.
|
||||||
|
|
||||||
|
For each log entry, the callback will be invoked with a reference to a
|
||||||
|
`google::LogMessage` instance containing the severity, filename, line
|
||||||
|
number, thread ID, and time of the event. It will also be given a
|
||||||
|
reference to the output stream, whose contents will be prepended to the actual
|
||||||
|
message in the final log line.
|
||||||
|
|
||||||
|
To enable the use of a prefix formatter, use the
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
google::InstallPrefixFormatter(&MyPrefixFormatter);
|
||||||
|
```
|
||||||
|
|
||||||
|
function to pass a pointer to the corresponding `MyPrefixFormatter` callback
|
||||||
|
during initialization. `InstallPrefixFormatter` takes a second optional argument
|
||||||
|
of type `#!cpp void*` that allows supplying user data to the callback.
|
||||||
|
|
||||||
|
!!! example "Custom prefix formatter"
|
||||||
|
The following function outputs a prefix that matches glog's default format.
|
||||||
|
The third parameter `data` can be used to access user-supplied data which
|
||||||
|
unless specified defaults to `#!cpp nullptr`.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
void MyPrefixFormatter(std::ostream& s, const google::LogMessage& m, void* /*data*/) {
|
||||||
|
s << google::GetLogSeverityName(m.severity())[0]
|
||||||
|
<< setw(4) << 1900 + m.time().year()
|
||||||
|
<< setw(2) << 1 + m.time().month()
|
||||||
|
<< setw(2) << m.time().day()
|
||||||
|
<< ' '
|
||||||
|
<< setw(2) << m.time().hour() << ':'
|
||||||
|
<< setw(2) << m.time().min() << ':'
|
||||||
|
<< setw(2) << m.time().sec() << "."
|
||||||
|
<< setw(6) << m.time().usec()
|
||||||
|
<< ' '
|
||||||
|
<< setfill(' ') << setw(5)
|
||||||
|
<< m.thread_id() << setfill('0')
|
||||||
|
<< ' '
|
||||||
|
<< m.basename() << ':' << m.line() << "]";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Conditional / Occasional Logging
|
||||||
|
|
||||||
|
Sometimes, you may only want to log a message under certain conditions.
|
||||||
|
You can use the following macros to perform conditional logging:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
|
```
|
||||||
|
|
||||||
|
The "Got lots of cookies" message is logged only when the variable
|
||||||
|
`num_cookies` exceeds 10. If a line of code is executed many times, it may be
|
||||||
|
useful to only log a message at certain intervals. This kind of logging is most
|
||||||
|
useful for informational messages.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
The above line outputs a log messages on the 1st, 11th, 21st, ... times
|
||||||
|
it is executed.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
The placeholder `#!cpp google::COUNTER` identifies the recurring repetition.
|
||||||
|
|
||||||
|
You can combine conditional and occasional logging with the following
|
||||||
|
macro.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_IF_EVERY_N(INFO, (size > 1024), 10) << "Got the " << google::COUNTER
|
||||||
|
<< "th big cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
Instead of outputting a message every nth time, you can also limit the
|
||||||
|
output to the first n occurrences:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_FIRST_N(INFO, 20) << "Got the " << google::COUNTER << "th cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
Outputs log messages for the first 20 times it is executed. The `#!cpp
|
||||||
|
google::COUNTER` identifier indicates which repetition is happening.
|
||||||
|
|
||||||
|
Other times, it is desired to only log a message periodically based on a
|
||||||
|
time. For instance, to log a message every 10ms:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_EVERY_T(INFO, 0.01) << "Got a cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
Or every 2.35s:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
LOG_EVERY_T(INFO, 2.35) << "Got a cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
## Verbose Logging
|
||||||
|
|
||||||
|
When you are chasing difficult bugs, thorough log messages are very
|
||||||
|
useful. However, you may want to ignore too verbose messages in usual
|
||||||
|
development. For such verbose logging, glog provides the `VLOG` macro, which
|
||||||
|
allows you to define your own numeric logging levels.
|
||||||
|
|
||||||
|
The `#!bash --v` command line option controls which verbose messages are logged:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
VLOG(1) << "I’m printed when you run the program with --v=1 or higher";
|
||||||
|
VLOG(2) << "I’m printed when you run the program with --v=2 or higher";
|
||||||
|
```
|
||||||
|
|
||||||
|
With `VLOG`, the lower the verbose level, the more likely messages are to be
|
||||||
|
logged. For example, if `#!bash --v==1`, `#!cpp VLOG(1)` will log, but `#!cpp
|
||||||
|
VLOG(2)` will not log.
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
The `VLOG` behavior is opposite of the severity level logging, where
|
||||||
|
`INFO`, `ERROR`, etc. are defined in increasing order and thus
|
||||||
|
`#!bash --minloglevel` of 1 will only log `WARNING` and above.
|
||||||
|
|
||||||
|
Though you can specify any integers for both `VLOG` macro and `--v` flag, the
|
||||||
|
common values for them are small positive integers. For example, if you write
|
||||||
|
`#!cpp VLOG(0)`, you should specify `--v=-1` or lower to silence it. This is less
|
||||||
|
useful since we may not want verbose logs by default in most cases. The `VLOG`
|
||||||
|
macros always log at the `INFO` log level (when they log at all).
|
||||||
|
|
||||||
|
Verbose logging can be controlled from the command line on a per-module basis:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
--vmodule=mapreduce=2,file=1,gfs*=3 --v=0
|
||||||
|
```
|
||||||
|
|
||||||
|
Specifying these options will specifically:
|
||||||
|
|
||||||
|
1. Print `#!cpp VLOG(2)` and lower messages from mapreduce.{h,cc}
|
||||||
|
2. Print `#!cpp VLOG(1)` and lower messages from file.{h,cc}
|
||||||
|
3. Print `#!cpp VLOG(3)` and lower messages from files prefixed with "gfs"
|
||||||
|
4. Print `#!cpp VLOG(0)` and lower messages from elsewhere
|
||||||
|
|
||||||
|
The wildcarding functionality 3. supports both `*` (matches 0 or more
|
||||||
|
characters) and `?` (matches any single character) wildcards. Please also refer
|
||||||
|
to [command line flags](flags.md) for more information.
|
||||||
|
|
||||||
|
There's also `#!cpp VLOG_IS_ON(n)` "verbose level" condition macro. This macro
|
||||||
|
returns `#!cpp true` when the `--v` is equal to or greater than `n`. The macro can be
|
||||||
|
used as follows:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
if (VLOG_IS_ON(2)) {
|
||||||
|
// (1)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Here we can perform some logging preparation and logging that can’t be
|
||||||
|
accomplished with just `#!cpp VLOG(2) << "message ...";`
|
||||||
|
|
||||||
|
Verbose level condition macros `VLOG_IF`, `VLOG_EVERY_N` and `VLOG_IF_EVERY_N`
|
||||||
|
behave analogous to `LOG_IF`, `LOG_EVERY_N`, `LOG_IF_EVERY_N`, but accept a
|
||||||
|
numeric verbosity level as opposed to a severity level.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
VLOG_IF(1, (size > 1024))
|
||||||
|
<< "I’m printed when size is more than 1024 and when you run the "
|
||||||
|
"program with --v=1 or more";
|
||||||
|
VLOG_EVERY_N(1, 10)
|
||||||
|
<< "I’m printed every 10th occurrence, and when you run the program "
|
||||||
|
"with --v=1 or more. Present occurrence is " << google::COUNTER;
|
||||||
|
VLOG_IF_EVERY_N(1, (size > 1024), 10)
|
||||||
|
<< "I’m printed on every 10th occurrence of case when size is more "
|
||||||
|
" than 1024, when you run the program with --v=1 or more. ";
|
||||||
|
"Present occurrence is " << google::COUNTER;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
!!! info "Performance"
|
||||||
|
The conditional logging macros provided by glog (e.g., `CHECK`, `LOG_IF`,
|
||||||
|
`VLOG`, etc.) are carefully implemented and don't execute the right hand
|
||||||
|
side expressions when the conditions are false. So, the following check may
|
||||||
|
not sacrifice the performance of your application.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK(obj.ok) << obj.CreatePrettyFormattedStringButVerySlow();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Debugging Support
|
||||||
|
|
||||||
|
Special debug mode logging macros only have an effect in debug mode and are
|
||||||
|
compiled away to nothing for non-debug mode compiles. Use these macros to avoid
|
||||||
|
slowing down your production application due to excessive logging.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
DLOG(INFO) << "Found cookies";
|
||||||
|
DLOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
|
||||||
|
DLOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
|
||||||
|
DLOG_FIRST_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
|
||||||
|
DLOG_EVERY_T(INFO, 0.01) << "Got a cookie";
|
||||||
|
```
|
||||||
|
|
||||||
|
## Runtime Checks
|
||||||
|
|
||||||
|
It is a good practice to check expected conditions in your program
|
||||||
|
frequently to detect errors as early as possible. The `CHECK` macro
|
||||||
|
provides the ability to abort the application when a condition is not met,
|
||||||
|
similar to the `assert` macro defined in the standard C library.
|
||||||
|
|
||||||
|
`CHECK` aborts the application if a condition is not true. Unlike
|
||||||
|
`assert`, it is **not** controlled by `NDEBUG`, so the check will be executed
|
||||||
|
regardless of compilation mode. Therefore, `fp->Write(x)` in the following
|
||||||
|
example is always executed:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK(fp->Write(x) == 4) << "Write failed!";
|
||||||
|
```
|
||||||
|
|
||||||
|
There are various helper macros for equality/inequality checks
|
||||||
|
-`CHECK_EQ`, `CHECK_NE`, `CHECK_LE`, `CHECK_LT`, `CHECK_GE`, and
|
||||||
|
`CHECK_GT`. They compare two values, and log a `FATAL` message including the two
|
||||||
|
values when the result is not as expected. The values must have
|
||||||
|
`#!cpp operator<<(ostream, ...)` defined.
|
||||||
|
|
||||||
|
You may append to the error message like so:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK_NE(1, 2) << ": The world must be ending!";
|
||||||
|
```
|
||||||
|
|
||||||
|
We are very careful to ensure that each argument is evaluated exactly
|
||||||
|
once, and that anything which is legal to pass as a function argument is legal
|
||||||
|
here. In particular, the arguments may be temporary expressions which will end
|
||||||
|
up being destroyed at the end of the apparent statement, for example:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK_EQ(string("abc")[1], ’b’);
|
||||||
|
```
|
||||||
|
|
||||||
|
The compiler reports an error if one of the arguments is a pointer and the other
|
||||||
|
is `#!cpp nullptr`. To work around this, simply `#!cpp static_cast` `#!cpp
|
||||||
|
nullptr` to the type of the desired pointer.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK_EQ(some_ptr, static_cast<SomeType*>(nullptr));
|
||||||
|
```
|
||||||
|
|
||||||
|
Better yet, use the `CHECK_NOTNULL` macro:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK_NOTNULL(some_ptr);
|
||||||
|
some_ptr->DoSomething();
|
||||||
|
```
|
||||||
|
|
||||||
|
Since this macro returns the given pointer, this is very useful in
|
||||||
|
constructor initializer lists.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
struct S {
|
||||||
|
S(Something* ptr) : ptr_(CHECK_NOTNULL(ptr)) {}
|
||||||
|
Something* ptr_;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
Due to the argument forwarding, `CHECK_NOTNULL` cannot be used to
|
||||||
|
simultaneously stream an additional custom message. To provide a custom
|
||||||
|
message, one can use the macro `CHECK_EQ` prior to the failing check.
|
||||||
|
|
||||||
|
If you are comparing C strings (`#!cpp char *`), a handy set of macros performs
|
||||||
|
both case sensitive and insensitive comparisons - `CHECK_STREQ`, `CHECK_STRNE`,
|
||||||
|
`CHECK_STRCASEEQ`, and `CHECK_STRCASENE`. The `CHECK_*CASE*` macro variants are
|
||||||
|
case-insensitive. You can safely pass `#!cpp nullptr` pointers to this macro.
|
||||||
|
They treat `#!cpp nullptr` and any non-`#!cpp nullptr` string as not equal. Two
|
||||||
|
`#!cpp nullptr`s are equal.
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Both arguments may be temporary objects which are destructed at the
|
||||||
|
end of the current *full expression*, such as
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
CHECK_STREQ(Foo().c_str(), Bar().c_str());
|
||||||
|
```
|
||||||
|
|
||||||
|
where `Foo` and `Bar` return `std::string`.
|
||||||
|
|
||||||
|
The `CHECK_DOUBLE_EQ` macro checks the equality of two floating point values,
|
||||||
|
accepting a small error margin. `CHECK_NEAR` accepts a third floating point
|
||||||
|
argument, which specifies the acceptable error margin.
|
||||||
|
|
||||||
|
|
||||||
|
## Raw Logging
|
||||||
|
|
||||||
|
The header file `<glog/raw_logging.h>` can be used for thread-safe logging,
|
||||||
|
which does not allocate any memory or acquire any locks. Therefore, the macros
|
||||||
|
defined in this header file can be used by low-level memory allocation and
|
||||||
|
synchronization code. Please check
|
||||||
|
[src/glog/raw_logging.h](https://github.com/google/glog/blob/master/src/glog/raw_logging.h)
|
||||||
|
for detail.
|
||||||
|
|
||||||
|
## Google Style `perror()`
|
||||||
|
|
||||||
|
`PLOG()` and `PLOG_IF()` and `PCHECK()` behave exactly like their `LOG*` and
|
||||||
|
`CHECK` equivalents with the addition that they append a description of the
|
||||||
|
current state of `errno` to their output lines. E.g.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
PCHECK(write(1, nullptr, 2) >= 0) << "Write nullptr failed";
|
||||||
|
```
|
||||||
|
|
||||||
|
This check fails with the following error message.
|
||||||
|
|
||||||
|
F0825 185142 test.cc:22] Check failed: write(1, nullptr, 2) >= 0 Write nullptr failed: Bad address [14]
|
||||||
|
|
||||||
|
## Syslog
|
||||||
|
|
||||||
|
`SYSLOG`, `SYSLOG_IF`, and `SYSLOG_EVERY_N` macros are available. These log to
|
||||||
|
syslog in addition to the normal logs. Be aware that logging to syslog can
|
||||||
|
drastically impact performance, especially if syslog is configured for remote
|
||||||
|
logging! Make sure you understand the implications of outputting to syslog
|
||||||
|
before you use these macros. In general, it's wise to use these macros
|
||||||
|
sparingly.
|
||||||
8
docs/overrides/main.html
Normal file
8
docs/overrides/main.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block outdated %}
|
||||||
|
You're not viewing the latest version.
|
||||||
|
<a href="{{ '../' ~ base_url }}">
|
||||||
|
<strong>Click here to go to latest.</strong>
|
||||||
|
</a>
|
||||||
|
{% endblock %}
|
||||||
34
docs/packages.md
Normal file
34
docs/packages.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# Installation using Package Managers
|
||||||
|
|
||||||
|
## conan
|
||||||
|
|
||||||
|
You can download and install glog using the [conan](https://conan.io)
|
||||||
|
package manager:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
pip install conan
|
||||||
|
conan install -r conancenter glog/<glog-version>@
|
||||||
|
```
|
||||||
|
|
||||||
|
The glog recipe in conan center is kept up to date by conan center index
|
||||||
|
community contributors. If the version is out of date, please create an
|
||||||
|
issue or pull request on the
|
||||||
|
[conan-center-index](https://github.com/conan-io/conan-center-index)
|
||||||
|
repository.
|
||||||
|
|
||||||
|
## vcpkg
|
||||||
|
|
||||||
|
You can download and install glog using the
|
||||||
|
[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
|
||||||
|
|
||||||
|
``` bash
|
||||||
|
git clone https://github.com/Microsoft/vcpkg.git
|
||||||
|
cd vcpkg
|
||||||
|
./bootstrap-vcpkg.sh
|
||||||
|
./vcpkg integrate install
|
||||||
|
./vcpkg install glog
|
||||||
|
```
|
||||||
|
|
||||||
|
The glog 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 on the vcpkg repository.
|
||||||
6
docs/requirements.txt
Normal file
6
docs/requirements.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
mike>=2.1.1
|
||||||
|
mkdocs-git-committers-plugin-2>=2.3.0
|
||||||
|
mkdocs-git-revision-date-localized-plugin>=1.2.6
|
||||||
|
mkdocs-material-extensions>=1.3.1
|
||||||
|
mkdocs-material>=9.5.26
|
||||||
|
mkdocs>=1.6.0
|
||||||
84
docs/sinks.md
Normal file
84
docs/sinks.md
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# Custom Sinks
|
||||||
|
|
||||||
|
Under certain circumstances, it is useful to send the log output to a
|
||||||
|
destination other than a file, `stderr` and/or `stdout`. In case, the library
|
||||||
|
provides the `#!cpp google::LogSink` interface whose implementations can be used
|
||||||
|
to write the log output to arbitrary locations.
|
||||||
|
|
||||||
|
## Basic Interface
|
||||||
|
|
||||||
|
The sink interface is defined as follows:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
class LogSink {
|
||||||
|
public:
|
||||||
|
virtual void send(LogSeverity severity, const char* full_filename,
|
||||||
|
const char* base_filename, int line,
|
||||||
|
const LogMessageTime& time, const char* message,
|
||||||
|
size_t message_len);
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
The user must implement `#!cpp google::LogSink::send`, which is called by the
|
||||||
|
library every time a message is logged.
|
||||||
|
|
||||||
|
!!! warning "Possible deadlock due to nested logging"
|
||||||
|
This method can't use `LOG()` or `CHECK()` as logging system mutex(s) are
|
||||||
|
held during this call.
|
||||||
|
|
||||||
|
## Registering Log Sinks
|
||||||
|
|
||||||
|
To use the custom sink and instance of the above interface implementation must
|
||||||
|
be registered using `google::AddLogSink` which expects a pointer to the
|
||||||
|
`google::LogSink` instance. To unregister use `google::RemoveLogSink`. Both
|
||||||
|
functions are thread-safe.
|
||||||
|
|
||||||
|
!!! danger "`LogSink` ownership"
|
||||||
|
The `google::LogSink` instance must not be destroyed until the referencing
|
||||||
|
pointer is unregistered.
|
||||||
|
|
||||||
|
## Direct Logging
|
||||||
|
|
||||||
|
Instead of registering the sink, we can directly use to log messages. While `#!
|
||||||
|
LOG_TO_SINK(sink, severity)` allows to log both to the sink and to a global log
|
||||||
|
registry, e.g., a file, `#!cpp LOG_TO_SINK_BUT_NOT_TO_LOGFILE(sink, severity)`
|
||||||
|
will avoid the latter.
|
||||||
|
|
||||||
|
!!! example "Using a custom sink"
|
||||||
|
``` cpp title="custom_sink.cc"
|
||||||
|
-8<- "examples/custom_sink.cc:33:"
|
||||||
|
```
|
||||||
|
|
||||||
|
1. `MySink` implements a custom sink that sends log messages to `std::cout`.
|
||||||
|
2. The custom sink must be registered to for use with existing logging
|
||||||
|
macros.
|
||||||
|
3. Once the custom sink is no longer needed we remove it from the registry.
|
||||||
|
4. A sink does not need to be registered globally. However, then, messages
|
||||||
|
must be logged using dedicated macros.
|
||||||
|
|
||||||
|
Running the above example as `#!bash GLOG_log_dir=. ./custom_sink_example`
|
||||||
|
will produce
|
||||||
|
|
||||||
|
<div class="annotate" markdown>
|
||||||
|
|
||||||
|
``` title="Custom sink output"
|
||||||
|
INFO custom_sink.cc:63 logging to MySink
|
||||||
|
INFO custom_sink.cc:68 direct logging
|
||||||
|
INFO custom_sink.cc:69 direct logging but not to file (1)
|
||||||
|
```
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
1. This line is not present in the log file because we used
|
||||||
|
`LOG_TO_SINK_BUT_NOT_TO_LOGFILE` to log the message.
|
||||||
|
|
||||||
|
and the corresponding log file will contain
|
||||||
|
|
||||||
|
``` title="Log file generated with the custom sink"
|
||||||
|
Log file created at: 2024/06/11 13:24:27
|
||||||
|
Running on machine: pc
|
||||||
|
Running duration (h:mm:ss): 0:00:00
|
||||||
|
Log line format: [IWEF]yyyymmdd hh:mm:ss.uuuuuu threadid file:line] msg
|
||||||
|
I20240611 13:24:27.476620 126237946035776 custom_sink.cc:63] logging to MySink
|
||||||
|
I20240611 13:24:27.476796 126237946035776 custom_sink.cc:68] direct logging
|
||||||
|
```
|
||||||
57
docs/unwinder.md
Normal file
57
docs/unwinder.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Installation Notes for 64-bit Linux Systems
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
The description on this page is possibly not up-to-date.
|
||||||
|
|
||||||
|
The [glibc built-in stack-unwinder](#glibc-built-in-stack-unwinder) on 64-bit
|
||||||
|
systems has some problems with glog. In particular, if you are using
|
||||||
|
[`InstallFailureSignalHandler()`](failures.md), the signal may be raised in the
|
||||||
|
middle of `malloc`, holding some `malloc`-related locks when they invoke the
|
||||||
|
stack unwinder. The built-in stack unwinder may call `malloc` recursively, which
|
||||||
|
may require the thread to acquire a lock it already holds resulting in a
|
||||||
|
deadlock.
|
||||||
|
|
||||||
|
## Recommended Approach: `libunwind`
|
||||||
|
|
||||||
|
For above reason, if you use a 64-bit system and you need
|
||||||
|
`InstallFailureSignalHandler()`, we strongly recommend you install `libunwind`
|
||||||
|
before trying to configure or install google glog. libunwind can be found
|
||||||
|
[here](http://download.savannah.nongnu.org/releases/libunwind/libunwind-snap-070410.tar.gz).
|
||||||
|
|
||||||
|
Even if you already have `libunwind` installed, you will probably still need to
|
||||||
|
install from the snapshot to get the latest version.
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
If you install libunwind from the URL above, be aware that you may have
|
||||||
|
trouble if you try to statically link your binary with glog: that is, if you
|
||||||
|
link with `gcc -static -lgcc_eh ...`. This is because both `libunwind` and
|
||||||
|
`libgcc` implement the same C++ exception handling APIs, but they implement
|
||||||
|
them differently on some platforms. This is not likely to be a problem on
|
||||||
|
ia64, but may be on x86-64.
|
||||||
|
|
||||||
|
Also, if you link binaries statically, make sure that you add
|
||||||
|
`-Wl,--eh-frame-hdr` to your linker options. This is required so that
|
||||||
|
`libunwind` can find the information generated by the compiler required for
|
||||||
|
stack unwinding.
|
||||||
|
|
||||||
|
Using `-static` is rare, though, so unless you know this will affect you it
|
||||||
|
probably won't.
|
||||||
|
|
||||||
|
## Alternative Stack-unwinder
|
||||||
|
|
||||||
|
If you cannot or do not wish to install `libunwind`, you can still try to use
|
||||||
|
two kinds of stack-unwinder:
|
||||||
|
|
||||||
|
### glibc Built-in Stack-unwinder
|
||||||
|
|
||||||
|
As we already mentioned, glibc's unwinder has a deadlock issue. However, if you
|
||||||
|
don't use `InstallFailureSignalHandler()` or you don't worry about the rare
|
||||||
|
possibilities of deadlocks, you can use this stack-unwinder. If you specify no
|
||||||
|
options and `libunwind` isn't detected on your system, the configure script
|
||||||
|
chooses this unwinder by default.
|
||||||
|
|
||||||
|
### Frame Pointer based Stack-unwinder
|
||||||
|
|
||||||
|
The frame pointer based stack unwinder requires that your application, the glog
|
||||||
|
library, and system libraries like libc, all be compiled with a frame pointer.
|
||||||
|
This is *not* the default for x86-64.
|
||||||
24
docs/usage.md
Normal file
24
docs/usage.md
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Using glog in a CMake Project
|
||||||
|
|
||||||
|
Assuming that glog was previously [built using CMake](build.md#cmake) or
|
||||||
|
installed using a package manager, you can use the CMake command `#!cmake
|
||||||
|
find_package` to build against glog in your CMake project as follows:
|
||||||
|
|
||||||
|
``` cmake title="CMakeLists.txt"
|
||||||
|
cmake_minimum_required (VERSION 3.16)
|
||||||
|
project (myproj VERSION 1.0)
|
||||||
|
|
||||||
|
find_package (glog 0.8.0 REQUIRED)
|
||||||
|
|
||||||
|
add_executable (myapp main.cpp)
|
||||||
|
target_link_libraries (myapp glog::glog)
|
||||||
|
```
|
||||||
|
|
||||||
|
Compile definitions and options will be added automatically to your target as
|
||||||
|
needed.
|
||||||
|
|
||||||
|
Alternatively, glog can be incorporated into using the CMake command `#!cmake
|
||||||
|
add_subdirectory` to include glog directly from a subdirectory of your project
|
||||||
|
by replacing the `#!cmake find_package` call from the previous snippet by
|
||||||
|
`add_subdirectory`. The `#!cmake glog::glog` target is in this case an `#!cmake
|
||||||
|
ALIAS` library target for the `glog` library target.
|
||||||
44
docs/windows.md
Normal file
44
docs/windows.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# Notes for Windows Users
|
||||||
|
|
||||||
|
glog defines the severity level `ERROR`, which is also defined by `windows.h`.
|
||||||
|
You can make glog not define `INFO`, `WARNING`, `ERROR`, and `FATAL` by defining
|
||||||
|
`GLOG_NO_ABBREVIATED_SEVERITIES` before including `glog/logging.h`. Even with
|
||||||
|
this macro, you can still use the iostream like logging facilities:
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
#include <windows.h>
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
LOG(ERROR) << "This should work";
|
||||||
|
LOG_IF(ERROR, x > y) << "This should be also OK";
|
||||||
|
```
|
||||||
|
|
||||||
|
However, you cannot use `INFO`, `WARNING`, `ERROR`, and `FATAL` anymore for
|
||||||
|
functions defined in `glog/logging.h`.
|
||||||
|
|
||||||
|
``` cpp
|
||||||
|
#define GLOG_NO_ABBREVIATED_SEVERITIES
|
||||||
|
#include <windows.h>
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// This won’t work.
|
||||||
|
// google::FlushLogFiles(google::ERROR);
|
||||||
|
|
||||||
|
// Use this instead.
|
||||||
|
google::FlushLogFiles(google::GLOG_ERROR);
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't need `ERROR` defined by `windows.h`, there are a couple of more
|
||||||
|
workarounds which sometimes don't work[^1]:
|
||||||
|
|
||||||
|
- `#!cpp #define WIN32_LEAN_AND_MEAN` or `NOGDI` **before**
|
||||||
|
`#!cpp #include <windows.h>`.
|
||||||
|
- `#!cpp #undef ERROR` **after** `#!cpp #include <windows.h>`.
|
||||||
|
|
||||||
|
[^1]: For more information refer to [this
|
||||||
|
issue](http://code.google.com/p/google-glog/issues/detail?id=33).
|
||||||
71
examples/custom_sink.cc
Normal file
71
examples/custom_sink.cc
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
// Copyright (c) 2024, 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: Sergiu Deitsch
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <glog/logging.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct MyLogSink : google::LogSink { // (1)!
|
||||||
|
void send(google::LogSeverity severity, const char* /*full_filename*/,
|
||||||
|
const char* base_filename, int line,
|
||||||
|
const google::LogMessageTime& /*time*/, const char* message,
|
||||||
|
std::size_t message_len) override {
|
||||||
|
std::cout << google::GetLogSeverityName(severity) << ' ' << base_filename
|
||||||
|
<< ':' << line << ' ';
|
||||||
|
std::copy_n(message, message_len,
|
||||||
|
std::ostreambuf_iterator<char>{std::cout});
|
||||||
|
std::cout << '\n';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
int main(int /*argc*/, char** argv) {
|
||||||
|
google::InitGoogleLogging(argv[0]);
|
||||||
|
|
||||||
|
MyLogSink sink;
|
||||||
|
google::AddLogSink(&sink); // (2)!
|
||||||
|
|
||||||
|
LOG(INFO) << "logging to MySink";
|
||||||
|
|
||||||
|
google::RemoveLogSink(&sink); // (3)!
|
||||||
|
|
||||||
|
// We can directly log to a sink without registering it
|
||||||
|
LOG_TO_SINK(&sink, INFO) << "direct logging"; // (4)!
|
||||||
|
LOG_TO_SINK_BUT_NOT_TO_LOGFILE(&sink, INFO)
|
||||||
|
<< "direct logging but not to file";
|
||||||
|
}
|
||||||
8
gcovr.cfg
Normal file
8
gcovr.cfg
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
exclude = src/.*_unittest\.cc
|
||||||
|
exclude = src/googletest\.h
|
||||||
|
exclude = src/mock-log\.h
|
||||||
|
exclude-directories = Tests/
|
||||||
|
exclude-throw-branches = yes
|
||||||
|
exclude-unreachable-branches = yes
|
||||||
|
filter = .*/glog/.*\.h
|
||||||
|
filter = src/
|
||||||
@ -5,7 +5,11 @@ endif (CMAKE_VERSION VERSION_LESS @glog_CMake_VERSION@)
|
|||||||
@PACKAGE_INIT@
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
include (CMakeFindDependencyMacro)
|
include (CMakeFindDependencyMacro)
|
||||||
|
include (${CMAKE_CURRENT_LIST_DIR}/glog-modules.cmake)
|
||||||
|
|
||||||
|
find_dependency (Threads)
|
||||||
|
|
||||||
@gflags_DEPENDENCY@
|
@gflags_DEPENDENCY@
|
||||||
|
@Unwind_DEPENDENCY@
|
||||||
|
|
||||||
include ("${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake")
|
include (${CMAKE_CURRENT_LIST_DIR}/glog-targets.cmake)
|
||||||
|
|||||||
18
glog-modules.cmake.in
Normal file
18
glog-modules.cmake.in
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
cmake_policy (PUSH)
|
||||||
|
cmake_policy (SET CMP0057 NEW)
|
||||||
|
|
||||||
|
if (CMAKE_VERSION VERSION_LESS 3.3)
|
||||||
|
message (FATAL_ERROR "glog-modules.cmake requires the consumer "
|
||||||
|
"to use CMake 3.3 (or newer)")
|
||||||
|
endif (CMAKE_VERSION VERSION_LESS 3.3)
|
||||||
|
|
||||||
|
set (glog_MODULE_PATH "@glog_FULL_CMake_DATADIR@")
|
||||||
|
list (APPEND CMAKE_MODULE_PATH ${glog_MODULE_PATH})
|
||||||
|
|
||||||
|
if (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
|
||||||
|
message (FATAL_ERROR "Cannot add '${glog_MODULE_PATH}' to "
|
||||||
|
"CMAKE_MODULE_PATH. This will cause glog-config.cmake to fail at "
|
||||||
|
"locating required find modules. Make sure CMAKE_MODULE_PATH is not a cache variable.")
|
||||||
|
endif (NOT glog_MODULE_PATH IN_LIST CMAKE_MODULE_PATH)
|
||||||
|
|
||||||
|
cmake_policy (POP)
|
||||||
@ -7,4 +7,5 @@ Name: libglog
|
|||||||
Description: Google Log (glog) C++ logging framework
|
Description: Google Log (glog) C++ logging framework
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Libs: -L${libdir} -lglog
|
Libs: -L${libdir} -lglog
|
||||||
|
Libs.private: @glog_libraries_options_for_static_linking@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|||||||
@ -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,14 +0,0 @@
|
|||||||
AC_DEFUN([AX_C___BUILTIN_EXPECT], [
|
|
||||||
AC_MSG_CHECKING(for __builtin_expect)
|
|
||||||
AC_CACHE_VAL(ac_cv___builtin_expect, [
|
|
||||||
AC_TRY_COMPILE(
|
|
||||||
[int foo(void) { if (__builtin_expect(0, 0)) return 1; return 0; }],
|
|
||||||
[],
|
|
||||||
ac_cv___builtin_expect=yes,
|
|
||||||
ac_cv___builtin_expect=no
|
|
||||||
)])
|
|
||||||
if test "$ac_cv___builtin_expect" = "yes"; then
|
|
||||||
AC_DEFINE(HAVE___BUILTIN_EXPECT, 1, [define if your compiler has __builtin_expect])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($ac_cv___builtin_expect)
|
|
||||||
])
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
AC_DEFUN([AX_C___SYNC_VAL_COMPARE_AND_SWAP], [
|
|
||||||
AC_MSG_CHECKING(for __sync_val_compare_and_swap)
|
|
||||||
AC_CACHE_VAL(ac_cv___sync_val_compare_and_swap, [
|
|
||||||
AC_TRY_LINK(
|
|
||||||
[],
|
|
||||||
[int a; if (__sync_val_compare_and_swap(&a, 0, 1)) return 1; return 0;],
|
|
||||||
ac_cv___sync_val_compare_and_swap=yes,
|
|
||||||
ac_cv___sync_val_compare_and_swap=no
|
|
||||||
)])
|
|
||||||
if test "$ac_cv___sync_val_compare_and_swap" = "yes"; then
|
|
||||||
AC_DEFINE(HAVE___SYNC_VAL_COMPARE_AND_SWAP, 1, [define if your compiler has __sync_val_compare_and_swap])
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT($ac_cv___sync_val_compare_and_swap)
|
|
||||||
])
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
# TODO(csilvers): it would be better to actually try to link against
|
|
||||||
# -pthreads, to make sure it defines these methods, but that may be
|
|
||||||
# too hard, since pthread support is really tricky.
|
|
||||||
|
|
||||||
# Check for support for pthread_rwlock_init() etc.
|
|
||||||
# These aren't posix, but are widely supported. To get them on linux,
|
|
||||||
# you need to define _XOPEN_SOURCE first, so this check assumes your
|
|
||||||
# application does that.
|
|
||||||
#
|
|
||||||
# Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but
|
|
||||||
# doesn't define PTHREAD_RWLOCK_INITIALIZER. Therefore, we don't test
|
|
||||||
# that particularly macro. It's probably best if you don't use that
|
|
||||||
# macro in your code either.
|
|
||||||
|
|
||||||
AC_DEFUN([AC_RWLOCK],
|
|
||||||
[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
|
|
||||||
ac_cv_rwlock,
|
|
||||||
[AC_LANG_SAVE
|
|
||||||
AC_LANG_C
|
|
||||||
AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
|
|
||||||
#include <pthread.h>],
|
|
||||||
[pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
|
|
||||||
pthread_rwlock_rdlock(&l);
|
|
||||||
return 0;],
|
|
||||||
ac_cv_rwlock=yes, ac_cv_rwlock=no)
|
|
||||||
AC_LANG_RESTORE
|
|
||||||
])
|
|
||||||
if test "$ac_cv_rwlock" = yes; then
|
|
||||||
AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
@ -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,36 +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'.
|
|
||||||
|
|
||||||
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)
|
|
||||||
])
|
|
||||||
123
m4/ltsugar.m4
vendored
123
m4/ltsugar.m4
vendored
@ -1,123 +0,0 @@
|
|||||||
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
|
||||||
#
|
|
||||||
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
|
||||||
# Written by Gary V. Vaughan, 2004
|
|
||||||
#
|
|
||||||
# This file is free software; the Free Software Foundation gives
|
|
||||||
# unlimited permission to copy and/or distribute it, with or without
|
|
||||||
# modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
# serial 6 ltsugar.m4
|
|
||||||
|
|
||||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
|
||||||
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_join(SEP, ARG1, [ARG2...])
|
|
||||||
# -----------------------------
|
|
||||||
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
|
||||||
# associated separator.
|
|
||||||
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
|
||||||
# versions in m4sugar had bugs.
|
|
||||||
m4_define([lt_join],
|
|
||||||
[m4_if([$#], [1], [],
|
|
||||||
[$#], [2], [[$2]],
|
|
||||||
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
|
||||||
m4_define([_lt_join],
|
|
||||||
[m4_if([$#$2], [2], [],
|
|
||||||
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_car(LIST)
|
|
||||||
# lt_cdr(LIST)
|
|
||||||
# ------------
|
|
||||||
# Manipulate m4 lists.
|
|
||||||
# These macros are necessary as long as will still need to support
|
|
||||||
# Autoconf-2.59 which quotes differently.
|
|
||||||
m4_define([lt_car], [[$1]])
|
|
||||||
m4_define([lt_cdr],
|
|
||||||
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
|
||||||
[$#], 1, [],
|
|
||||||
[m4_dquote(m4_shift($@))])])
|
|
||||||
m4_define([lt_unquote], $1)
|
|
||||||
|
|
||||||
|
|
||||||
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
|
||||||
# ------------------------------------------
|
|
||||||
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
|
||||||
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
|
||||||
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
|
||||||
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
|
||||||
# than defined and empty).
|
|
||||||
#
|
|
||||||
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
|
||||||
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
|
||||||
m4_define([lt_append],
|
|
||||||
[m4_define([$1],
|
|
||||||
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
|
||||||
# ----------------------------------------------------------
|
|
||||||
# Produce a SEP delimited list of all paired combinations of elements of
|
|
||||||
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
|
||||||
# has the form PREFIXmINFIXSUFFIXn.
|
|
||||||
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
|
||||||
m4_define([lt_combine],
|
|
||||||
[m4_if(m4_eval([$# > 3]), [1],
|
|
||||||
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
|
||||||
[[m4_foreach([_Lt_prefix], [$2],
|
|
||||||
[m4_foreach([_Lt_suffix],
|
|
||||||
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
|
||||||
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
|
||||||
# -----------------------------------------------------------------------
|
|
||||||
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
|
||||||
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
|
||||||
m4_define([lt_if_append_uniq],
|
|
||||||
[m4_ifdef([$1],
|
|
||||||
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
|
||||||
[lt_append([$1], [$2], [$3])$4],
|
|
||||||
[$5])],
|
|
||||||
[lt_append([$1], [$2], [$3])$4])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_dict_add(DICT, KEY, VALUE)
|
|
||||||
# -----------------------------
|
|
||||||
m4_define([lt_dict_add],
|
|
||||||
[m4_define([$1($2)], [$3])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
|
||||||
# --------------------------------------------
|
|
||||||
m4_define([lt_dict_add_subkey],
|
|
||||||
[m4_define([$1($2:$3)], [$4])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
|
||||||
# ----------------------------------
|
|
||||||
m4_define([lt_dict_fetch],
|
|
||||||
[m4_ifval([$3],
|
|
||||||
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
|
||||||
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
m4_define([lt_if_dict_fetch],
|
|
||||||
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
|
||||||
[$5],
|
|
||||||
[$6])])
|
|
||||||
|
|
||||||
|
|
||||||
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
|
||||||
# --------------------------------------------------------------
|
|
||||||
m4_define([lt_dict_filter],
|
|
||||||
[m4_if([$5], [], [],
|
|
||||||
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
|
||||||
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
|
||||||
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
|
||||||
])
|
|
||||||
98
m4/lt~obsolete.m4
vendored
98
m4/lt~obsolete.m4
vendored
@ -1,98 +0,0 @@
|
|||||||
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
|
||||||
#
|
|
||||||
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
|
||||||
# Written by Scott James Remnant, 2004.
|
|
||||||
#
|
|
||||||
# This file is free software; the Free Software Foundation gives
|
|
||||||
# unlimited permission to copy and/or distribute it, with or without
|
|
||||||
# modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
# serial 5 lt~obsolete.m4
|
|
||||||
|
|
||||||
# These exist entirely to fool aclocal when bootstrapping libtool.
|
|
||||||
#
|
|
||||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
|
||||||
# which have later been changed to m4_define as they aren't part of the
|
|
||||||
# exported API, or moved to Autoconf or Automake where they belong.
|
|
||||||
#
|
|
||||||
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
|
||||||
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
|
||||||
# using a macro with the same name in our local m4/libtool.m4 it'll
|
|
||||||
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
|
||||||
# and doesn't know about Autoconf macros at all.)
|
|
||||||
#
|
|
||||||
# So we provide this file, which has a silly filename so it's always
|
|
||||||
# included after everything else. This provides aclocal with the
|
|
||||||
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
|
||||||
# because those macros already exist, or will be overwritten later.
|
|
||||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
|
||||||
#
|
|
||||||
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
|
||||||
# Yes, that means every name once taken will need to remain here until
|
|
||||||
# we give up compatibility with versions before 1.7, at which point
|
|
||||||
# we need to keep only those names which we still refer to.
|
|
||||||
|
|
||||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
|
||||||
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
|
||||||
|
|
||||||
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
|
||||||
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
|
||||||
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
|
||||||
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
|
||||||
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
|
||||||
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
|
||||||
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
|
||||||
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
|
||||||
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
|
||||||
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
|
||||||
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
|
||||||
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
|
||||||
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
|
||||||
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
|
||||||
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
|
||||||
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
|
||||||
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
|
||||||
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
|
||||||
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
|
||||||
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
|
||||||
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
|
||||||
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
|
||||||
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
|
||||||
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
|
||||||
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
|
||||||
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
|
||||||
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
|
||||||
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
|
||||||
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
|
||||||
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
|
||||||
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
|
||||||
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
|
||||||
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
|
||||||
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
|
||||||
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
|
||||||
@ -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,71 +0,0 @@
|
|||||||
# We want to access the "PC" (Program Counter) register from a struct
|
|
||||||
# ucontext. Every system has its own way of doing that. We try all the
|
|
||||||
# possibilities we know about. Note REG_PC should come first (REG_RIP
|
|
||||||
# is also defined on solaris, but does the wrong thing).
|
|
||||||
|
|
||||||
# OpenBSD doesn't have ucontext.h, but we can get PC from ucontext_t
|
|
||||||
# by using signal.h.
|
|
||||||
|
|
||||||
# The first argument of AC_PC_FROM_UCONTEXT will be invoked when we
|
|
||||||
# cannot find a way to obtain PC from ucontext.
|
|
||||||
|
|
||||||
AC_DEFUN([AC_PC_FROM_UCONTEXT],
|
|
||||||
[AC_CHECK_HEADERS(ucontext.h)
|
|
||||||
AC_CHECK_HEADERS(sys/ucontext.h) # ucontext on OS X 10.6 (at least)
|
|
||||||
AC_MSG_CHECKING([how to access the program counter from a struct ucontext])
|
|
||||||
pc_fields=" uc_mcontext.gregs[[REG_PC]]" # Solaris x86 (32 + 64 bit)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.gregs[[REG_EIP]]" # Linux (i386)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.gregs[[REG_RIP]]" # Linux (x86_64)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.sc_ip" # Linux (ia64)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.uc_regs->gregs[[PT_NIP]]" # Linux (ppc)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.gregs[[R15]]" # Linux (arm old [untested])
|
|
||||||
pc_fields="$pc_fields uc_mcontext.arm_pc" # Linux (arm new [untested])
|
|
||||||
pc_fields="$pc_fields uc_mcontext.mc_eip" # FreeBSD (i386)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested])
|
|
||||||
pc_fields="$pc_fields uc_mcontext.__gregs[[_REG_EIP]]" # NetBSD (i386)
|
|
||||||
pc_fields="$pc_fields uc_mcontext.__gregs[[_REG_RIP]]" # NetBSD (x86_64)
|
|
||||||
pc_fields="$pc_fields uc_mcontext->ss.eip" # OS X (i386, <=10.4)
|
|
||||||
pc_fields="$pc_fields uc_mcontext->__ss.__eip" # OS X (i386, >=10.5)
|
|
||||||
pc_fields="$pc_fields uc_mcontext->ss.rip" # OS X (x86_64)
|
|
||||||
pc_fields="$pc_fields uc_mcontext->__ss.__rip" # OS X (>=10.5 [untested])
|
|
||||||
pc_fields="$pc_fields uc_mcontext->ss.srr0" # OS X (ppc, ppc64 [untested])
|
|
||||||
pc_fields="$pc_fields uc_mcontext->__ss.__srr0" # OS X (>=10.5 [untested])
|
|
||||||
pc_field_found=false
|
|
||||||
for pc_field in $pc_fields; do
|
|
||||||
if ! $pc_field_found; then
|
|
||||||
if test "x$ac_cv_header_sys_ucontext_h" = xyes; then
|
|
||||||
AC_TRY_COMPILE([#define _GNU_SOURCE 1
|
|
||||||
#include <sys/ucontext.h>],
|
|
||||||
[ucontext_t u; return u.$pc_field == 0;],
|
|
||||||
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
|
|
||||||
How to access the PC from a struct ucontext)
|
|
||||||
AC_MSG_RESULT([$pc_field])
|
|
||||||
pc_field_found=true)
|
|
||||||
else
|
|
||||||
AC_TRY_COMPILE([#define _GNU_SOURCE 1
|
|
||||||
#include <ucontext.h>],
|
|
||||||
[ucontext_t u; return u.$pc_field == 0;],
|
|
||||||
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
|
|
||||||
How to access the PC from a struct ucontext)
|
|
||||||
AC_MSG_RESULT([$pc_field])
|
|
||||||
pc_field_found=true)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if ! $pc_field_found; then
|
|
||||||
pc_fields=" sc_eip" # OpenBSD (i386)
|
|
||||||
pc_fields="$pc_fields sc_rip" # OpenBSD (x86_64)
|
|
||||||
for pc_field in $pc_fields; do
|
|
||||||
if ! $pc_field_found; then
|
|
||||||
AC_TRY_COMPILE([#include <signal.h>],
|
|
||||||
[ucontext_t u; return u.$pc_field == 0;],
|
|
||||||
AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field,
|
|
||||||
How to access the PC from a struct ucontext)
|
|
||||||
AC_MSG_RESULT([$pc_field])
|
|
||||||
pc_field_found=true)
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
if ! $pc_field_found; then
|
|
||||||
[$1]
|
|
||||||
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
|
|
||||||
])
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
AC_DEFUN([AC_CXX_USING_OPERATOR],
|
|
||||||
[AC_CACHE_CHECK(
|
|
||||||
whether compiler supports using ::operator<<,
|
|
||||||
ac_cv_cxx_using_operator,
|
|
||||||
[AC_LANG_SAVE
|
|
||||||
AC_LANG_CPLUSPLUS
|
|
||||||
AC_TRY_COMPILE([#include <iostream>
|
|
||||||
std::ostream& operator<<(std::ostream&, struct s);],
|
|
||||||
[using ::operator<<; return 0;],
|
|
||||||
ac_cv_cxx_using_operator=1,
|
|
||||||
ac_cv_cxx_using_operator=0)
|
|
||||||
AC_LANG_RESTORE])
|
|
||||||
if test "$ac_cv_cxx_using_operator" = 1; then
|
|
||||||
AC_DEFINE(HAVE_USING_OPERATOR, 1, [define if the compiler supports using expression for operator])
|
|
||||||
fi])
|
|
||||||
123
mkdocs.yml
Normal file
123
mkdocs.yml
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
---
|
||||||
|
site_name: Google Logging Library
|
||||||
|
site_url: https://google.github.io/glog/
|
||||||
|
repo_url: https://github.com/google/glog
|
||||||
|
repo_name: google/glog
|
||||||
|
edit_uri: edit/master/docs/
|
||||||
|
copyright: Copyright © 2024 Google Inc. & contributors - <a href="#__consent">Change cookie settings</a>
|
||||||
|
markdown_extensions:
|
||||||
|
- admonition
|
||||||
|
- attr_list
|
||||||
|
- def_list
|
||||||
|
- footnotes
|
||||||
|
- md_in_html
|
||||||
|
- pymdownx.details
|
||||||
|
- pymdownx.highlight:
|
||||||
|
anchor_linenums: true
|
||||||
|
line_spans: __span
|
||||||
|
pygments_lang_class: true
|
||||||
|
- pymdownx.inlinehilite
|
||||||
|
- pymdownx.snippets:
|
||||||
|
base_path:
|
||||||
|
- '.'
|
||||||
|
check_paths: true
|
||||||
|
- pymdownx.superfences
|
||||||
|
- tables
|
||||||
|
- toc:
|
||||||
|
permalink: true
|
||||||
|
theme:
|
||||||
|
name: material
|
||||||
|
custom_dir: docs/overrides
|
||||||
|
icon:
|
||||||
|
annotation: material/chevron-right-circle
|
||||||
|
edit: material/pencil
|
||||||
|
repo: fontawesome/brands/git-alt
|
||||||
|
view: material/eye
|
||||||
|
language: en
|
||||||
|
features:
|
||||||
|
- content.action.edit
|
||||||
|
- content.code.annotate
|
||||||
|
- content.code.copy
|
||||||
|
- content.code.select
|
||||||
|
- header.autohide
|
||||||
|
- navigation.expand
|
||||||
|
- navigation.instant.preview
|
||||||
|
- navigation.instant.progress
|
||||||
|
- navigation.prune
|
||||||
|
- navigation.indexes
|
||||||
|
- toc.follow
|
||||||
|
- navigation.top
|
||||||
|
- navigation.path
|
||||||
|
# - navigation.sections
|
||||||
|
# - navigation.tabs
|
||||||
|
# - navigation.tabs.sticky
|
||||||
|
- navigation.tracking
|
||||||
|
- search.highlight
|
||||||
|
- search.share
|
||||||
|
- search.suggest
|
||||||
|
palette:
|
||||||
|
# Palette toggle for automatic mode
|
||||||
|
- media: "(prefers-color-scheme)"
|
||||||
|
toggle:
|
||||||
|
icon: material/brightness-auto
|
||||||
|
name: Switch to light mode
|
||||||
|
# Palette toggle for light mode
|
||||||
|
- media: "(prefers-color-scheme: light)"
|
||||||
|
scheme: default
|
||||||
|
primary: teal
|
||||||
|
accent: green
|
||||||
|
toggle:
|
||||||
|
icon: material/brightness-7
|
||||||
|
name: Switch to dark mode
|
||||||
|
# Palette toggle for dark mode
|
||||||
|
- media: "(prefers-color-scheme: dark)"
|
||||||
|
scheme: slate
|
||||||
|
primary: black
|
||||||
|
toggle:
|
||||||
|
icon: material/brightness-4
|
||||||
|
name: Switch to system preference
|
||||||
|
plugins:
|
||||||
|
- git-revision-date-localized:
|
||||||
|
enable_creation_date: true
|
||||||
|
- git-committers:
|
||||||
|
repository: google/glog
|
||||||
|
branch: master
|
||||||
|
- privacy
|
||||||
|
- search
|
||||||
|
- tags
|
||||||
|
extra:
|
||||||
|
version:
|
||||||
|
alias: true
|
||||||
|
default:
|
||||||
|
- dev
|
||||||
|
- stable
|
||||||
|
provider: mike
|
||||||
|
consent:
|
||||||
|
actions:
|
||||||
|
- manage
|
||||||
|
- accept
|
||||||
|
- reject
|
||||||
|
title: Cookie consent
|
||||||
|
description: >-
|
||||||
|
We use cookies to recognize your repeated visits and preferences, as well
|
||||||
|
as to measure the effectiveness of our documentation and whether users
|
||||||
|
find what they're searching for. With your consent, you're helping us to
|
||||||
|
make our documentation better.
|
||||||
|
nav:
|
||||||
|
- Getting Started:
|
||||||
|
- Overview: index.md
|
||||||
|
- Usage in CMake Projects: usage.md
|
||||||
|
- Building from Source: build.md
|
||||||
|
- Installation using Package Managers: packages.md
|
||||||
|
- User Guide:
|
||||||
|
- Logging: logging.md
|
||||||
|
- Adjusting Output: flags.md
|
||||||
|
- Custom Sinks: sinks.md
|
||||||
|
- Failure Handler: failures.md
|
||||||
|
- Log Removal: log_cleaner.md
|
||||||
|
- Stripping Log Messages: log_stripping.md
|
||||||
|
- System-specific Considerations:
|
||||||
|
- Usage on Windows: windows.md
|
||||||
|
- Linux Unwinder: unwinder.md
|
||||||
|
- Contributing: contribute.md
|
||||||
|
- License: license.md
|
||||||
@ -1,73 +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"
|
|
||||||
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
|
|
||||||
|
|
||||||
package="google-glog_$VERSION"
|
|
||||||
|
|
||||||
# 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}${package}.orig.tar.gz"
|
|
||||||
tar zfx "${LIB}${package}.orig.tar.gz"
|
|
||||||
mv "${archive}" "${LIB}${package}"
|
|
||||||
cd "${LIB}${package}"
|
|
||||||
# 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,7 +0,0 @@
|
|||||||
The list of files here isn't complete. For a step-by-step guide on
|
|
||||||
how to set this package up correctly, check out
|
|
||||||
http://www.debian.org/doc/maint-guide/
|
|
||||||
|
|
||||||
Most of the files that are in this directory are boilerplate.
|
|
||||||
However, you may need to change the list of binary-arch dependencies
|
|
||||||
in 'rules'.
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
google-glog (0.4.0-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Tue, 22 Jan 2019 21:00:26 +0900
|
|
||||||
|
|
||||||
google-glog (0.3.5-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Tue, 09 May 2017 16:22:12 +0900
|
|
||||||
|
|
||||||
google-glog (0.3.4-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Tue, 10 Mar 2015 12:02:20 +0900
|
|
||||||
|
|
||||||
google-glog (0.3.3-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Fri, 01 Feb 2012 14:54:14 +0900
|
|
||||||
|
|
||||||
google-glog (0.3.2-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Thu, 12 Jan 2012 17:36:14 +0900
|
|
||||||
|
|
||||||
google-glog (0.3.1-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Tue, 15 Jun 2010 13:50:47 +0900
|
|
||||||
|
|
||||||
google-glog (0.3-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Thu, 30 Jul 2009 21:31:35 +0900
|
|
||||||
|
|
||||||
google-glog (0.2.1-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Fri, 10 Apr 2009 15:24:17 +0900
|
|
||||||
|
|
||||||
google-glog (0.2-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Fri, 23 Jan 2009 03:14:29 +0900
|
|
||||||
|
|
||||||
google-glog (0.1.2-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Tue, 18 Nov 2008 20:37:00 +0900
|
|
||||||
|
|
||||||
google-glog (0.1.1-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* New upstream release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Wed, 15 Oct 2008 20:38:19 +0900
|
|
||||||
|
|
||||||
google-glog (0.1-1) unstable; urgency=low
|
|
||||||
|
|
||||||
* Initial release.
|
|
||||||
|
|
||||||
-- Google Inc. <opensource@google.com> Sat, 10 May 2008 12:31:10 +0900
|
|
||||||
@ -1 +0,0 @@
|
|||||||
4
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
Source: google-glog
|
|
||||||
Priority: optional
|
|
||||||
Maintainer: Google Inc. <opensource@google.com>
|
|
||||||
Build-Depends: debhelper (>= 4.0.0), binutils
|
|
||||||
Standards-Version: 3.6.1
|
|
||||||
|
|
||||||
Package: libgoogle-glog-dev
|
|
||||||
Section: libdevel
|
|
||||||
Architecture: any
|
|
||||||
Depends: libgoogle-glog0 (= ${Source-Version})
|
|
||||||
Description: a library that implements application-level logging.
|
|
||||||
This library provides logging APIs based on C++-style streams and
|
|
||||||
various helper macros. The devel package contains static and debug
|
|
||||||
libraries and header files for developing applications that use the
|
|
||||||
google-glog package.
|
|
||||||
|
|
||||||
Package: libgoogle-glog0
|
|
||||||
Section: libs
|
|
||||||
Architecture: any
|
|
||||||
Depends: ${shlibs:Depends}
|
|
||||||
Description: a library that implements application-level logging.
|
|
||||||
This library provides logging APIs based on C++-style streams and
|
|
||||||
various helper macros.
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
AUTHORS
|
|
||||||
COPYING
|
|
||||||
ChangeLog
|
|
||||||
INSTALL
|
|
||||||
README.md
|
|
||||||
doc/designstyle.css
|
|
||||||
doc/glog.html
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
usr/lib
|
|
||||||
usr/lib/pkgconfig
|
|
||||||
usr/include
|
|
||||||
usr/include/glog
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
usr/include/glog/*
|
|
||||||
usr/lib/lib*.so
|
|
||||||
usr/lib/lib*.a
|
|
||||||
usr/lib/*.la
|
|
||||||
usr/lib/pkgconfig/*
|
|
||||||
debian/tmp/usr/include/glog/*
|
|
||||||
debian/tmp/usr/lib/lib*.so
|
|
||||||
debian/tmp/usr/lib/lib*.a
|
|
||||||
debian/tmp/usr/lib/*.la
|
|
||||||
debian/tmp/usr/lib/pkgconfig/*
|
|
||||||
@ -1 +0,0 @@
|
|||||||
usr/lib
|
|
||||||
@ -1,2 +0,0 @@
|
|||||||
usr/lib/lib*.so.*
|
|
||||||
debian/tmp/usr/lib/lib*.so.*
|
|
||||||
@ -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"/v"$VERSION".tar.gz
|
|
||||||
|
|
||||||
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,72 +0,0 @@
|
|||||||
%define RELEASE 1
|
|
||||||
%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
|
|
||||||
%define prefix /usr
|
|
||||||
|
|
||||||
Name: %NAME
|
|
||||||
Summary: A C++ application logging library
|
|
||||||
Version: %VERSION
|
|
||||||
Release: %rel
|
|
||||||
Group: Development/Libraries
|
|
||||||
URL: http://github.com/google/glog
|
|
||||||
License: BSD
|
|
||||||
Vendor: Google
|
|
||||||
Packager: Google Inc. <opensource@google.com>
|
|
||||||
Source: https://github.com/google/glog/archive/v%{VERSION}.tar.gz
|
|
||||||
Distribution: Redhat 7 and above.
|
|
||||||
Buildroot: %{_tmppath}/%{name}-root
|
|
||||||
Prefix: %prefix
|
|
||||||
|
|
||||||
%description
|
|
||||||
The %name package contains a library that implements application-level
|
|
||||||
logging. This library provides logging APIs based on C++-style
|
|
||||||
streams and various helper macros.
|
|
||||||
|
|
||||||
%package devel
|
|
||||||
Summary: A C++ application logging library
|
|
||||||
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
|
|
||||||
* Wed Mar 26 2008 <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 README.md
|
|
||||||
%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
|
|
||||||
%{prefix}/share/doc/%{NAME}-%{VERSION}/*
|
|
||||||
|
|
||||||
%{prefix}/lib/libglog.so.0
|
|
||||||
%{prefix}/lib/libglog.so.0.0.0
|
|
||||||
|
|
||||||
%files devel
|
|
||||||
%defattr(-,root,root)
|
|
||||||
|
|
||||||
%{prefix}/include/glog
|
|
||||||
%{prefix}/lib/libglog.a
|
|
||||||
%{prefix}/lib/libglog.la
|
|
||||||
%{prefix}/lib/libglog.so
|
|
||||||
%{prefix}/lib/pkgconfig/libglog.pc
|
|
||||||
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) 2008, Google Inc.
|
// Copyright (c) 2008, Google Inc.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
@ -14,7 +14,7 @@
|
|||||||
// * Neither the name of Google Inc. nor the names of its
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
// contributors may be used to endorse or promote products derived from
|
// contributors may be used to endorse or promote products derived from
|
||||||
// this software without specific prior written permission.
|
// this software without specific prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
@ -48,59 +48,66 @@
|
|||||||
#ifndef BASE_COMMANDLINEFLAGS_H__
|
#ifndef BASE_COMMANDLINEFLAGS_H__
|
||||||
#define BASE_COMMANDLINEFLAGS_H__
|
#define BASE_COMMANDLINEFLAGS_H__
|
||||||
|
|
||||||
#include "config.h"
|
#include <cstdlib> // for getenv
|
||||||
|
#include <cstring> // for memchr
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string.h> // for memchr
|
|
||||||
#include <stdlib.h> // for getenv
|
|
||||||
|
|
||||||
#ifdef HAVE_LIB_GFLAGS
|
#include "config.h"
|
||||||
|
|
||||||
#include <gflags/gflags.h>
|
#ifdef GLOG_USE_GFLAGS
|
||||||
|
|
||||||
|
# include <gflags/gflags.h>
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include "glog/logging.h"
|
# include "glog/logging.h"
|
||||||
|
|
||||||
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
# define DECLARE_VARIABLE(type, shorttype, name, tn) \
|
||||||
namespace fL##shorttype { \
|
namespace fL##shorttype { \
|
||||||
extern GOOGLE_GLOG_DLL_DECL type FLAGS_##name; \
|
extern GLOG_EXPORT type FLAGS_##name; \
|
||||||
} \
|
} \
|
||||||
using fL##shorttype::FLAGS_##name
|
using fL##shorttype::FLAGS_##name
|
||||||
#define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
|
# define DEFINE_VARIABLE(type, shorttype, name, value, meaning, tn) \
|
||||||
namespace fL##shorttype { \
|
namespace fL##shorttype { \
|
||||||
GOOGLE_GLOG_DLL_DECL type FLAGS_##name(value); \
|
GLOG_EXPORT type FLAGS_##name(value); \
|
||||||
char FLAGS_no##name; \
|
char FLAGS_no##name; \
|
||||||
} \
|
} \
|
||||||
using fL##shorttype::FLAGS_##name
|
using fL##shorttype::FLAGS_##name
|
||||||
|
|
||||||
// bool specialization
|
// bool specialization
|
||||||
#define DECLARE_bool(name) \
|
# define DECLARE_bool(name) DECLARE_VARIABLE(bool, B, name, bool)
|
||||||
DECLARE_VARIABLE(bool, B, name, bool)
|
# define DEFINE_bool(name, value, meaning) \
|
||||||
#define DEFINE_bool(name, value, meaning) \
|
DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
|
||||||
DEFINE_VARIABLE(bool, B, name, value, meaning, bool)
|
|
||||||
|
|
||||||
// int32 specialization
|
// int32 specialization
|
||||||
#define DECLARE_int32(name) \
|
# define DECLARE_int32(name) DECLARE_VARIABLE(google::int32, I, name, int32)
|
||||||
DECLARE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, int32)
|
# define DEFINE_int32(name, value, meaning) \
|
||||||
#define DEFINE_int32(name, value, meaning) \
|
DEFINE_VARIABLE(google::int32, I, name, value, meaning, int32)
|
||||||
DEFINE_VARIABLE(GOOGLE_NAMESPACE::int32, I, name, value, meaning, int32)
|
|
||||||
|
// uint32 specialization
|
||||||
|
# ifndef DECLARE_uint32
|
||||||
|
# define DECLARE_uint32(name) \
|
||||||
|
DECLARE_VARIABLE(google::uint32, U, name, uint32)
|
||||||
|
# endif // DECLARE_uint64
|
||||||
|
# define DEFINE_uint32(name, value, meaning) \
|
||||||
|
DEFINE_VARIABLE(google::uint32, U, name, value, meaning, uint32)
|
||||||
|
|
||||||
// Special case for string, because we have to specify the namespace
|
// Special case for string, because we have to specify the namespace
|
||||||
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
|
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
|
||||||
#define DECLARE_string(name) \
|
# define DECLARE_string(name) \
|
||||||
namespace fLS { \
|
namespace fLS { \
|
||||||
extern GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name; \
|
extern GLOG_EXPORT std::string& FLAGS_##name; \
|
||||||
} \
|
} \
|
||||||
using fLS::FLAGS_##name
|
using fLS::FLAGS_##name
|
||||||
#define DEFINE_string(name, value, meaning) \
|
# define DEFINE_string(name, value, meaning) \
|
||||||
namespace fLS { \
|
namespace fLS { \
|
||||||
std::string FLAGS_##name##_buf(value); \
|
std::string FLAGS_##name##_buf(value); \
|
||||||
GOOGLE_GLOG_DLL_DECL std::string& FLAGS_##name = FLAGS_##name##_buf; \
|
GLOG_EXPORT std::string& FLAGS_##name = FLAGS_##name##_buf; \
|
||||||
char FLAGS_no##name; \
|
char FLAGS_no##name; \
|
||||||
} \
|
} \
|
||||||
using fLS::FLAGS_##name
|
using fLS::FLAGS_##name
|
||||||
|
|
||||||
#endif // HAVE_LIB_GFLAGS
|
#endif // GLOG_USE_GFLAGS
|
||||||
|
|
||||||
// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
|
// Define GLOG_DEFINE_* using DEFINE_* . By using these macros, we
|
||||||
// have GLOG_* environ variables even if we have gflags installed.
|
// have GLOG_* environ variables even if we have gflags installed.
|
||||||
@ -115,19 +122,28 @@
|
|||||||
#define GLOG_DEFINE_int32(name, value, meaning) \
|
#define GLOG_DEFINE_int32(name, value, meaning) \
|
||||||
DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
|
DEFINE_int32(name, EnvToInt("GLOG_" #name, value), meaning)
|
||||||
|
|
||||||
|
#define GLOG_DEFINE_uint32(name, value, meaning) \
|
||||||
|
DEFINE_uint32(name, EnvToUInt("GLOG_" #name, value), meaning)
|
||||||
|
|
||||||
#define GLOG_DEFINE_string(name, value, meaning) \
|
#define GLOG_DEFINE_string(name, value, meaning) \
|
||||||
DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
|
DEFINE_string(name, EnvToString("GLOG_" #name, value), meaning)
|
||||||
|
|
||||||
// These macros (could be functions, but I don't want to bother with a .cc
|
// These macros (could be functions, but I don't want to bother with a .cc
|
||||||
// file), make it easier to initialize flags from the environment.
|
// file), make it easier to initialize flags from the environment.
|
||||||
|
|
||||||
#define EnvToString(envname, dflt) \
|
#define EnvToString(envname, dflt) (!getenv(envname) ? (dflt) : getenv(envname))
|
||||||
(!getenv(envname) ? (dflt) : getenv(envname))
|
|
||||||
|
|
||||||
#define EnvToBool(envname, dflt) \
|
#define EnvToBool(envname, dflt) \
|
||||||
(!getenv(envname) ? (dflt) : memchr("tTyY1\0", getenv(envname)[0], 6) != NULL)
|
(!getenv(envname) ? (dflt) \
|
||||||
|
: memchr("tTyY1\0", getenv(envname)[0], 6) != nullptr)
|
||||||
|
|
||||||
#define EnvToInt(envname, dflt) \
|
#define EnvToInt(envname, dflt) \
|
||||||
(!getenv(envname) ? (dflt) : strtol(getenv(envname), NULL, 10))
|
(!getenv(envname) ? (dflt) \
|
||||||
|
: static_cast<int>(strtol(getenv(envname), nullptr, 10)))
|
||||||
|
|
||||||
|
#define EnvToUInt(envname, dflt) \
|
||||||
|
(!getenv(envname) \
|
||||||
|
? (dflt) \
|
||||||
|
: static_cast<unsigned>(strtoul(getenv(envname), nullptr, 10)))
|
||||||
|
|
||||||
#endif // BASE_COMMANDLINEFLAGS_H__
|
#endif // BASE_COMMANDLINEFLAGS_H__
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
// Copyright (c) 2008, Google Inc.
|
// Copyright (c) 2008, Google Inc.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
@ -14,7 +14,7 @@
|
|||||||
// * Neither the name of Google Inc. nor the names of its
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
// contributors may be used to endorse or promote products derived from
|
// contributors may be used to endorse or promote products derived from
|
||||||
// this software without specific prior written permission.
|
// this software without specific prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
@ -35,17 +35,15 @@
|
|||||||
|
|
||||||
class GoogleInitializer {
|
class GoogleInitializer {
|
||||||
public:
|
public:
|
||||||
typedef void (*void_function)(void);
|
using void_function = void (*)();
|
||||||
GoogleInitializer(const char*, void_function f) {
|
GoogleInitializer(const char*, void_function f) { f(); }
|
||||||
f();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define REGISTER_MODULE_INITIALIZER(name, body) \
|
#define REGISTER_MODULE_INITIALIZER(name, body) \
|
||||||
namespace { \
|
namespace { \
|
||||||
static void google_init_module_##name () { body; } \
|
static void google_init_module_##name() { body; } \
|
||||||
GoogleInitializer google_initializer_module_##name(#name, \
|
GoogleInitializer google_initializer_module_##name( \
|
||||||
google_init_module_##name); \
|
#name, google_init_module_##name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _GOOGLEINIT_H */
|
#endif /* _GOOGLEINIT_H */
|
||||||
|
|||||||
333
src/base/mutex.h
333
src/base/mutex.h
@ -1,333 +0,0 @@
|
|||||||
// 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.
|
|
||||||
//
|
|
||||||
// ---
|
|
||||||
// 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 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:
|
|
||||||
// 1) TryLock() under Windows is a bit annoying (it requires a
|
|
||||||
// #define to be defined very early).
|
|
||||||
// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
|
|
||||||
// mode.
|
|
||||||
// If you need TryLock(), and either these two caveats are not a
|
|
||||||
// problem for you, or you're willing to work around them, then
|
|
||||||
// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
|
|
||||||
// in the code below.
|
|
||||||
//
|
|
||||||
// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
|
|
||||||
// http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
|
|
||||||
// Because of that, we might as well use windows locks for
|
|
||||||
// cygwin. They seem to be more reliable than the cygwin pthreads layer.
|
|
||||||
//
|
|
||||||
// TRICKY IMPLEMENTATION NOTE:
|
|
||||||
// This class is designed to be safe to use during
|
|
||||||
// dynamic-initialization -- that is, by global constructors that are
|
|
||||||
// run before main() starts. The issue in this case is that
|
|
||||||
// dynamic-initialization happens in an unpredictable order, and it
|
|
||||||
// could be that someone else's dynamic initializer could call a
|
|
||||||
// function that tries to acquire this mutex -- but that all happens
|
|
||||||
// before this mutex's constructor has run. (This can happen even if
|
|
||||||
// the mutex and the function that uses the mutex are in the same .cc
|
|
||||||
// file.) Basically, because Mutex does non-trivial work in its
|
|
||||||
// constructor, it's not, in the naive implementation, safe to use
|
|
||||||
// before dynamic initialization has run on it.
|
|
||||||
//
|
|
||||||
// The solution used here is to pair the actual mutex primitive with a
|
|
||||||
// bool that is set to true when the mutex is dynamically initialized.
|
|
||||||
// (Before that it's false.) Then we modify all mutex routines to
|
|
||||||
// look at the bool, and not try to lock/unlock until the bool makes
|
|
||||||
// it to true (which happens after the Mutex constructor has run.)
|
|
||||||
//
|
|
||||||
// This works because before main() starts -- particularly, during
|
|
||||||
// dynamic initialization -- there are no threads, so a) it's ok that
|
|
||||||
// the mutex operations are a no-op, since we don't need locking then
|
|
||||||
// anyway; and b) we can be quite confident our bool won't change
|
|
||||||
// state between a call to Lock() and a call to Unlock() (that would
|
|
||||||
// require a global constructor in one translation unit to call Lock()
|
|
||||||
// and another global constructor in another translation unit to call
|
|
||||||
// Unlock() later, which is pretty perverse).
|
|
||||||
//
|
|
||||||
// That said, it's tricky, and can conceivably fail; it's safest to
|
|
||||||
// avoid trying to acquire a mutex in a global constructor, if you
|
|
||||||
// can. One way it can fail is that a really smart compiler might
|
|
||||||
// initialize the bool to true at static-initialization time (too
|
|
||||||
// early) rather than at dynamic-initialization time. To discourage
|
|
||||||
// that, we set is_safe_ to true in code (not the constructor
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
#ifndef GOOGLE_MUTEX_H_
|
|
||||||
#define GOOGLE_MUTEX_H_
|
|
||||||
|
|
||||||
#include "config.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__)
|
|
||||||
# ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
# define WIN32_LEAN_AND_MEAN // We only need minimal includes
|
|
||||||
# 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
|
|
||||||
// lines, and change TryLock() to assert(0) or something.
|
|
||||||
# ifndef _WIN32_WINNT
|
|
||||||
# define _WIN32_WINNT 0x0400
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
// To avoid macro definition of ERROR.
|
|
||||||
# ifndef NOGDI
|
|
||||||
# define NOGDI
|
|
||||||
# endif
|
|
||||||
// To avoid macro definition of min/max.
|
|
||||||
# ifndef NOMINMAX
|
|
||||||
# define NOMINMAX
|
|
||||||
# endif
|
|
||||||
# include <windows.h>
|
|
||||||
typedef CRITICAL_SECTION MutexType;
|
|
||||||
#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
|
|
||||||
// Needed for pthread_rwlock_*. If it causes problems, you could take it
|
|
||||||
// out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
|
|
||||||
// *does* cause problems for FreeBSD, or MacOSX, but isn't needed
|
|
||||||
// for locking there.)
|
|
||||||
# ifdef __linux__
|
|
||||||
# ifndef _XOPEN_SOURCE // Some other header might have already set it for us.
|
|
||||||
# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# include <pthread.h>
|
|
||||||
typedef pthread_rwlock_t MutexType;
|
|
||||||
#elif defined(HAVE_PTHREAD)
|
|
||||||
# include <pthread.h>
|
|
||||||
typedef pthread_mutex_t MutexType;
|
|
||||||
#else
|
|
||||||
# error Need to implement mutex.h for your architecture, or #define NO_THREADS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// We need to include these header files after defining _XOPEN_SOURCE
|
|
||||||
// as they may define the _XOPEN_SOURCE macro.
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h> // for abort()
|
|
||||||
|
|
||||||
#define MUTEX_NAMESPACE glog_internal_namespace_
|
|
||||||
|
|
||||||
namespace MUTEX_NAMESPACE {
|
|
||||||
|
|
||||||
class Mutex {
|
|
||||||
public:
|
|
||||||
// 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();
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
inline ~Mutex();
|
|
||||||
|
|
||||||
inline void Lock(); // Block if needed until free then acquire exclusively
|
|
||||||
inline void Unlock(); // Release a lock acquired via Lock()
|
|
||||||
#ifdef GMUTEX_TRYLOCK
|
|
||||||
inline bool TryLock(); // If free, Lock() and return true, else return false
|
|
||||||
#endif
|
|
||||||
// Note that on systems that don't support read-write locks, these may
|
|
||||||
// be implemented as synonyms to Lock() and Unlock(). So you can use
|
|
||||||
// these for efficiency, but don't use them anyplace where being able
|
|
||||||
// to do shared reads is necessary to avoid deadlock.
|
|
||||||
inline void ReaderLock(); // Block until free or shared then acquire a share
|
|
||||||
inline void ReaderUnlock(); // Release a read share of this Mutex
|
|
||||||
inline void WriterLock() { Lock(); } // Acquire an exclusive lock
|
|
||||||
inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
|
|
||||||
|
|
||||||
// TODO(hamaji): Do nothing, implement correctly.
|
|
||||||
inline void AssertHeld() {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
MutexType mutex_;
|
|
||||||
// We want to make sure that the compiler sets is_safe_ to true only
|
|
||||||
// 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_;
|
|
||||||
|
|
||||||
inline void SetIsSafe() { is_safe_ = true; }
|
|
||||||
|
|
||||||
// Catch the error of writing Mutex when intending MutexLock.
|
|
||||||
Mutex(Mutex* /*ignored*/) {}
|
|
||||||
// Disallow "evil" constructors
|
|
||||||
Mutex(const Mutex&);
|
|
||||||
void operator=(const Mutex&);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Now the implementation of Mutex for various systems
|
|
||||||
#if defined(NO_THREADS)
|
|
||||||
|
|
||||||
// When we don't have threads, we can be either reading or writing,
|
|
||||||
// but not both. We can have lots of readers at once (in no-threads
|
|
||||||
// mode, that's most likely to happen in recursive function calls),
|
|
||||||
// but only one writer. We represent this by having mutex_ be -1 when
|
|
||||||
// writing and a number > 0 when reading (and 0 when no lock is held).
|
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
|
|
||||||
Mutex::Mutex() : mutex_(0) { }
|
|
||||||
Mutex::~Mutex() { assert(mutex_ == 0); }
|
|
||||||
void Mutex::Lock() { assert(--mutex_ == -1); }
|
|
||||||
void Mutex::Unlock() { assert(mutex_++ == -1); }
|
|
||||||
#ifdef GMUTEX_TRYLOCK
|
|
||||||
bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
|
|
||||||
#endif
|
|
||||||
void Mutex::ReaderLock() { assert(++mutex_ > 0); }
|
|
||||||
void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
|
|
||||||
|
|
||||||
#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
|
|
||||||
|
|
||||||
Mutex::Mutex() { InitializeCriticalSection(&mutex_); SetIsSafe(); }
|
|
||||||
Mutex::~Mutex() { DeleteCriticalSection(&mutex_); }
|
|
||||||
void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); }
|
|
||||||
void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); }
|
|
||||||
#ifdef GMUTEX_TRYLOCK
|
|
||||||
bool Mutex::TryLock() { return is_safe_ ?
|
|
||||||
TryEnterCriticalSection(&mutex_) != 0 : true; }
|
|
||||||
#endif
|
|
||||||
void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
|
|
||||||
void Mutex::ReaderUnlock() { Unlock(); }
|
|
||||||
|
|
||||||
#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
|
|
||||||
|
|
||||||
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
|
|
||||||
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
Mutex::Mutex() {
|
|
||||||
SetIsSafe();
|
|
||||||
if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
|
|
||||||
}
|
|
||||||
Mutex::~Mutex() { 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; }
|
|
||||||
#endif
|
|
||||||
void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); }
|
|
||||||
void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
|
|
||||||
#undef SAFE_PTHREAD
|
|
||||||
|
|
||||||
#elif defined(HAVE_PTHREAD)
|
|
||||||
|
|
||||||
#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
|
|
||||||
if (is_safe_ && fncall(&mutex_) != 0) abort(); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
Mutex::Mutex() {
|
|
||||||
SetIsSafe();
|
|
||||||
if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
|
|
||||||
}
|
|
||||||
Mutex::~Mutex() { SAFE_PTHREAD(pthread_mutex_destroy); }
|
|
||||||
void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); }
|
|
||||||
void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); }
|
|
||||||
#ifdef GMUTEX_TRYLOCK
|
|
||||||
bool Mutex::TryLock() { return is_safe_ ?
|
|
||||||
pthread_mutex_trylock(&mutex_) == 0 : true; }
|
|
||||||
#endif
|
|
||||||
void Mutex::ReaderLock() { Lock(); }
|
|
||||||
void Mutex::ReaderUnlock() { Unlock(); }
|
|
||||||
#undef SAFE_PTHREAD
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
|
||||||
// Some helper classes
|
|
||||||
|
|
||||||
// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
|
|
||||||
class MutexLock {
|
|
||||||
public:
|
|
||||||
explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
|
|
||||||
~MutexLock() { mu_->Unlock(); }
|
|
||||||
private:
|
|
||||||
Mutex * const mu_;
|
|
||||||
// Disallow "evil" constructors
|
|
||||||
MutexLock(const MutexLock&);
|
|
||||||
void operator=(const MutexLock&);
|
|
||||||
};
|
|
||||||
|
|
||||||
// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
|
|
||||||
class ReaderMutexLock {
|
|
||||||
public:
|
|
||||||
explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
|
|
||||||
~ReaderMutexLock() { mu_->ReaderUnlock(); }
|
|
||||||
private:
|
|
||||||
Mutex * const mu_;
|
|
||||||
// Disallow "evil" constructors
|
|
||||||
ReaderMutexLock(const ReaderMutexLock&);
|
|
||||||
void operator=(const ReaderMutexLock&);
|
|
||||||
};
|
|
||||||
|
|
||||||
class WriterMutexLock {
|
|
||||||
public:
|
|
||||||
explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
|
|
||||||
~WriterMutexLock() { mu_->WriterUnlock(); }
|
|
||||||
private:
|
|
||||||
Mutex * const mu_;
|
|
||||||
// Disallow "evil" constructors
|
|
||||||
WriterMutexLock(const WriterMutexLock&);
|
|
||||||
void operator=(const WriterMutexLock&);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
|
|
||||||
#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
|
|
||||||
#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
|
|
||||||
#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
|
|
||||||
|
|
||||||
} // namespace MUTEX_NAMESPACE
|
|
||||||
|
|
||||||
using namespace MUTEX_NAMESPACE;
|
|
||||||
|
|
||||||
#undef MUTEX_NAMESPACE
|
|
||||||
|
|
||||||
#endif /* #define GOOGLE_MUTEX_H__ */
|
|
||||||
96
src/cleanup_immediately_unittest.cc
Normal file
96
src/cleanup_immediately_unittest.cc
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
// Copyright (c) 2024, 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.
|
||||||
|
|
||||||
|
#include "base/commandlineflags.h"
|
||||||
|
#include "glog/logging.h"
|
||||||
|
#include "glog/raw_logging.h"
|
||||||
|
#include "googletest.h"
|
||||||
|
|
||||||
|
#ifdef GLOG_USE_GFLAGS
|
||||||
|
# include <gflags/gflags.h>
|
||||||
|
using namespace GFLAGS_NAMESPACE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LIB_GMOCK
|
||||||
|
# include <gmock/gmock.h>
|
||||||
|
|
||||||
|
# include "mock-log.h"
|
||||||
|
// Introduce several symbols from gmock.
|
||||||
|
using google::glog_testing::ScopedMockLog;
|
||||||
|
using testing::_;
|
||||||
|
using testing::AllOf;
|
||||||
|
using testing::AnyNumber;
|
||||||
|
using testing::HasSubstr;
|
||||||
|
using testing::InitGoogleMock;
|
||||||
|
using testing::StrictMock;
|
||||||
|
using testing::StrNe;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace google;
|
||||||
|
|
||||||
|
TEST(CleanImmediately, logging) {
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
google::SetLogFilenameExtension(".foobar");
|
||||||
|
google::EnableLogCleaner(0h);
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < 1000; ++i) {
|
||||||
|
LOG(INFO) << "cleanup test";
|
||||||
|
}
|
||||||
|
|
||||||
|
google::DisableLogCleaner();
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
FLAGS_colorlogtostderr = false;
|
||||||
|
FLAGS_timestamp_in_logfile_name = true;
|
||||||
|
#ifdef GLOG_USE_GFLAGS
|
||||||
|
ParseCommandLineFlags(&argc, &argv, true);
|
||||||
|
#endif
|
||||||
|
// Make sure stderr is not buffered as stderr seems to be buffered
|
||||||
|
// on recent windows.
|
||||||
|
setbuf(stderr, nullptr);
|
||||||
|
|
||||||
|
// Test some basics before InitGoogleLogging:
|
||||||
|
CaptureTestStderr();
|
||||||
|
const string early_stderr = GetCapturedTestStderr();
|
||||||
|
|
||||||
|
EXPECT_FALSE(IsGoogleLoggingInitialized());
|
||||||
|
|
||||||
|
InitGoogleLogging(argv[0]);
|
||||||
|
|
||||||
|
EXPECT_TRUE(IsGoogleLoggingInitialized());
|
||||||
|
|
||||||
|
InitGoogleTest(&argc, argv);
|
||||||
|
#ifdef HAVE_LIB_GMOCK
|
||||||
|
InitGoogleMock(&argc, argv);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// so that death tests run before we use threads
|
||||||
|
CHECK_EQ(RUN_ALL_TESTS(), 0);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user