Compare commits
1564 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7709a275d6 | ||
|
|
ca7ea4a541 | ||
|
|
e6dc4d404f | ||
|
|
33cdb8a01f | ||
|
|
dfcdb6ba09 | ||
|
|
ae244983b0 | ||
|
|
8d2bdd4a18 | ||
|
|
246db973b4 | ||
|
|
d49c38bf18 | ||
|
|
c1aa88c720 | ||
|
|
937618b177 | ||
|
|
4a0936a4b5 | ||
|
|
891286c447 | ||
|
|
04db5d1075 | ||
|
|
997037a232 | ||
|
|
f0dfb0b080 | ||
|
|
f9c07b4806 | ||
|
|
9f9a21bb73 | ||
|
|
386528a892 | ||
|
|
4efe28cf52 | ||
|
|
2528f71bbf | ||
|
|
5610eaa839 | ||
|
|
881cc46aa9 | ||
|
|
81f342e9bf | ||
|
|
fe9d670800 | ||
|
|
ffb54802d4 | ||
|
|
518da73ad2 | ||
|
|
3e78b74474 | ||
|
|
34a7ebf53f | ||
|
|
45be739fea | ||
|
|
68ae8afaf9 | ||
|
|
2bdcd9d07f | ||
|
|
24f5457203 | ||
|
|
f941bc4334 | ||
|
|
ab5bce69ee | ||
|
|
050a8c3923 | ||
|
|
8817bf53e3 | ||
|
|
5e21037230 | ||
|
|
cabaf0fd1c | ||
|
|
bd92a09a48 | ||
|
|
61f90c665a | ||
|
|
32dbd40e64 | ||
|
|
a69e04a817 | ||
|
|
159de683e8 | ||
|
|
a9dbaf5e0a | ||
|
|
3c3d8c2400 | ||
|
|
b4080f8e2d | ||
|
|
5de94d6610 | ||
|
|
829045c262 | ||
|
|
b02d70fba0 | ||
|
|
64ed6e99f0 | ||
|
|
33d3bb2870 | ||
|
|
4df2193a4c | ||
|
|
343be08467 | ||
|
|
788b83bff3 | ||
|
|
c201ac90ba | ||
|
|
af3c66ad08 | ||
|
|
9bffc4bb82 | ||
|
|
132db6225e | ||
|
|
257086cbfc | ||
|
|
7755f1ec52 | ||
|
|
c5f1ac808b | ||
|
|
1a8660909d | ||
|
|
e6826a4c7c | ||
|
|
801bb8a075 | ||
|
|
b2c965e22d | ||
|
|
be3cbc642b | ||
|
|
24331d3c90 | ||
|
|
8a16e6c99f | ||
|
|
f36e8fbeca | ||
|
|
718ef09adf | ||
|
|
6443849ea9 | ||
|
|
cbb7e473ba | ||
|
|
118957362f | ||
|
|
ed7f73769f | ||
|
|
ae15dcb318 | ||
|
|
c4af22481c | ||
|
|
ae17f76bb4 | ||
|
|
7e62d17fda | ||
|
|
f9185e8bc8 | ||
|
|
1361f9b57d | ||
|
|
b86eae026b | ||
|
|
79d938a4f4 | ||
|
|
23068a70a2 | ||
|
|
0aa5e0bb88 | ||
|
|
5040275969 | ||
|
|
1daccf40ee | ||
|
|
4fd302286b | ||
|
|
18f9f19e61 | ||
|
|
1de6d4461a | ||
|
|
4198f47ab6 | ||
|
|
d9049ba342 | ||
|
|
f75ac3e4c2 | ||
|
|
06698deaca | ||
|
|
445eb29bd3 | ||
|
|
cc034f6841 | ||
|
|
3c368651f1 | ||
|
|
321730e384 | ||
|
|
c2fd88670f | ||
|
|
7b03103a1f | ||
|
|
ac3e19c91a | ||
|
|
4c7d2224e3 | ||
|
|
3ab800d99e | ||
|
|
332cef0f84 | ||
|
|
9de6d7627b | ||
|
|
98b42e88c1 | ||
|
|
e642e9561a | ||
|
|
77f500cb64 | ||
|
|
d04a8fc677 | ||
|
|
6028ae7b61 | ||
|
|
347c2cbd8b | ||
|
|
919ffb314b | ||
|
|
c033d69d54 | ||
|
|
356d289972 | ||
|
|
eeabbce377 | ||
|
|
0b992fdd46 | ||
|
|
a7e56d2af9 | ||
|
|
b10619e4d8 | ||
|
|
74518f299c | ||
|
|
407b527a55 | ||
|
|
b21cc835b2 | ||
|
|
4de8c3a38e | ||
|
|
72d8b8f78c | ||
|
|
45f4f601bf | ||
|
|
731283aa0b | ||
|
|
89ce328ba5 | ||
|
|
28e5270d87 | ||
|
|
4a237de72a | ||
|
|
e91aac1dd9 | ||
|
|
7cab44a17d | ||
|
|
cf57624688 | ||
|
|
c7448f290d | ||
|
|
55f9937238 | ||
|
|
ac1ef4d1ba | ||
|
|
ee1baafb59 | ||
|
|
9522e385cd | ||
|
|
a9b047b168 | ||
|
|
8c6e6143c2 | ||
|
|
0704876dfd | ||
|
|
54b75a3219 | ||
|
|
11d59d1b00 | ||
|
|
4e042db404 | ||
|
|
0f6285b2e9 | ||
|
|
a3d2107bfd | ||
|
|
a66c91bc5a | ||
|
|
4602602a5f | ||
|
|
0511d5903a | ||
|
|
7597ce3b37 | ||
|
|
7509d929d8 | ||
|
|
c7e03600aa | ||
|
|
4871f5ed8e | ||
|
|
e5a6f1e2d9 | ||
|
|
a29491658b | ||
|
|
26976b715d | ||
|
|
8d564d6ed1 | ||
|
|
18fbac26dc | ||
|
|
9f82933149 | ||
|
|
9b7aa959b0 | ||
|
|
1c46c26e6b | ||
|
|
506c6aaa9e | ||
|
|
dd61d475cb | ||
|
|
6e5eed7957 | ||
|
|
7859c0a191 | ||
|
|
ef46d21582 | ||
|
|
5071c1e0cf | ||
|
|
ecd52a9e1a | ||
|
|
0a6a47a099 | ||
|
|
9880fe225e | ||
|
|
5d44552a60 | ||
|
|
ffa32f8c98 | ||
|
|
b7086a993d | ||
|
|
d2d172f6ec | ||
|
|
34f6ea4db2 | ||
|
|
d8c4db17f2 | ||
|
|
c340dde03d | ||
|
|
e502b87b63 | ||
|
|
d6f320fb5e | ||
|
|
e4eca079e6 | ||
|
|
68ceac3678 | ||
|
|
991d603a0c | ||
|
|
74a6f7382a | ||
|
|
9264482dc3 | ||
|
|
1a61c49fc7 | ||
|
|
c2480d7227 | ||
|
|
72b5976605 | ||
|
|
1b742aa933 | ||
|
|
9412f631fa | ||
|
|
be07df3043 | ||
|
|
8f89127900 | ||
|
|
c72059e73f | ||
|
|
2fc2b7c12b | ||
|
|
a652cb4f0a | ||
|
|
16b8980d28 | ||
|
|
841a55c266 | ||
|
|
2aa6adfd46 | ||
|
|
bac0b3d745 | ||
|
|
b08b597397 | ||
|
|
25cb81221e | ||
|
|
4f5749878f | ||
|
|
2aa3ba4d36 | ||
|
|
6a2421e2e7 | ||
|
|
e78061b077 | ||
|
|
379f97e15a | ||
|
|
2afd2c500b | ||
|
|
0c3e144547 | ||
|
|
842d1b8d93 | ||
|
|
5c2c2a8c01 | ||
|
|
61f0837114 | ||
|
|
aa95d8fe3d | ||
|
|
a52c4779c8 | ||
|
|
1ece0e6051 | ||
|
|
6a56d048c0 | ||
|
|
e34999b6a9 | ||
|
|
103b2c0f33 | ||
|
|
2fe45cb8c2 | ||
|
|
64a44d6c1b | ||
|
|
3073a175d7 | ||
|
|
3b550c3a93 | ||
|
|
1d2c0cb8c6 | ||
|
|
2f369299c5 | ||
|
|
e65b513562 | ||
|
|
6959b688be | ||
|
|
7db999d801 | ||
|
|
703ad01c8b | ||
|
|
199879aea8 | ||
|
|
eefa0f07a7 | ||
|
|
6e6fb44bdb | ||
|
|
0892d14933 | ||
|
|
400da6ec92 | ||
|
|
18539831d1 | ||
|
|
9548270306 | ||
|
|
44aec1384a | ||
|
|
42139835d5 | ||
|
|
49f0f8e28f | ||
|
|
36b75b2398 | ||
|
|
9a53824d6d | ||
|
|
a9e2672820 | ||
|
|
138cf5d4f8 | ||
|
|
4b2e358783 | ||
|
|
851b3659ee | ||
|
|
27d4e05f2b | ||
|
|
deade4438d | ||
|
|
deafc6814d | ||
|
|
1fd6e91c68 | ||
|
|
67126ab494 | ||
|
|
e3318fb0d2 | ||
|
|
e9d28ee5c1 | ||
|
|
2ffc99aecf | ||
|
|
450afff50b | ||
|
|
570b0d3c5b | ||
|
|
09daa2a865 | ||
|
|
e97837e103 | ||
|
|
84add2d864 | ||
|
|
4c224def62 | ||
|
|
2242a1d101 | ||
|
|
b957c0930d | ||
|
|
f7434711ad | ||
|
|
5f0b23edd7 | ||
|
|
2eff62ad0d | ||
|
|
686795618a | ||
|
|
5c8c5a2c45 | ||
|
|
d98b99f7b3 | ||
|
|
8d472a9c7b | ||
|
|
3747d79143 | ||
|
|
910a5557ab | ||
|
|
8163448a6c | ||
|
|
ac0e93dcad | ||
|
|
ed420c3645 | ||
|
|
b872860443 | ||
|
|
992f4c7b5d | ||
|
|
8f15478ba4 | ||
|
|
1c371e7be6 | ||
|
|
937c80f694 | ||
|
|
15bd41bd71 | ||
|
|
b9156b7955 | ||
|
|
623a484ae3 | ||
|
|
2ace698101 | ||
|
|
34e0c722e7 | ||
|
|
82ee06a6bd | ||
|
|
584ee8fffe | ||
|
|
d80d232ee5 | ||
|
|
de47736038 | ||
|
|
0da16e6034 | ||
|
|
6c9a156610 | ||
|
|
1726c27078 | ||
|
|
64b43a47b5 | ||
|
|
8005a58ed5 | ||
|
|
d1d42701f5 | ||
|
|
c57fceff17 | ||
|
|
265336463d | ||
|
|
3ba1c88672 | ||
|
|
90e6afe159 | ||
|
|
3209507b6c | ||
|
|
fa97d8497a | ||
|
|
a687273d57 | ||
|
|
28f13b806c | ||
|
|
f1342d7bb8 | ||
|
|
c3428c6d57 | ||
|
|
0efddbd9ff | ||
|
|
be0aba4bfa | ||
|
|
c3f03b6bbf | ||
|
|
e15839a2cb | ||
|
|
e0efbd7d26 | ||
|
|
8e57288819 | ||
|
|
107f512545 | ||
|
|
14dc348179 | ||
|
|
eccbd98d79 | ||
|
|
a5115aa69e | ||
|
|
327574db7c | ||
|
|
8b4a29cbd3 | ||
|
|
544feee19f | ||
|
|
bee60da089 | ||
|
|
c466b44143 | ||
|
|
27222d524c | ||
|
|
b99e2cbbdd | ||
|
|
a5bdc24a14 | ||
|
|
0b6d94f202 | ||
|
|
bf5035388b | ||
|
|
640c136bcc | ||
|
|
6ebd2eef00 | ||
|
|
c954d02125 | ||
|
|
a34414849c | ||
|
|
c1ffb1b332 | ||
|
|
d06448cdfd | ||
|
|
117ef68916 | ||
|
|
83b384ab97 | ||
|
|
5ee5ba473b | ||
|
|
4055af4afd | ||
|
|
65dad7acfd | ||
|
|
a21927e510 | ||
|
|
094c948a87 | ||
|
|
31003f13af | ||
|
|
c1f39e167c | ||
|
|
0e28436aa9 | ||
|
|
bc1c816b99 | ||
|
|
32424e5640 | ||
|
|
760f1308f3 | ||
|
|
dfe8e364be | ||
|
|
33feeb0a01 | ||
|
|
50eb21ce23 | ||
|
|
d2052b9e4c | ||
|
|
2c5ad97697 | ||
|
|
8283422717 | ||
|
|
4a293ff1e1 | ||
|
|
828307ca96 | ||
|
|
a83901d2e4 | ||
|
|
878ba534b5 | ||
|
|
f17e6637d6 | ||
|
|
66b2ad5f30 | ||
|
|
463151c830 | ||
|
|
77b6a903ac | ||
|
|
1813a7bf8b | ||
|
|
6839cba56a | ||
|
|
f73fb6424b | ||
|
|
af2ae76ca2 | ||
|
|
a870534ea0 | ||
|
|
ba61314c32 | ||
|
|
d32e478456 | ||
|
|
1b29210f16 | ||
|
|
760f23b370 | ||
|
|
a7cba5f1a3 | ||
|
|
27033f4ebb | ||
|
|
c772179149 | ||
|
|
4c7eacf4fc | ||
|
|
672037d1f2 | ||
|
|
80cedb913a | ||
|
|
734621be82 | ||
|
|
dd3944161d | ||
|
|
1aabbb13c0 | ||
|
|
5574f263b1 | ||
|
|
2117c66c9a | ||
|
|
1fbfc498bf | ||
|
|
a02693e4dd | ||
|
|
24118e8e67 | ||
|
|
19ad64cc96 | ||
|
|
e81affce51 | ||
|
|
dec0bff972 | ||
|
|
5daf4aa777 | ||
|
|
2f24a53a01 | ||
|
|
28af96229b | ||
|
|
6d776632a9 | ||
|
|
1853500e10 | ||
|
|
8e01fcb7f0 | ||
|
|
3cddb0df2e | ||
|
|
37c4a4bbcb | ||
|
|
af8f0e1155 | ||
|
|
5df00a481d | ||
|
|
d299c55ea4 | ||
|
|
d9d83a6807 | ||
|
|
3fec94bb94 | ||
|
|
09926d12bb | ||
|
|
19bcdae6ac | ||
|
|
36025384f4 | ||
|
|
4bdbb89e6f | ||
|
|
e94314dc95 | ||
|
|
5dd68a4055 | ||
|
|
fff4e9b4b8 | ||
|
|
8a6f5b49a3 | ||
|
|
c8290b913e | ||
|
|
e6e6d811c6 | ||
|
|
cdc35b3c32 | ||
|
|
c68e00730e | ||
|
|
0496374328 | ||
|
|
6608dd0b8d | ||
|
|
432b4ab69d | ||
|
|
967b3646a6 | ||
|
|
4110d1975a | ||
|
|
b1862ce1c1 | ||
|
|
a432c3429c | ||
|
|
949190b48d | ||
|
|
6885bf6368 | ||
|
|
78f354925c | ||
|
|
a87b7603d1 | ||
|
|
1f3a232a9d | ||
|
|
99346d6486 | ||
|
|
067bd3cbd7 | ||
|
|
6e716fe3c5 | ||
|
|
831c7f53b2 | ||
|
|
1c5a829e82 | ||
|
|
4751949628 | ||
|
|
f8abafdefa | ||
|
|
4798d1e3b3 | ||
|
|
10140d143c | ||
|
|
f3609b06d7 | ||
|
|
f25577649a | ||
|
|
cf5586037e | ||
|
|
c6e3c31fae | ||
|
|
0c3e1f602a | ||
|
|
d3a35e3f8d | ||
|
|
b34bafc348 | ||
|
|
cdb316834a | ||
|
|
8b30e2e931 | ||
|
|
841bd0e515 | ||
|
|
90677188ec | ||
|
|
6d5df7c9af | ||
|
|
79e1830ba9 | ||
|
|
f0db784b46 | ||
|
|
ef5c9f0175 | ||
|
|
84081286f0 | ||
|
|
1b913443ad | ||
|
|
f5c19b9e5c | ||
|
|
5a561e03b8 | ||
|
|
ab207727fd | ||
|
|
b3231883f6 | ||
|
|
d9ff42ab3c | ||
|
|
fb20751330 | ||
|
|
c5bf72f0b3 | ||
|
|
cfdcb8b3df | ||
|
|
7d0cbf6d02 | ||
|
|
0b4f576c54 | ||
|
|
d93bed216a | ||
|
|
89abfe6f86 | ||
|
|
78fbc214ca | ||
|
|
fc649854ff | ||
|
|
60e71f5724 | ||
|
|
b78807e5ed | ||
|
|
4e39027958 | ||
|
|
b527918350 | ||
|
|
16a352c70a | ||
|
|
5035f9c3d6 | ||
|
|
a662318417 | ||
|
|
573934e505 | ||
|
|
927e86bdc9 | ||
|
|
cfa2c4e424 | ||
|
|
79bafbb943 | ||
|
|
36bfaf0f05 | ||
|
|
3d7da6e858 | ||
|
|
f81f374ab9 | ||
|
|
82050a5e46 | ||
|
|
9cf26e1fc2 | ||
|
|
fa869f21ad | ||
|
|
6af65004a5 | ||
|
|
d189aadd12 | ||
|
|
6048019926 | ||
|
|
021ba21b4f | ||
|
|
96b7612d73 | ||
|
|
7e8ebdb852 | ||
|
|
2e52fe64b8 | ||
|
|
8b367c8eab | ||
|
|
68481b8921 | ||
|
|
a5aeac312c | ||
|
|
d29d35ab23 | ||
|
|
20eb6a3eca | ||
|
|
54c4b1de83 | ||
|
|
d3572dd4ec | ||
|
|
696a5f967d | ||
|
|
3fa4f73b6f | ||
|
|
afbafbe689 | ||
|
|
18b02594cb | ||
|
|
8288de7f79 | ||
|
|
1693c97924 | ||
|
|
e3d69b4d8e | ||
|
|
f8eef33b7b | ||
|
|
d5af2588bc | ||
|
|
432bf03f0a | ||
|
|
2ba3ff852c | ||
|
|
76e9d912d6 | ||
|
|
29e71bec86 | ||
|
|
1d1857e5a7 | ||
|
|
8a2407ecbb | ||
|
|
05146faacf | ||
|
|
b7fb8fb0ca | ||
|
|
5ddab7d3b2 | ||
|
|
ebcbf79237 | ||
|
|
f5fd05a1e4 | ||
|
|
a644b2dee5 | ||
|
|
1d073cd0d9 | ||
|
|
a1e74c3286 | ||
|
|
a6cc7eda61 | ||
|
|
a36e128e57 | ||
|
|
daffb602bb | ||
|
|
0f28a1bd86 | ||
|
|
4043130f75 | ||
|
|
835083a741 | ||
|
|
daf63eb418 | ||
|
|
4d5e5e1635 | ||
|
|
15c3ff0544 | ||
|
|
68d19cd6fb | ||
|
|
ecc1730912 | ||
|
|
9c2d062886 | ||
|
|
7b3c3b9fab | ||
|
|
a37299b4ae | ||
|
|
0c2ec8cb71 | ||
|
|
7c2af68e3c | ||
|
|
c0ec1d2c9a | ||
|
|
28911f03a7 | ||
|
|
c65b0eb544 | ||
|
|
f11eb17313 | ||
|
|
453386a49a | ||
|
|
accd69386a | ||
|
|
610d592f5a | ||
|
|
2b955eb00d | ||
|
|
f38d200e93 | ||
|
|
0b1f605bba | ||
|
|
278b617290 | ||
|
|
27c259bf7c | ||
|
|
f520251935 | ||
|
|
aa888c704e | ||
|
|
bbd3cb3469 | ||
|
|
bd2c67e8ec | ||
|
|
b5afce0bbd | ||
|
|
c5f714def8 | ||
|
|
fdeb194d0e | ||
|
|
975f3b420e | ||
|
|
8d5f1191dd | ||
|
|
7c89a8b178 | ||
|
|
7c24e67c50 | ||
|
|
1cb9ea16da | ||
|
|
c4a9532784 | ||
|
|
43163b400d | ||
|
|
93e30f44c0 | ||
|
|
b6b44a2c86 | ||
|
|
cb53a4f923 | ||
|
|
85f147f679 | ||
|
|
17cb8bd764 | ||
|
|
b2eb4ea70c | ||
|
|
c6089637e7 | ||
|
|
2f72ed2e80 | ||
|
|
7b6a4d76a8 | ||
|
|
8c7e498861 | ||
|
|
9824cc7068 | ||
|
|
d16ff5cb5c | ||
|
|
0409a81e36 | ||
|
|
e0883b72dc | ||
|
|
b592b3c658 | ||
|
|
d277f1750d | ||
|
|
d54bf78c08 | ||
|
|
b1be8bb7f3 | ||
|
|
0b7061afb7 | ||
|
|
b132578692 | ||
|
|
c18bdddb60 | ||
|
|
6cd07b23f1 | ||
|
|
ab546f54ab | ||
|
|
11068eee38 | ||
|
|
f80e23ac5e | ||
|
|
513a4fd16c | ||
|
|
98b3c8a812 | ||
|
|
f5ffa65ea7 | ||
|
|
a559a09217 | ||
|
|
3cb831bb56 | ||
|
|
bce8a3b3cc | ||
|
|
65ee3a5345 | ||
|
|
3c8a8efc03 | ||
|
|
99facf6764 | ||
|
|
8f3b10875e | ||
|
|
33ef6cc3f7 | ||
|
|
bcadee8575 | ||
|
|
77f8855fd6 | ||
|
|
b4243dc95b | ||
|
|
2f4d254bc6 | ||
|
|
e98e9391bf | ||
|
|
e1757d68a5 | ||
|
|
a46f1145f5 | ||
|
|
d21e5db701 | ||
|
|
1c1e64f48f | ||
|
|
4b6d1934c3 | ||
|
|
8561af1f84 | ||
|
|
0880c762c9 | ||
|
|
886619a099 | ||
|
|
64f4df5005 | ||
|
|
fd5e9fa85f | ||
|
|
6a0506386d | ||
|
|
c5787381aa | ||
|
|
22ed61f69c | ||
|
|
f6e204e4fb | ||
|
|
6f5abf105d | ||
|
|
8106a949bd | ||
|
|
497012f98e | ||
|
|
46f57756e7 | ||
|
|
6a6f3d61bb | ||
|
|
956af9177e | ||
|
|
f2d1c820f5 | ||
|
|
5999998ead | ||
|
|
293820747f | ||
|
|
4b97f76aa7 | ||
|
|
2e465ba04a | ||
|
|
7c367d4e9c | ||
|
|
773ee898f7 | ||
|
|
8b85b9b06b | ||
|
|
7c092411b0 | ||
|
|
e237c02295 | ||
|
|
4b36cd4a58 | ||
|
|
a20f4450e9 | ||
|
|
bc99ceee12 | ||
|
|
2c3e37024e | ||
|
|
a399bd7b62 | ||
|
|
c90c303fd4 | ||
|
|
29236442de | ||
|
|
b93f4fa879 | ||
|
|
971083415c | ||
|
|
a1a23cf6c5 | ||
|
|
51974891a8 | ||
|
|
7670094e7d | ||
|
|
69addc1d52 | ||
|
|
ab4e0127c5 | ||
|
|
ba9e7d8056 | ||
|
|
878b200217 | ||
|
|
1ffa9f7c0c | ||
|
|
d46b8f9963 | ||
|
|
1b52b3e685 | ||
|
|
5eef36c47a | ||
|
|
5c156a9d86 | ||
|
|
4f72de8289 | ||
|
|
a9c165f8a4 | ||
|
|
767bdc1a30 | ||
|
|
f09b828217 | ||
|
|
d2b28f60ff | ||
|
|
21b1d5b52e | ||
|
|
f61becccb3 | ||
|
|
0da6696e83 | ||
|
|
4091bf9da5 | ||
|
|
da86dd08c4 | ||
|
|
59a12dfe1d | ||
|
|
468f28941f | ||
|
|
a987bcac6f | ||
|
|
782d71a745 | ||
|
|
212bd47d36 | ||
|
|
bcf301ce6a | ||
|
|
01b4f52fb0 | ||
|
|
2cc41405d2 | ||
|
|
37c6636788 | ||
|
|
80c24532ba | ||
|
|
4702e3d586 | ||
|
|
466f901105 | ||
|
|
ed4e91ee7f | ||
|
|
ee6f919ea7 | ||
|
|
9f84fe6d5a | ||
|
|
2580ca7afd | ||
|
|
aee0e75971 | ||
|
|
ce4b35ba1a | ||
|
|
dc77a053ea | ||
|
|
565153c5f7 | ||
|
|
6aab72beb8 | ||
|
|
c8bd1f5f5b | ||
|
|
5f2b3a10ff | ||
|
|
1466539d88 | ||
|
|
01b02fd6b1 | ||
|
|
16a6af820a | ||
|
|
ac7e5cb742 | ||
|
|
2dbbec88f7 | ||
|
|
6dc9210a7e | ||
|
|
4a6031ba38 | ||
|
|
466cc0b98d | ||
|
|
ed6dcb6a5b | ||
|
|
ec8d2646cd | ||
|
|
bca94dc4be | ||
|
|
8e00ae1d44 | ||
|
|
99303883dc | ||
|
|
ea2b1e179e | ||
|
|
bf10ab4bb1 | ||
|
|
0f24c79ce9 | ||
|
|
c5ad7849ac | ||
|
|
d66c730c30 | ||
|
|
61730f3ee1 | ||
|
|
1cc2933c32 | ||
|
|
34b42cc5d7 | ||
|
|
4cb43c6747 | ||
|
|
189590edb9 | ||
|
|
c711847b4e | ||
|
|
b3fcd87a20 | ||
|
|
3654ff5f5c | ||
|
|
31c5b00fed | ||
|
|
2484555854 | ||
|
|
9600965bcf | ||
|
|
1bd6ba61a7 | ||
|
|
899d09bfcc | ||
|
|
35433cb8a4 | ||
|
|
7d9642210d | ||
|
|
8126418ef3 | ||
|
|
d0a6772245 | ||
|
|
3f921251ee | ||
|
|
cf94149dc1 | ||
|
|
74d26eac86 | ||
|
|
225d174ec6 | ||
|
|
3bc4d6fd63 | ||
|
|
94787c6da8 | ||
|
|
6d2b530330 | ||
|
|
c2fbb6f10f | ||
|
|
2f54cf26a9 | ||
|
|
9945fc1767 | ||
|
|
186cf58197 | ||
|
|
1c80ae45d8 | ||
|
|
2c992c3f16 | ||
|
|
e2f7a0ef5c | ||
|
|
665df2fe4e | ||
|
|
311020034e | ||
|
|
564a9abf42 | ||
|
|
6a60fa3458 | ||
|
|
94cf62f510 | ||
|
|
1920f529be | ||
|
|
1234cf42e9 | ||
|
|
ed9307097b | ||
|
|
f16bde1ac8 | ||
|
|
49b027f2a0 | ||
|
|
ff2c0e52b4 | ||
|
|
8094d13c2e | ||
|
|
37839ff247 | ||
|
|
e32b13e226 | ||
|
|
3a678f5a9b | ||
|
|
b8cfb5c8be | ||
|
|
476721b4b9 | ||
|
|
b4a37bf20d | ||
|
|
4a6a81b5d4 | ||
|
|
d9392d5c39 | ||
|
|
279d919164 | ||
|
|
9e47335f98 | ||
|
|
43ab8a2e36 | ||
|
|
b5cb6459b0 | ||
|
|
4622be4cef | ||
|
|
b9e522fd8d | ||
|
|
71f2dee332 | ||
|
|
b86e402fc0 | ||
|
|
658be9bd58 | ||
|
|
65df86e741 | ||
|
|
0197a47007 | ||
|
|
ce42937e3f | ||
|
|
aec4278292 | ||
|
|
8fef329437 | ||
|
|
128d30bd4b | ||
|
|
7dea17cdc7 | ||
|
|
82386fe2ef | ||
|
|
c2f56f1881 | ||
|
|
68fc758e94 | ||
|
|
1cd7706461 | ||
|
|
2e5141bd25 | ||
|
|
f6d8573221 | ||
|
|
562982cc30 | ||
|
|
df13aa408b | ||
|
|
4329d46ac4 | ||
|
|
bf9e900731 | ||
|
|
40ad9fad32 | ||
|
|
3951f6f516 | ||
|
|
58d94e9883 | ||
|
|
55c0ba5b06 | ||
|
|
e327c5ad0e | ||
|
|
bf176ffd4d | ||
|
|
6a7695a8f0 | ||
|
|
4bb63a9827 | ||
|
|
2a40ca6295 | ||
|
|
e9c99089e1 | ||
|
|
93af7491ee | ||
|
|
2075d92369 | ||
|
|
9bcd3298ba | ||
|
|
2f9a43effd | ||
|
|
535a01ea30 | ||
|
|
1193f9bb65 | ||
|
|
623b993fa9 | ||
|
|
7773f6b4f7 | ||
|
|
2b47e62dd8 | ||
|
|
3d21dc309c | ||
|
|
6dadfaffac | ||
|
|
f0ef3a4569 | ||
|
|
140f5d3b0a | ||
|
|
22f314d158 | ||
|
|
8653ee79ea | ||
|
|
0cc146a170 | ||
|
|
56378772cc | ||
|
|
64561fa57b | ||
|
|
b34021abd5 | ||
|
|
c6b17c9005 | ||
|
|
331023e878 | ||
|
|
d47fb4da03 | ||
|
|
40faef0bf8 | ||
|
|
b8c9d9c0f3 | ||
|
|
d33ae35fb3 | ||
|
|
5f56d2d38f | ||
|
|
d7e7701927 | ||
|
|
005ec30d7b | ||
|
|
15a8e1f08f | ||
|
|
2d06d455cd | ||
|
|
f2b773dac7 | ||
|
|
14774b03ad | ||
|
|
190e3e8c2f | ||
|
|
0464e611c7 | ||
|
|
f7386e8e70 | ||
|
|
a5be867238 | ||
|
|
002cbce499 | ||
|
|
5f38bb4bf2 | ||
|
|
726141d6da | ||
|
|
ed09681479 | ||
|
|
d194dfbc09 | ||
|
|
8ef3e923e8 | ||
|
|
564410ac7e | ||
|
|
f2beb4443a | ||
|
|
1a88370566 | ||
|
|
01b4339b6f | ||
|
|
308a249891 | ||
|
|
1244d5df03 | ||
|
|
f26425f17a | ||
|
|
b28313559d | ||
|
|
d933472a16 | ||
|
|
6c034506c3 | ||
|
|
8979f12111 | ||
|
|
289d1055e5 | ||
|
|
41ebd51fca | ||
|
|
07569d008d | ||
|
|
e5f3d1d8bc | ||
|
|
f670c774d3 | ||
|
|
7c41dc2e7e | ||
|
|
7c40f3332f | ||
|
|
2df95bb4bd | ||
|
|
68a4975fe1 | ||
|
|
41c56f706a | ||
|
|
56962a26cc | ||
|
|
7f776c0d53 | ||
|
|
bee0109e33 | ||
|
|
fd6b367746 | ||
|
|
5e12a9d057 | ||
|
|
5228451c9c | ||
|
|
c78770138d | ||
|
|
947cf57100 | ||
|
|
4a59efadeb | ||
|
|
66b929c3fa | ||
|
|
c1d1059a9a | ||
|
|
ccacdf7e6b | ||
|
|
69100fcca3 | ||
|
|
cd8edf933f | ||
|
|
00e9960d77 | ||
|
|
c9eac98d53 | ||
|
|
7fc90d3dce | ||
|
|
12890af0cc | ||
|
|
3724cf0e68 | ||
|
|
1cfd782bdd | ||
|
|
1351a2695e | ||
|
|
e49b484c2f | ||
|
|
66a94c6778 | ||
|
|
278459bdf2 | ||
|
|
ed88e55e04 | ||
|
|
5e1a102de4 | ||
|
|
27ed3ca4b9 | ||
|
|
4ea1b8d666 | ||
|
|
bfe221d571 | ||
|
|
be65834e1b | ||
|
|
3b54658e52 | ||
|
|
3462f403fe | ||
|
|
6675bb2276 | ||
|
|
3e0b75c4f7 | ||
|
|
621a342809 | ||
|
|
3ad4770b44 | ||
|
|
2c2d127683 | ||
|
|
6271dba5bf | ||
|
|
c85f8345f2 | ||
|
|
1ef5dc2c5d | ||
|
|
181c6ddd9d | ||
|
|
8ed9934a87 | ||
|
|
99f9b98258 | ||
|
|
e2cc2d600b | ||
|
|
6397261a33 | ||
|
|
b368664d96 | ||
|
|
5617a4e59b | ||
|
|
f137502020 | ||
|
|
6a114ae027 | ||
|
|
8cb1e73fc0 | ||
|
|
293ab2c2a2 | ||
|
|
98bb191c4a | ||
|
|
d3d72eb03c | ||
|
|
a3bf40fd69 | ||
|
|
a1d06e682e | ||
|
|
48003c8bc9 | ||
|
|
0552c9fde2 | ||
|
|
f7cc3a9e73 | ||
|
|
af8bb2a992 | ||
|
|
ac2d16b15c | ||
|
|
6fb3c399de | ||
|
|
0c44b11e9c | ||
|
|
5f4e4a0d54 | ||
|
|
7d56d772d4 | ||
|
|
c848af3960 | ||
|
|
ee745a20ef | ||
|
|
30f26f462b | ||
|
|
344dc90d56 | ||
|
|
9b29fd1385 | ||
|
|
c8a9efe5c8 | ||
|
|
940994288b | ||
|
|
3e8fbc8179 | ||
|
|
1644ee6fad | ||
|
|
d419d29cc8 | ||
|
|
d5fae8dba7 | ||
|
|
7935b2e957 | ||
|
|
8f0bda3dab | ||
|
|
8de93f4120 | ||
|
|
84da9d4758 | ||
|
|
20c4090f71 | ||
|
|
f3e18d135c | ||
|
|
0ca9047f8c | ||
|
|
90e9bce8de | ||
|
|
6d1e9ee3d4 | ||
|
|
7331001bb2 | ||
|
|
aac8382cf0 | ||
|
|
5272c48b7a | ||
|
|
81862e30d1 | ||
|
|
adb0efdf97 | ||
|
|
2677f06d44 | ||
|
|
3a031e9364 | ||
|
|
d2a8863384 | ||
|
|
81277c2b25 | ||
|
|
a90cdd9c7e | ||
|
|
2faca7d7e2 | ||
|
|
7be177e9ab | ||
|
|
f2b39196a0 | ||
|
|
a8f85f0d91 | ||
|
|
b0ad7f6bf7 | ||
|
|
7b5d7376c6 | ||
|
|
8bb694a910 | ||
|
|
25f3f77849 | ||
|
|
06dfeb72d7 | ||
|
|
f9878e75e3 | ||
|
|
58ede9caee | ||
|
|
24beaf6ce4 | ||
|
|
e46380f2d9 | ||
|
|
ffe729a53b | ||
|
|
f3afe45e72 | ||
|
|
059fc7c4fa | ||
|
|
cb295bfabc | ||
|
|
0ac2560508 | ||
|
|
98d315b3f7 | ||
|
|
28de2ceed8 | ||
|
|
28c814e4ef | ||
|
|
fdffe2e06a | ||
|
|
fb08f81e75 | ||
|
|
9affd767e4 | ||
|
|
9ccb015411 | ||
|
|
e5b81dd825 | ||
|
|
fe33db1620 | ||
|
|
2e02f5ac2c | ||
|
|
198d567df2 | ||
|
|
b1ecf08013 | ||
|
|
7c9eb35568 | ||
|
|
1839a37294 | ||
|
|
bd39b29c1d | ||
|
|
1cc7c6b4cf | ||
|
|
0cf4663c7d | ||
|
|
424221201c | ||
|
|
a14df55bd8 | ||
|
|
c16fa02558 | ||
|
|
8946aa9ee5 | ||
|
|
c4f868cd89 | ||
|
|
cc88b1edcd | ||
|
|
b3f918970b | ||
|
|
3d26f79b8b | ||
|
|
3d8e05fa2a | ||
|
|
aaeb90436c | ||
|
|
42f4c816b7 | ||
|
|
8d06ea5a15 | ||
|
|
9f23dcb0c4 | ||
|
|
5f1047c574 | ||
|
|
8d1c345580 | ||
|
|
3a17bf519f | ||
|
|
7599b00a13 | ||
|
|
f5492144ad | ||
|
|
d61f89e3c9 | ||
|
|
879cd79fdc | ||
|
|
c2f15ff47c | ||
|
|
c9226f6b63 | ||
|
|
95ff7acd6d | ||
|
|
0673e70aca | ||
|
|
fd53ff014e | ||
|
|
f5cbae3958 | ||
|
|
273c9b3479 | ||
|
|
3f9f79c155 | ||
|
|
3a5b8a1075 | ||
|
|
5a9ad787d5 | ||
|
|
7f7267027e | ||
|
|
c19ef521b3 | ||
|
|
83270e13f8 | ||
|
|
cfc71a47db | ||
|
|
45228f920d | ||
|
|
627c0a6b57 | ||
|
|
573c493d5d | ||
|
|
c5329968f7 | ||
|
|
d235e045d8 | ||
|
|
bb26127ed5 | ||
|
|
beddc1cb21 | ||
|
|
acc6f6b3c3 | ||
|
|
30f6dc2b2d | ||
|
|
e0194d4d06 | ||
|
|
a224c392e8 | ||
|
|
a6e08bfc0f | ||
|
|
b755880dd3 | ||
|
|
b082bce2b1 | ||
|
|
1c13ace366 | ||
|
|
da8692f6a3 | ||
|
|
b81373366b | ||
|
|
aa37a0b539 | ||
|
|
b71ee44505 | ||
|
|
dea8ac2cf8 | ||
|
|
3a78568a6f | ||
|
|
6898697246 | ||
|
|
820b223ea9 | ||
|
|
769c6a2e03 | ||
|
|
7991a53f3b | ||
|
|
d1f386860c | ||
|
|
eec7385045 | ||
|
|
2d8fbb89c9 | ||
|
|
7cf55fa993 | ||
|
|
c260158a2c | ||
|
|
3b654a0986 | ||
|
|
bd60dfb61d | ||
|
|
a07f90c158 | ||
|
|
9b6c34213b | ||
|
|
c58df7a3d9 | ||
|
|
62462165b7 | ||
|
|
4069878d54 | ||
|
|
72479ce61e | ||
|
|
db547a53d6 | ||
|
|
37c8c80b82 | ||
|
|
b279f4ce02 | ||
|
|
4e34328156 | ||
|
|
757cf4c8e7 | ||
|
|
1e0741cf17 | ||
|
|
e0ec2bd886 | ||
|
|
dd5a3352fe | ||
|
|
054825807a | ||
|
|
b2b5dd4eb8 | ||
|
|
2b92c10625 | ||
|
|
29f20096fd | ||
|
|
8bbb6cf541 | ||
|
|
03d4dde6a4 | ||
|
|
68fd65b55a | ||
|
|
7d97ebf581 | ||
|
|
2b40e044c4 | ||
|
|
2bc0360d8e | ||
|
|
cd68104de1 | ||
|
|
7da511fc32 | ||
|
|
84608b67fa | ||
|
|
121ba63347 | ||
|
|
1ea476b634 | ||
|
|
8c31a0e2c5 | ||
|
|
a3365512b3 | ||
|
|
c231e555da | ||
|
|
4a0e78fcbc | ||
|
|
eb348c08ad | ||
|
|
e15a284ae5 | ||
|
|
2f0b6e1e09 | ||
|
|
feaa9e7def | ||
|
|
50007bbc62 | ||
|
|
6c15ee6556 | ||
|
|
320ae772f3 | ||
|
|
be923a9ecb | ||
|
|
a94ad1c1fa | ||
|
|
98ee2cbd7e | ||
|
|
c164bd200e | ||
|
|
d2983deb48 | ||
|
|
5071cbfc2e | ||
|
|
7acce90927 | ||
|
|
f86a194962 | ||
|
|
a93ea1b90b | ||
|
|
f1bb636f91 | ||
|
|
e55c8e20e5 | ||
|
|
5d75b3b223 | ||
|
|
c2eeea8b70 | ||
|
|
b98d0461d1 | ||
|
|
a3493f5f6b | ||
|
|
52245a7fef | ||
|
|
af8eb800e6 | ||
|
|
c37cb7b2c4 | ||
|
|
f8c8734e79 | ||
|
|
b7ef79f1b7 | ||
|
|
28e464f368 | ||
|
|
26a7de79c7 | ||
|
|
4ddac28142 | ||
|
|
fec7e95406 | ||
|
|
60db043325 | ||
|
|
dc34799317 | ||
|
|
77eb745abc | ||
|
|
b005b2a53a | ||
|
|
c6cc69b01b | ||
|
|
1e4da55190 | ||
|
|
7c3ba8bd9a | ||
|
|
c7de0ccf99 | ||
|
|
b601fa2037 | ||
|
|
cab39e31a1 | ||
|
|
79f42837f2 | ||
|
|
0378869938 | ||
|
|
fc488959ea | ||
|
|
cd340f0fb6 | ||
|
|
626351e897 | ||
|
|
d176a58d33 | ||
|
|
88639c2052 | ||
|
|
322484c286 | ||
|
|
324f12641a | ||
|
|
cd02bbd1cb | ||
|
|
22609412e4 | ||
|
|
f0b3527bb5 | ||
|
|
893946879a | ||
|
|
685fda1565 | ||
|
|
f3df997b5b | ||
|
|
2d222c721b | ||
|
|
adfc916ea0 | ||
|
|
f8b355c9d8 | ||
|
|
d7c7360205 | ||
|
|
2524b407be | ||
|
|
32c44e4883 | ||
|
|
95ab62b286 | ||
|
|
ebd852a060 | ||
|
|
4fdc1f3311 | ||
|
|
4992d19e8f | ||
|
|
c639b4cf6c | ||
|
|
ee465c4169 | ||
|
|
5a7e0b05a4 | ||
|
|
d770034e5c | ||
|
|
fcb751ae4a | ||
|
|
e350824896 | ||
|
|
1586475232 | ||
|
|
17c0da930f | ||
|
|
c985afa4f4 | ||
|
|
3631396329 | ||
|
|
7cb6b29f1b | ||
|
|
5f487f4ce1 | ||
|
|
e1c3585b46 | ||
|
|
7766172831 | ||
|
|
10f57e9a87 | ||
|
|
59cb20bab8 | ||
|
|
2266a2a662 | ||
|
|
5ff3700203 | ||
|
|
065c56fce4 | ||
|
|
ee3f48bcae | ||
|
|
a2c055c379 | ||
|
|
99703b1121 | ||
|
|
4008cf519c | ||
|
|
6dc2e9e6df | ||
|
|
7317f28ab3 | ||
|
|
a62b7d5ce7 | ||
|
|
d2b32564b8 | ||
|
|
c847bfb6a5 | ||
|
|
b6e36275bb | ||
|
|
5e5dafac26 | ||
|
|
9127b41923 | ||
|
|
74cd0ddd8b | ||
|
|
b57b4dd102 | ||
|
|
0b08c6bef1 | ||
|
|
1405a7c103 | ||
|
|
1d0214ed54 | ||
|
|
21340ac775 | ||
|
|
d2b1fb8b5d | ||
|
|
179e2627eb | ||
|
|
c010c098fc | ||
|
|
4218011417 | ||
|
|
2e97a396ce | ||
|
|
58ba9e3617 | ||
|
|
27961f45f0 | ||
|
|
1e94239d06 | ||
|
|
a619d4e82a | ||
|
|
a2bf387147 | ||
|
|
d8da1b7ab5 | ||
|
|
79a81258ec | ||
|
|
1b5b11907e | ||
|
|
0a80dd0d87 | ||
|
|
64931839cc | ||
|
|
f6cf4e2878 | ||
|
|
e1cf05c327 | ||
|
|
1c2c10fc58 | ||
|
|
1c6bdf7aef | ||
|
|
b80be075d7 | ||
|
|
fb39f2d511 | ||
|
|
2b8c630922 | ||
|
|
c420751ffc | ||
|
|
92fd0f56b4 | ||
|
|
28b1ed82a5 | ||
|
|
1850cd159d | ||
|
|
9630632120 | ||
|
|
8e18f2ab43 | ||
|
|
f599278d8d | ||
|
|
e89e57b5a0 | ||
|
|
e3fe8d046a | ||
|
|
56d23a03cf | ||
|
|
5de463638c | ||
|
|
d6b5e9f5a5 | ||
|
|
4ddc33e881 | ||
|
|
bf17e716e9 | ||
|
|
43806994eb | ||
|
|
c4a5b0acc8 | ||
|
|
8c71d22bea | ||
|
|
618ca2f011 | ||
|
|
f04156da0e | ||
|
|
4ab397dfb2 | ||
|
|
7eab3337bf | ||
|
|
2f68adf73d | ||
|
|
6f5202c8cf | ||
|
|
313732ae25 | ||
|
|
e3ca2594bc | ||
|
|
812ce207dd | ||
|
|
3b9a0cfbc8 | ||
|
|
2a7fd8caa5 | ||
|
|
46dff21e97 | ||
|
|
f4a22ef857 | ||
|
|
0cadfbaddb | ||
|
|
e0b9f23dad | ||
|
|
7071ac29e8 | ||
|
|
5578849508 | ||
|
|
d096c043f0 | ||
|
|
2882cb728f | ||
|
|
f9e3afaad2 | ||
|
|
4f87e82a19 | ||
|
|
a2701faa2b | ||
|
|
9f2d8e6fff | ||
|
|
174a2d36aa | ||
|
|
2773c22f9b | ||
|
|
50f9fbd728 | ||
|
|
8f96442cc7 | ||
|
|
0269affb69 | ||
|
|
1c9fcbb387 | ||
|
|
368afacd14 | ||
|
|
9f160b11fa | ||
|
|
323c0a7e1e | ||
|
|
48541479fb | ||
|
|
97a6f8aeb0 | ||
|
|
2e8e641024 | ||
|
|
1df39f81ee | ||
|
|
136cffbab9 | ||
|
|
2493c401f9 | ||
|
|
90285944d9 | ||
|
|
aa0fea6931 | ||
|
|
8a4ab08810 | ||
|
|
bd442fb412 | ||
|
|
d04067bd09 | ||
|
|
a62d433262 | ||
|
|
cb16e4edf0 | ||
|
|
b2eb601fc4 | ||
|
|
0ce0f81144 | ||
|
|
ae308a274c | ||
|
|
e536820629 | ||
|
|
d2a42e47ce | ||
|
|
62628a66bd | ||
|
|
0478d90578 | ||
|
|
d29832ce5c | ||
|
|
a0875697cd | ||
|
|
45c7c711ad | ||
|
|
c03250f09b | ||
|
|
50f7893b2f | ||
|
|
6c219bd628 | ||
|
|
8208730130 | ||
|
|
dc96269bc6 | ||
|
|
3546b5777b | ||
|
|
a45b4ffb43 | ||
|
|
d08d2fdec8 | ||
|
|
b47ff37612 | ||
|
|
1ec0eed867 | ||
|
|
3054be307e | ||
|
|
0d22841da1 | ||
|
|
d20dbaa7d2 | ||
|
|
a7886443c5 | ||
|
|
674abf478b | ||
|
|
0f96939828 | ||
|
|
2f4689ba37 | ||
|
|
045234912c | ||
|
|
049c1e16b0 | ||
|
|
c7ca3d9261 | ||
|
|
a6cd08e056 | ||
|
|
d340b74bb9 | ||
|
|
fcf4cf88ea | ||
|
|
758d45af68 | ||
|
|
50d21405cf | ||
|
|
8ea58c8a7e | ||
|
|
7c1af50bda | ||
|
|
fd4155f4b6 | ||
|
|
1d6e2b4182 | ||
|
|
630819cfe5 | ||
|
|
4b04bc573b | ||
|
|
e38615d15b | ||
|
|
f140b4f35c | ||
|
|
167d336274 | ||
|
|
0fca6ee425 | ||
|
|
748a952e81 | ||
|
|
a30119706d | ||
|
|
77cdc0fa4c | ||
|
|
3bdf6e553d | ||
|
|
546422609a | ||
|
|
b971799638 | ||
|
|
bedb567eba | ||
|
|
b4cf0b429b | ||
|
|
ca5fb91350 | ||
|
|
621c0a0249 | ||
|
|
d0b7a983d1 | ||
|
|
54cf0a6a91 | ||
|
|
bde8782328 | ||
|
|
c8d95e58c3 | ||
|
|
95cd6cf775 | ||
|
|
dd7ab5a0ff | ||
|
|
865061faf0 | ||
|
|
02c06f1654 | ||
|
|
0aa6fa9302 | ||
|
|
8a08964755 | ||
|
|
413c24bde8 | ||
|
|
f9fe8a056a | ||
|
|
d8c95f844f | ||
|
|
61b1128d76 | ||
|
|
1317f26d04 | ||
|
|
7112e163e6 | ||
|
|
4b4c8c8e37 | ||
|
|
3a159111f3 | ||
|
|
f6beee3693 | ||
|
|
4f32024d3b | ||
|
|
edb6c0e8e9 | ||
|
|
74af7dc80e | ||
|
|
e284efa648 | ||
|
|
4a0b012f5b | ||
|
|
e643bcfc98 | ||
|
|
526079d76c | ||
|
|
0c8f2f1ea0 | ||
|
|
6e05e8d84b | ||
|
|
cff27f33dc | ||
|
|
ed67f77f9f | ||
|
|
eb0477f9d7 | ||
|
|
5fa50192a7 | ||
|
|
bba6ecba65 | ||
|
|
dcc8013028 | ||
|
|
0ddfdad180 | ||
|
|
466b4bf5e4 | ||
|
|
a5632c08c7 | ||
|
|
1dea1123de | ||
|
|
c419c4d560 | ||
|
|
269576805b | ||
|
|
0b52275e53 | ||
|
|
9c06bbb8eb | ||
|
|
da5717f66e | ||
|
|
8250ec1872 | ||
|
|
1efc71db0c | ||
|
|
062b8da2d3 | ||
|
|
15ef9140da | ||
|
|
2dc609ff6b | ||
|
|
8c7fceb081 | ||
|
|
778b89d5c9 | ||
|
|
b61cba8e01 | ||
|
|
0c585aca39 | ||
|
|
da2a9a5bf5 | ||
|
|
47797f4cec | ||
|
|
aef77312aa | ||
|
|
9a424ff264 | ||
|
|
022fba2ba4 | ||
|
|
adba4cf1fa | ||
|
|
0e21b53c2f | ||
|
|
13816b696f | ||
|
|
04ea11c61e | ||
|
|
523717477d | ||
|
|
6d0b1889f2 | ||
|
|
bb67cba384 | ||
|
|
14e7b4aefe | ||
|
|
1b9ce0b511 | ||
|
|
bf5e7b794e | ||
|
|
d7ee098a10 | ||
|
|
736696ac36 | ||
|
|
0b4d789afb | ||
|
|
55ad048b3a | ||
|
|
252fdcdd1e | ||
|
|
13e2af8990 | ||
|
|
8ecbf79199 | ||
|
|
03d686a246 | ||
|
|
f03249f5d5 | ||
|
|
0d8dfb41bc | ||
|
|
38c6302f11 | ||
|
|
dcc13b447c | ||
|
|
5d2eb3e4cf | ||
|
|
c8427140bd | ||
|
|
23228e111c | ||
|
|
2257e8ebe7 | ||
|
|
3c87835f82 | ||
|
|
bc8c95a7f7 | ||
|
|
369a3ed909 | ||
|
|
eb747e2304 | ||
|
|
e0df1a763c | ||
|
|
fe764ae97f | ||
|
|
0fc962454d | ||
|
|
b1b415e862 | ||
|
|
b5f0355015 | ||
|
|
d11899561b | ||
|
|
71f3002717 | ||
|
|
9f03d1be05 | ||
|
|
899d1955c0 | ||
|
|
c962922e75 | ||
|
|
562353929e | ||
|
|
4c8bd8d3ca | ||
|
|
e31c088470 | ||
|
|
172eee49e5 | ||
|
|
14fd78a5af | ||
|
|
c056eacfab | ||
|
|
ca2477a521 | ||
|
|
c06c627002 | ||
|
|
6edd21bfe6 | ||
|
|
f1e6092b94 | ||
|
|
1014841e2c | ||
|
|
dd49033a08 | ||
|
|
07835ea832 | ||
|
|
a8e8f6d409 | ||
|
|
54fe7a8606 | ||
|
|
f9897b607b | ||
|
|
798f4c1a69 | ||
|
|
7a04780841 | ||
|
|
d3e1edcc93 | ||
|
|
50a0902f92 | ||
|
|
84da051385 | ||
|
|
c77699dcd5 | ||
|
|
02865a9179 | ||
|
|
410d2a83a2 | ||
|
|
d46f96a8d6 | ||
|
|
ce1b58dd13 | ||
|
|
05b8e08ee8 | ||
|
|
24a05a2ebe | ||
|
|
2dc46964b4 | ||
|
|
30df7dacde | ||
|
|
fa628ce4d1 | ||
|
|
92eb988f2a | ||
|
|
ecc820f784 | ||
|
|
85cb3cb0d0 | ||
|
|
ec91f9a026 | ||
|
|
8fd728ca59 | ||
|
|
cf1ce7d7e5 | ||
|
|
54fc42cc73 | ||
|
|
a39844f9f3 | ||
|
|
2195c2af37 | ||
|
|
a3b37f58e3 | ||
|
|
d3dbbed6af | ||
|
|
9b75abdb09 | ||
|
|
bdf4c1a272 | ||
|
|
647e6afa14 | ||
|
|
0e08d7d703 | ||
|
|
8776876e93 | ||
|
|
1271eeb808 | ||
|
|
77ebb91d37 | ||
|
|
ca64b81785 | ||
|
|
4e6eaa2849 | ||
|
|
188704d177 | ||
|
|
4aa943b871 | ||
|
|
68c498163d | ||
|
|
0b35781d55 | ||
|
|
f838fa5d45 | ||
|
|
2922f78c20 | ||
|
|
5be20f26f3 | ||
|
|
0a01adf101 | ||
|
|
5e3e46847e | ||
|
|
c68b7ff4a8 | ||
|
|
740153475c | ||
|
|
71c363e115 | ||
|
|
8f40538d01 | ||
|
|
733fca3d49 | ||
|
|
d7e5d07a77 | ||
|
|
e199a1a1d6 | ||
|
|
e8a0762eee | ||
|
|
8cea1705d1 | ||
|
|
a6236ab593 | ||
|
|
bb22201f4a | ||
|
|
2eaf9a2c22 | ||
|
|
c92ccf8a44 | ||
|
|
7a5857e838 | ||
|
|
b24635d24e | ||
|
|
1230748ef5 | ||
|
|
f95be54bd5 | ||
|
|
97a6f3a7b2 | ||
|
|
f1063afea1 | ||
|
|
0dfef2ab25 | ||
|
|
8e59d9800d | ||
|
|
1ccd8cfd89 | ||
|
|
f4a713a500 | ||
|
|
4a9ff22eeb | ||
|
|
7dd616357f | ||
|
|
d42e380698 | ||
|
|
75c47e96b6 | ||
|
|
6523cf43be | ||
|
|
5d96bd8966 | ||
|
|
d39ad79986 | ||
|
|
b9c3ca535d | ||
|
|
5e501b9611 | ||
|
|
983a7e31dc | ||
|
|
693781a014 | ||
|
|
aee659b518 | ||
|
|
271c37442d | ||
|
|
7a1633abdf | ||
|
|
14ee1c5189 | ||
|
|
c262210cf3 | ||
|
|
6707e481de | ||
|
|
0bc98aad3b | ||
|
|
34fd992fb9 | ||
|
|
f62fded4bd | ||
|
|
aa7c5e652c | ||
|
|
632725e788 | ||
|
|
98516a2a22 | ||
|
|
b578b639e8 | ||
|
|
b5f1d5b435 | ||
|
|
efe83160a1 | ||
|
|
e29776d2b2 | ||
|
|
9dbdf75c14 | ||
|
|
583ea76c85 | ||
|
|
8e7574b9ae | ||
|
|
b8f1468ab5 | ||
|
|
4b318d072a | ||
|
|
1f53b80c9b | ||
|
|
707dc2f56f | ||
|
|
a1e7014524 | ||
|
|
aacc250481 | ||
|
|
fbb144ede4 | ||
|
|
b26bd29325 | ||
|
|
b7edebf272 | ||
|
|
dd74e69ab7 | ||
|
|
e4544bec97 | ||
|
|
dad825d68d | ||
|
|
a9cf5743a3 | ||
|
|
21164d1f01 | ||
|
|
eeb3a096d4 | ||
|
|
87b955b2ce | ||
|
|
da13f3599c | ||
|
|
727a91b689 | ||
|
|
873b399ee8 | ||
|
|
a6e905020d | ||
|
|
9fe563c9f3 | ||
|
|
755d4c242b | ||
|
|
8308a0f769 | ||
|
|
e23a6f533c | ||
|
|
31aa797f0e | ||
|
|
086af65f89 | ||
|
|
e11b70415d | ||
|
|
b8ca422e71 | ||
|
|
a68a345c32 | ||
|
|
31dbe29cae | ||
|
|
5bb9cda747 | ||
|
|
afb567265e | ||
|
|
dfb049d13c | ||
|
|
734d17c429 | ||
|
|
684ab3e3e5 | ||
|
|
a3c2009a48 | ||
|
|
f77df0ab83 | ||
|
|
cd25894a39 | ||
|
|
95f56f040a | ||
|
|
39721e5bcd | ||
|
|
8e622eaca6 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,10 +3,12 @@
|
||||
*.aps
|
||||
*.suo
|
||||
*.vshost.exe
|
||||
*/.vs
|
||||
/bin/
|
||||
/bin-release/
|
||||
/bin
|
||||
/bin-release
|
||||
/indra/out/
|
||||
/indra/viewer-*
|
||||
/indra/newview/vivox-runtime/
|
||||
/indra/newview/dbghelp.dll
|
||||
@@ -25,5 +27,4 @@ qtcreator-build/
|
||||
/.pc
|
||||
/build-*
|
||||
/viewer-*
|
||||
|
||||
|
||||
/Pipfile.lock
|
||||
|
||||
286
.gitlab-ci.yml
Normal file
286
.gitlab-ci.yml
Normal file
@@ -0,0 +1,286 @@
|
||||
stages:
|
||||
- build
|
||||
- upload
|
||||
|
||||
default:
|
||||
interruptible: true
|
||||
timeout: 4h
|
||||
|
||||
variables:
|
||||
AUTOBUILD_BUILD_ID: $CI_PIPELINE_ID
|
||||
AUTOBUILD_INSTALLABLE_CACHE: "$CI_PROJECT_DIR/.cache/autobuild"
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
|
||||
VIEWER_USE_CRASHPAD: "TRUE"
|
||||
VIEWER_CRASHPAD_URL: $SENTRY_DSN
|
||||
|
||||
.win_build:
|
||||
stage: build
|
||||
tags:
|
||||
- autobuild
|
||||
- windows
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- autobuild.xml
|
||||
prefix: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- .cache/autobuild
|
||||
- .cache/pip
|
||||
- .venv/
|
||||
when: 'always'
|
||||
before_script:
|
||||
- virtualenv .venv
|
||||
- .\.venv\Scripts\activate.ps1
|
||||
- pip install --upgrade autobuild -i https://pkg.alchemyviewer.org/repository/autobuild/simple --extra-index-url https://pypi.org/simple
|
||||
script:
|
||||
- |
|
||||
autobuild configure -c Release -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DVS_DISABLE_FATAL_WARNINGS=ON -DREVISION_FROM_VCS=FALSE
|
||||
autobuild build -c Release --no-configure
|
||||
artifacts:
|
||||
name: "$env:CI_COMMIT_REF_NAME-$env:CI_COMMIT_SHORT_SHA"
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- build-vc-*/newview/Release/build_data.json
|
||||
- build-vc-*/newview/Release/singularity-bin.exe
|
||||
- build-vc-*/newview/Release/*.pdb
|
||||
- build-vc-*/newview/Release/*.dll
|
||||
- build-vc-*/newview/Release/Singularity_*_Setup.exe
|
||||
|
||||
.linux_build:
|
||||
stage: build
|
||||
image: r.alchemyviewer.org/singularity/infrastructure/debian-build-image:latest
|
||||
tags:
|
||||
- linux
|
||||
- docker
|
||||
cache:
|
||||
key:
|
||||
files:
|
||||
- autobuild.xml
|
||||
prefix: ${CI_JOB_NAME}
|
||||
paths:
|
||||
- .cache/autobuild
|
||||
- .cache/pip
|
||||
- .venv
|
||||
when: 'always'
|
||||
before_script:
|
||||
- virtualenv .venv -p python2
|
||||
- source .venv/bin/activate
|
||||
- pip install --upgrade autobuild -i https://pkg.alchemyviewer.org/repository/autobuild/simple --extra-index-url https://pypi.org/simple
|
||||
script:
|
||||
- |
|
||||
autobuild configure -c Release -- -DUSE_FMODSTUDIO=ON -DUSE_NVAPI=ON -DUSE_LTO=ON -DUNIX_DISABLE_FATAL_WARNINGS=ON -DREVISION_FROM_VCS=FALSE
|
||||
autobuild build -c Release --no-configure
|
||||
artifacts:
|
||||
name: "$env:CI_COMMIT_REF_NAME-$env:CI_COMMIT_SHORT_SHA"
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- build-linux-*/build_data.json
|
||||
- build-linux-*/newview/Singularity_*.tar.xz
|
||||
|
||||
.win32_build:
|
||||
extends: .win_build
|
||||
variables:
|
||||
AUTOBUILD_ADDRSIZE: 32
|
||||
VIEWER_USE_CRASHPAD: "FALSE"
|
||||
cache:
|
||||
key:
|
||||
prefix: windows32
|
||||
|
||||
.win64_build:
|
||||
extends: .win_build
|
||||
variables:
|
||||
AUTOBUILD_ADDRSIZE: 64
|
||||
cache:
|
||||
key:
|
||||
prefix: windows64
|
||||
|
||||
.linux32_build:
|
||||
extends: .linux_build
|
||||
variables:
|
||||
AUTOBUILD_ADDRSIZE: 32
|
||||
cache:
|
||||
key:
|
||||
prefix: linux32
|
||||
|
||||
.linux64_build:
|
||||
extends: .linux_build
|
||||
variables:
|
||||
AUTOBUILD_ADDRSIZE: 64
|
||||
cache:
|
||||
key:
|
||||
prefix: linux64
|
||||
|
||||
.master_rules:
|
||||
rules:
|
||||
- if: $BUILD_CHANNEL || $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: '$CI_PIPELINE_SOURCE == "web"'
|
||||
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
||||
#- if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "push"'
|
||||
# when: delayed
|
||||
# start_in: '12 hours'
|
||||
variables:
|
||||
VIEWER_CHANNEL_TYPE: Test
|
||||
VIEWER_USE_CRASHPAD: "FALSE"
|
||||
|
||||
.project_rules:
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Project" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-project/'
|
||||
variables:
|
||||
VIEWER_CHANNEL_TYPE: Project
|
||||
|
||||
.beta_rules:
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Beta" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-beta/'
|
||||
variables:
|
||||
VIEWER_CHANNEL_TYPE: Beta
|
||||
|
||||
.release_rules:
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Release" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-release/'
|
||||
variables:
|
||||
VIEWER_CHANNEL_TYPE: Release
|
||||
|
||||
.build:master:linux64:
|
||||
extends:
|
||||
- .linux64_build
|
||||
- .master_rules
|
||||
|
||||
build:master:windows32:
|
||||
extends:
|
||||
- .win32_build
|
||||
- .master_rules
|
||||
|
||||
build:master:windows64:
|
||||
extends:
|
||||
- .win64_build
|
||||
- .master_rules
|
||||
|
||||
.build:project:linux64:
|
||||
extends:
|
||||
- .linux64_build
|
||||
- .project_rules
|
||||
|
||||
build:project:windows32:
|
||||
extends:
|
||||
- .win32_build
|
||||
- .project_rules
|
||||
|
||||
build:project:windows64:
|
||||
extends:
|
||||
- .win64_build
|
||||
- .project_rules
|
||||
|
||||
.build:beta:linux64:
|
||||
extends:
|
||||
- .linux64_build
|
||||
- .beta_rules
|
||||
|
||||
build:beta:windows32:
|
||||
extends:
|
||||
- .win32_build
|
||||
- .beta_rules
|
||||
|
||||
build:beta:windows64:
|
||||
extends:
|
||||
- .win64_build
|
||||
- .beta_rules
|
||||
|
||||
.build:release:linux64:
|
||||
extends:
|
||||
- .linux64_build
|
||||
- .release_rules
|
||||
|
||||
build:release:windows32:
|
||||
extends:
|
||||
- .win32_build
|
||||
- .release_rules
|
||||
|
||||
build:release:windows64:
|
||||
extends:
|
||||
- .win64_build
|
||||
- .release_rules
|
||||
|
||||
.upload_template:
|
||||
stage: upload
|
||||
tags:
|
||||
- autobuild
|
||||
- windows
|
||||
allow_failure: false
|
||||
script:
|
||||
- |
|
||||
$BuildData = Get-Content .\build-vc-64\newview\Release\build_data.json | ConvertFrom-Json
|
||||
$BuildChannelVersion = $BuildData."Channel" + ' ' + $BuildData."Version"
|
||||
$UploadDestViewerDir = $BuildChannelVersion.ToLower().Replace(" ", "/")
|
||||
$UploadDestURL = "https://pkg.alchemyviewer.org/repository/viewer/${UploadDestViewerDir}"
|
||||
|
||||
$UploadParams = @{ UseBasicParsing = $true;
|
||||
Method = "PUT";
|
||||
Headers = @{
|
||||
ContentType = "application/x-executable";
|
||||
Authorization = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$env:AUTOBUILD_HTTP_USER`:$env:AUTOBUILD_HTTP_PASS")))"; };
|
||||
Verbose = $true; };
|
||||
|
||||
Function try_upload($build_type, $file_pattern)
|
||||
{
|
||||
$build_newview = ".\build-${build_type}\newview\"
|
||||
If (Test-Path -LiteralPath $build_newview)
|
||||
{
|
||||
Push-Location $build_newview
|
||||
$FileName = Get-ChildItem -Path . -Name -Include $file_pattern
|
||||
Invoke-WebRequest @UploadParams -InFile .\$FileName -Uri "${UploadDestURL}/${FileName}"
|
||||
|
||||
If (($env:VIEWER_USE_CRASHPAD -eq 'TRUE') -and ($build_type -eq "vc-64"))
|
||||
{
|
||||
sentry-cli upload-dif --include-sources singularity-bin.exe singularity-bin.pdb crashpad_handler.exe crashpad_handler.pdb fmod.dll libcrypto-1_1.dll libcrypto-1_1.pdb libssl-1_1.dll libssl-1_1.pdb libcrypto-1_1-x64.dll libcrypto-1_1-x64.pdb libssl-1_1-x64.dll libssl-1_1-x64.pdb vcruntime140.dll msvcp140.dll libhunspell.dll libhunspell.pdb glod.dll
|
||||
}
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
try_upload("linux-64", "Singularity_*.tar.xz")
|
||||
try_upload("vc-64", "Singularity_*_Setup.exe")
|
||||
try_upload("vc-32", "Singularity_*_Setup.exe")
|
||||
|
||||
If ($env:VIEWER_USE_CRASHPAD -eq 'TRUE')
|
||||
{
|
||||
sentry-cli releases new $BuildChannelVersion
|
||||
sentry-cli releases set-commits --auto $BuildChannelVersion
|
||||
sentry-cli releases finalize $BuildChannelVersion
|
||||
}
|
||||
|
||||
upload:project:
|
||||
extends:
|
||||
- .upload_template
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Project" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
when: manual
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-project/'
|
||||
when: manual
|
||||
environment:
|
||||
name: qa
|
||||
|
||||
upload:beta:
|
||||
extends:
|
||||
- .upload_template
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Beta" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
when: manual
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-beta/'
|
||||
when: manual
|
||||
environment:
|
||||
name: beta
|
||||
|
||||
upload:release:
|
||||
extends:
|
||||
- .upload_template
|
||||
rules:
|
||||
- if: '$BUILD_CHANNEL == "Release" && ($CI_PIPELINE_SOURCE == "web" || $CI_PIPELINE_SOURCE == "schedule")'
|
||||
when: manual
|
||||
- if: '$CI_COMMIT_TAG =~ /.*-release/'
|
||||
when: manual
|
||||
environment:
|
||||
name: release
|
||||
14
Pipfile
Normal file
14
Pipfile
Normal file
@@ -0,0 +1,14 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
llbase = "*"
|
||||
certifi = "*"
|
||||
autobuild = {git = "https://git.alchemyviewer.org/alchemy/autobuild.git"}
|
||||
|
||||
[requires]
|
||||
python_version = "2.7"
|
||||
2
README
2
README
@@ -18,7 +18,7 @@ as those based upon the OpenSim platform.
|
||||
Singularity is maintained by a small group of volunteers who can be contacted
|
||||
both, in-world (SingularityViewer group) as well as on IRC (#SingularityViewer
|
||||
@ FreeNode). Bug requests and features requests can be submitted through our
|
||||
Issue Tracker (http://code.google.com/p/singularity-viewer/issues/list or from
|
||||
Issue Tracker (http://links.singularityviewer.org/?to=issues or from
|
||||
the viewer menu: Help --> Bug Reporting --> Singularity Issue Tracker...)
|
||||
|
||||
|
||||
|
||||
1000
autobuild.xml
1000
autobuild.xml
File diff suppressed because it is too large
Load Diff
@@ -236,6 +236,14 @@
|
||||
<boolean>false</boolean>
|
||||
</map>
|
||||
|
||||
<key>ObjectAnimation</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
<string>template</string>
|
||||
<key>trusted-sender</key>
|
||||
<boolean>false</boolean>
|
||||
</map>
|
||||
|
||||
<key>AvatarAppearance</key>
|
||||
<map>
|
||||
<key>flavor</key>
|
||||
|
||||
@@ -3,12 +3,7 @@
|
||||
# cmake_minimum_required should appear before any
|
||||
# other commands to guarantee full compatibility
|
||||
# with the version specified
|
||||
## prior to 2.8, the add_custom_target commands used in setting the version did not work correctly
|
||||
if(WIN32)
|
||||
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
set(ROOT_PROJECT_NAME "Singularity" CACHE STRING
|
||||
"The root project/makefile/solution name. Defaults to Singularity.")
|
||||
@@ -16,14 +11,21 @@ project(${ROOT_PROJECT_NAME})
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
include(Variables)
|
||||
include(BuildVersion)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
"Build type. One of: Debug Release RelWithDebInfo" FORCE)
|
||||
endif (NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
include(Variables)
|
||||
include(00-Common)
|
||||
include(BuildVersion)
|
||||
include(CTest)
|
||||
|
||||
add_subdirectory(deps)
|
||||
|
||||
add_subdirectory(cmake)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}aistatemachine)
|
||||
add_subdirectory(${LIBS_OPEN_PREFIX}llaudio)
|
||||
@@ -58,5 +60,10 @@ add_subdirectory(${LIBS_OPEN_PREFIX}plugins)
|
||||
|
||||
add_subdirectory(${VIEWER_PREFIX}newview/statemachine)
|
||||
add_subdirectory(${VIEWER_PREFIX}newview)
|
||||
add_dependencies(viewer singularity-bin)
|
||||
add_dependencies(viewer ${VIEWER_BINARY_NAME})
|
||||
|
||||
|
||||
if (WINDOWS)
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PROPERTY VS_STARTUP_PROJECT ${VIEWER_BINARY_NAME})
|
||||
endif (WINDOWS)
|
||||
|
||||
@@ -39,3 +39,9 @@ set_source_files_properties(${aistatemachine_HEADER_FILES}
|
||||
list(APPEND aistatemachine_SOURCE_FILES ${aistatemachine_HEADER_FILES})
|
||||
|
||||
add_library (aistatemachine ${aistatemachine_SOURCE_FILES})
|
||||
|
||||
target_link_libraries(
|
||||
aistatemachine
|
||||
PUBLIC
|
||||
llcommon
|
||||
)
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
|
||||
set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
include(Variables)
|
||||
|
||||
|
||||
# Portable compilation flags.
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -DLL_DEBUG=1")
|
||||
@@ -18,27 +18,11 @@ set(CMAKE_C_FLAGS_RELEASE
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"-DLL_RELEASE=1 -D_SECURE_SCL=0 -DNDEBUG -DLL_RELEASE_WITH_DEBUG_INFO=1")
|
||||
|
||||
# Configure crash reporting
|
||||
set(RELEASE_CRASH_REPORTING OFF CACHE BOOL "Enable use of crash reporting in release builds")
|
||||
set(NON_RELEASE_CRASH_REPORTING OFF CACHE BOOL "Enable use of crash reporting in developer builds")
|
||||
|
||||
if(RELEASE_CRASH_REPORTING)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DLL_SEND_CRASH_REPORTS=1")
|
||||
endif()
|
||||
|
||||
if(NON_RELEASE_CRASH_REPORTING)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DLL_SEND_CRASH_REPORTS=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLL_SEND_CRASH_REPORTS=1")
|
||||
endif()
|
||||
|
||||
|
||||
# Don't bother with a MinSizeRel build.
|
||||
|
||||
set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release;Debug" CACHE STRING
|
||||
"Supported build types." FORCE)
|
||||
|
||||
# Platform-specific compilation flags.
|
||||
|
||||
if (WINDOWS)
|
||||
# Don't build DLLs.
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
@@ -55,9 +39,17 @@ if (WINDOWS)
|
||||
"${CMAKE_C_FLAGS_RELEASE} ${LL_C_FLAGS} /O2 /Zi /MD /MP /fp:fast"
|
||||
CACHE STRING "C compiler release options" FORCE)
|
||||
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
|
||||
if (FULL_DEBUG_SYMS OR USE_CRASHPAD)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG:FULL")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG:FULL")
|
||||
else ()
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG:FASTLINK")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG:FASTLINK")
|
||||
endif ()
|
||||
|
||||
if (USE_LTO)
|
||||
if(INCREMENTAL_LINK)
|
||||
@@ -88,10 +80,12 @@ if (WINDOWS)
|
||||
/DNOMINMAX
|
||||
/DUNICODE
|
||||
/D_UNICODE
|
||||
/DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
|
||||
/GS
|
||||
/TP
|
||||
/W3
|
||||
/c
|
||||
/Zc:__cplusplus
|
||||
/Zc:forScope
|
||||
/Zc:rvalueCast
|
||||
/Zc:wchar_t
|
||||
@@ -110,9 +104,9 @@ if (WINDOWS)
|
||||
)
|
||||
endif (USE_LTO)
|
||||
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
add_compile_options(/arch:SSE2)
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
|
||||
if (NOT DISABLE_FATAL_WARNINGS)
|
||||
add_definitions(/WX)
|
||||
@@ -128,21 +122,28 @@ set (GCC_EXTRA_OPTIMIZATIONS "-ffast-math")
|
||||
if (LINUX)
|
||||
set(CMAKE_SKIP_RPATH TRUE)
|
||||
|
||||
add_compile_options(
|
||||
-fvisibility=hidden
|
||||
-fexceptions
|
||||
-fno-math-errno
|
||||
-fno-strict-aliasing
|
||||
-fsigned-char
|
||||
-g
|
||||
-pthread
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DLL_LINUX=1
|
||||
-DAPPID=secondlife
|
||||
-D_REENTRANT
|
||||
-fexceptions
|
||||
-fno-math-errno
|
||||
-fno-strict-aliasing
|
||||
-fsigned-char
|
||||
-fvisibility=hidden
|
||||
-g
|
||||
-pthread
|
||||
)
|
||||
-DLL_LINUX=1
|
||||
-DAPPID=secondlife
|
||||
-D_REENTRANT
|
||||
-DGDK_DISABLE_DEPRECATED
|
||||
-DGTK_DISABLE_DEPRECATED
|
||||
-DGSEAL_ENABLE
|
||||
-DGTK_DISABLE_SINGLE_INCLUDES
|
||||
)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2")
|
||||
|
||||
@@ -199,37 +200,40 @@ if (LINUX)
|
||||
|
||||
# End of hacks.
|
||||
|
||||
if (NOT STANDALONE)
|
||||
# this stops us requiring a really recent glibc at runtime
|
||||
add_definitions(-fno-stack-protector)
|
||||
endif (NOT STANDALONE)
|
||||
CHECK_C_COMPILER_FLAG(-fstack-protector-strong HAS_STRONG_STACK_PROTECTOR)
|
||||
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
if(HAS_STRONG_STACK_PROTECTOR)
|
||||
add_compile_options(-fstack-protector-strong)
|
||||
endif(HAS_STRONG_STACK_PROTECTOR)
|
||||
endif (${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||
|
||||
if (${ARCH} STREQUAL "x86_64")
|
||||
add_definitions(-pipe)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -msse4.1")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math -msse4.1")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -ffast-math -msse4.1")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -ffast-math -msse4.1")
|
||||
else (${ARCH} STREQUAL "x86_64")
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -march=pentium4")
|
||||
endif (NOT STANDALONE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse2 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse3")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse3 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -mfpmath=sse,387 -msse3 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse3 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -mfpmath=sse,387 -msse3 ${GCC_EXTRA_OPTIMIZATIONS}")
|
||||
endif (${ARCH} STREQUAL "x86_64")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse2")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse3")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline -msse3")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}${MARCH_FLAG} -msse3")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}${MARCH_FLAG} -msse3")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse3")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}${MARCH_FLAG} -msse3")
|
||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
|
||||
if (NOT STANDALONE)
|
||||
set(MARCH_FLAG " -axsse4.1 -msse2")
|
||||
set(MARCH_FLAG " -axsse4.1 -msse3")
|
||||
endif (NOT STANDALONE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}${MARCH_FLAG} -fno-inline-functions")
|
||||
@@ -293,19 +297,26 @@ if (LINUX OR DARWIN)
|
||||
|
||||
set(CMAKE_C_FLAGS "${UNIX_WARNINGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${UNIX_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}")
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
||||
elseif (WORD_SIZE EQUAL 64)
|
||||
elseif (ADDRESS_SIZE EQUAL 64)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
endif (LINUX OR DARWIN)
|
||||
|
||||
|
||||
if (STANDALONE)
|
||||
add_definitions(-DLL_STANDALONE=1)
|
||||
else (STANDALONE)
|
||||
#Enforce compile-time correctness for fmt strings
|
||||
add_definitions(-DFMT_STRING_ALIAS=1)
|
||||
|
||||
if(USE_CRASHPAD)
|
||||
add_definitions(-DUSE_CRASHPAD=1 -DCRASHPAD_URL="${CRASHPAD_URL}")
|
||||
endif()
|
||||
|
||||
set(${ARCH}_linux_INCLUDES
|
||||
atk-1.0
|
||||
cairo
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
if (LINUX)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(OGG REQUIRED ogg)
|
||||
pkg_check_modules(VORBIS REQUIRED vorbis)
|
||||
pkg_check_modules(VORBISENC REQUIRED vorbisenc)
|
||||
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)
|
||||
else (STANDALONE)
|
||||
else (LINUX)
|
||||
use_prebuilt_binary(ogg_vorbis)
|
||||
set(VORBIS_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
set(VORBISENC_INCLUDE_DIRS ${VORBIS_INCLUDE_DIRS})
|
||||
@@ -32,7 +32,7 @@ else (STANDALONE)
|
||||
set(VORBISENC_LIBRARIES vorbisenc)
|
||||
set(VORBISFILE_LIBRARIES vorbisfile)
|
||||
endif (WINDOWS)
|
||||
endif (STANDALONE)
|
||||
endif (LINUX)
|
||||
|
||||
link_directories(
|
||||
${VORBIS_LIBRARY_DIRS}
|
||||
|
||||
38
indra/cmake/BuildBranding.cmake
Normal file
38
indra/cmake/BuildBranding.cmake
Normal file
@@ -0,0 +1,38 @@
|
||||
# -*- cmake -*-
|
||||
if (WINDOWS)
|
||||
#message(WARNING, ${CMAKE_CURRENT_BINARY_DIR}/newview/viewerRes.rc.in)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/res/viewerRes.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/viewerRes.rc
|
||||
)
|
||||
endif (WINDOWS)
|
||||
|
||||
if (DARWIN)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/English.lproj/InfoPlist.strings.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/English.lproj/InfoPlist.strings
|
||||
)
|
||||
endif (DARWIN)
|
||||
|
||||
if (LINUX)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/linux_tools/wrapper.sh.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/linux_tools/wrapper.sh
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/linux_tools/handle_secondlifeprotocol.sh.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/linux_tools/handle_secondlifeprotocol.sh
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/linux_tools/install.sh.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/linux_tools/install.sh
|
||||
@ONLY
|
||||
)
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/newview/linux_tools/refresh_desktop_app_entry.sh.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/linux_tools/refresh_desktop_app_entry.sh
|
||||
@ONLY
|
||||
)
|
||||
endif (LINUX)
|
||||
@@ -3,9 +3,18 @@
|
||||
include(Python)
|
||||
include(Variables)
|
||||
|
||||
# packages-formatter.py runs autobuild install --versions, which needs to know
|
||||
# the build_directory, which (on Windows) depends on AUTOBUILD_ADDRSIZE.
|
||||
# Within an autobuild build, AUTOBUILD_ADDRSIZE is already set. But when
|
||||
# building in an IDE, it probably isn't. Set it explicitly using
|
||||
# run_build_test.py.
|
||||
add_custom_command(OUTPUT packages-info.txt
|
||||
COMMENT "Generating packages-info.txt for the about box"
|
||||
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/../autobuild.xml
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/../scripts/packages-formatter.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/../scripts/packages-formatter.py -p=${AUTOBUILD_PLATFORM_NAME} > packages-info.txt
|
||||
${CMAKE_SOURCE_DIR}/../autobuild.xml
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${CMAKE_SOURCE_DIR}/cmake/run_build_test.py -DAUTOBUILD_ADDRSIZE=${ADDRESS_SIZE}
|
||||
${PYTHON_EXECUTABLE}
|
||||
${CMAKE_SOURCE_DIR}/../scripts/packages-formatter.py "${VIEWER_CHANNEL}" "${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION}" > packages-info.txt
|
||||
)
|
||||
|
||||
@@ -46,6 +46,7 @@ if (NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/n
|
||||
|
||||
set(VIEWER_CHANNEL_VERSION_DEFINES
|
||||
"LL_VIEWER_CHANNEL=\"${VIEWER_CHANNEL}\""
|
||||
"LL_VIEWER_CHANNEL_GRK=L\"${VIEWER_CHANNEL_GRK}\""
|
||||
"LL_VIEWER_VERSION_MAJOR=${VIEWER_VERSION_MAJOR}"
|
||||
"LL_VIEWER_VERSION_MINOR=${VIEWER_VERSION_MINOR}"
|
||||
"LL_VIEWER_VERSION_PATCH=${VIEWER_VERSION_PATCH}"
|
||||
|
||||
@@ -6,7 +6,7 @@ if (USESYSTEMLIBS)
|
||||
set(CEFPLUGIN OFF CACHE BOOL
|
||||
"CEFPLUGIN support for the llplugin/llmedia test apps.")
|
||||
else (USESYSTEMLIBS)
|
||||
use_prebuilt_binary(llceflib)
|
||||
use_prebuilt_binary(dullahan)
|
||||
set(CEFPLUGIN ON CACHE BOOL
|
||||
"CEFPLUGIN support for the llplugin/llmedia test apps.")
|
||||
set(CEF_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/cef)
|
||||
@@ -16,7 +16,7 @@ if (WINDOWS)
|
||||
set(CEF_PLUGIN_LIBRARIES
|
||||
libcef.lib
|
||||
libcef_dll_wrapper.lib
|
||||
llceflib.lib
|
||||
dullahan.lib
|
||||
)
|
||||
elseif (DARWIN)
|
||||
FIND_LIBRARY(APPKIT_LIBRARY AppKit)
|
||||
@@ -31,15 +31,15 @@ elseif (DARWIN)
|
||||
|
||||
set(CEF_PLUGIN_LIBRARIES
|
||||
${ARCH_PREBUILT_DIRS_RELEASE}/libcef_dll_wrapper.a
|
||||
${ARCH_PREBUILT_DIRS_RELEASE}/libLLCefLib.a
|
||||
${ARCH_PREBUILT_DIRS_RELEASE}/libdullahan.a
|
||||
${APPKIT_LIBRARY}
|
||||
${CEF_LIBRARY}
|
||||
)
|
||||
|
||||
elseif (LINUX)
|
||||
set(CEF_PLUGIN_LIBRARIES
|
||||
llceflib
|
||||
cef_dll_wrapper
|
||||
dullahan
|
||||
cef_dll_wrapper.a
|
||||
cef
|
||||
)
|
||||
endif (WINDOWS)
|
||||
|
||||
@@ -13,43 +13,43 @@ set(cmake_SOURCE_FILES
|
||||
Audio.cmake
|
||||
BasicPluginBase.cmake
|
||||
Boost.cmake
|
||||
BuildBranding.cmake
|
||||
BuildVersion.cmake
|
||||
CARes.cmake
|
||||
CEFPlugin.cmake
|
||||
CMakeCopyIfDifferent.cmake
|
||||
CURL.cmake
|
||||
Colladadom.cmake
|
||||
ConfigurePkgConfig.cmake
|
||||
CURL.cmake
|
||||
Copy3rdPartyLibs.cmake
|
||||
CrashPad.cmake
|
||||
Cwdebug.cmake
|
||||
DBusGlib.cmake
|
||||
DeploySharedLibs.cmake
|
||||
EXPAT.cmake
|
||||
ExamplePlugin.cmake
|
||||
FMODSTUDIO.cmake
|
||||
FindAPR.cmake
|
||||
FindAutobuild.cmake
|
||||
FindCARes.cmake
|
||||
FindColladadom.cmake
|
||||
FindGLOD.cmake
|
||||
FindGoogleBreakpad.cmake
|
||||
FindGooglePerfTools.cmake
|
||||
FindHunSpell.cmake
|
||||
FindJsonCpp.cmake
|
||||
FindNDOF.cmake
|
||||
FindOpenJPEG.cmake
|
||||
FindTut.cmake
|
||||
FindURIPARSER.cmake
|
||||
FindXmlRpcEpi.cmake
|
||||
FMODSTUDIO.cmake
|
||||
FreeType.cmake
|
||||
GeneratePrecompiledHeader.cmake
|
||||
GLOD.cmake
|
||||
GStreamer010Plugin.cmake
|
||||
Glui.cmake
|
||||
Glut.cmake
|
||||
GoogleBreakpad.cmake
|
||||
GooglePerfTools.cmake
|
||||
Hunspell.cmake
|
||||
JPEG.cmake
|
||||
JsonCpp.cmake
|
||||
LLAddBuildTest.cmake
|
||||
LLAppearance.cmake
|
||||
LLAudio.cmake
|
||||
@@ -64,7 +64,6 @@ set(cmake_SOURCE_FILES
|
||||
LLPlugin.cmake
|
||||
LLPrimitive.cmake
|
||||
LLPhysicsExtensions.cmake
|
||||
LLSharedLibs.cmake
|
||||
LLRender.cmake
|
||||
LLSharedLibs.cmake
|
||||
LLUI.cmake
|
||||
@@ -85,16 +84,16 @@ set(cmake_SOURCE_FILES
|
||||
Prebuilt.cmake
|
||||
PulseAudio.cmake
|
||||
Python.cmake
|
||||
QuickTimePlugin.cmake
|
||||
RunBuildTest.cmake
|
||||
StateMachine.cmake
|
||||
TemplateCheck.cmake
|
||||
Tut.cmake
|
||||
UI.cmake
|
||||
UnixInstall.cmake
|
||||
URIPARSER.cmake
|
||||
Variables.cmake
|
||||
ViewerMiscLibs.cmake
|
||||
WinManifest.cmake
|
||||
LibVLCPlugin.cmake
|
||||
XmlRpcEpi.cmake
|
||||
ZLIB.cmake
|
||||
)
|
||||
|
||||
@@ -10,8 +10,8 @@ else (STANDALONE)
|
||||
use_prebuilt_binary(curl)
|
||||
if (WINDOWS)
|
||||
set(CURL_LIBRARIES
|
||||
debug libcurld
|
||||
optimized libcurl)
|
||||
debug libcurl_a_debug
|
||||
optimized libcurl_a)
|
||||
else (WINDOWS)
|
||||
use_prebuilt_binary(libidn)
|
||||
set(CURL_LIBRARIES curl idn)
|
||||
|
||||
@@ -6,17 +6,17 @@ SET(DEBUG_PKG_CONFIG "YES")
|
||||
IF("$ENV{PKG_CONFIG_LIBDIR}" STREQUAL "")
|
||||
|
||||
# Guess at architecture-specific system library paths.
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
SET(PKG_CONFIG_NO_MULTI_GUESS /usr/lib32 /usr/lib)
|
||||
SET(PKG_CONFIG_NO_MULTI_LOCAL_GUESS /usr/local/lib32 /usr/local/lib)
|
||||
SET(PKG_CONFIG_MULTI_GUESS /usr/lib/i386-linux-gnu)
|
||||
SET(PKG_CONFIG_MULTI_LOCAL_GUESS /usr/local/lib/i386-linux-gnu)
|
||||
else (WORD_SIZE EQUAL 32)
|
||||
else (ADDRESS_SIZE EQUAL 32)
|
||||
SET(PKG_CONFIG_NO_MULTI_GUESS /usr/lib64 /usr/lib)
|
||||
SET(PKG_CONFIG_NO_MULTI_LOCAL_GUESS /usr/local/lib64 /usr/local/lib)
|
||||
SET(PKG_CONFIG_MULTI_GUESS /usr/lib/x86_64-linux-gnu)
|
||||
SET(PKG_CONFIG_MULTI_LOCAL_GUESS /usr/local/lib/x86_64-linux-gnu)
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
|
||||
# Use DPKG architecture, if available.
|
||||
IF (${DPKG_ARCH})
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
include(CMakeCopyIfDifferent)
|
||||
include(Linking)
|
||||
include(Variables)
|
||||
include(LLCommon)
|
||||
|
||||
###################################################################
|
||||
# set up platform specific lists of files that need to be copied
|
||||
@@ -20,14 +22,19 @@ if(WINDOWS)
|
||||
set(vivox_src_dir "${ARCH_PREBUILT_DIRS_RELEASE}")
|
||||
set(vivox_files
|
||||
SLVoice.exe
|
||||
ca-bundle.crt
|
||||
libsndfile-1.dll
|
||||
vivoxplatform.dll
|
||||
vivoxsdk.dll
|
||||
ortp.dll
|
||||
zlib1.dll
|
||||
vivoxoal.dll
|
||||
)
|
||||
if (ADDRESS_SIZE EQUAL 64)
|
||||
list(APPEND vivox_files
|
||||
vivoxsdk_x64.dll
|
||||
ortp_x64.dll
|
||||
)
|
||||
else (ADDRESS_SIZE EQUAL 64)
|
||||
list(APPEND vivox_files
|
||||
vivoxsdk.dll
|
||||
ortp.dll
|
||||
)
|
||||
endif (ADDRESS_SIZE EQUAL 64)
|
||||
|
||||
#*******************************
|
||||
# Misc shared libs
|
||||
@@ -37,8 +44,6 @@ if(WINDOWS)
|
||||
libapr-1.dll
|
||||
libaprutil-1.dll
|
||||
libapriconv-1.dll
|
||||
ssleay32.dll
|
||||
libeay32.dll
|
||||
glod.dll
|
||||
libhunspell.dll
|
||||
)
|
||||
@@ -48,26 +53,45 @@ if(WINDOWS)
|
||||
libapr-1.dll
|
||||
libaprutil-1.dll
|
||||
libapriconv-1.dll
|
||||
ssleay32.dll
|
||||
libeay32.dll
|
||||
glod.dll
|
||||
libhunspell.dll
|
||||
)
|
||||
|
||||
if(ADDRESS_SIZE EQUAL 64)
|
||||
list(APPEND debug_files
|
||||
libcrypto-1_1-x64.dll
|
||||
libssl-1_1-x64.dll
|
||||
)
|
||||
list(APPEND release_files
|
||||
libcrypto-1_1-x64.dll
|
||||
libssl-1_1-x64.dll
|
||||
)
|
||||
else(ADDRESS_SIZE EQUAL 64)
|
||||
list(APPEND debug_files
|
||||
libcrypto-1_1.dll
|
||||
libssl-1_1.dll
|
||||
)
|
||||
list(APPEND release_files
|
||||
libcrypto-1_1.dll
|
||||
libssl-1_1.dll
|
||||
)
|
||||
endif(ADDRESS_SIZE EQUAL 64)
|
||||
|
||||
if(NOT DISABLE_TCMALLOC)
|
||||
set(debug_files ${debug_files} libtcmalloc_minimal-debug.dll)
|
||||
set(release_files ${release_files} libtcmalloc_minimal.dll)
|
||||
list(APPEND debug_files libtcmalloc_minimal-debug.dll)
|
||||
list(APPEND release_files libtcmalloc_minimal.dll)
|
||||
endif(NOT DISABLE_TCMALLOC)
|
||||
|
||||
if (FMODSTUDIO)
|
||||
if(WORD_SIZE STREQUAL 64)
|
||||
set(debug_files ${debug_files} fmodL64.dll)
|
||||
set(release_files ${release_files} fmod64.dll)
|
||||
else(WORD_SIZE STREQUAL 64)
|
||||
set(debug_files ${debug_files} fmodL.dll)
|
||||
set(release_files ${release_files} fmod.dll)
|
||||
endif(WORD_SIZE STREQUAL 64)
|
||||
endif (FMODSTUDIO)
|
||||
if(OPENAL)
|
||||
list(APPEND debug_files alut.dll OpenAL32.dll)
|
||||
list(APPEND release_files alut.dll OpenAL32.dll)
|
||||
endif(OPENAL)
|
||||
|
||||
if (USE_FMODSTUDIO)
|
||||
list(APPEND debug_files fmodL.dll)
|
||||
list(APPEND release_files fmod.dll)
|
||||
endif (USE_FMODSTUDIO)
|
||||
|
||||
elseif(DARWIN)
|
||||
set(SHARED_LIB_STAGING_DIR_DEBUG "${SHARED_LIB_STAGING_DIR}/Debug/Resources")
|
||||
set(SHARED_LIB_STAGING_DIR_RELWITHDEBINFO "${SHARED_LIB_STAGING_DIR}/RelWithDebInfo/Resources")
|
||||
@@ -100,10 +124,10 @@ elseif(DARWIN)
|
||||
libndofdev.dylib
|
||||
)
|
||||
|
||||
if (FMODSTUDIO)
|
||||
set(debug_files ${debug_files} libfmodL.dylib)
|
||||
set(release_files ${release_files} libfmod.dylib)
|
||||
endif (FMODSTUDIO)
|
||||
if (USE_FMODSTUDIO)
|
||||
list(APPEND debug_files libfmodL.dylib)
|
||||
list(APPEND release_files libfmod.dylib)
|
||||
endif (USE_FMODSTUDIO)
|
||||
|
||||
elseif(LINUX)
|
||||
# linux is weird, multiple side by side configurations aren't supported
|
||||
@@ -120,7 +144,6 @@ elseif(LINUX)
|
||||
libvivoxplatform.so
|
||||
libvivoxsdk.so
|
||||
SLVoice
|
||||
# ca-bundle.crt #No cert for linux. It is actually still 3.2SDK.
|
||||
)
|
||||
# *TODO - update this to use LIBS_PREBUILT_DIR and LL_ARCH_DIR variables
|
||||
# or ARCH_PREBUILT_DIRS
|
||||
@@ -134,29 +157,20 @@ elseif(LINUX)
|
||||
set(release_files
|
||||
libapr-1.so.0
|
||||
libaprutil-1.so.0
|
||||
libatk-1.0.so
|
||||
libexpat.so
|
||||
libexpat.so.1
|
||||
libfreetype.so.6.12.3
|
||||
libfreetype.so.6
|
||||
libfreetype.so
|
||||
libGLOD.so
|
||||
libgmodule-2.0.so
|
||||
libgobject-2.0.so
|
||||
libopenal.so
|
||||
libfontconfig.so.1.8.0
|
||||
libfontconfig.so.1
|
||||
libfontconfig.so
|
||||
)
|
||||
|
||||
if (USE_TCMALLOC)
|
||||
set(release_files ${release_files} "libtcmalloc_minimal.so")
|
||||
list(APPEND release_files "libtcmalloc_minimal.so")
|
||||
endif (USE_TCMALLOC)
|
||||
|
||||
if (FMODSTUDIO)
|
||||
set(debug_files ${debug_files} "libfmodL.so")
|
||||
set(release_files ${release_files} "libfmod.so")
|
||||
endif (FMODSTUDIO)
|
||||
if (USE_FMODSTUDIO)
|
||||
list(APPEND debug_files "libfmodL.so")
|
||||
list(APPEND release_files "libfmod.so")
|
||||
endif (USE_FMODSTUDIO)
|
||||
|
||||
else(WINDOWS)
|
||||
message(STATUS "WARNING: unrecognized platform for staging 3rd party libs, skipping...")
|
||||
@@ -209,13 +223,13 @@ set(third_party_targets ${third_party_targets} ${out_targets})
|
||||
|
||||
|
||||
|
||||
copy_if_different(
|
||||
${debug_src_dir}
|
||||
"${SHARED_LIB_STAGING_DIR_DEBUG}"
|
||||
out_targets
|
||||
${debug_files}
|
||||
)
|
||||
set(third_party_targets ${third_party_targets} ${out_targets})
|
||||
#copy_if_different(
|
||||
# ${debug_src_dir}
|
||||
# "${SHARED_LIB_STAGING_DIR_DEBUG}"
|
||||
# out_targets
|
||||
# ${debug_files}
|
||||
# )
|
||||
#set(third_party_targets ${third_party_targets} ${out_targets})
|
||||
|
||||
copy_if_different(
|
||||
${release_src_dir}
|
||||
|
||||
22
indra/cmake/CrashPad.cmake
Normal file
22
indra/cmake/CrashPad.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
include(Variables)
|
||||
|
||||
if(USE_CRASHPAD)
|
||||
|
||||
if (USESYSTEMLIBS)
|
||||
else (USESYSTEMLIBS)
|
||||
use_prebuilt_binary(crashpad)
|
||||
if (WINDOWS)
|
||||
set(CRASHPAD_LIBRARIES
|
||||
debug client.lib util.lib base.lib
|
||||
optimized client.lib util.lib base.lib)
|
||||
elseif (LINUX)
|
||||
|
||||
else (DARWIN)
|
||||
|
||||
endif ()
|
||||
set(CRASHPAD_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/crashpad)
|
||||
endif (USESYSTEMLIBS)
|
||||
|
||||
endif()
|
||||
@@ -1,24 +1,11 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
if (LINUX)
|
||||
include(FindPkgConfig)
|
||||
|
||||
pkg_check_modules(DBUSGLIB REQUIRED dbus-glib-1)
|
||||
|
||||
elseif (LINUX)
|
||||
use_prebuilt_binary(dbus-glib)
|
||||
set(DBUSGLIB_FOUND ON FORCE BOOL)
|
||||
set(DBUSGLIB_INCLUDE_DIRS
|
||||
${LIBS_PREBUILT_DIR}/include/dbus
|
||||
)
|
||||
# We don't need to explicitly link against dbus-glib itself, because
|
||||
# the viewer probes for the system's copy at runtime.
|
||||
set(DBUSGLIB_LIBRARIES
|
||||
gobject-2.0
|
||||
glib-2.0
|
||||
)
|
||||
endif (STANDALONE)
|
||||
endif (LINUX)
|
||||
|
||||
if (DBUSGLIB_FOUND)
|
||||
set(DBUSGLIB ON CACHE BOOL "Build with dbus-glib message bus support.")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Variables)
|
||||
if (FMODSTUDIO)
|
||||
if (USE_FMODSTUDIO)
|
||||
use_prebuilt_binary(fmodstudio)
|
||||
if(WINDOWS)
|
||||
set(lib_suffix .dll)
|
||||
@@ -11,13 +11,8 @@ if (FMODSTUDIO)
|
||||
set(lib_suffix .so)
|
||||
endif(WINDOWS)
|
||||
if(WINDOWS)
|
||||
if(WORD_SIZE EQUAL 64)
|
||||
set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmod64${lib_suffix})
|
||||
set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodL64${lib_suffix})
|
||||
else(WORD_SIZE EQUAL 64)
|
||||
set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmod${lib_suffix})
|
||||
set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodL${lib_suffix})
|
||||
endif(WORD_SIZE EQUAL 64)
|
||||
set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/fmod${lib_suffix})
|
||||
set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/fmodL${lib_suffix})
|
||||
else(WINDOWS)
|
||||
set(FMOD_LIBRARY_RELEASE ${LIBS_PREBUILT_DIR}/lib/release/libfmod${lib_suffix})
|
||||
set(FMOD_LIBRARY_DEBUG ${LIBS_PREBUILT_DIR}/lib/debug/libfmodL${lib_suffix})
|
||||
@@ -35,22 +30,21 @@ if (FMODSTUDIO)
|
||||
optimized ${FMOD_LINK_LIBRARY_RELEASE}
|
||||
)
|
||||
|
||||
set(FMOD_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/fmodstudio)
|
||||
endif(FMODSTUDIO)
|
||||
set(FMODSTUDIO_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/fmodstudio)
|
||||
endif(USE_FMODSTUDIO)
|
||||
|
||||
if(FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR)
|
||||
if(FMOD_LIBRARY_RELEASE AND FMODSTUDIO_INCLUDE_DIR)
|
||||
set(FMOD ON)
|
||||
if (NOT FMOD_LIBRARY_DEBUG) #Use release library in debug configuration if debug library is absent.
|
||||
set(FMOD_LIBRARY_DEBUG ${FMOD_LIBRARY_RELEASE})
|
||||
endif (NOT FMOD_LIBRARY_DEBUG)
|
||||
else (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR)
|
||||
else (FMOD_LIBRARY_RELEASE AND FMODSTUDIO_INCLUDE_DIR)
|
||||
message(STATUS "No support for FMOD Studio audio (need to set FMODSTUDIO_SDK_DIR?)")
|
||||
set(FMOD OFF)
|
||||
set(FMODSTUDIO OFF)
|
||||
endif (FMOD_LIBRARY_RELEASE AND FMOD_INCLUDE_DIR)
|
||||
set(USE_FMODSTUDIO OFF)
|
||||
endif (FMOD_LIBRARY_RELEASE AND FMODSTUDIO_INCLUDE_DIR)
|
||||
|
||||
if (FMOD)
|
||||
message(STATUS "Building with FMOD Studio audio support")
|
||||
set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMODSTUDIO=1")
|
||||
endif (FMOD)
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
# - Find Google BreakPad
|
||||
# Find the Google BreakPad includes and library
|
||||
# This module defines
|
||||
# BREAKPAD_INCLUDE_DIRECTORIES, where to find the Goole BreakPad includes.
|
||||
# BREAKPAD_EXCEPTION_HANDLER_LIBRARIES, the libraries needed to use Google BreakPad.
|
||||
# BREAKPAD_EXCEPTION_HANDLER_FOUND, If false, do not try to use Google BreakPad.
|
||||
# also defined, but not for general use are
|
||||
# BREAKPAD_EXCEPTION_HANDLER_LIBRARY, where to find the Google BreakPad library.
|
||||
|
||||
FIND_PATH(BREAKPAD_INCLUDE_DIRECTORIES common/using_std_string.h PATH_SUFFIXES google_breakpad)
|
||||
|
||||
SET(BREAKPAD_EXCEPTION_HANDLER_NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES} breakpad_client)
|
||||
FIND_LIBRARY(BREAKPAD_EXCEPTION_HANDLER_LIBRARY
|
||||
NAMES ${BREAKPAD_EXCEPTION_HANDLER_NAMES}
|
||||
)
|
||||
|
||||
IF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_INCLUDE_DIRECTORIES)
|
||||
SET(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES ${BREAKPAD_EXCEPTION_HANDLER_LIBRARY})
|
||||
SET(BREAKPAD_EXCEPTION_HANDLER_FOUND "YES")
|
||||
ELSE (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_INCLUDE_DIRECTORIES)
|
||||
SET(BREAKPAD_EXCEPTION_HANDLER_FOUND "NO")
|
||||
ENDIF (BREAKPAD_EXCEPTION_HANDLER_LIBRARY AND BREAKPAD_INCLUDE_DIRECTORIES)
|
||||
|
||||
|
||||
IF (BREAKPAD_EXCEPTION_HANDLER_FOUND)
|
||||
IF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Google BreakPad: ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES}")
|
||||
ENDIF (NOT BREAKPAD_EXCEPTION_HANDLER_FIND_QUIETLY)
|
||||
ELSE (BREAKPAD_EXCEPTION_HANDLER_FOUND)
|
||||
IF (BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find Google BreakPad library")
|
||||
ENDIF (BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED)
|
||||
ENDIF (BREAKPAD_EXCEPTION_HANDLER_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
BREAKPAD_EXCEPTION_HANDLER_LIBRARY
|
||||
BREAKPAD_INCLUDE_DIRECTORIES
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
# - Find JSONCpp
|
||||
# Find the JSONCpp includes and library
|
||||
# This module defines
|
||||
# JSONCPP_FOUND, System has libjsoncpp.
|
||||
# JSONCPP_INCLUDE_DIRS - The libjsoncpp include directories.
|
||||
# JSONCPP_LIBRARIES - The libraries needed to use libjsoncpp.
|
||||
# JSONCPP_DEFINITIONS - Compiler switches required for using libjsoncpp.
|
||||
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
PKG_CHECK_MODULES(PC_JSONCPP jsoncpp)
|
||||
SET(JSONCPP_DEFINITIONS ${PC_JSONCPP_CFLAGS_OTHER})
|
||||
|
||||
FIND_PATH(JSONCPP_INCLUDE_DIR json/reader.h
|
||||
HINTS ${PC_JSONCPP_INCLUDE_DIR} ${PC_JSONCPP_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES jsoncpp)
|
||||
|
||||
# Get the GCC compiler version
|
||||
EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
|
||||
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
|
||||
OUTPUT_VARIABLE _gcc_COMPILER_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# Try to find a library that was compiled with the same compiler version as we currently use.
|
||||
FIND_LIBRARY(JSONCPP_LIBRARY
|
||||
NAMES libjson_linux-gcc-${_gcc_COMPILER_VERSION}_libmt.so libjsoncpp.so
|
||||
HINTS ${PC_JSONCPP_LIBDIR} ${PC_JSONCPP_LIBRARY_DIRS}
|
||||
PATHS /usr/lib /usr/local/lib)
|
||||
|
||||
SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARY})
|
||||
SET(JSONCPP_INCLUDE_DIRS ${JSONCPP_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(JSONCPP DEFAULT_MSG
|
||||
JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR)
|
||||
46
indra/cmake/FindURIPARSER.cmake
Normal file
46
indra/cmake/FindURIPARSER.cmake
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
# - Find uriparser
|
||||
# Find the URIPARSER includes and library
|
||||
# This module defines
|
||||
# URIPARSER_INCLUDE_DIRS, where to find uriparser.h, etc.
|
||||
# URIPARSER_LIBRARY, the libraries needed to use uriparser.
|
||||
# URIPARSER_FOUND, If false, do not try to use uriparser.
|
||||
#
|
||||
# This FindURIPARSER is about 43 times as fast the one provided with cmake (2.8.x),
|
||||
# because it doesn't look up the version of uriparser, resulting in a dramatic
|
||||
# speed up for configure (from 4 minutes 22 seconds to 6 seconds).
|
||||
#
|
||||
# Note: Since this file is only used for standalone, the windows
|
||||
# specific parts were left out.
|
||||
|
||||
FIND_PATH(URIPARSER_INCLUDE_DIR uriparser/Uri.h
|
||||
NO_SYSTEM_ENVIRONMENT_PATH
|
||||
)
|
||||
|
||||
FIND_LIBRARY(URIPARSER_LIBRARY uriparser)
|
||||
|
||||
if (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
|
||||
SET(URIPARSER_INCLUDE_DIRS ${URIPARSER_INCLUDE_DIR})
|
||||
SET(URIPARSER_LIBRARY ${URIPARSER_LIBRARY})
|
||||
SET(URIPARSER_FOUND "YES")
|
||||
else (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
|
||||
SET(URIPARSER_FOUND "NO")
|
||||
endif (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
|
||||
|
||||
if (URIPARSER_FOUND)
|
||||
if (NOT URIPARSER_FIND_QUIETLY)
|
||||
message(STATUS "Found URIPARSER: ${URIPARSER_LIBRARY}")
|
||||
SET(URIPARSER_FIND_QUIETLY TRUE)
|
||||
endif (NOT URIPARSER_FIND_QUIETLY)
|
||||
else (URIPARSER_FOUND)
|
||||
if (URIPARSER_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find URIPARSER library")
|
||||
endif (URIPARSER_FIND_REQUIRED)
|
||||
endif (URIPARSER_FOUND)
|
||||
|
||||
mark_as_advanced(
|
||||
URIPARSER_LIBRARY
|
||||
URIPARSER_INCLUDE_DIR
|
||||
)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
if (LINUX)
|
||||
include(FindPkgConfig)
|
||||
|
||||
pkg_check_modules(FREETYPE REQUIRED freetype2)
|
||||
else (STANDALONE)
|
||||
else (LINUX)
|
||||
use_prebuilt_binary(freetype)
|
||||
set(FREETYPE_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/freetype2)
|
||||
set(FREETYPE_LIBRARIES freetype)
|
||||
endif (STANDALONE)
|
||||
endif (LINUX)
|
||||
|
||||
link_directories(${FREETYPE_LIBRARY_DIRS})
|
||||
|
||||
116
indra/cmake/GeneratePrecompiledHeader.cmake
Normal file
116
indra/cmake/GeneratePrecompiledHeader.cmake
Normal file
@@ -0,0 +1,116 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
# Distributed under the MIT Software License
|
||||
# Copyright (c) 2015-2017 Borislav Stanimirov
|
||||
# Modifications Copyright (c) 2019 Cinder Roxley. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
# of the Software, and to permit persons to whom the Software is furnished to do
|
||||
# so, subject to the following conditions:
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# target_precompiled_header
|
||||
#
|
||||
# Sets a precompiled header for a given target
|
||||
# Args:
|
||||
# TARGET_NAME - Name of the target. Only valid after add_library or add_executable
|
||||
# PRECOMPILED_HEADER - Header file to precompile
|
||||
# PRECOMPILED_SOURCE - MSVC specific source to do the actual precompilation. Ignored on other platforms
|
||||
#
|
||||
|
||||
macro(target_precompiled_header TARGET_NAME PRECOMPILED_HEADER PRECOMPILED_SOURCE)
|
||||
get_filename_component(PRECOMPILED_HEADER_NAME ${PRECOMPILED_HEADER} NAME)
|
||||
|
||||
if(MSVC)
|
||||
get_filename_component(PRECOMPILED_SOURCE_NAME ${PRECOMPILED_SOURCE} NAME)
|
||||
get_filename_component(PRECOMPILED_HEADER_PATH ${PRECOMPILED_HEADER} DIRECTORY)
|
||||
target_include_directories(${TARGET_NAME} PRIVATE ${PRECOMPILED_HEADER_PATH}) # fixes occasional IntelliSense glitches
|
||||
|
||||
get_filename_component(PRECOMPILED_HEADER_WE ${PRECOMPILED_HEADER} NAME_WE)
|
||||
if(GEN_IS_MULTI_CONFIG)
|
||||
set(PRECOMPILED_BINARY "$(IntDir)/${PRECOMPILED_HEADER_WE}.pch")
|
||||
else()
|
||||
set(PRECOMPILED_BINARY "${CMAKE_CURRENT_BINARY_DIR}/${PRECOMPILED_HEADER_WE}.pch")
|
||||
endif()
|
||||
|
||||
set_source_files_properties(${PRECOMPILED_SOURCE} PROPERTIES
|
||||
COMPILE_OPTIONS "/Yc${PRECOMPILED_HEADER_NAME};/Fp${PRECOMPILED_BINARY}"
|
||||
OBJECT_OUTPUTS "${PRECOMPILED_BINARY}")
|
||||
|
||||
get_target_property(TARGET_SOURCES ${TARGET_NAME} SOURCES)
|
||||
foreach(src ${TARGET_SOURCES})
|
||||
if(${src} MATCHES \\.\(cpp|cxx|cc\)$)
|
||||
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/${src}" PROPERTIES
|
||||
COMPILE_OPTIONS "/Yu${PRECOMPILED_HEADER_NAME};/FI${PRECOMPILED_HEADER_NAME};/Fp${PRECOMPILED_BINARY}"
|
||||
OBJECT_DEPENDS "${PRECOMPILED_BINARY}"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
#set_target_properties(${TARGET_NAME} PROPERTIES
|
||||
# COMPILE_OPTIONS "/Yu${PRECOMPILED_HEADER_NAME};/FI${PRECOMPILED_HEADER_NAME};/Fp${PRECOMPILED_BINARY}")
|
||||
|
||||
target_sources(${TARGET_NAME} PRIVATE ${PRECOMPILED_SOURCE} ${PRECOMPILED_HEADER})
|
||||
elseif(CMAKE_GENERATOR STREQUAL Xcode)
|
||||
set_target_properties(
|
||||
${TARGET_NAME}
|
||||
PROPERTIES
|
||||
XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${PRECOMPILED_HEADER}"
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES"
|
||||
)
|
||||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# Create and set output directory.
|
||||
set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${PRECOMPILED_HEADER_NAME}.gch")
|
||||
make_directory(${OUTPUT_DIR})
|
||||
set(OUTPUT_NAME "${OUTPUT_DIR}/${PRECOMPILED_HEADER_NAME}.gch")
|
||||
|
||||
# Export compiler flags via a generator to a response file
|
||||
set(PCH_FLAGS_FILE "${OUTPUT_DIR}/${PRECOMPILED_HEADER_NAME}.rsp")
|
||||
set(_include_directories "$<TARGET_PROPERTY:${TARGET_NAME},INCLUDE_DIRECTORIES>")
|
||||
set(_compile_definitions "$<TARGET_PROPERTY:${TARGET_NAME},COMPILE_DEFINITIONS>")
|
||||
set(_compile_flags "$<TARGET_PROPERTY:${TARGET_NAME},COMPILE_FLAGS>")
|
||||
set(_compile_options "$<TARGET_PROPERTY:${TARGET_NAME},COMPILE_OPTIONS>")
|
||||
set(_include_directories "$<$<BOOL:${_include_directories}>:-I$<JOIN:${_include_directories},\n-I>\n>")
|
||||
set(_compile_definitions "$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions},\n-D>\n>")
|
||||
set(_compile_flags "$<$<BOOL:${_compile_flags}>:$<JOIN:${_compile_flags},\n>\n>")
|
||||
set(_compile_options "$<$<BOOL:${_compile_options}>:$<JOIN:${_compile_options},\n>\n>")
|
||||
file(GENERATE OUTPUT "${PCH_FLAGS_FILE}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}\n")
|
||||
|
||||
# Gather global compiler options, definitions, etc.
|
||||
string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" CXX_FLAGS)
|
||||
set(COMPILER_FLAGS "${${CXX_FLAGS}} ${CMAKE_CXX_FLAGS}")
|
||||
separate_arguments(COMPILER_FLAGS)
|
||||
|
||||
# Add a custom target for building the precompiled header.
|
||||
add_custom_command(
|
||||
OUTPUT ${OUTPUT_NAME}
|
||||
COMMAND ${CMAKE_CXX_COMPILER} @${PCH_FLAGS_FILE} ${COMPILER_FLAGS} -x c++-header -o ${OUTPUT_NAME} ${PRECOMPILED_HEADER}
|
||||
DEPENDS ${PRECOMPILED_HEADER})
|
||||
add_custom_target(${TARGET_NAME}_gch DEPENDS ${OUTPUT_NAME})
|
||||
add_dependencies(${TARGET_NAME} ${TARGET_NAME}_gch)
|
||||
|
||||
# set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_FLAGS "-include ${PRECOMPILED_HEADER_NAME} -Winvalid-pch")
|
||||
get_target_property(SOURCE_FILES ${TARGET_NAME} SOURCES)
|
||||
get_target_property(asdf ${TARGET_NAME} COMPILE_FLAGS)
|
||||
foreach(SOURCE_FILE ${SOURCE_FILES})
|
||||
if(SOURCE_FILE MATCHES \\.\(c|cc|cxx|cpp\)$)
|
||||
set_source_files_properties(${SOURCE_FILE} PROPERTIES
|
||||
COMPILE_FLAGS "-include ${OUTPUT_DIR}/${PRECOMPILED_HEADER_NAME} -Winvalid-pch"
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown generator for target_precompiled_header. [${CMAKE_CXX_COMPILER_ID}]")
|
||||
endif()
|
||||
endmacro(target_precompiled_header)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
set(BREAKPAD_EXCEPTION_HANDLER_FIND_REQUIRED ON)
|
||||
include(FindGoogleBreakpad)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(google_breakpad)
|
||||
if (DARWIN)
|
||||
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES exception_handler)
|
||||
endif (DARWIN)
|
||||
if (LINUX)
|
||||
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES breakpad_client)
|
||||
endif (LINUX)
|
||||
if (WINDOWS)
|
||||
set(BREAKPAD_EXCEPTION_HANDLER_LIBRARIES exception_handler crash_generation_client crash_generation_server common)
|
||||
endif (WINDOWS)
|
||||
# yes, this does look dumb, no, it's not incorrect
|
||||
# I think it's incorrect: the second one should go --Aleric
|
||||
set(BREAKPAD_INCLUDE_DIRECTORIES
|
||||
${LIBS_PREBUILT_DIR}/include/google_breakpad
|
||||
${LIBS_PREBUILT_LEGACY_DIR}/include/google_breakpad
|
||||
${LIBS_PREBUILT_DIR}/include/google_breakpad/google_breakpad
|
||||
${LIBS_PREBUILT_LEGACY_DIR}/include/google_breakpad/google_breakpad
|
||||
)
|
||||
endif (STANDALONE)
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
include(Prebuilt)
|
||||
|
||||
if(WORD_SIZE EQUAL 64)
|
||||
if(ADDRESS_SIZE EQUAL 64)
|
||||
set(DISABLE_TCMALLOC TRUE)
|
||||
endif(WORD_SIZE EQUAL 64)
|
||||
endif(ADDRESS_SIZE EQUAL 64)
|
||||
|
||||
if (STANDALONE)
|
||||
include(FindGooglePerfTools)
|
||||
else (STANDALONE)
|
||||
if (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
if (LINUX OR WINDOWS AND NOT ADDRESS_SIZE EQUAL 64)
|
||||
use_prebuilt_binary(gperftools)
|
||||
endif (LINUX OR WINDOWS AND NOT WORD_SIZE EQUAL 64)
|
||||
endif (LINUX OR WINDOWS AND NOT ADDRESS_SIZE EQUAL 64)
|
||||
if (WINDOWS AND NOT DISABLE_TCMALLOC)
|
||||
set(TCMALLOC_LIBRARIES libtcmalloc_minimal.lib)
|
||||
set(TCMALLOC_LINKER_FLAGS "/INCLUDE:\"__tcmalloc\"")
|
||||
|
||||
@@ -12,4 +12,5 @@ else (STANDALONE)
|
||||
set(HUNSPELL_LIBRARY libhunspell)
|
||||
endif (LINUX OR DARWIN)
|
||||
set(HUNSPELL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/hunspell)
|
||||
use_prebuilt_binary(dictionaries)
|
||||
endif (STANDALONE)
|
||||
|
||||
6
indra/cmake/Json.cmake
Normal file
6
indra/cmake/Json.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Prebuilt)
|
||||
|
||||
use_prebuilt_binary(modernjson)
|
||||
set(JSON_INCLUDE_DIR "${LIBS_PREBUILT_DIR}/include")
|
||||
@@ -1,22 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Prebuilt)
|
||||
|
||||
set(JSONCPP_FIND_QUIETLY OFF)
|
||||
set(JSONCPP_FIND_REQUIRED ON)
|
||||
|
||||
if (STANDALONE)
|
||||
include(FindJsonCpp)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(jsoncpp)
|
||||
if (WINDOWS)
|
||||
set(JSONCPP_LIBRARIES
|
||||
debug jsoncppd.lib
|
||||
optimized jsoncpp.lib)
|
||||
elseif (DARWIN)
|
||||
set(JSONCPP_LIBRARIES json_linux-gcc-4.0.1_libmt)
|
||||
elseif (LINUX)
|
||||
set(JSONCPP_LIBRARIES jsoncpp)
|
||||
endif (WINDOWS)
|
||||
set(JSONCPP_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/)
|
||||
endif (STANDALONE)
|
||||
@@ -105,17 +105,6 @@ MACRO(ADD_BUILD_TEST_INTERNAL name parent libraries source_files)
|
||||
IF (NOT "$ENV{LD_LIBRARY_PATH}" STREQUAL "")
|
||||
SET(LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}")
|
||||
ENDIF (NOT "$ENV{LD_LIBRARY_PATH}" STREQUAL "")
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${TEST_OUTPUT}
|
||||
COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
"-DLD_LIBRARY_PATH=${LD_LIBRARY_PATH}"
|
||||
"-DTEST_CMD:STRING=${TEST_CMD}"
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/RunBuildTest.cmake
|
||||
DEPENDS ${name}_test
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(${name}_test_ok ALL DEPENDS ${TEST_OUTPUT})
|
||||
IF (${parent})
|
||||
|
||||
@@ -7,6 +7,6 @@ set(LLAUDIO_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llaudio
|
||||
)
|
||||
|
||||
add_definitions(-DOV_EXCLUDE_STATIC_CALLBACKS)
|
||||
#add_definitions(-DOV_EXCLUDE_STATIC_CALLBACKS)
|
||||
|
||||
set(LLAUDIO_LIBRARIES llaudio ${OPENAL_LIBRARIES})
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
include(APR)
|
||||
include(Boost)
|
||||
include(EXPAT)
|
||||
include(Linking)
|
||||
include(ZLIB)
|
||||
|
||||
if (DARWIN)
|
||||
@@ -10,7 +11,6 @@ if (DARWIN)
|
||||
find_library(CORESERVICES_LIBRARY CoreServices)
|
||||
endif (DARWIN)
|
||||
|
||||
|
||||
set(LLCOMMON_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/cwdebug
|
||||
${LIBS_OPEN_DIR}/llcommon
|
||||
@@ -19,14 +19,9 @@ set(LLCOMMON_INCLUDE_DIRS
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
if (LINUX)
|
||||
# In order to support using ld.gold on linux, we need to explicitely
|
||||
# specify all libraries that llcommon uses.
|
||||
# llcommon uses `clock_gettime' which is provided by librt on linux.
|
||||
set(LLCOMMON_LIBRARIES llcommon rt)
|
||||
else (LINUX)
|
||||
set(LLCOMMON_LIBRARIES llcommon)
|
||||
endif (LINUX)
|
||||
set(LLCOMMON_LIBRARIES llcommon
|
||||
fmt::fmt
|
||||
)
|
||||
|
||||
set(LLCOMMON_LINK_SHARED OFF CACHE BOOL "Build the llcommon target as a shared library.")
|
||||
if(LLCOMMON_LINK_SHARED)
|
||||
|
||||
@@ -5,10 +5,4 @@ set(LLPLUGIN_INCLUDE_DIRS
|
||||
${LIBS_OPEN_DIR}/llplugin
|
||||
)
|
||||
|
||||
if (LINUX)
|
||||
# In order to support using ld.gold on linux, we need to explicitely
|
||||
# specify all libraries that llplugin uses.
|
||||
set(LLPLUGIN_LIBRARIES llplugin pthread)
|
||||
else (LINUX)
|
||||
set(LLPLUGIN_LIBRARIES llplugin)
|
||||
endif (LINUX)
|
||||
set(LLPLUGIN_LIBRARIES llplugin)
|
||||
|
||||
@@ -1,32 +1,40 @@
|
||||
# ll_deploy_sharedlibs_command
|
||||
# target_exe: the cmake target of the executable for which the shared libs will be deployed.
|
||||
macro(ll_deploy_sharedlibs_command target_exe)
|
||||
set(OUTPUT_PATH $<TARGET_FILE_DIR:${target_exe}>)
|
||||
set(TARGET_LOCATION $<TARGET_FILE:${target_exe}>)
|
||||
get_filename_component(OUTPUT_PATH ${TARGET_LOCATION} PATH)
|
||||
|
||||
if(DARWIN)
|
||||
SET_TEST_PATH(SEARCH_DIRS)
|
||||
get_target_property(IS_BUNDLE ${target_exe} MACOSX_BUNDLE)
|
||||
if(IS_BUNDLE)
|
||||
set(OUTPUT_PATH ${OUTPUT_PATH}/../Resources)
|
||||
endif(IS_BUNDLE)
|
||||
elseif(WINDOWS)
|
||||
SET_TEST_PATH(SEARCH_DIRS)
|
||||
LIST(APPEND SEARCH_DIRS "$ENV{SystemRoot}/system32")
|
||||
elseif(LINUX)
|
||||
SET_TEST_PATH(SEARCH_DIRS)
|
||||
set(OUTPUT_PATH ${OUTPUT_PATH}/lib)
|
||||
endif(DARWIN)
|
||||
# It's not clear that this does anything useful for us on Darwin. It has
|
||||
# been broken for some time now; the BIN_NAME was being constructed as a
|
||||
# ridiculous nonexistent path with duplicated segments. Fixing that only
|
||||
# produces ominous spammy warnings: at the time the command below is run, we
|
||||
# have not yet populated the nested mac-crash-logger.app/Contents/Resources
|
||||
# with the .dylibs with which it was linked. Moreover, the form of the
|
||||
# embedded @executable_path/../Resources/mumble.dylib pathname confuses the
|
||||
# GetPrerequisites.cmake tool invoked by DeploySharedLibs.cmake. It seems
|
||||
# clear that we have long since accomplished by other means what this was
|
||||
# originally supposed to do. Skipping it only eliminates an annoying
|
||||
# non-fatal error.
|
||||
if(NOT DARWIN)
|
||||
if(WINDOWS)
|
||||
SET_TEST_PATH(SEARCH_DIRS)
|
||||
LIST(APPEND SEARCH_DIRS "$ENV{SystemRoot}/system32")
|
||||
elseif(LINUX)
|
||||
SET_TEST_PATH(SEARCH_DIRS)
|
||||
set(OUTPUT_PATH ${OUTPUT_PATH}/lib)
|
||||
endif(WINDOWS)
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${target_exe} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS
|
||||
"-DBIN_NAME=\"$<TARGET_FILE:${target_exe}>\""
|
||||
"-DSEARCH_DIRS=\"${SEARCH_DIRS}\""
|
||||
"-DDST_PATH=\"${OUTPUT_PATH}\""
|
||||
"-P"
|
||||
"${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${target_exe} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS
|
||||
"-DBIN_NAME=\"${TARGET_LOCATION}\""
|
||||
"-DSEARCH_DIRS=\"${SEARCH_DIRS}\""
|
||||
"-DDST_PATH=\"${OUTPUT_PATH}\""
|
||||
"-P"
|
||||
"${CMAKE_SOURCE_DIR}/cmake/DeploySharedLibs.cmake"
|
||||
)
|
||||
endif(NOT DARWIN)
|
||||
|
||||
endmacro(ll_deploy_sharedlibs_command)
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(OpenGL)
|
||||
include(Prebuilt)
|
||||
|
||||
if (STANDALONE)
|
||||
if (LINUX)
|
||||
include(FindSDL)
|
||||
|
||||
# This should be done by FindSDL. Sigh.
|
||||
@@ -12,14 +11,7 @@ if (STANDALONE)
|
||||
SDL_INCLUDE_DIR
|
||||
SDL_LIBRARY
|
||||
)
|
||||
else (STANDALONE)
|
||||
if (LINUX)
|
||||
use_prebuilt_binary(SDL)
|
||||
set (SDL_FOUND TRUE)
|
||||
set (SDL_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include)
|
||||
set (SDL_LIBRARY SDL)
|
||||
endif (LINUX)
|
||||
endif (STANDALONE)
|
||||
endif (LINUX)
|
||||
|
||||
if (SDL_FOUND)
|
||||
add_definitions(-DLL_SDL=1)
|
||||
|
||||
30
indra/cmake/LibVLCPlugin.cmake
Normal file
30
indra/cmake/LibVLCPlugin.cmake
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- cmake -*-
|
||||
include(Linking)
|
||||
include(Prebuilt)
|
||||
include(Variables)
|
||||
|
||||
if (LIBVLCPLUGIN)
|
||||
if (USESYSTEMLIBS)
|
||||
else (USESYSTEMLIBS)
|
||||
use_prebuilt_binary(vlc-bin)
|
||||
set(VLC_INCLUDE_DIR ${LIBS_PREBUILT_DIR}/include/vlc)
|
||||
endif (USESYSTEMLIBS)
|
||||
|
||||
if (WINDOWS)
|
||||
set(VLC_PLUGIN_LIBRARIES
|
||||
libvlc.lib
|
||||
libvlccore.lib
|
||||
)
|
||||
elseif (DARWIN)
|
||||
set(VLC_PLUGIN_LIBRARIES
|
||||
libvlc.dylib
|
||||
libvlccore.dylib
|
||||
)
|
||||
elseif (LINUX)
|
||||
# Specify a full path to make sure we get a static link
|
||||
set(VLC_PLUGIN_LIBRARIES
|
||||
${LIBS_PREBUILT_DIR}/lib/libvlc.a
|
||||
${LIBS_PREBUILT_DIR}/lib/libvlccore.a
|
||||
)
|
||||
endif (WINDOWS)
|
||||
endif (LIBVLCPLUGIN)
|
||||
@@ -27,15 +27,15 @@ endif (WINDOWS)
|
||||
# windows) and CMAKE_BUILD_TYPE on Makefile based generators (like linux). The reason for this is
|
||||
# that CMAKE_BUILD_TYPE is essentially meaningless at configuration time for IDE generators and
|
||||
# CMAKE_CFG_INTDIR is meaningless at build time for Makefile generators
|
||||
if(WINDOWS OR DARWIN)
|
||||
if(GEN_IS_MULTI_CONFIG)
|
||||
# the cmake xcode and VS generators implicitly append ${CMAKE_CFG_INTDIR} to the library paths for us
|
||||
# fortunately both windows and darwin are case insensitive filesystems so this works.
|
||||
set(AUTOBUILD_LIBS_INSTALL_DIRS "${AUTOBUILD_INSTALL_DIR}/lib/")
|
||||
else(WINDOWS OR DARWIN)
|
||||
else()
|
||||
# else block is for linux and any other makefile based generators
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER)
|
||||
set(AUTOBUILD_LIBS_INSTALL_DIRS ${AUTOBUILD_INSTALL_DIR}/lib/${CMAKE_BUILD_TYPE_LOWER})
|
||||
endif(WINDOWS OR DARWIN)
|
||||
endif()
|
||||
|
||||
if (NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
|
||||
# When we're building something other than Release, append the
|
||||
@@ -48,9 +48,11 @@ link_directories(${AUTOBUILD_LIBS_INSTALL_DIRS})
|
||||
|
||||
if (LINUX)
|
||||
set(DL_LIBRARY dl)
|
||||
set(RT_LIBRARY rt)
|
||||
set(PTHREAD_LIBRARY pthread)
|
||||
else (LINUX)
|
||||
set(DL_LIBRARY "")
|
||||
set(RT_LIBRARY "")
|
||||
set(PTHREAD_LIBRARY "")
|
||||
endif (LINUX)
|
||||
|
||||
@@ -73,6 +75,6 @@ else (WINDOWS)
|
||||
set(WINDOWS_LIBRARIES "")
|
||||
endif (WINDOWS)
|
||||
|
||||
mark_as_advanced(DL_LIBRARY PTHREAD_LIBRARY WINDOWS_LIBRARIES)
|
||||
mark_as_advanced(DL_LIBRARY RT_LIBRARY PTHREAD_LIBRARY WINDOWS_LIBRARIES)
|
||||
|
||||
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
include(Prebuilt)
|
||||
include(Variables)
|
||||
|
||||
if (NVAPI)
|
||||
if (USE_NVAPI)
|
||||
if (WINDOWS)
|
||||
use_prebuilt_binary(nvapi)
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
set(NVAPI_LIBRARY nvapi)
|
||||
elseif (WORD_SIZE EQUAL 64)
|
||||
elseif (ADDRESS_SIZE EQUAL 64)
|
||||
set(NVAPI_LIBRARY nvapi64)
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
else (WINDOWS)
|
||||
set(NVAPI_LIBRARY "")
|
||||
endif (WINDOWS)
|
||||
else (NVAPI)
|
||||
else (USE_NVAPI)
|
||||
set(NVAPI_LIBRARY "")
|
||||
endif (NVAPI)
|
||||
endif (USE_NVAPI)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
include(Linking)
|
||||
include(Prebuilt)
|
||||
|
||||
if(NOT FMOD)
|
||||
if (LINUX)
|
||||
set(OPENAL ON CACHE BOOL "Enable OpenAL")
|
||||
else (LINUX)
|
||||
@@ -10,6 +9,7 @@ else (LINUX)
|
||||
endif (LINUX)
|
||||
|
||||
if (OPENAL)
|
||||
set(OPENAL_LIB_INCLUDE_DIRS "${LIBS_PREBUILT_DIR}/include/AL")
|
||||
if (STANDALONE)
|
||||
include(FindPkgConfig)
|
||||
include(FindOpenAL)
|
||||
@@ -18,15 +18,16 @@ if (OPENAL)
|
||||
else (STANDALONE)
|
||||
use_prebuilt_binary(openal)
|
||||
endif (STANDALONE)
|
||||
if(WINDOWS)
|
||||
set(OPENAL_LIBRARIES
|
||||
openal
|
||||
OpenAL32
|
||||
alut
|
||||
)
|
||||
set(OPENAL_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include)
|
||||
endif (OPENAL)
|
||||
|
||||
if (OPENAL)
|
||||
else()
|
||||
set(OPENAL_LIBRARIES
|
||||
openal
|
||||
alut
|
||||
)
|
||||
endif()
|
||||
message(STATUS "Building with OpenAL audio support")
|
||||
set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_OPENAL")
|
||||
endif (OPENAL)
|
||||
endif(NOT FMOD)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
include(Variables)
|
||||
include(Prebuilt)
|
||||
|
||||
if (NOT (STANDALONE OR DARWIN))
|
||||
@@ -8,3 +10,5 @@ if (NOT (STANDALONE OR DARWIN))
|
||||
${LIBS_PREBUILT_LEGACY_DIR}/include
|
||||
)
|
||||
endif (NOT (STANDALONE OR DARWIN))
|
||||
|
||||
include(FindOpenGL)
|
||||
|
||||
@@ -9,7 +9,7 @@ if (STANDALONE OR USE_SYSTEM_OPENSSL)
|
||||
else (STANDALONE OR USE_SYSTEM_OPENSSL)
|
||||
use_prebuilt_binary(openssl)
|
||||
if (WINDOWS)
|
||||
set(OPENSSL_LIBRARIES ssleay32 libeay32)
|
||||
set(OPENSSL_LIBRARIES libssl libcrypto)
|
||||
else (WINDOWS)
|
||||
set(OPENSSL_LIBRARIES ssl)
|
||||
endif (WINDOWS)
|
||||
|
||||
@@ -4,7 +4,6 @@ if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
|
||||
set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
|
||||
|
||||
include(FindAutobuild)
|
||||
include(Variables)
|
||||
if(INSTALL_PROPRIETARY)
|
||||
include(FindSCP)
|
||||
endif(INSTALL_PROPRIETARY)
|
||||
@@ -40,14 +39,13 @@ macro (use_prebuilt_binary _binary)
|
||||
|
||||
if(${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/${_binary}_installed OR NOT ${${_binary}_installed} EQUAL 0)
|
||||
if(DEBUG_PREBUILT)
|
||||
message("cd ${CMAKE_SOURCE_DIR} && ${AUTOBUILD_EXECUTABLE} install
|
||||
message(STATUS "cd ${CMAKE_SOURCE_DIR} && ${AUTOBUILD_EXECUTABLE} install
|
||||
--install-dir=${AUTOBUILD_INSTALL_DIR}
|
||||
${_binary} ")
|
||||
endif(DEBUG_PREBUILT)
|
||||
execute_process(COMMAND "${AUTOBUILD_EXECUTABLE}"
|
||||
install
|
||||
--install-dir=${AUTOBUILD_INSTALL_DIR}
|
||||
-p ${AUTOBUILD_PLATFORM_NAME}
|
||||
${_binary}
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE ${_binary}_installed
|
||||
|
||||
@@ -5,25 +5,33 @@ set(PYTHONINTERP_FOUND)
|
||||
if (WINDOWS)
|
||||
# On Windows, explicitly avoid Cygwin Python.
|
||||
|
||||
find_program(PYTHON_EXECUTABLE
|
||||
NAMES python25.exe python23.exe python.exe
|
||||
NO_DEFAULT_PATH # added so that cmake does not find cygwin python
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
|
||||
)
|
||||
if (DEFINED ENV{VIRTUAL_ENV})
|
||||
find_program(PYTHON_EXECUTABLE
|
||||
NAMES python.exe
|
||||
PATHS
|
||||
"$ENV{VIRTUAL_ENV}\\scripts"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
else()
|
||||
find_program(PYTHON_EXECUTABLE
|
||||
NAMES python25.exe python23.exe python.exe
|
||||
NO_DEFAULT_PATH # added so that cmake does not find cygwin python
|
||||
PATHS
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
|
||||
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath]
|
||||
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
elseif (EXISTS /etc/arch-release)
|
||||
# On Archlinux, use Python 2
|
||||
elseif (EXISTS /usr/bin/python2)
|
||||
# if this is there, use it
|
||||
|
||||
find_program(PYTHON_EXECUTABLE python2 PATHS /usr/bin)
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
if(INSTALL_PROPRIETARY OR USE_QUICKTIME_PREBUILT)
|
||||
include(Prebuilt)
|
||||
if (WINDOWS)
|
||||
use_prebuilt_binary(quicktime)
|
||||
endif (WINDOWS)
|
||||
endif(INSTALL_PROPRIETARY OR USE_QUICKTIME_PREBUILT)
|
||||
|
||||
if (DARWIN)
|
||||
include(CMakeFindFrameworks)
|
||||
find_library(QUICKTIME_LIBRARY QuickTime)
|
||||
elseif (WINDOWS AND WORD_SIZE EQUAL 32)
|
||||
SET(program_files "ProgramFiles(x86)")
|
||||
SET(program_files $ENV{${program_files}})
|
||||
if(NOT program_files)
|
||||
SET(program_files $ENV{ProgramW6432})
|
||||
endif(NOT program_files)
|
||||
if(NOT program_files)
|
||||
SET(program_files $ENV{ProgramFiles})
|
||||
endif(NOT program_files)
|
||||
|
||||
set(QUICKTIME_SDK_DIR "${program_files}/QuickTime SDK"
|
||||
CACHE PATH "Location of the QuickTime SDK.")
|
||||
|
||||
find_library(DEBUG_QUICKTIME_LIBRARY qtmlclient
|
||||
PATHS
|
||||
${ARCH_PREBUILT_DIRS_DEBUG}
|
||||
"${QUICKTIME_SDK_DIR}\\libraries"
|
||||
)
|
||||
|
||||
find_library(RELEASE_QUICKTIME_LIBRARY qtmlclient
|
||||
PATHS
|
||||
${ARCH_PREBUILT_DIRS_RELEASE}
|
||||
"${QUICKTIME_SDK_DIR}\\libraries"
|
||||
)
|
||||
|
||||
if (DEBUG_QUICKTIME_LIBRARY AND RELEASE_QUICKTIME_LIBRARY)
|
||||
set(QUICKTIME_LIBRARY
|
||||
optimized ${RELEASE_QUICKTIME_LIBRARY}
|
||||
debug ${DEBUG_QUICKTIME_LIBRARY}
|
||||
)
|
||||
|
||||
endif (DEBUG_QUICKTIME_LIBRARY AND RELEASE_QUICKTIME_LIBRARY)
|
||||
|
||||
include_directories(
|
||||
${LIBS_PREBUILT_DIR}/include/quicktime
|
||||
"${QUICKTIME_SDK_DIR}\\CIncludes"
|
||||
)
|
||||
endif (DARWIN)
|
||||
|
||||
mark_as_advanced(QUICKTIME_LIBRARY)
|
||||
|
||||
if (QUICKTIME_LIBRARY)
|
||||
set(QUICKTIME ON CACHE BOOL "Build with QuickTime streaming media support.")
|
||||
endif (QUICKTIME_LIBRARY)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#This cmake script is meant to be run as a build time custom command.
|
||||
#The script is run using cmake w/ the -P option.
|
||||
# parameters are passed to this scripts execution with the -D option.
|
||||
# A full command line would look like this:
|
||||
# cmake -D LD_LIBRARY_PATH=~/checkout/libraries -D TEST_CMD=./llunit_test -D ARGS=--touch=llunit_test_ok.txt -P RunBuildTest.cmake
|
||||
|
||||
# Parameters:
|
||||
# LD_LIBRARY_PATH: string, What to set the LD_LIBRARY_PATH env var.
|
||||
# TEST_CMD: string list, command to run the unit test with, followed by its args.
|
||||
set(ENV{LD_LIBRARY_PATH} ${LD_LIBRARY_PATH})
|
||||
#message("Running: ${TEST_CMD}")
|
||||
execute_process(
|
||||
COMMAND ${TEST_CMD}
|
||||
RESULT_VARIABLE RES
|
||||
)
|
||||
|
||||
if(NOT ${RES} STREQUAL 0)
|
||||
message(STATUS "Failure running: ${TEST_CMD}")
|
||||
message(FATAL_ERROR "Error: ${RES}")
|
||||
endif(NOT ${RES} STREQUAL 0)
|
||||
@@ -1,11 +1,9 @@
|
||||
# -*- cmake -*-
|
||||
include(Prebuilt)
|
||||
include(FreeType)
|
||||
|
||||
if (STANDALONE)
|
||||
if (LINUX)
|
||||
include(FindPkgConfig)
|
||||
|
||||
if (LINUX)
|
||||
|
||||
set(PKGCONFIG_PACKAGES
|
||||
atk
|
||||
cairo
|
||||
@@ -21,8 +19,8 @@ if (STANDALONE)
|
||||
pangox
|
||||
pangoxft
|
||||
sdl
|
||||
x11
|
||||
)
|
||||
endif (LINUX)
|
||||
|
||||
foreach(pkg ${PKGCONFIG_PACKAGES})
|
||||
pkg_check_modules(${pkg} REQUIRED ${pkg})
|
||||
@@ -31,39 +29,6 @@ if (STANDALONE)
|
||||
list(APPEND UI_LIBRARIES ${${pkg}_LIBRARIES})
|
||||
add_definitions(${${pkg}_CFLAGS_OTHERS})
|
||||
endforeach(pkg)
|
||||
else (STANDALONE)
|
||||
if (LINUX)
|
||||
use_prebuilt_binary(gtk-atk-pango-glib)
|
||||
set(UI_LIBRARIES
|
||||
atk-1.0
|
||||
cairo
|
||||
gdk-x11-2.0
|
||||
gdk_pixbuf-2.0
|
||||
Xinerama
|
||||
glib-2.0
|
||||
gio-2.0
|
||||
gmodule-2.0
|
||||
gobject-2.0
|
||||
gthread-2.0
|
||||
gtk-x11-2.0
|
||||
pango-1.0
|
||||
pangoft2-1.0
|
||||
pangoxft-1.0
|
||||
pangocairo-1.0
|
||||
pixman-1
|
||||
X11
|
||||
${FREETYPE_LIBRARIES}
|
||||
)
|
||||
endif (LINUX)
|
||||
|
||||
include_directories (
|
||||
${LIBS_PREBUILT_DIR}/include
|
||||
)
|
||||
foreach(include ${${LL_ARCH}_INCLUDES})
|
||||
include_directories(${LIBS_PREBUILT_DIR}/include/${include})
|
||||
endforeach(include)
|
||||
endif (STANDALONE)
|
||||
|
||||
if (LINUX)
|
||||
add_definitions(-DLL_GTK=1 -DLL_X11=1)
|
||||
endif (LINUX)
|
||||
|
||||
20
indra/cmake/URIPARSER.cmake
Normal file
20
indra/cmake/URIPARSER.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- cmake -*-
|
||||
|
||||
set(URIPARSER_FIND_QUIETLY ON)
|
||||
set(URIPARSER_FIND_REQUIRED ON)
|
||||
|
||||
include(Prebuilt)
|
||||
|
||||
if (USESYSTEMLIBS)
|
||||
include(FindURIPARSER)
|
||||
else (USESYSTEMLIBS)
|
||||
use_prebuilt_binary(uriparser)
|
||||
if (WINDOWS)
|
||||
set(URIPARSER_LIBRARY
|
||||
debug uriparserd
|
||||
optimized uriparser)
|
||||
elseif (DARWIN OR LINUX)
|
||||
set(URIPARSER_LIBRARY uriparser)
|
||||
endif (WINDOWS)
|
||||
set(URIPARSER_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/uriparser)
|
||||
endif (USESYSTEMLIBS)
|
||||
@@ -9,9 +9,7 @@
|
||||
# LINUX - Linux
|
||||
# WINDOWS - Windows
|
||||
|
||||
|
||||
# Relative and absolute paths to subtrees.
|
||||
|
||||
if(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
|
||||
set(${CMAKE_CURRENT_LIST_FILE}_INCLUDED "YES")
|
||||
|
||||
@@ -19,21 +17,73 @@ if(NOT DEFINED COMMON_CMAKE_DIR)
|
||||
set(COMMON_CMAKE_DIR "${CMAKE_SOURCE_DIR}/cmake")
|
||||
endif(NOT DEFINED COMMON_CMAKE_DIR)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# https://blog.kitware.com/upcoming-in-cmake-2-8-12-osx-rpath-support/
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
option(GEN_IS_MULTI_CONFIG "" ${_isMultiConfig})
|
||||
mark_as_advanced(GEN_IS_MULTI_CONFIG)
|
||||
|
||||
set(LIBS_CLOSED_PREFIX)
|
||||
set(LIBS_OPEN_PREFIX)
|
||||
set(SCRIPTS_PREFIX ../scripts)
|
||||
set(VIEWER_PREFIX)
|
||||
set(INTEGRATION_TESTS_PREFIX)
|
||||
set(LL_TESTS OFF CACHE BOOL "Build and run unit and integration tests (disable for build timing runs to reduce variation)")
|
||||
|
||||
option(LL_TESTS "Build and run unit and integration tests (disable for build timing runs to reduce variation" OFF)
|
||||
option(BUILD_TESTING "Build test suite" OFF)
|
||||
option(UNATTENDED "Disable use of uneeded tooling for automated builds" OFF)
|
||||
|
||||
# Compiler and toolchain options
|
||||
option(USESYSTEMLIBS "Use libraries from your system rather than Linden-supplied prebuilt libraries." OFF)
|
||||
option(STANDALONE "Use libraries from your system rather than Linden-supplied prebuilt libraries." OFF)
|
||||
if (USESYSTEMLIBS)
|
||||
set(STANDALONE ON)
|
||||
elseif (STANDALONE)
|
||||
set(USESYSTEMLIBS ON)
|
||||
endif (USESYSTEMLIBS)
|
||||
option(INCREMENTAL_LINK "Use incremental linking on win32 builds (enable for faster links on some machines)" OFF)
|
||||
option(USE_PRECOMPILED_HEADERS "Enable use of precompiled header directives where supported." ON)
|
||||
option(USE_LTO "Enable global and interprocedural optimizations" OFF)
|
||||
|
||||
# Configure crash reporting
|
||||
option(USE_CRASHPAD "Build support for crashpad reporting engine" OFF)
|
||||
if (DEFINED ENV{VIEWER_USE_CRASHPAD})
|
||||
set(USE_CRASHPAD $ENV{VIEWER_USE_CRASHPAD})
|
||||
endif()
|
||||
|
||||
if (DEFINED ENV{VIEWER_CRASHPAD_URL})
|
||||
set(CRASHPAD_URL $ENV{VIEWER_CRASHPAD_URL} CACHE STRING "Viewer Channel Base Name")
|
||||
else()
|
||||
set(CRASHPAD_URL "" CACHE STRING "Crashpad endpoint url")
|
||||
endif()
|
||||
|
||||
set(VIEWER_SYMBOL_FILE "" CACHE STRING "Name of tarball into which to place symbol files")
|
||||
|
||||
# Media Plugins
|
||||
option(ENABLE_MEDIA_PLUGINS "Turn off building media plugins if they are imported by third-party library mechanism" ON)
|
||||
option(LIBVLCPLUGIN "Turn off building support for libvlc plugin" ON)
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(LIBVLCPLUGIN OFF)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
# Mallocs
|
||||
set(DISABLE_TCMALLOC OFF CACHE BOOL "Disable linkage of TCMalloc. (64bit builds automatically disable TCMalloc)")
|
||||
set(DISABLE_FATAL_WARNINGS TRUE CACHE BOOL "Set this to FALSE to enable fatal warnings.")
|
||||
option(INCREMENTAL_LINK "Use incremental linking or incremental LTCG for LTO on win32 builds (enable for faster links on some machines)" OFF)
|
||||
option(USE_LTO "Enable Whole Program Optimization and related folding and binary reduction routines" OFF)
|
||||
|
||||
# Audio Engines
|
||||
option(USE_FMODSTUDIO "Build with support for the FMOD Studio audio engine" OFF)
|
||||
|
||||
# Proprietary Library Features
|
||||
option(NVAPI "Use nvapi driver interface library" OFF)
|
||||
option(USE_NVAPI "Use nvapi driver interface library" OFF)
|
||||
|
||||
|
||||
if(LIBS_CLOSED_DIR)
|
||||
file(TO_CMAKE_PATH "${LIBS_CLOSED_DIR}" LIBS_CLOSED_DIR)
|
||||
@@ -60,67 +110,60 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/Server.cmake)
|
||||
set(INSTALL_PROPRIETARY ON CACHE BOOL "Install proprietary binaries")
|
||||
endif (EXISTS ${CMAKE_SOURCE_DIR}/Server.cmake)
|
||||
set(TEMPLATE_VERIFIER_OPTIONS "" CACHE STRING "Options for scripts/template_verifier.py")
|
||||
set(TEMPLATE_VERIFIER_MASTER_URL "http://bitbucket.org/lindenlab/master-message-template/raw/tip/message_template.msg" CACHE STRING "Location of the master message template")
|
||||
set(TEMPLATE_VERIFIER_MASTER_URL "https://git.alchemyviewer.org/alchemy/master-message-template/raw/master/message_template.msg" CACHE STRING "Location of the master message template")
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
||||
"Build type. One of: Debug Release RelWithDebInfo" FORCE)
|
||||
endif (NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
set(WINDOWS ON BOOL FORCE)
|
||||
if (WORD_SIZE EQUAL 64)
|
||||
set(ARCH x86_64 CACHE STRING "Viewer Architecture")
|
||||
set(LL_ARCH ${ARCH}_win64)
|
||||
set(LL_ARCH_DIR ${ARCH}-win64)
|
||||
set(WORD_SIZE 64)
|
||||
set(AUTOBUILD_PLATFORM_NAME "windows64")
|
||||
else (WORD_SIZE EQUAL 64)
|
||||
set(ARCH i686 CACHE STRING "Viewer Architecture")
|
||||
set(LL_ARCH ${ARCH}_win32)
|
||||
set(LL_ARCH_DIR ${ARCH}-win32)
|
||||
set(WORD_SIZE 32)
|
||||
set(AUTOBUILD_PLATFORM_NAME "windows")
|
||||
endif (WORD_SIZE EQUAL 64)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LINUX ON BOOl FORCE)
|
||||
|
||||
# If someone has specified a word size, use that to determine the
|
||||
# architecture. Otherwise, let the architecture specify the word size.
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
#message(STATUS "WORD_SIZE is 32")
|
||||
set(ARCH i686)
|
||||
set(AUTOBUILD_PLATFORM_NAME "linux")
|
||||
elseif (WORD_SIZE EQUAL 64)
|
||||
#message(STATUS "WORD_SIZE is 64")
|
||||
set(ARCH x86_64)
|
||||
set(AUTOBUILD_PLATFORM_NAME "linux64")
|
||||
else (WORD_SIZE EQUAL 32)
|
||||
#message(STATUS "WORD_SIZE is UNDEFINED")
|
||||
# If someone has specified an address size, use that to determine the
|
||||
# architecture. Otherwise, let the architecture specify the address size.
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
#message(STATUS "ADDRESS_SIZE is 32")
|
||||
set(ARCH i686)
|
||||
elseif (ADDRESS_SIZE EQUAL 64)
|
||||
#message(STATUS "ADDRESS_SIZE is 64")
|
||||
set(ARCH x86_64)
|
||||
else (ADDRESS_SIZE EQUAL 32)
|
||||
#message(STATUS "ADDRESS_SIZE is UNDEFINED")
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
message(STATUS "Size of void pointer is detected as 8; ARCH is 64-bit")
|
||||
set(WORD_SIZE 64)
|
||||
set(AUTOBUILD_PLATFORM_NAME "linux64")
|
||||
set(ARCH x86_64)
|
||||
set(ADDRESS_SIZE 64)
|
||||
elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
message(STATUS "Size of void pointer is detected as 4; ARCH is 32-bit")
|
||||
set(WORD_SIZE 32)
|
||||
set(AUTOBUILD_PLATFORM_NAME "linux")
|
||||
set(ADDRESS_SIZE 32)
|
||||
set(ARCH i686)
|
||||
else()
|
||||
message(FATAL_ERROR "Unkown Architecture!")
|
||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif()
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
|
||||
if (NOT STANDALONE AND MULTIARCH_HACK)
|
||||
if (WORD_SIZE EQUAL 32)
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
set(WINDOWS ON BOOL FORCE)
|
||||
if (ADDRESS_SIZE EQUAL 64)
|
||||
set(LL_ARCH ${ARCH}_win64)
|
||||
set(LL_ARCH_DIR ${ARCH}-win64)
|
||||
elseif (ADDRESS_SIZE EQUAL 32)
|
||||
set(LL_ARCH ${ARCH}_win32)
|
||||
set(LL_ARCH_DIR ${ARCH}-win32)
|
||||
else()
|
||||
message(FATAL_ERROR "Unkown Architecture!")
|
||||
endif ()
|
||||
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(LINUX ON BOOL FORCE)
|
||||
|
||||
if (ADDRESS_SIZE EQUAL 32)
|
||||
set(DEB_ARCHITECTURE i386)
|
||||
set(FIND_LIBRARY_USE_LIB64_PATHS OFF)
|
||||
set(CMAKE_SYSTEM_LIBRARY_PATH /usr/lib32 ${CMAKE_SYSTEM_LIBRARY_PATH})
|
||||
else (WORD_SIZE EQUAL 32)
|
||||
else (ADDRESS_SIZE EQUAL 32)
|
||||
set(DEB_ARCHITECTURE amd64)
|
||||
set(FIND_LIBRARY_USE_LIB64_PATHS ON)
|
||||
endif (WORD_SIZE EQUAL 32)
|
||||
endif (ADDRESS_SIZE EQUAL 32)
|
||||
|
||||
execute_process(COMMAND dpkg-architecture -a${DEB_ARCHITECTURE} -qDEB_HOST_MULTIARCH
|
||||
RESULT_VARIABLE DPKG_RESULT
|
||||
@@ -133,70 +176,108 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
endif (DPKG_RESULT EQUAL 0)
|
||||
|
||||
include(ConfigurePkgConfig)
|
||||
endif (NOT STANDALONE AND MULTIARCH_HACK)
|
||||
|
||||
set(LL_ARCH ${ARCH}_linux)
|
||||
set(LL_ARCH_DIR ${ARCH}-linux)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(DARWIN 1)
|
||||
set(DARWIN ON BOOL FORCE)
|
||||
|
||||
execute_process(
|
||||
COMMAND sh -c "xcodebuild -version | grep Xcode | cut -d ' ' -f2 | cut -d'.' -f1-2"
|
||||
OUTPUT_VARIABLE XCODE_VERSION )
|
||||
string(REGEX REPLACE "(\r?\n)+$" "" XCODE_VERSION "${XCODE_VERSION}")
|
||||
# Architecture
|
||||
set(CMAKE_OSX_SYSROOT macosx10.14)
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_VALID_ARCHS "x86_64")
|
||||
|
||||
# Hardcode SDK we build against until we can test and allow newer ones
|
||||
# as autodetected in the code above
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6)
|
||||
set(CMAKE_OSX_SYSROOT macosx10.6)
|
||||
# Build Options
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] "dwarf")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release] "dwarf-with-dsym")
|
||||
|
||||
# Support for Unix Makefiles generator
|
||||
if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||
execute_process(COMMAND xcodebuild -version -sdk "${CMAKE_OSX_SYSROOT}" Path | head -n 1 OUTPUT_VARIABLE CMAKE_OSX_SYSROOT)
|
||||
string(REGEX REPLACE "(\r?\n)+$" "" CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT}")
|
||||
endif (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
||||
|
||||
# LLVM-GCC has been removed in Xcode5
|
||||
if (XCODE_VERSION GREATER 4.9)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
|
||||
else (XCODE_VERSION GREATER 4.9)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvmgcc42")
|
||||
endif (XCODE_VERSION GREATER 4.9)
|
||||
# Deployment
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
|
||||
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym)
|
||||
# Linking
|
||||
set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING YES)
|
||||
|
||||
message(STATUS "Xcode version: ${XCODE_VERSION}")
|
||||
message(STATUS "OSX sysroot: ${CMAKE_OSX_SYSROOT}")
|
||||
message(STATUS "OSX deployment target: ${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
|
||||
# Build only for i386 by default, system default on MacOSX 10.6 is x86_64
|
||||
set(CMAKE_OSX_ARCHITECTURES i386)
|
||||
set(ARCH i386)
|
||||
set(WORD_SIZE 32)
|
||||
set(AUTOBUILD_PLATFORM_NAME "darwin")
|
||||
# Apple Clang - Code Gen
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Release] YES)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.1)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=Debug] 0)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=Release] 3)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
|
||||
|
||||
# Apple Clang - Custom Compiler Flags
|
||||
set(CMAKE_XCODE_ATTRIBUTE_WARNING_CFLAGS "-Wall -Wextra -Wno-reorder -Wno-sign-compare -Wno-ignored-qualifiers -Wno-unused-local-typedef -Wno-unused-parameter")
|
||||
|
||||
# Apple Clang - Language - C++
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD c++14)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
||||
|
||||
# Apple Clang - Warning Policies
|
||||
set(CMAKE_XCODE_ATTRIBUTE_GCC_TREAT_WARNINGS_AS_ERRORS YES)
|
||||
|
||||
set(LL_ARCH ${ARCH}_darwin)
|
||||
set(LL_ARCH_DIR universal-darwin)
|
||||
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
|
||||
# Platform specific
|
||||
if (WINDOWS)
|
||||
option(LLWINDOW_SDL2 "Use SDL2 for window and input handling. Windows only" OFF)
|
||||
endif()
|
||||
|
||||
# Default deploy grid
|
||||
set(GRID agni CACHE STRING "Target Grid")
|
||||
|
||||
set(VIEWER_CHANNEL "Singularity Test" CACHE STRING "Viewer Channel Name")
|
||||
if (DEFINED ENV{VIEWER_CHANNEL_BASE})
|
||||
set(VIEWER_CHANNEL_BASE $ENV{VIEWER_CHANNEL_BASE} CACHE STRING "Viewer Channel Base Name" FORCE)
|
||||
else()
|
||||
set(VIEWER_CHANNEL_BASE "Singularity" CACHE STRING "Viewer Channel Base Name")
|
||||
endif()
|
||||
|
||||
string(REPLACE " " "" VIEWER_CHANNEL_NOSPACE ${VIEWER_CHANNEL})
|
||||
set(VIEWER_CHANNEL_NOSPACE ${VIEWER_CHANNEL_NOSPACE} CACHE STRING "Prefix used for resulting artifacts.")
|
||||
if (DEFINED ENV{VIEWER_CHANNEL_TYPE})
|
||||
set(VIEWER_CHANNEL_TYPE $ENV{VIEWER_CHANNEL_TYPE} CACHE STRING "Viewer Channel Type Name" FORCE)
|
||||
else()
|
||||
set(VIEWER_CHANNEL_TYPE "Test" CACHE STRING "Viewer Channel Type Name")
|
||||
endif()
|
||||
|
||||
set(ENABLE_SIGNING OFF CACHE BOOL "Enable signing the viewer")
|
||||
if (DEFINED ENV{VIEWER_CHANNEL_CODENAME})
|
||||
set(VIEWER_CHANNEL_CODENAME $ENV{VIEWER_CHANNEL_CODENAME} CACHE STRING "Viewer Channel Code Name for Project type" FORCE)
|
||||
else()
|
||||
set(VIEWER_CHANNEL_CODENAME "Default" CACHE STRING "Viewer Channel Code Name for Project type")
|
||||
endif()
|
||||
|
||||
if("${VIEWER_CHANNEL_TYPE}" STREQUAL "Project")
|
||||
set(VIEWER_CHANNEL "${VIEWER_CHANNEL_BASE} ${VIEWER_CHANNEL_TYPE} ${VIEWER_CHANNEL_CODENAME}")
|
||||
else()
|
||||
set(VIEWER_CHANNEL "${VIEWER_CHANNEL_BASE} ${VIEWER_CHANNEL_TYPE}")
|
||||
endif()
|
||||
|
||||
string(TOLOWER "${VIEWER_CHANNEL_BASE}" VIEWER_BRANDING_ID)
|
||||
string(REPLACE " " "-" VIEWER_BRANDING_ID ${VIEWER_BRANDING_ID})
|
||||
set(VIEWER_BINARY_NAME "${VIEWER_BRANDING_ID}-bin" CACHE STRING
|
||||
"The name of the viewer executable to create.")
|
||||
|
||||
string(REPLACE " " "" VIEWER_CHANNEL_ONEWORD ${VIEWER_CHANNEL})
|
||||
set(VIEWER_CHANNEL_NOSPACE ${VIEWER_CHANNEL_ONEWORD} CACHE STRING "Prefix used for resulting artifacts.")
|
||||
|
||||
option(VIEWER_CHANNEL_GRK "Greek character(s) to represent the viewer channel for support purposes, override only for special branches" "")
|
||||
if (NOT VIEWER_CHANNEL_GRK)
|
||||
if (VIEWER_CHANNEL_TYPE MATCHES "Test")
|
||||
set(VIEWER_CHANNEL_GRK "\\u03C4") # "τ"
|
||||
elseif (VIEWER_CHANNEL_TYPE MATCHES "Alpha")
|
||||
set(VIEWER_CHANNEL_GRK "\\u03B1") # "α"
|
||||
elseif (VIEWER_CHANNEL_TYPE MATCHES "Beta")
|
||||
set(VIEWER_CHANNEL_GRK "\\u03B2") # "β"
|
||||
else()
|
||||
set(VIEWER_CHANNEL_GRK "")
|
||||
endif ()
|
||||
endif (NOT VIEWER_CHANNEL_GRK)
|
||||
|
||||
option(ENABLE_SIGNING "Enable signing the viewer" OFF)
|
||||
set(SIGNING_IDENTITY "" CACHE STRING "Specifies the signing identity to use, if necessary.")
|
||||
|
||||
set(VERSION_BUILD "0" CACHE STRING "Revision number passed in from the outside")
|
||||
set(STANDALONE OFF CACHE BOOL "Do not use Linden-supplied prebuilt libraries.")
|
||||
|
||||
set(USE_PRECOMPILED_HEADERS ON CACHE BOOL "Enable use of precompiled header directives where supported.")
|
||||
|
||||
source_group("CMake Rules" FILES CMakeLists.txt)
|
||||
|
||||
endif(NOT DEFINED ${CMAKE_CURRENT_LIST_FILE}_INCLUDED)
|
||||
|
||||
@@ -3,9 +3,6 @@ include(Prebuilt)
|
||||
|
||||
if (NOT STANDALONE)
|
||||
use_prebuilt_binary(slvoice)
|
||||
if(LINUX)
|
||||
use_prebuilt_binary(fontconfig)
|
||||
endif(LINUX)
|
||||
else (NOT STANDALONE)
|
||||
# Download there even when using standalone.
|
||||
set(STANDALONE OFF)
|
||||
@@ -15,3 +12,10 @@ else (NOT STANDALONE)
|
||||
endif(LINUX AND ${ARCH} STREQUAL "x86_64")
|
||||
set(STANDALONE ON)
|
||||
endif(NOT STANDALONE)
|
||||
|
||||
if(LINUX)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
||||
endif(LINUX)
|
||||
|
||||
use_prebuilt_binary(fonts)
|
||||
|
||||
340
indra/cmake/run_build_test.py
Normal file
340
indra/cmake/run_build_test.py
Normal file
@@ -0,0 +1,340 @@
|
||||
#!/usr/bin/env python2
|
||||
"""\
|
||||
@file run_build_test.py
|
||||
@author Nat Goodspeed
|
||||
@date 2009-09-03
|
||||
@brief Helper script to allow CMake to run some command after setting
|
||||
environment variables.
|
||||
|
||||
CMake has commands to run an external program. But remember that each CMake
|
||||
command must be backed by multiple build-system implementations. Unfortunately
|
||||
it seems CMake can't promise that every target build system can set specified
|
||||
environment variables before running the external program of interest.
|
||||
|
||||
This helper script is a workaround. It simply sets the requested environment
|
||||
variables and then executes the program specified on the rest of its command
|
||||
line.
|
||||
|
||||
Example:
|
||||
|
||||
python run_build_test.py -DFOO=bar myprog somearg otherarg
|
||||
|
||||
sets environment variable FOO=bar, then runs:
|
||||
myprog somearg otherarg
|
||||
|
||||
$LicenseInfo:firstyear=2009&license=viewerlgpl$
|
||||
Second Life Viewer Source Code
|
||||
Copyright (C) 2009-2010, Linden Research, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation;
|
||||
version 2.1 of the License only.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import errno
|
||||
import HTMLParser
|
||||
import re
|
||||
import signal
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
def main(command, arguments=[], libpath=[], vars={}):
|
||||
"""Pass:
|
||||
command is the command to be executed
|
||||
|
||||
argument is a sequence (e.g. a list) of strings to be passed to command
|
||||
|
||||
libpath is a sequence of directory pathnames. These will be appended to
|
||||
the platform-specific dynamic library search path environment variable.
|
||||
|
||||
vars is a dict of arbitrary (var, value) pairs to be added to the
|
||||
environment before running 'command'.
|
||||
|
||||
This function runs the specified command, waits for it to terminate and
|
||||
returns its return code. This will be negative if the command terminated
|
||||
with a signal, else it will be the process's specified exit code.
|
||||
"""
|
||||
# Handle platform-dependent libpath first.
|
||||
if sys.platform == "win32":
|
||||
lpvars = ["PATH"]
|
||||
elif sys.platform == "darwin":
|
||||
lpvars = ["LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH"]
|
||||
elif sys.platform.startswith("linux"):
|
||||
lpvars = ["LD_LIBRARY_PATH"]
|
||||
else:
|
||||
# No idea what the right pathname might be! But only crump if this
|
||||
# feature is requested.
|
||||
if libpath:
|
||||
raise RuntimeError("run_build_test: unknown platform %s" % sys.platform)
|
||||
lpvars = []
|
||||
for var in lpvars:
|
||||
# Split the existing path. Bear in mind that the variable in question
|
||||
# might not exist; instead of KeyError, just use an empty string.
|
||||
dirs = os.environ.get(var, "").split(os.pathsep)
|
||||
# Append the sequence in libpath
|
||||
log.info("%s += %r" % (var, libpath))
|
||||
for dir in libpath:
|
||||
# append system paths at the end
|
||||
if dir in ('/lib', '/usr/lib'):
|
||||
dirs.append(dir)
|
||||
# prepend non-system paths
|
||||
else:
|
||||
dirs.insert(0, dir)
|
||||
|
||||
# Filter out some useless pieces
|
||||
clean_dirs = []
|
||||
for dir in dirs:
|
||||
if dir and dir not in ('', '.'):
|
||||
clean_dirs.append(dir)
|
||||
|
||||
# Now rebuild the path string. This way we use a minimum of separators
|
||||
# -- and we avoid adding a pointless separator when libpath is empty.
|
||||
os.environ[var] = os.pathsep.join(clean_dirs)
|
||||
log.info("%s = %r" % (var, os.environ[var]))
|
||||
# Now handle arbitrary environment variables. The tricky part is ensuring
|
||||
# that all the keys and values we try to pass are actually strings.
|
||||
if vars:
|
||||
log.info("Setting: %s" % ("\n".join(["%s=%s" % (key, value) for key, value in vars.iteritems()])))
|
||||
os.environ.update(dict([(str(key), str(value)) for key, value in vars.iteritems()]))
|
||||
# Run the child process.
|
||||
command_list = [command]
|
||||
command_list.extend(arguments)
|
||||
log.info("Running: %s" % " ".join(command_list))
|
||||
# Make sure we see all relevant output *before* child-process output.
|
||||
sys.stdout.flush()
|
||||
try:
|
||||
return subprocess.call(command_list)
|
||||
except OSError as err:
|
||||
# If the caller is trying to execute a test program that doesn't
|
||||
# exist, we want to produce a reasonable error message rather than a
|
||||
# traceback. This happens when the build is halted by errors, but
|
||||
# CMake tries to proceed with testing anyway <eyeroll/>. However, do
|
||||
# NOT attempt to handle any error but "doesn't exist."
|
||||
if err.errno != errno.ENOENT:
|
||||
raise
|
||||
# In practice, the pathnames into CMake's build tree are so long as to
|
||||
# obscure the name of the test program. Just log its basename.
|
||||
log.warn("No such program %s; check for preceding build errors" % \
|
||||
os.path.basename(command[0]))
|
||||
# What rc should we simulate for missing executable? Windows produces
|
||||
# 9009.
|
||||
return 9009
|
||||
|
||||
# swiped from vita, sigh, seems like a Bad Idea to introduce dependency
|
||||
def translate_rc(rc):
|
||||
"""
|
||||
Accept an rc encoded as for subprocess.Popen.returncode:
|
||||
None means still running
|
||||
int >= 0 means terminated voluntarily with specified rc
|
||||
int < 0 means terminated by signal (-rc)
|
||||
|
||||
Return a string explaining the outcome. In case of a signal, try to
|
||||
name the corresponding symbol from the 'signal' module.
|
||||
"""
|
||||
if rc is None:
|
||||
return "still running"
|
||||
|
||||
if rc >= 0:
|
||||
return "terminated with rc %s" % rc
|
||||
|
||||
if sys.platform.startswith("win"):
|
||||
# From http://stackoverflow.com/questions/20629027/process-finished-with-exit-code-1073741571
|
||||
# [-1073741571] is the signed integer representation of Microsoft's
|
||||
# "stack overflow/stack exhaustion" error code 0xC00000FD.
|
||||
# Anytime you see strange, large negative exit codes in windows, convert
|
||||
# them to hex and then look them up in the ntstatus error codes
|
||||
# http://msdn.microsoft.com/en-us/library/cc704588.aspx
|
||||
|
||||
# Python bends over backwards to give you all the integer precision
|
||||
# you need, avoiding truncation. But only with 32-bit signed ints is
|
||||
# -1073741571 equivalent to 0xC00000FD! Explicitly truncate before
|
||||
# converting.
|
||||
hexrc = "0x%X" % (rc & 0xFFFFFFFF)
|
||||
# At this point, we're only trying to format the rc to make it easier
|
||||
# for a human being to understand. Any exception here -- file doesn't
|
||||
# exist, HTML parsing error, unrecognized table structure, unknown key
|
||||
# -- should NOT kill the script! It should only cause us to shrug and
|
||||
# present our caller with the best information available.
|
||||
try:
|
||||
table = get_windows_table()
|
||||
symbol, desc = table[hexrc]
|
||||
except Exception, err:
|
||||
log.error("(%s -- carrying on)" % err)
|
||||
log.error("terminated with rc %s (%s)" % (rc, hexrc))
|
||||
else:
|
||||
log.info("terminated with rc %s: %s: %s" % (hexrc, symbol, desc))
|
||||
|
||||
else:
|
||||
# On Posix, negative rc means the child was terminated by signal -rc.
|
||||
rc = -rc
|
||||
for attr in dir(signal):
|
||||
if attr.startswith('SIG') and getattr(signal, attr) == rc:
|
||||
strc = attr
|
||||
break
|
||||
else:
|
||||
strc = str(rc)
|
||||
return "terminated by signal %s" % strc
|
||||
|
||||
class TableParser(HTMLParser.HTMLParser):
|
||||
"""
|
||||
This HTMLParser subclass is designed to parse the table we know exists
|
||||
in windows-rcs.html, hopefully without building in too much knowledge of
|
||||
the specific way that table is currently formatted.
|
||||
"""
|
||||
# regular expression matching any string containing only whitespace
|
||||
whitespace = re.compile(r'\s*$')
|
||||
|
||||
def __init__(self):
|
||||
# Because Python 2.x's HTMLParser is an old-style class, we must use
|
||||
# old-style syntax to forward the __init__() call -- not super().
|
||||
HTMLParser.HTMLParser.__init__(self)
|
||||
# this will collect all the data, eventually
|
||||
self.table = []
|
||||
# Stack whose top (last item) indicates where to append current
|
||||
# element data. When empty, don't collect data at all.
|
||||
self.dest = []
|
||||
|
||||
def handle_starttag(self, tag, attrs):
|
||||
if tag == "table":
|
||||
# This is the outermost tag we recognize. Collect nested elements
|
||||
# within self.table.
|
||||
self.dest.append(self.table)
|
||||
elif tag in ("tr", "td"):
|
||||
# Nested elements whose contents we want to capture as sublists.
|
||||
# To the list currently designated by the top of the dest stack,
|
||||
# append a new empty sublist.
|
||||
self.dest[-1].append([])
|
||||
# Now push THAT new, empty list as the new top of the dest stack.
|
||||
self.dest.append(self.dest[-1][-1])
|
||||
elif tag == "p":
|
||||
# We could handle <p> ... </p> just like <tr> or <td>, but that
|
||||
# introduces an unnecessary extra level of nesting. Just skip.
|
||||
pass
|
||||
else:
|
||||
# For any tag we don't recognize (notably <th>), push a new, empty
|
||||
# list to the top of the dest stack. This new list is NOT
|
||||
# referenced by anything in self.table; thus, when we pop it, any
|
||||
# data we've collected inside that list will be discarded.
|
||||
self.dest.append([])
|
||||
|
||||
def handle_endtag(self, tag):
|
||||
# Because we avoid pushing self.dest for <p> in handle_starttag(), we
|
||||
# must refrain from popping it for </p> here.
|
||||
if tag != "p":
|
||||
# For everything else, including unrecognized tags, pop the dest
|
||||
# stack, reverting to outer collection.
|
||||
self.dest.pop()
|
||||
|
||||
def handle_startendtag(self, tag, attrs):
|
||||
# The table of interest contains <td> entries of the form:
|
||||
# <p>0x00000000<br />STATUS_SUCCESS</p>
|
||||
# The <br/> is very useful -- we definitely want two different data
|
||||
# items for "0x00000000" and "STATUS_SUCCESS" -- but we don't need or
|
||||
# want it to push, then discard, an empty list as it would if we let
|
||||
# the default HTMLParser.handle_startendtag() call handle_starttag()
|
||||
# followed by handle_endtag(). Just ignore <br/> or any other
|
||||
# singleton tag.
|
||||
pass
|
||||
|
||||
def handle_data(self, data):
|
||||
# Outside the <table> of interest, self.dest is empty. Do not bother
|
||||
# collecting data when self.dest is empty.
|
||||
# HTMLParser calls handle_data() with every chunk of whitespace
|
||||
# between tags. That would be lovely if our eventual goal was to
|
||||
# reconstitute the original input stream with its existing formatting,
|
||||
# but for us, whitespace only clutters the table. Ignore it.
|
||||
if self.dest and not self.whitespace.match(data):
|
||||
# Here we're within our <table> and we have non-whitespace data.
|
||||
# Append it to the list designated by the top of the dest stack.
|
||||
self.dest[-1].append(data)
|
||||
|
||||
# cache for get_windows_table()
|
||||
_windows_table = None
|
||||
|
||||
def get_windows_table():
|
||||
global _windows_table
|
||||
# If we already loaded _windows_table, no need to load it all over again.
|
||||
if _windows_table:
|
||||
return _windows_table
|
||||
|
||||
# windows-rcs.html was fetched on 2015-03-24 with the following command:
|
||||
# curl -o windows-rcs.html \
|
||||
# https://msdn.microsoft.com/en-us/library/cc704588.aspx
|
||||
parser = TableParser()
|
||||
with open(os.path.join(os.path.dirname(__file__), "windows-rcs.html")) as hf:
|
||||
# We tried feeding the file data to TableParser in chunks, to avoid
|
||||
# buffering the entire file as a single string. Unfortunately its
|
||||
# handle_data() cannot tell the difference between distinct calls
|
||||
# separated by HTML tags, and distinct calls necessitated by a chunk
|
||||
# boundary. Sigh! Read in the whole file. At the time this was
|
||||
# written, it was only 500KB anyway.
|
||||
parser.feed(hf.read())
|
||||
parser.close()
|
||||
table = parser.table
|
||||
|
||||
# With our parser, any <tr><th>...</th></tr> row leaves a table entry
|
||||
# consisting only of an empty list. Remove any such.
|
||||
while table and not table[0]:
|
||||
table.pop(0)
|
||||
|
||||
# We expect rows of the form:
|
||||
# [['0x00000000', 'STATUS_SUCCESS'],
|
||||
# ['The operation completed successfully.']]
|
||||
# The latter list will have multiple entries if Microsoft embedded <br/>
|
||||
# or <p> ... </p> in the text, in which case joining with '\n' is
|
||||
# appropriate.
|
||||
# Turn that into a dict whose key is the hex string, and whose value is
|
||||
# the pair (symbol, desc).
|
||||
_windows_table = dict((key, (symbol, '\n'.join(desc)))
|
||||
for (key, symbol), desc in table)
|
||||
|
||||
return _windows_table
|
||||
|
||||
log=logging.getLogger(__name__)
|
||||
logging.basicConfig()
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-d", "--debug", dest="loglevel", action="store_const",
|
||||
const=logging.DEBUG, default=logging.INFO)
|
||||
parser.add_argument("-D", "--define", dest="vars", default=[], action="append",
|
||||
metavar="VAR=value",
|
||||
help="Add VAR=value to the env variables defined")
|
||||
parser.add_argument("-l", "--libpath", dest="libpath", default=[], action="append",
|
||||
metavar="DIR",
|
||||
help="Add DIR to the platform-dependent DLL search path")
|
||||
parser.add_argument("command")
|
||||
parser.add_argument('args', nargs=argparse.REMAINDER)
|
||||
args = parser.parse_args()
|
||||
|
||||
log.setLevel(args.loglevel)
|
||||
|
||||
# What we have in opts.vars is a list of strings of the form "VAR=value"
|
||||
# or possibly just "VAR". What we want is a dict. We can build that dict by
|
||||
# constructing a list of ["VAR", "value"] pairs -- so split each
|
||||
# "VAR=value" string on the '=' sign (but only once, in case we have
|
||||
# "VAR=some=user=string"). To handle the case of just "VAR", append "" to
|
||||
# the list returned by split(), then slice off anything after the pair we
|
||||
# want.
|
||||
rc = main(command=args.command, arguments=args.args, libpath=args.libpath,
|
||||
vars=dict([(pair.split('=', 1) + [""])[:2] for pair in args.vars]))
|
||||
if rc not in (None, 0):
|
||||
log.error("Failure running: %s" % " ".join([args.command] + args.args))
|
||||
log.error("Error %s: %s" % (rc, translate_rc(rc)))
|
||||
sys.exit((rc < 0) and 255 or rc)
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python2
|
||||
"""\
|
||||
@file start-client.py
|
||||
|
||||
|
||||
62
indra/deps/CMakeLists.txt
Normal file
62
indra/deps/CMakeLists.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
project(deps)
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
set(CMAKE_FOLDER "Third Party")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
FetchContent_Declare(
|
||||
Catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.11.0
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_Declare(
|
||||
fmt
|
||||
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
|
||||
GIT_TAG 8d78045e7cb44d39ad4cd95dd27816b8749e1944
|
||||
)
|
||||
FetchContent_Declare(
|
||||
nlohmann_json
|
||||
GIT_REPOSITORY https://github.com/nlohmann/json.git
|
||||
GIT_TAG v3.7.3
|
||||
GIT_SHALLOW TRUE
|
||||
)
|
||||
FetchContent_Declare(
|
||||
absl
|
||||
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
|
||||
GIT_TAG 768eb2ca2857342673fcd462792ce04b8bac3fa3
|
||||
)
|
||||
|
||||
# This is a hack because absl has dumb cmake
|
||||
set(OLD_BUILD_TEST ${BUILD_TESTING})
|
||||
set(BUILD_TESTING OFF)
|
||||
FetchContent_MakeAvailable(absl)
|
||||
set(BUILD_TESTING ${OLD_BUILD_TEST})
|
||||
|
||||
# Supress warnings inside abseil under MSVC
|
||||
if(WINDOWS)
|
||||
target_compile_options(absl_strings PRIVATE /wd4018)
|
||||
target_compile_options(absl_str_format_internal PRIVATE /wd4018)
|
||||
target_compile_options(absl_flags_usage_internal PRIVATE /wd4018)
|
||||
endif()
|
||||
|
||||
|
||||
if (BUILD_TESTING)
|
||||
FetchContent_MakeAvailable(Catch2)
|
||||
endif()
|
||||
|
||||
#Download the rest of the libraries
|
||||
FetchContent_MakeAvailable(fmt)
|
||||
|
||||
# Typically you don't care so much for a third party library's tests to be
|
||||
# run from your own project's code.
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
|
||||
# If you only include this third party in PRIVATE source files, you do not
|
||||
# need to install it when your main project gets installed.
|
||||
set(JSON_Install OFF CACHE INTERNAL "")
|
||||
FetchContent_MakeAvailable(nlohmann_json)
|
||||
|
||||
unset(CMAKE_FOLDER)
|
||||
unset(CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
@@ -1,27 +0,0 @@
|
||||
"""\
|
||||
@file __init__.py
|
||||
@brief Initialization file for the indra.base module.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
@@ -1,73 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
##
|
||||
## $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||
## Second Life Viewer Source Code
|
||||
## Copyright (C) 2011, Linden Research, Inc.
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation;
|
||||
## version 2.1 of the License only.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library; if not, write to the Free Software
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##
|
||||
## Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
## $/LicenseInfo$
|
||||
from indra.base import llsd, lluuid
|
||||
from datetime import datetime
|
||||
import cllsd
|
||||
import time, sys
|
||||
|
||||
class myint(int):
|
||||
pass
|
||||
|
||||
values = (
|
||||
'&<>',
|
||||
u'\u81acj',
|
||||
llsd.uri('http://foo<'),
|
||||
lluuid.UUID(),
|
||||
llsd.LLSD(['thing']),
|
||||
1,
|
||||
myint(31337),
|
||||
sys.maxint + 10,
|
||||
llsd.binary('foo'),
|
||||
[],
|
||||
{},
|
||||
{u'f&\u1212': 3},
|
||||
3.1,
|
||||
True,
|
||||
None,
|
||||
datetime.fromtimestamp(time.time()),
|
||||
)
|
||||
|
||||
def valuator(values):
|
||||
for v in values:
|
||||
yield v
|
||||
|
||||
longvalues = () # (values, list(values), iter(values), valuator(values))
|
||||
|
||||
for v in values + longvalues:
|
||||
print '%r => %r' % (v, cllsd.llsd_to_xml(v))
|
||||
|
||||
a = [[{'a':3}]] * 1000000
|
||||
|
||||
s = time.time()
|
||||
print hash(cllsd.llsd_to_xml(a))
|
||||
e = time.time()
|
||||
t1 = e - s
|
||||
print t1
|
||||
|
||||
s = time.time()
|
||||
print hash(llsd.LLSDXMLFormatter()._format(a))
|
||||
e = time.time()
|
||||
t2 = e - s
|
||||
print t2
|
||||
|
||||
print 'Speedup:', t2 / t1
|
||||
@@ -1,266 +0,0 @@
|
||||
"""\
|
||||
@file config.py
|
||||
@brief Utility module for parsing and accessing the indra.xml config file.
|
||||
|
||||
$LicenseInfo:firstyear=2006&license=mit$
|
||||
|
||||
Copyright (c) 2006-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import copy
|
||||
import errno
|
||||
import os
|
||||
import traceback
|
||||
import time
|
||||
import types
|
||||
|
||||
from os.path import dirname, getmtime, join, realpath
|
||||
from indra.base import llsd
|
||||
|
||||
_g_config = None
|
||||
|
||||
class IndraConfig(object):
|
||||
"""
|
||||
IndraConfig loads a 'indra' xml configuration file
|
||||
and loads into memory. This representation in memory
|
||||
can get updated to overwrite values or add new values.
|
||||
|
||||
The xml configuration file is considered a live file and changes
|
||||
to the file are checked and reloaded periodically. If a value had
|
||||
been overwritten via the update or set method, the loaded values
|
||||
from the file are ignored (the values from the update/set methods
|
||||
override)
|
||||
"""
|
||||
def __init__(self, indra_config_file):
|
||||
self._indra_config_file = indra_config_file
|
||||
self._reload_check_interval = 30 # seconds
|
||||
self._last_check_time = 0
|
||||
self._last_mod_time = 0
|
||||
|
||||
self._config_overrides = {}
|
||||
self._config_file_dict = {}
|
||||
self._combined_dict = {}
|
||||
|
||||
self._load()
|
||||
|
||||
def _load(self):
|
||||
# if you initialize the IndraConfig with None, no attempt
|
||||
# is made to load any files
|
||||
if self._indra_config_file is None:
|
||||
return
|
||||
|
||||
config_file = open(self._indra_config_file)
|
||||
self._config_file_dict = llsd.parse(config_file.read())
|
||||
self._combine_dictionaries()
|
||||
config_file.close()
|
||||
|
||||
self._last_mod_time = self._get_last_modified_time()
|
||||
self._last_check_time = time.time() # now
|
||||
|
||||
def _get_last_modified_time(self):
|
||||
"""
|
||||
Returns the mtime (last modified time) of the config file,
|
||||
if such exists.
|
||||
"""
|
||||
if self._indra_config_file is not None:
|
||||
return os.path.getmtime(self._indra_config_file)
|
||||
|
||||
return 0
|
||||
|
||||
def _combine_dictionaries(self):
|
||||
self._combined_dict = {}
|
||||
self._combined_dict.update(self._config_file_dict)
|
||||
self._combined_dict.update(self._config_overrides)
|
||||
|
||||
def _reload_if_necessary(self):
|
||||
now = time.time()
|
||||
|
||||
if (now - self._last_check_time) > self._reload_check_interval:
|
||||
self._last_check_time = now
|
||||
try:
|
||||
modtime = self._get_last_modified_time()
|
||||
if modtime > self._last_mod_time:
|
||||
self._load()
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT: # file not found
|
||||
# someone messed with our internal state
|
||||
# or removed the file
|
||||
|
||||
print 'WARNING: Configuration file has been removed ' + (self._indra_config_file)
|
||||
print 'Disabling reloading of configuration file.'
|
||||
|
||||
traceback.print_exc()
|
||||
|
||||
self._indra_config_file = None
|
||||
self._last_check_time = 0
|
||||
self._last_mod_time = 0
|
||||
else:
|
||||
raise # pass the exception along to the caller
|
||||
|
||||
def __getitem__(self, key):
|
||||
self._reload_if_necessary()
|
||||
|
||||
return self._combined_dict[key]
|
||||
|
||||
def get(self, key, default = None):
|
||||
try:
|
||||
return self.__getitem__(key)
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
"""
|
||||
Sets the value of the config setting of key to be newval
|
||||
|
||||
Once any key/value pair is changed via the set method,
|
||||
that key/value pair will remain set with that value until
|
||||
change via the update or set method
|
||||
"""
|
||||
self._config_overrides[key] = value
|
||||
self._combine_dictionaries()
|
||||
|
||||
def set(self, key, newval):
|
||||
return self.__setitem__(key, newval)
|
||||
|
||||
def update(self, new_conf):
|
||||
"""
|
||||
Load an XML file and apply its map as overrides or additions
|
||||
to the existing config. Update can be a file or a dict.
|
||||
|
||||
Once any key/value pair is changed via the update method,
|
||||
that key/value pair will remain set with that value until
|
||||
change via the update or set method
|
||||
"""
|
||||
if isinstance(new_conf, dict):
|
||||
overrides = new_conf
|
||||
else:
|
||||
# assuming that it is a filename
|
||||
config_file = open(new_conf)
|
||||
overrides = llsd.parse(config_file.read())
|
||||
config_file.close()
|
||||
|
||||
self._config_overrides.update(overrides)
|
||||
self._combine_dictionaries()
|
||||
|
||||
def as_dict(self):
|
||||
"""
|
||||
Returns immutable copy of the IndraConfig as a dictionary
|
||||
"""
|
||||
return copy.deepcopy(self._combined_dict)
|
||||
|
||||
def load(config_xml_file = None):
|
||||
global _g_config
|
||||
|
||||
load_default_files = config_xml_file is None
|
||||
if load_default_files:
|
||||
## going from:
|
||||
## "/opt/linden/indra/lib/python/indra/base/config.py"
|
||||
## to:
|
||||
## "/opt/linden/etc/indra.xml"
|
||||
config_xml_file = realpath(
|
||||
dirname(realpath(__file__)) + "../../../../../../etc/indra.xml")
|
||||
|
||||
try:
|
||||
_g_config = IndraConfig(config_xml_file)
|
||||
except IOError:
|
||||
# Failure to load passed in file
|
||||
# or indra.xml default file
|
||||
if load_default_files:
|
||||
try:
|
||||
config_xml_file = realpath(
|
||||
dirname(realpath(__file__)) + "../../../../../../etc/globals.xml")
|
||||
_g_config = IndraConfig(config_xml_file)
|
||||
return
|
||||
except IOError:
|
||||
# Failure to load globals.xml
|
||||
# fall to code below
|
||||
pass
|
||||
|
||||
# Either failed to load passed in file
|
||||
# or failed to load all default files
|
||||
_g_config = IndraConfig(None)
|
||||
|
||||
def dump(indra_xml_file, indra_cfg = None, update_in_mem=False):
|
||||
'''
|
||||
Dump config contents into a file
|
||||
Kindof reverse of load.
|
||||
Optionally takes a new config to dump.
|
||||
Does NOT update global config unless requested.
|
||||
'''
|
||||
global _g_config
|
||||
|
||||
if not indra_cfg:
|
||||
if _g_config is None:
|
||||
return
|
||||
|
||||
indra_cfg = _g_config.as_dict()
|
||||
|
||||
if not indra_cfg:
|
||||
return
|
||||
|
||||
config_file = open(indra_xml_file, 'w')
|
||||
_config_xml = llsd.format_xml(indra_cfg)
|
||||
config_file.write(_config_xml)
|
||||
config_file.close()
|
||||
|
||||
if update_in_mem:
|
||||
update(indra_cfg)
|
||||
|
||||
def update(new_conf):
|
||||
global _g_config
|
||||
|
||||
if _g_config is None:
|
||||
# To keep with how this function behaved
|
||||
# previously, a call to update
|
||||
# before the global is defined
|
||||
# make a new global config which does not
|
||||
# load data from a file.
|
||||
_g_config = IndraConfig(None)
|
||||
|
||||
return _g_config.update(new_conf)
|
||||
|
||||
def get(key, default = None):
|
||||
global _g_config
|
||||
|
||||
if _g_config is None:
|
||||
load()
|
||||
|
||||
return _g_config.get(key, default)
|
||||
|
||||
def set(key, newval):
|
||||
"""
|
||||
Sets the value of the config setting of key to be newval
|
||||
|
||||
Once any key/value pair is changed via the set method,
|
||||
that key/value pair will remain set with that value until
|
||||
change via the update or set method or program termination
|
||||
"""
|
||||
global _g_config
|
||||
|
||||
if _g_config is None:
|
||||
_g_config = IndraConfig(None)
|
||||
|
||||
_g_config.set(key, newval)
|
||||
|
||||
def get_config():
|
||||
global _g_config
|
||||
return _g_config
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,319 +0,0 @@
|
||||
"""\
|
||||
@file lluuid.py
|
||||
@brief UUID parser/generator.
|
||||
|
||||
$LicenseInfo:firstyear=2004&license=mit$
|
||||
|
||||
Copyright (c) 2004-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import random, socket, string, time, re
|
||||
import uuid
|
||||
try:
|
||||
# Python 2.6
|
||||
from hashlib import md5
|
||||
except ImportError:
|
||||
# Python 2.5 and earlier
|
||||
from md5 import new as md5
|
||||
|
||||
def _int2binstr(i,l):
|
||||
s=''
|
||||
for a in range(l):
|
||||
s=chr(i&0xFF)+s
|
||||
i>>=8
|
||||
return s
|
||||
|
||||
def _binstr2int(s):
|
||||
i = long(0)
|
||||
for c in s:
|
||||
i = (i<<8) + ord(c)
|
||||
return i
|
||||
|
||||
class UUID(object):
|
||||
"""
|
||||
A class which represents a 16 byte integer. Stored as a 16 byte 8
|
||||
bit character string.
|
||||
|
||||
The string version is to be of the form:
|
||||
AAAAAAAA-AAAA-BBBB-BBBB-BBBBBBCCCCCC (a 128-bit number in hex)
|
||||
where A=network address, B=timestamp, C=random.
|
||||
"""
|
||||
|
||||
NULL_STR = "00000000-0000-0000-0000-000000000000"
|
||||
|
||||
# the UUIDREGEX_STRING is helpful for parsing UUID's in text
|
||||
hex_wildcard = r"[0-9a-fA-F]"
|
||||
word = hex_wildcard + r"{4,4}-"
|
||||
long_word = hex_wildcard + r"{8,8}-"
|
||||
very_long_word = hex_wildcard + r"{12,12}"
|
||||
UUID_REGEX_STRING = long_word + word + word + word + very_long_word
|
||||
uuid_regex = re.compile(UUID_REGEX_STRING)
|
||||
|
||||
rand = random.Random()
|
||||
ip = ''
|
||||
try:
|
||||
ip = socket.gethostbyname(socket.gethostname())
|
||||
except(socket.gaierror, socket.error):
|
||||
# no ip address, so just default to somewhere in 10.x.x.x
|
||||
ip = '10'
|
||||
for i in range(3):
|
||||
ip += '.' + str(rand.randrange(1,254))
|
||||
hexip = ''.join(["%04x" % long(i) for i in ip.split('.')])
|
||||
lastid = ''
|
||||
|
||||
def __init__(self, possible_uuid=None):
|
||||
"""
|
||||
Initialize to first valid UUID in argument (if a string),
|
||||
or to null UUID if none found or argument is not supplied.
|
||||
|
||||
If the argument is a UUID, the constructed object will be a copy of it.
|
||||
"""
|
||||
self._bits = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
if possible_uuid is None:
|
||||
return
|
||||
|
||||
if isinstance(possible_uuid, type(self)):
|
||||
self.set(possible_uuid)
|
||||
return
|
||||
|
||||
uuid_match = UUID.uuid_regex.search(possible_uuid)
|
||||
if uuid_match:
|
||||
uuid_string = uuid_match.group()
|
||||
s = string.replace(uuid_string, '-', '')
|
||||
self._bits = _int2binstr(string.atol(s[:8],16),4) + \
|
||||
_int2binstr(string.atol(s[8:16],16),4) + \
|
||||
_int2binstr(string.atol(s[16:24],16),4) + \
|
||||
_int2binstr(string.atol(s[24:],16),4)
|
||||
|
||||
def __len__(self):
|
||||
"""
|
||||
Used by the len() builtin.
|
||||
"""
|
||||
return 36
|
||||
|
||||
def __nonzero__(self):
|
||||
return self._bits != "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
||||
|
||||
def __str__(self):
|
||||
uuid_string = self.toString()
|
||||
return uuid_string
|
||||
|
||||
__repr__ = __str__
|
||||
|
||||
def __getitem__(self, index):
|
||||
return str(self)[index]
|
||||
|
||||
def __eq__(self, other):
|
||||
if isinstance(other, (str, unicode)):
|
||||
return other == str(self)
|
||||
return self._bits == getattr(other, '_bits', '')
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __le__(self, other):
|
||||
return self._bits <= other._bits
|
||||
|
||||
def __ge__(self, other):
|
||||
return self._bits >= other._bits
|
||||
|
||||
def __lt__(self, other):
|
||||
return self._bits < other._bits
|
||||
|
||||
def __gt__(self, other):
|
||||
return self._bits > other._bits
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._bits)
|
||||
|
||||
def set(self, uuid):
|
||||
self._bits = uuid._bits
|
||||
|
||||
def setFromString(self, uuid_string):
|
||||
"""
|
||||
Given a string version of a uuid, set self bits
|
||||
appropriately. Returns self.
|
||||
"""
|
||||
s = string.replace(uuid_string, '-', '')
|
||||
self._bits = _int2binstr(string.atol(s[:8],16),4) + \
|
||||
_int2binstr(string.atol(s[8:16],16),4) + \
|
||||
_int2binstr(string.atol(s[16:24],16),4) + \
|
||||
_int2binstr(string.atol(s[24:],16),4)
|
||||
return self
|
||||
|
||||
def setFromMemoryDump(self, gdb_string):
|
||||
"""
|
||||
We expect to get gdb_string as four hex units. eg:
|
||||
0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2
|
||||
Which will be translated to:
|
||||
db547d14-1b3f4bc3-9b984f71-d22f890a
|
||||
Returns self.
|
||||
"""
|
||||
s = string.replace(gdb_string, '0x', '')
|
||||
s = string.replace(s, ' ', '')
|
||||
t = ''
|
||||
for i in range(8,40,8):
|
||||
for j in range(0,8,2):
|
||||
t = t + s[i-j-2:i-j]
|
||||
self.setFromString(t)
|
||||
|
||||
def toString(self):
|
||||
"""
|
||||
Return as a string matching the LL standard
|
||||
AAAAAAAA-AAAA-BBBB-BBBB-BBBBBBCCCCCC (a 128-bit number in hex)
|
||||
where A=network address, B=timestamp, C=random.
|
||||
"""
|
||||
return uuid_bits_to_string(self._bits)
|
||||
|
||||
def getAsString(self):
|
||||
"""
|
||||
Return a different string representation of the form
|
||||
AAAAAAAA-AAAABBBB-BBBBBBBB-BBCCCCCC (a 128-bit number in hex)
|
||||
where A=network address, B=timestamp, C=random.
|
||||
"""
|
||||
i1 = _binstr2int(self._bits[0:4])
|
||||
i2 = _binstr2int(self._bits[4:8])
|
||||
i3 = _binstr2int(self._bits[8:12])
|
||||
i4 = _binstr2int(self._bits[12:16])
|
||||
return '%08lx-%08lx-%08lx-%08lx' % (i1,i2,i3,i4)
|
||||
|
||||
def generate(self):
|
||||
"""
|
||||
Generate a new uuid. This algorithm is slightly different
|
||||
from c++ implementation for portability reasons.
|
||||
Returns self.
|
||||
"""
|
||||
m = md5()
|
||||
m.update(uuid.uuid1().bytes)
|
||||
self._bits = m.digest()
|
||||
return self
|
||||
|
||||
def isNull(self):
|
||||
"""
|
||||
Returns 1 if the uuid is null - ie, equal to default uuid.
|
||||
"""
|
||||
return (self._bits == "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0")
|
||||
|
||||
def xor(self, rhs):
|
||||
"""
|
||||
xors self with rhs.
|
||||
"""
|
||||
v1 = _binstr2int(self._bits[0:4]) ^ _binstr2int(rhs._bits[0:4])
|
||||
v2 = _binstr2int(self._bits[4:8]) ^ _binstr2int(rhs._bits[4:8])
|
||||
v3 = _binstr2int(self._bits[8:12]) ^ _binstr2int(rhs._bits[8:12])
|
||||
v4 = _binstr2int(self._bits[12:16]) ^ _binstr2int(rhs._bits[12:16])
|
||||
self._bits = _int2binstr(v1,4) + \
|
||||
_int2binstr(v2,4) + \
|
||||
_int2binstr(v3,4) + \
|
||||
_int2binstr(v4,4)
|
||||
|
||||
|
||||
# module-level null constant
|
||||
NULL = UUID()
|
||||
|
||||
def printTranslatedMemory(four_hex_uints):
|
||||
"""
|
||||
We expect to get the string as four hex units. eg:
|
||||
0x147d54db 0xc34b3f1b 0x714f989b 0x0a892fd2
|
||||
Which will be translated to:
|
||||
db547d14-1b3f4bc3-9b984f71-d22f890a
|
||||
"""
|
||||
uuid = UUID()
|
||||
uuid.setFromMemoryDump(four_hex_uints)
|
||||
print uuid.toString()
|
||||
|
||||
def isUUID(id_str):
|
||||
"""
|
||||
This function returns:
|
||||
- 1 if the string passed is a UUID
|
||||
- 0 is the string passed is not a UUID
|
||||
- None if it neither of the if's below is satisfied
|
||||
"""
|
||||
if not id_str or len(id_str) < 5 or len(id_str) > 36:
|
||||
return 0
|
||||
|
||||
if isinstance(id_str, UUID) or UUID.uuid_regex.match(id_str):
|
||||
return 1
|
||||
|
||||
return None
|
||||
|
||||
def isPossiblyID(id_str):
|
||||
"""
|
||||
This function returns 1 if the string passed has some uuid-like
|
||||
characteristics. Otherwise returns 0.
|
||||
"""
|
||||
|
||||
is_uuid = isUUID(id_str)
|
||||
if is_uuid is not None:
|
||||
return is_uuid
|
||||
|
||||
# build a string which matches every character.
|
||||
hex_wildcard = r"[0-9a-fA-F]"
|
||||
chars = len(id_str)
|
||||
next = min(chars, 8)
|
||||
matcher = hex_wildcard+"{"+str(next)+","+str(next)+"}"
|
||||
chars = chars - next
|
||||
if chars > 0:
|
||||
matcher = matcher + "-"
|
||||
chars = chars - 1
|
||||
for block in range(3):
|
||||
next = max(min(chars, 4), 0)
|
||||
if next:
|
||||
matcher = matcher + hex_wildcard+"{"+str(next)+","+str(next)+"}"
|
||||
chars = chars - next
|
||||
if chars > 0:
|
||||
matcher = matcher + "-"
|
||||
chars = chars - 1
|
||||
if chars > 0:
|
||||
next = min(chars, 12)
|
||||
matcher = matcher + hex_wildcard+"{"+str(next)+","+str(next)+"}"
|
||||
#print matcher
|
||||
uuid_matcher = re.compile(matcher)
|
||||
if uuid_matcher.match(id_str):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def uuid_bits_to_string(bits):
|
||||
i1 = _binstr2int(bits[0:4])
|
||||
i2 = _binstr2int(bits[4:6])
|
||||
i3 = _binstr2int(bits[6:8])
|
||||
i4 = _binstr2int(bits[8:10])
|
||||
i5 = _binstr2int(bits[10:12])
|
||||
i6 = _binstr2int(bits[12:16])
|
||||
return '%08lx-%04lx-%04lx-%04lx-%04lx%08lx' % (i1,i2,i3,i4,i5,i6)
|
||||
|
||||
def uuid_bits_to_uuid(bits):
|
||||
return UUID(uuid_bits_to_string(bits))
|
||||
|
||||
|
||||
try:
|
||||
from mulib import stacked
|
||||
stacked.NoProducer() # just to exercise stacked
|
||||
except:
|
||||
#print "Couldn't import mulib.stacked, not registering UUID converter"
|
||||
pass
|
||||
else:
|
||||
def convertUUID(uuid, req):
|
||||
req.write(str(uuid))
|
||||
|
||||
stacked.add_producer(UUID, convertUUID, "*/*")
|
||||
stacked.add_producer(UUID, convertUUID, "text/html")
|
||||
@@ -1,121 +0,0 @@
|
||||
"""\
|
||||
@file metrics.py
|
||||
@author Phoenix
|
||||
@date 2007-11-27
|
||||
@brief simple interface for logging metrics
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import sys
|
||||
try:
|
||||
import syslog
|
||||
except ImportError:
|
||||
# Windows
|
||||
import sys
|
||||
class syslog(object):
|
||||
# wrap to a lame syslog for windows
|
||||
_logfp = sys.stderr
|
||||
def syslog(msg):
|
||||
_logfp.write(msg)
|
||||
if not msg.endswith('\n'):
|
||||
_logfp.write('\n')
|
||||
syslog = staticmethod(syslog)
|
||||
|
||||
from indra.base.llsd import format_notation
|
||||
|
||||
def record_metrics(table, stats):
|
||||
"Write a standard metrics log"
|
||||
_log("LLMETRICS", table, stats)
|
||||
|
||||
def record_event(table, data):
|
||||
"Write a standard logmessage log"
|
||||
_log("LLLOGMESSAGE", table, data)
|
||||
|
||||
def set_destination(dest):
|
||||
"""Set the destination of metrics logs for this process.
|
||||
|
||||
If you do not call this function prior to calling a logging
|
||||
method, that function will open sys.stdout as a destination.
|
||||
Attempts to set dest to None will throw a RuntimeError.
|
||||
@param dest a file-like object which will be the destination for logs."""
|
||||
if dest is None:
|
||||
raise RuntimeError("Attempt to unset metrics destination.")
|
||||
global _destination
|
||||
_destination = dest
|
||||
|
||||
def destination():
|
||||
"""Get the destination of the metrics logs for this process.
|
||||
Returns None if no destination is set"""
|
||||
global _destination
|
||||
return _destination
|
||||
|
||||
class SysLogger(object):
|
||||
"A file-like object which writes to syslog."
|
||||
def __init__(self, ident='indra', logopt = None, facility = None):
|
||||
try:
|
||||
if logopt is None:
|
||||
logopt = syslog.LOG_CONS | syslog.LOG_PID
|
||||
if facility is None:
|
||||
facility = syslog.LOG_LOCAL0
|
||||
syslog.openlog(ident, logopt, facility)
|
||||
import atexit
|
||||
atexit.register(syslog.closelog)
|
||||
except AttributeError:
|
||||
# No syslog module on Windows
|
||||
pass
|
||||
|
||||
def write(str):
|
||||
syslog.syslog(str)
|
||||
write = staticmethod(write)
|
||||
|
||||
def flush():
|
||||
pass
|
||||
flush = staticmethod(flush)
|
||||
|
||||
#
|
||||
# internal API
|
||||
#
|
||||
_sequence_id = 0
|
||||
_destination = None
|
||||
|
||||
def _next_id():
|
||||
global _sequence_id
|
||||
next = _sequence_id
|
||||
_sequence_id += 1
|
||||
return next
|
||||
|
||||
def _dest():
|
||||
global _destination
|
||||
if _destination is None:
|
||||
# this default behavior is documented in the metrics functions above.
|
||||
_destination = sys.stdout
|
||||
return _destination
|
||||
|
||||
def _log(header, table, data):
|
||||
log_line = "%s (%d) %s %s" \
|
||||
% (header, _next_id(), table, format_notation(data))
|
||||
dest = _dest()
|
||||
dest.write(log_line)
|
||||
dest.flush()
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
## $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||
## Second Life Viewer Source Code
|
||||
## Copyright (C) 2011, Linden Research, Inc.
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation;
|
||||
## version 2.1 of the License only.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library; if not, write to the Free Software
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##
|
||||
## Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
## $/LicenseInfo$
|
||||
|
||||
import warnings
|
||||
|
||||
warnings.warn("indra.ipc.httputil has been deprecated; use eventlet.httpc instead", DeprecationWarning, 2)
|
||||
|
||||
from eventlet.httpc import *
|
||||
|
||||
|
||||
makeConnection = make_connection
|
||||
@@ -1,100 +0,0 @@
|
||||
"""\
|
||||
@file llsdhttp.py
|
||||
@brief Functions to ease moving llsd over http
|
||||
|
||||
$LicenseInfo:firstyear=2006&license=mit$
|
||||
|
||||
Copyright (c) 2006-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import os.path
|
||||
import os
|
||||
import urlparse
|
||||
|
||||
from indra.base import llsd
|
||||
|
||||
from eventlet import httpc
|
||||
|
||||
suite = httpc.HttpSuite(llsd.format_xml, llsd.parse, 'application/llsd+xml')
|
||||
delete = suite.delete
|
||||
delete_ = suite.delete_
|
||||
get = suite.get
|
||||
get_ = suite.get_
|
||||
head = suite.head
|
||||
head_ = suite.head_
|
||||
post = suite.post
|
||||
post_ = suite.post_
|
||||
put = suite.put
|
||||
put_ = suite.put_
|
||||
request = suite.request
|
||||
request_ = suite.request_
|
||||
|
||||
# import every httpc error exception into our namespace for convenience
|
||||
for x in httpc.status_to_error_map.itervalues():
|
||||
globals()[x.__name__] = x
|
||||
ConnectionError = httpc.ConnectionError
|
||||
Retriable = httpc.Retriable
|
||||
|
||||
for x in (httpc.ConnectionError,):
|
||||
globals()[x.__name__] = x
|
||||
|
||||
|
||||
def postFile(url, filename):
|
||||
f = open(filename)
|
||||
body = f.read()
|
||||
f.close()
|
||||
llsd_body = llsd.parse(body)
|
||||
return post_(url, llsd_body)
|
||||
|
||||
|
||||
# deprecated in favor of get_
|
||||
def getStatus(url, use_proxy=False):
|
||||
status, _headers, _body = get_(url, use_proxy=use_proxy)
|
||||
return status
|
||||
|
||||
# deprecated in favor of put_
|
||||
def putStatus(url, data):
|
||||
status, _headers, _body = put_(url, data)
|
||||
return status
|
||||
|
||||
# deprecated in favor of delete_
|
||||
def deleteStatus(url):
|
||||
status, _headers, _body = delete_(url)
|
||||
return status
|
||||
|
||||
# deprecated in favor of post_
|
||||
def postStatus(url, data):
|
||||
status, _headers, _body = post_(url, data)
|
||||
return status
|
||||
|
||||
|
||||
def postFileStatus(url, filename):
|
||||
status, _headers, body = postFile(url, filename)
|
||||
return status, body
|
||||
|
||||
|
||||
def getFromSimulator(path, use_proxy=False):
|
||||
return get('http://' + simulatorHostAndPort + path, use_proxy=use_proxy)
|
||||
|
||||
|
||||
def postToSimulator(path, data=None):
|
||||
return post('http://' + simulatorHostAndPort + path, data)
|
||||
@@ -1,81 +0,0 @@
|
||||
"""\
|
||||
@file mysql_pool.py
|
||||
@brief Thin wrapper around eventlet.db_pool that chooses MySQLdb and Tpool.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import MySQLdb
|
||||
from eventlet import db_pool
|
||||
|
||||
class DatabaseConnector(db_pool.DatabaseConnector):
|
||||
def __init__(self, credentials, *args, **kwargs):
|
||||
super(DatabaseConnector, self).__init__(MySQLdb, credentials,
|
||||
conn_pool=db_pool.ConnectionPool,
|
||||
*args, **kwargs)
|
||||
|
||||
# get is extended relative to eventlet.db_pool to accept a port argument
|
||||
def get(self, host, dbname, port=3306):
|
||||
key = (host, dbname, port)
|
||||
if key not in self._databases:
|
||||
new_kwargs = self._kwargs.copy()
|
||||
new_kwargs['db'] = dbname
|
||||
new_kwargs['host'] = host
|
||||
new_kwargs['port'] = port
|
||||
new_kwargs.update(self.credentials_for(host))
|
||||
dbpool = ConnectionPool(*self._args, **new_kwargs)
|
||||
self._databases[key] = dbpool
|
||||
|
||||
return self._databases[key]
|
||||
|
||||
class ConnectionPool(db_pool.TpooledConnectionPool):
|
||||
"""A pool which gives out saranwrapped MySQLdb connections from a pool
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ConnectionPool, self).__init__(MySQLdb, *args, **kwargs)
|
||||
|
||||
def get(self):
|
||||
conn = super(ConnectionPool, self).get()
|
||||
# annotate the connection object with the details on the
|
||||
# connection; this is used elsewhere to check that you haven't
|
||||
# suddenly changed databases in midstream while making a
|
||||
# series of queries on a connection.
|
||||
arg_names = ['host','user','passwd','db','port','unix_socket','conv','connect_timeout',
|
||||
'compress', 'named_pipe', 'init_command', 'read_default_file', 'read_default_group',
|
||||
'cursorclass', 'use_unicode', 'charset', 'sql_mode', 'client_flag', 'ssl',
|
||||
'local_infile']
|
||||
# you could have constructed this connectionpool with a mix of
|
||||
# keyword and non-keyword arguments, but we want to annotate
|
||||
# the connection object with a dict so it's easy to check
|
||||
# against so here we are converting the list of non-keyword
|
||||
# arguments (in self._args) into a dict of keyword arguments,
|
||||
# and merging that with the actual keyword arguments
|
||||
# (self._kwargs). The arg_names variable lists the
|
||||
# constructor arguments for MySQLdb Connection objects.
|
||||
converted_kwargs = dict([ (arg_names[i], arg) for i, arg in enumerate(self._args) ])
|
||||
converted_kwargs.update(self._kwargs)
|
||||
conn.connection_parameters = converted_kwargs
|
||||
return conn
|
||||
|
||||
@@ -1,165 +0,0 @@
|
||||
"""\
|
||||
@file russ.py
|
||||
@brief Recursive URL Substitution Syntax helpers
|
||||
@author Phoenix
|
||||
|
||||
Many details on how this should work is available on the wiki:
|
||||
https://wiki.secondlife.com/wiki/Recursive_URL_Substitution_Syntax
|
||||
|
||||
Adding features to this should be reflected in that page in the
|
||||
implementations section.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import urllib
|
||||
from indra.ipc import llsdhttp
|
||||
|
||||
class UnbalancedBraces(Exception):
|
||||
pass
|
||||
|
||||
class UnknownDirective(Exception):
|
||||
pass
|
||||
|
||||
class BadDirective(Exception):
|
||||
pass
|
||||
|
||||
def format_value_for_path(value):
|
||||
if type(value) in [list, tuple]:
|
||||
# *NOTE: treat lists as unquoted path components so that the quoting
|
||||
# doesn't get out-of-hand. This is a workaround for the fact that
|
||||
# russ always quotes, even if the data it's given is already quoted,
|
||||
# and it's not safe to simply unquote a path directly, so if we want
|
||||
# russ to substitute urls parts inside other url parts we always
|
||||
# have to do so via lists of unquoted path components.
|
||||
return '/'.join([urllib.quote(str(item)) for item in value])
|
||||
else:
|
||||
return urllib.quote(str(value))
|
||||
|
||||
def format(format_str, context):
|
||||
"""@brief Format format string according to rules for RUSS.
|
||||
@see https://osiris.lindenlab.com/mediawiki/index.php/Recursive_URL_Substitution_Syntax
|
||||
@param format_str The input string to format.
|
||||
@param context A map used for string substitutions.
|
||||
@return Returns the formatted string. If no match, the braces remain intact.
|
||||
"""
|
||||
while True:
|
||||
#print "format_str:", format_str
|
||||
all_matches = _find_sub_matches(format_str)
|
||||
if not all_matches:
|
||||
break
|
||||
substitutions = 0
|
||||
while True:
|
||||
matches = all_matches.pop()
|
||||
# we work from right to left to make sure we do not
|
||||
# invalidate positions earlier in format_str
|
||||
matches.reverse()
|
||||
for pos in matches:
|
||||
# Use index since _find_sub_matches should have raised
|
||||
# an exception, and failure to find now is an exception.
|
||||
end = format_str.index('}', pos)
|
||||
#print "directive:", format_str[pos+1:pos+5]
|
||||
if format_str[pos + 1] == '$':
|
||||
value = context[format_str[pos + 2:end]]
|
||||
if value is not None:
|
||||
value = format_value_for_path(value)
|
||||
elif format_str[pos + 1] == '%':
|
||||
value = _build_query_string(
|
||||
context.get(format_str[pos + 2:end]))
|
||||
elif format_str[pos+1:pos+5] == 'http' or format_str[pos+1:pos+5] == 'file':
|
||||
value = _fetch_url_directive(format_str[pos + 1:end])
|
||||
else:
|
||||
raise UnknownDirective, format_str[pos:end + 1]
|
||||
if value is not None:
|
||||
format_str = format_str[:pos]+str(value)+format_str[end+1:]
|
||||
substitutions += 1
|
||||
|
||||
# If there were any substitutions at this depth, re-parse
|
||||
# since this may have revealed new things to substitute
|
||||
if substitutions:
|
||||
break
|
||||
if not all_matches:
|
||||
break
|
||||
|
||||
# If there were no substitutions at all, and we have exhausted
|
||||
# the possible matches, bail.
|
||||
if not substitutions:
|
||||
break
|
||||
return format_str
|
||||
|
||||
def _find_sub_matches(format_str):
|
||||
"""@brief Find all of the substitution matches.
|
||||
@param format_str the RUSS conformant format string.
|
||||
@return Returns an array of depths of arrays of positional matches in input.
|
||||
"""
|
||||
depth = 0
|
||||
matches = []
|
||||
for pos in range(len(format_str)):
|
||||
if format_str[pos] == '{':
|
||||
depth += 1
|
||||
if not len(matches) == depth:
|
||||
matches.append([])
|
||||
matches[depth - 1].append(pos)
|
||||
continue
|
||||
if format_str[pos] == '}':
|
||||
depth -= 1
|
||||
continue
|
||||
if not depth == 0:
|
||||
raise UnbalancedBraces, format_str
|
||||
return matches
|
||||
|
||||
def _build_query_string(query_dict):
|
||||
"""\
|
||||
@breif given a dict, return a query string. utility wrapper for urllib.
|
||||
@param query_dict input query dict
|
||||
@returns Returns an urlencoded query string including leading '?'.
|
||||
"""
|
||||
if query_dict:
|
||||
keys = query_dict.keys()
|
||||
keys.sort()
|
||||
def stringize(value):
|
||||
if type(value) in (str,unicode):
|
||||
return value
|
||||
else:
|
||||
return str(value)
|
||||
query_list = [urllib.quote(str(key)) + '=' + urllib.quote(stringize(query_dict[key])) for key in keys]
|
||||
return '?' + '&'.join(query_list)
|
||||
else:
|
||||
return ''
|
||||
|
||||
def _fetch_url_directive(directive):
|
||||
"*FIX: This only supports GET"
|
||||
commands = directive.split('|')
|
||||
resource = llsdhttp.get(commands[0])
|
||||
if len(commands) == 3:
|
||||
resource = _walk_resource(resource, commands[2])
|
||||
return resource
|
||||
|
||||
def _walk_resource(resource, path):
|
||||
path = path.split('/')
|
||||
for child in path:
|
||||
if not child:
|
||||
continue
|
||||
resource = resource[child]
|
||||
return resource
|
||||
@@ -1,134 +0,0 @@
|
||||
"""\
|
||||
@file servicebuilder.py
|
||||
@author Phoenix
|
||||
@brief Class which will generate service urls.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
from indra.base import config
|
||||
from indra.ipc import llsdhttp
|
||||
from indra.ipc import russ
|
||||
|
||||
# *NOTE: agent presence relies on this variable existing and being current, it is a huge hack
|
||||
services_config = {}
|
||||
try:
|
||||
services_config = llsdhttp.get(config.get('services-config'))
|
||||
except:
|
||||
pass
|
||||
|
||||
_g_builder = None
|
||||
def _builder():
|
||||
global _g_builder
|
||||
if _g_builder is None:
|
||||
_g_builder = ServiceBuilder()
|
||||
return _g_builder
|
||||
|
||||
def build(name, context={}, **kwargs):
|
||||
""" Convenience method for using a global, singleton, service builder. Pass arguments either via a dict or via python keyword arguments, or both!
|
||||
|
||||
Example use:
|
||||
> context = {'channel':'Second Life Release', 'version':'1.18.2.0'}
|
||||
> servicebuilder.build('version-manager-version', context)
|
||||
'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
|
||||
> servicebuilder.build('version-manager-version', channel='Second Life Release', version='1.18.2.0')
|
||||
'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.2.0'
|
||||
> servicebuilder.build('version-manager-version', context, version='1.18.1.2')
|
||||
'http://int.util.vaak.lindenlab.com/channel/Second%20Life%20Release/1.18.1.2'
|
||||
"""
|
||||
global _g_builder
|
||||
if _g_builder is None:
|
||||
_g_builder = ServiceBuilder()
|
||||
return _g_builder.buildServiceURL(name, context, **kwargs)
|
||||
|
||||
def build_path(name, context={}, **kwargs):
|
||||
context = context.copy() # shouldn't modify the caller's dictionary
|
||||
context.update(kwargs)
|
||||
return _builder().buildPath(name, context)
|
||||
|
||||
class ServiceBuilder(object):
|
||||
def __init__(self, services_definition = services_config):
|
||||
"""\
|
||||
@brief
|
||||
@brief Create a ServiceBuilder.
|
||||
@param services_definition Complete services definition, services.xml.
|
||||
"""
|
||||
# no need to keep a copy of the services section of the
|
||||
# complete services definition, but it doesn't hurt much.
|
||||
self.services = services_definition['services']
|
||||
self.builders = {}
|
||||
for service in self.services:
|
||||
service_builder = service.get('service-builder')
|
||||
if not service_builder:
|
||||
continue
|
||||
if isinstance(service_builder, dict):
|
||||
# We will be constructing several builders
|
||||
for name, builder in service_builder.iteritems():
|
||||
full_builder_name = service['name'] + '-' + name
|
||||
self.builders[full_builder_name] = builder
|
||||
else:
|
||||
self.builders[service['name']] = service_builder
|
||||
|
||||
def buildPath(self, name, context):
|
||||
"""\
|
||||
@brief given the environment on construction, return a service path.
|
||||
@param name The name of the service.
|
||||
@param context A dict of name value lookups for the service.
|
||||
@returns Returns the
|
||||
"""
|
||||
return russ.format(self.builders[name], context)
|
||||
|
||||
def buildServiceURL(self, name, context={}, **kwargs):
|
||||
"""\
|
||||
@brief given the environment on construction, return a service URL.
|
||||
@param name The name of the service.
|
||||
@param context A dict of name value lookups for the service.
|
||||
@param kwargs Any keyword arguments are treated as members of the
|
||||
context, this allows you to be all 31337 by writing shit like:
|
||||
servicebuilder.build('name', param=value)
|
||||
@returns Returns the
|
||||
"""
|
||||
context = context.copy() # shouldn't modify the caller's dictionary
|
||||
context.update(kwargs)
|
||||
base_url = config.get('services-base-url')
|
||||
svc_path = russ.format(self.builders[name], context)
|
||||
return base_url + svc_path
|
||||
|
||||
|
||||
def on_in(query_name, host_key, schema_key):
|
||||
"""\
|
||||
@brief Constructs an on/in snippet (for running named queries)
|
||||
from a schema name and two keys referencing values stored in
|
||||
indra.xml.
|
||||
|
||||
@param query_name Name of the query.
|
||||
@param host_key Logical name of destination host. Will be
|
||||
looked up in indra.xml.
|
||||
@param schema_key Logical name of destination schema. Will
|
||||
be looked up in indra.xml.
|
||||
"""
|
||||
return "on/config:%s/in/config:%s/%s" % (host_key.strip('/'),
|
||||
schema_key.strip('/'),
|
||||
query_name.lstrip('/'))
|
||||
|
||||
@@ -1,468 +0,0 @@
|
||||
"""\
|
||||
@file siesta.py
|
||||
@brief A tiny llsd based RESTful web services framework
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
from indra.base import config
|
||||
from indra.base import llsd
|
||||
from webob import exc
|
||||
import webob
|
||||
import re, socket
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
|
||||
try:
|
||||
import cjson
|
||||
json_decode = cjson.decode
|
||||
json_encode = cjson.encode
|
||||
JsonDecodeError = cjson.DecodeError
|
||||
JsonEncodeError = cjson.EncodeError
|
||||
except ImportError:
|
||||
import simplejson
|
||||
json_decode = simplejson.loads
|
||||
json_encode = simplejson.dumps
|
||||
JsonDecodeError = ValueError
|
||||
JsonEncodeError = TypeError
|
||||
|
||||
|
||||
llsd_parsers = {
|
||||
'application/json': json_decode,
|
||||
llsd.BINARY_MIME_TYPE: llsd.parse_binary,
|
||||
'application/llsd+notation': llsd.parse_notation,
|
||||
llsd.XML_MIME_TYPE: llsd.parse_xml,
|
||||
'application/xml': llsd.parse_xml,
|
||||
}
|
||||
|
||||
|
||||
def mime_type(content_type):
|
||||
'''Given a Content-Type header, return only the MIME type.'''
|
||||
|
||||
return content_type.split(';', 1)[0].strip().lower()
|
||||
|
||||
class BodyLLSD(object):
|
||||
'''Give a webob Request or Response an llsd based "content" property.
|
||||
|
||||
Getting the content property parses the body, and caches the result.
|
||||
|
||||
Setting the content property formats a payload, and the body property
|
||||
is set.'''
|
||||
|
||||
def _llsd__get(self):
|
||||
'''Get, set, or delete the LLSD value stored in this object.'''
|
||||
|
||||
try:
|
||||
return self._llsd
|
||||
except AttributeError:
|
||||
if not self.body:
|
||||
raise AttributeError('No llsd attribute has been set')
|
||||
else:
|
||||
mtype = mime_type(self.content_type)
|
||||
try:
|
||||
parser = llsd_parsers[mtype]
|
||||
except KeyError:
|
||||
raise exc.HTTPUnsupportedMediaType(
|
||||
'Content type %s not supported' % mtype).exception
|
||||
try:
|
||||
self._llsd = parser(self.body)
|
||||
except (llsd.LLSDParseError, JsonDecodeError, TypeError), err:
|
||||
raise exc.HTTPBadRequest(
|
||||
'Could not parse body: %r' % err.args).exception
|
||||
return self._llsd
|
||||
|
||||
def _llsd__set(self, val):
|
||||
req = getattr(self, 'request', None)
|
||||
if req is not None:
|
||||
formatter, ctype = formatter_for_request(req)
|
||||
self.content_type = ctype
|
||||
else:
|
||||
formatter, ctype = formatter_for_mime_type(
|
||||
mime_type(self.content_type))
|
||||
self.body = formatter(val)
|
||||
|
||||
def _llsd__del(self):
|
||||
if hasattr(self, '_llsd'):
|
||||
del self._llsd
|
||||
|
||||
content = property(_llsd__get, _llsd__set, _llsd__del)
|
||||
|
||||
|
||||
class Response(webob.Response, BodyLLSD):
|
||||
'''Response class with LLSD support.
|
||||
|
||||
A sensible default content type is used.
|
||||
|
||||
Setting the llsd property also sets the body. Getting the llsd
|
||||
property parses the body if necessary.
|
||||
|
||||
If you set the body property directly, the llsd property will be
|
||||
deleted.'''
|
||||
|
||||
default_content_type = 'application/llsd+xml'
|
||||
|
||||
def _body__set(self, body):
|
||||
if hasattr(self, '_llsd'):
|
||||
del self._llsd
|
||||
super(Response, self)._body__set(body)
|
||||
|
||||
def cache_forever(self):
|
||||
self.cache_expires(86400 * 365)
|
||||
|
||||
body = property(webob.Response._body__get, _body__set,
|
||||
webob.Response._body__del,
|
||||
webob.Response._body__get.__doc__)
|
||||
|
||||
|
||||
class Request(webob.Request, BodyLLSD):
|
||||
'''Request class with LLSD support.
|
||||
|
||||
Sensible content type and accept headers are used by default.
|
||||
|
||||
Setting the content property also sets the body. Getting the content
|
||||
property parses the body if necessary.
|
||||
|
||||
If you set the body property directly, the content property will be
|
||||
deleted.'''
|
||||
|
||||
default_content_type = 'application/llsd+xml'
|
||||
default_accept = ('application/llsd+xml; q=0.5, '
|
||||
'application/llsd+notation; q=0.3, '
|
||||
'application/llsd+binary; q=0.2, '
|
||||
'application/xml; q=0.1, '
|
||||
'application/json; q=0.0')
|
||||
|
||||
def __init__(self, environ=None, *args, **kwargs):
|
||||
if environ is None:
|
||||
environ = {}
|
||||
else:
|
||||
environ = environ.copy()
|
||||
if 'CONTENT_TYPE' not in environ:
|
||||
environ['CONTENT_TYPE'] = self.default_content_type
|
||||
if 'HTTP_ACCEPT' not in environ:
|
||||
environ['HTTP_ACCEPT'] = self.default_accept
|
||||
super(Request, self).__init__(environ, *args, **kwargs)
|
||||
|
||||
def _body__set(self, body):
|
||||
if hasattr(self, '_llsd'):
|
||||
del self._llsd
|
||||
super(Request, self)._body__set(body)
|
||||
|
||||
def path_urljoin(self, *parts):
|
||||
return '/'.join([path_url.rstrip('/')] + list(parts))
|
||||
|
||||
body = property(webob.Request._body__get, _body__set,
|
||||
webob.Request._body__del, webob.Request._body__get.__doc__)
|
||||
|
||||
def create_response(self, content=None, status='200 OK',
|
||||
conditional_response=webob.NoDefault):
|
||||
resp = self.ResponseClass(status=status, request=self,
|
||||
conditional_response=conditional_response)
|
||||
resp.content = content
|
||||
return resp
|
||||
|
||||
def curl(self):
|
||||
'''Create and fill out a pycurl easy object from this request.'''
|
||||
|
||||
import pycurl
|
||||
c = pycurl.Curl()
|
||||
c.setopt(pycurl.URL, self.url())
|
||||
if self.headers:
|
||||
c.setopt(pycurl.HTTPHEADER,
|
||||
['%s: %s' % (k, self.headers[k]) for k in self.headers])
|
||||
c.setopt(pycurl.FOLLOWLOCATION, True)
|
||||
c.setopt(pycurl.AUTOREFERER, True)
|
||||
c.setopt(pycurl.MAXREDIRS, 16)
|
||||
c.setopt(pycurl.NOSIGNAL, True)
|
||||
c.setopt(pycurl.READFUNCTION, self.body_file.read)
|
||||
c.setopt(pycurl.SSL_VERIFYHOST, 2)
|
||||
|
||||
if self.method == 'POST':
|
||||
c.setopt(pycurl.POST, True)
|
||||
post301 = getattr(pycurl, 'POST301', None)
|
||||
if post301 is not None:
|
||||
# Added in libcurl 7.17.1.
|
||||
c.setopt(post301, True)
|
||||
elif self.method == 'PUT':
|
||||
c.setopt(pycurl.PUT, True)
|
||||
elif self.method != 'GET':
|
||||
c.setopt(pycurl.CUSTOMREQUEST, self.method)
|
||||
return c
|
||||
|
||||
Request.ResponseClass = Response
|
||||
Response.RequestClass = Request
|
||||
|
||||
|
||||
llsd_formatters = {
|
||||
'application/json': json_encode,
|
||||
'application/llsd+binary': llsd.format_binary,
|
||||
'application/llsd+notation': llsd.format_notation,
|
||||
'application/llsd+xml': llsd.format_xml,
|
||||
'application/xml': llsd.format_xml,
|
||||
}
|
||||
|
||||
formatter_qualities = (
|
||||
('application/llsd+xml', 1.0),
|
||||
('application/llsd+notation', 0.5),
|
||||
('application/llsd+binary', 0.4),
|
||||
('application/xml', 0.3),
|
||||
('application/json', 0.2),
|
||||
)
|
||||
|
||||
def formatter_for_mime_type(mime_type):
|
||||
'''Return a formatter that encodes to the given MIME type.
|
||||
|
||||
The result is a pair of function and MIME type.'''
|
||||
try:
|
||||
return llsd_formatters[mime_type], mime_type
|
||||
except KeyError:
|
||||
raise exc.HTTPInternalServerError(
|
||||
'Could not use MIME type %r to format response' %
|
||||
mime_type).exception
|
||||
|
||||
|
||||
def formatter_for_request(req):
|
||||
'''Return a formatter that encodes to the preferred type of the client.
|
||||
|
||||
The result is a pair of function and actual MIME type.'''
|
||||
ctype = req.accept.best_match(formatter_qualities)
|
||||
try:
|
||||
return llsd_formatters[ctype], ctype
|
||||
except KeyError:
|
||||
raise exc.HTTPNotAcceptable().exception
|
||||
|
||||
|
||||
def wsgi_adapter(func, environ, start_response):
|
||||
'''Adapt a Siesta callable to act as a WSGI application.'''
|
||||
# Process the request as appropriate.
|
||||
try:
|
||||
req = Request(environ)
|
||||
#print req.urlvars
|
||||
resp = func(req, **req.urlvars)
|
||||
if not isinstance(resp, webob.Response):
|
||||
try:
|
||||
formatter, ctype = formatter_for_request(req)
|
||||
resp = req.ResponseClass(formatter(resp), content_type=ctype)
|
||||
resp._llsd = resp
|
||||
except (JsonEncodeError, TypeError), err:
|
||||
resp = exc.HTTPInternalServerError(
|
||||
detail='Could not format response')
|
||||
except exc.HTTPException, e:
|
||||
resp = e
|
||||
except socket.error, e:
|
||||
resp = exc.HTTPInternalServerError(detail=e.args[1])
|
||||
return resp(environ, start_response)
|
||||
|
||||
|
||||
def llsd_callable(func):
|
||||
'''Turn a callable into a Siesta application.'''
|
||||
|
||||
def replacement(environ, start_response):
|
||||
return wsgi_adapter(func, environ, start_response)
|
||||
|
||||
return replacement
|
||||
|
||||
|
||||
def llsd_method(http_method, func):
|
||||
def replacement(environ, start_response):
|
||||
if environ['REQUEST_METHOD'] == http_method:
|
||||
return wsgi_adapter(func, environ, start_response)
|
||||
return exc.HTTPMethodNotAllowed()(environ, start_response)
|
||||
|
||||
return replacement
|
||||
|
||||
|
||||
http11_methods = 'OPTIONS GET HEAD POST PUT DELETE TRACE CONNECT'.split()
|
||||
http11_methods.sort()
|
||||
|
||||
def llsd_class(cls):
|
||||
'''Turn a class into a Siesta application.
|
||||
|
||||
A new instance is created for each request. A HTTP method FOO is
|
||||
turned into a call to the handle_foo method of the instance.'''
|
||||
|
||||
def foo(req, **kwargs):
|
||||
instance = cls()
|
||||
method = req.method.lower()
|
||||
try:
|
||||
handler = getattr(instance, 'handle_' + method)
|
||||
except AttributeError:
|
||||
allowed = [m for m in http11_methods
|
||||
if hasattr(instance, 'handle_' + m.lower())]
|
||||
raise exc.HTTPMethodNotAllowed(
|
||||
headers={'Allow': ', '.join(allowed)}).exception
|
||||
#print "kwargs: ", kwargs
|
||||
return handler(req, **kwargs)
|
||||
|
||||
def replacement(environ, start_response):
|
||||
return wsgi_adapter(foo, environ, start_response)
|
||||
|
||||
return replacement
|
||||
|
||||
|
||||
def curl(reqs):
|
||||
import pycurl
|
||||
|
||||
m = pycurl.CurlMulti()
|
||||
curls = [r.curl() for r in reqs]
|
||||
io = {}
|
||||
for c in curls:
|
||||
fp = StringIO()
|
||||
hdr = StringIO()
|
||||
c.setopt(pycurl.WRITEFUNCTION, fp.write)
|
||||
c.setopt(pycurl.HEADERFUNCTION, hdr.write)
|
||||
io[id(c)] = fp, hdr
|
||||
m.handles = curls
|
||||
try:
|
||||
while True:
|
||||
ret, num_handles = m.perform()
|
||||
if ret != pycurl.E_CALL_MULTI_PERFORM:
|
||||
break
|
||||
finally:
|
||||
m.close()
|
||||
|
||||
for req, c in zip(reqs, curls):
|
||||
fp, hdr = io[id(c)]
|
||||
hdr.seek(0)
|
||||
status = hdr.readline().rstrip()
|
||||
headers = []
|
||||
name, values = None, None
|
||||
|
||||
# XXX We don't currently handle bogus header data.
|
||||
|
||||
for line in hdr.readlines():
|
||||
if not line[0].isspace():
|
||||
if name:
|
||||
headers.append((name, ' '.join(values)))
|
||||
name, value = line.strip().split(':', 1)
|
||||
value = [value]
|
||||
else:
|
||||
values.append(line.strip())
|
||||
if name:
|
||||
headers.append((name, ' '.join(values)))
|
||||
|
||||
resp = c.ResponseClass(fp.getvalue(), status, headers, request=req)
|
||||
|
||||
|
||||
route_re = re.compile(r'''
|
||||
\{ # exact character "{"
|
||||
(\w*) # "config" or variable (restricted to a-z, 0-9, _)
|
||||
(?:([:~])([^}]+))? # optional :type or ~regex part
|
||||
\} # exact character "}"
|
||||
''', re.VERBOSE)
|
||||
|
||||
predefined_regexps = {
|
||||
'uuid': r'[a-f0-9][a-f0-9-]{31,35}',
|
||||
'int': r'\d+',
|
||||
'host': r'[a-z0-9][a-z0-9\-\.]*',
|
||||
}
|
||||
|
||||
def compile_route(route):
|
||||
fp = StringIO()
|
||||
last_pos = 0
|
||||
for match in route_re.finditer(route):
|
||||
#print "matches: ", match.groups()
|
||||
fp.write(re.escape(route[last_pos:match.start()]))
|
||||
var_name = match.group(1)
|
||||
sep = match.group(2)
|
||||
expr = match.group(3)
|
||||
if var_name == 'config':
|
||||
expr = re.escape(str(config.get(var_name)))
|
||||
else:
|
||||
if expr:
|
||||
if sep == ':':
|
||||
expr = predefined_regexps[expr]
|
||||
# otherwise, treat what follows '~' as a regexp
|
||||
else:
|
||||
expr = '[^/]+'
|
||||
if var_name != '':
|
||||
expr = '(?P<%s>%s)' % (var_name, expr)
|
||||
else:
|
||||
expr = '(%s)' % (expr,)
|
||||
fp.write(expr)
|
||||
last_pos = match.end()
|
||||
fp.write(re.escape(route[last_pos:]))
|
||||
compiled_route = '^%s$' % fp.getvalue()
|
||||
#print route, "->", compiled_route
|
||||
return compiled_route
|
||||
|
||||
class Router(object):
|
||||
'''WSGI routing class. Parses a URL and hands off a request to
|
||||
some other WSGI application. If no suitable application is found,
|
||||
responds with a 404.'''
|
||||
|
||||
def __init__(self):
|
||||
self._new_routes = []
|
||||
self._routes = []
|
||||
self._paths = []
|
||||
|
||||
def add(self, route, app, methods=None):
|
||||
self._new_routes.append((route, app, methods))
|
||||
|
||||
def _create_routes(self):
|
||||
for route, app, methods in self._new_routes:
|
||||
self._paths.append(route)
|
||||
self._routes.append(
|
||||
(re.compile(compile_route(route)),
|
||||
app,
|
||||
methods and dict.fromkeys(methods)))
|
||||
self._new_routes = []
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
# load up the config from the config file. Only needs to be
|
||||
# done once per interpreter. This is the entry point of all
|
||||
# siesta applications, so this is where we trap it.
|
||||
_conf = config.get_config()
|
||||
if _conf is None:
|
||||
import os.path
|
||||
fname = os.path.join(
|
||||
environ.get('ll.config_dir', '/local/linden/etc'),
|
||||
'indra.xml')
|
||||
config.load(fname)
|
||||
|
||||
# proceed with handling the request
|
||||
self._create_routes()
|
||||
path_info = environ['PATH_INFO']
|
||||
request_method = environ['REQUEST_METHOD']
|
||||
allowed = []
|
||||
for regex, app, methods in self._routes:
|
||||
m = regex.match(path_info)
|
||||
if m:
|
||||
#print "groupdict:",m.groupdict()
|
||||
if not methods or request_method in methods:
|
||||
environ['paste.urlvars'] = m.groupdict()
|
||||
return app(environ, start_response)
|
||||
else:
|
||||
allowed += methods
|
||||
if allowed:
|
||||
allowed = dict.fromkeys(allows).keys()
|
||||
allowed.sort()
|
||||
resp = exc.HTTPMethodNotAllowed(
|
||||
headers={'Allow': ', '.join(allowed)})
|
||||
else:
|
||||
resp = exc.HTTPNotFound()
|
||||
return resp(environ, start_response)
|
||||
@@ -1,235 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
## $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||
## Second Life Viewer Source Code
|
||||
## Copyright (C) 2011, Linden Research, Inc.
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation;
|
||||
## version 2.1 of the License only.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library; if not, write to the Free Software
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##
|
||||
## Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
## $/LicenseInfo$
|
||||
from indra.base import llsd, lluuid
|
||||
from indra.ipc import siesta
|
||||
import datetime, math, unittest
|
||||
from webob import exc
|
||||
|
||||
|
||||
class ClassApp(object):
|
||||
def handle_get(self, req):
|
||||
pass
|
||||
|
||||
def handle_post(self, req):
|
||||
return req.llsd
|
||||
|
||||
|
||||
def callable_app(req):
|
||||
if req.method == 'UNDERPANTS':
|
||||
raise exc.HTTPMethodNotAllowed()
|
||||
elif req.method == 'GET':
|
||||
return None
|
||||
return req.llsd
|
||||
|
||||
|
||||
class TestBase:
|
||||
def test_basic_get(self):
|
||||
req = siesta.Request.blank('/')
|
||||
self.assertEquals(req.get_response(self.server).body,
|
||||
llsd.format_xml(None))
|
||||
|
||||
def test_bad_method(self):
|
||||
req = siesta.Request.blank('/')
|
||||
req.environ['REQUEST_METHOD'] = 'UNDERPANTS'
|
||||
self.assertEquals(req.get_response(self.server).status_int,
|
||||
exc.HTTPMethodNotAllowed.code)
|
||||
|
||||
json_safe = {
|
||||
'none': None,
|
||||
'bool_true': True,
|
||||
'bool_false': False,
|
||||
'int_zero': 0,
|
||||
'int_max': 2147483647,
|
||||
'int_min': -2147483648,
|
||||
'long_zero': 0,
|
||||
'long_max': 2147483647L,
|
||||
'long_min': -2147483648L,
|
||||
'float_zero': 0,
|
||||
'float': math.pi,
|
||||
'float_huge': 3.14159265358979323846e299,
|
||||
'str_empty': '',
|
||||
'str': 'foo',
|
||||
u'unic\u1e51de_empty': u'',
|
||||
u'unic\u1e51de': u'\u1e4exx\u10480',
|
||||
}
|
||||
json_safe['array'] = json_safe.values()
|
||||
json_safe['tuple'] = tuple(json_safe.values())
|
||||
json_safe['dict'] = json_safe.copy()
|
||||
|
||||
json_unsafe = {
|
||||
'uuid_empty': lluuid.UUID(),
|
||||
'uuid_full': lluuid.UUID('dc61ab0530200d7554d23510559102c1a98aab1b'),
|
||||
'binary_empty': llsd.binary(),
|
||||
'binary': llsd.binary('f\0\xff'),
|
||||
'uri_empty': llsd.uri(),
|
||||
'uri': llsd.uri('http://www.secondlife.com/'),
|
||||
'datetime_empty': datetime.datetime(1970,1,1),
|
||||
'datetime': datetime.datetime(1999,9,9,9,9,9),
|
||||
}
|
||||
json_unsafe.update(json_safe)
|
||||
json_unsafe['array'] = json_unsafe.values()
|
||||
json_unsafe['tuple'] = tuple(json_unsafe.values())
|
||||
json_unsafe['dict'] = json_unsafe.copy()
|
||||
json_unsafe['iter'] = iter(json_unsafe.values())
|
||||
|
||||
def _test_client_content_type_good(self, content_type, ll):
|
||||
def run(ll):
|
||||
req = siesta.Request.blank('/')
|
||||
req.environ['REQUEST_METHOD'] = 'POST'
|
||||
req.content_type = content_type
|
||||
req.llsd = ll
|
||||
req.accept = content_type
|
||||
resp = req.get_response(self.server)
|
||||
self.assertEquals(resp.status_int, 200)
|
||||
return req, resp
|
||||
|
||||
if False and isinstance(ll, dict):
|
||||
def fixup(v):
|
||||
if isinstance(v, float):
|
||||
return '%.5f' % v
|
||||
if isinstance(v, long):
|
||||
return int(v)
|
||||
if isinstance(v, (llsd.binary, llsd.uri)):
|
||||
return v
|
||||
if isinstance(v, (tuple, list)):
|
||||
return [fixup(i) for i in v]
|
||||
if isinstance(v, dict):
|
||||
return dict([(k, fixup(i)) for k, i in v.iteritems()])
|
||||
return v
|
||||
for k, v in ll.iteritems():
|
||||
l = [k, v]
|
||||
req, resp = run(l)
|
||||
self.assertEquals(fixup(resp.llsd), fixup(l))
|
||||
|
||||
run(ll)
|
||||
|
||||
def test_client_content_type_json_good(self):
|
||||
self._test_client_content_type_good('application/json', self.json_safe)
|
||||
|
||||
def test_client_content_type_llsd_xml_good(self):
|
||||
self._test_client_content_type_good('application/llsd+xml',
|
||||
self.json_unsafe)
|
||||
|
||||
def test_client_content_type_llsd_notation_good(self):
|
||||
self._test_client_content_type_good('application/llsd+notation',
|
||||
self.json_unsafe)
|
||||
|
||||
def test_client_content_type_llsd_binary_good(self):
|
||||
self._test_client_content_type_good('application/llsd+binary',
|
||||
self.json_unsafe)
|
||||
|
||||
def test_client_content_type_xml_good(self):
|
||||
self._test_client_content_type_good('application/xml',
|
||||
self.json_unsafe)
|
||||
|
||||
def _test_client_content_type_bad(self, content_type):
|
||||
req = siesta.Request.blank('/')
|
||||
req.environ['REQUEST_METHOD'] = 'POST'
|
||||
req.body = '\0invalid nonsense under all encodings'
|
||||
req.content_type = content_type
|
||||
self.assertEquals(req.get_response(self.server).status_int,
|
||||
exc.HTTPBadRequest.code)
|
||||
|
||||
def test_client_content_type_json_bad(self):
|
||||
self._test_client_content_type_bad('application/json')
|
||||
|
||||
def test_client_content_type_llsd_xml_bad(self):
|
||||
self._test_client_content_type_bad('application/llsd+xml')
|
||||
|
||||
def test_client_content_type_llsd_notation_bad(self):
|
||||
self._test_client_content_type_bad('application/llsd+notation')
|
||||
|
||||
def test_client_content_type_llsd_binary_bad(self):
|
||||
self._test_client_content_type_bad('application/llsd+binary')
|
||||
|
||||
def test_client_content_type_xml_bad(self):
|
||||
self._test_client_content_type_bad('application/xml')
|
||||
|
||||
def test_client_content_type_bad(self):
|
||||
req = siesta.Request.blank('/')
|
||||
req.environ['REQUEST_METHOD'] = 'POST'
|
||||
req.body = 'XXX'
|
||||
req.content_type = 'application/nonsense'
|
||||
self.assertEquals(req.get_response(self.server).status_int,
|
||||
exc.HTTPUnsupportedMediaType.code)
|
||||
|
||||
def test_request_default_content_type(self):
|
||||
req = siesta.Request.blank('/')
|
||||
self.assertEquals(req.content_type, req.default_content_type)
|
||||
|
||||
def test_request_default_accept(self):
|
||||
req = siesta.Request.blank('/')
|
||||
from webob import acceptparse
|
||||
self.assertEquals(str(req.accept).replace(' ', ''),
|
||||
req.default_accept.replace(' ', ''))
|
||||
|
||||
def test_request_llsd_auto_body(self):
|
||||
req = siesta.Request.blank('/')
|
||||
req.llsd = {'a': 2}
|
||||
self.assertEquals(req.body, '<?xml version="1.0" ?><llsd><map>'
|
||||
'<key>a</key><integer>2</integer></map></llsd>')
|
||||
|
||||
def test_request_llsd_mod_body_changes_llsd(self):
|
||||
req = siesta.Request.blank('/')
|
||||
req.llsd = {'a': 2}
|
||||
req.body = '<?xml version="1.0" ?><llsd><integer>1337</integer></llsd>'
|
||||
self.assertEquals(req.llsd, 1337)
|
||||
|
||||
def test_request_bad_llsd_fails(self):
|
||||
def crashme(ctype):
|
||||
def boom():
|
||||
class foo(object): pass
|
||||
req = siesta.Request.blank('/')
|
||||
req.content_type = ctype
|
||||
req.llsd = foo()
|
||||
for mime_type in siesta.llsd_parsers:
|
||||
self.assertRaises(TypeError, crashme(mime_type))
|
||||
|
||||
|
||||
class ClassServer(TestBase, unittest.TestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
unittest.TestCase.__init__(self, *args, **kwargs)
|
||||
self.server = siesta.llsd_class(ClassApp)
|
||||
|
||||
|
||||
class CallableServer(TestBase, unittest.TestCase):
|
||||
def __init__(self, *args, **kwargs):
|
||||
unittest.TestCase.__init__(self, *args, **kwargs)
|
||||
self.server = siesta.llsd_callable(callable_app)
|
||||
|
||||
|
||||
class RouterServer(unittest.TestCase):
|
||||
def test_router(self):
|
||||
def foo(req, quux):
|
||||
print quux
|
||||
|
||||
r = siesta.Router()
|
||||
r.add('/foo/{quux:int}', siesta.llsd_callable(foo), methods=['GET'])
|
||||
req = siesta.Request.blank('/foo/33')
|
||||
req.get_response(r)
|
||||
|
||||
req = siesta.Request.blank('/foo/bar')
|
||||
self.assertEquals(req.get_response(r).status_int,
|
||||
exc.HTTPNotFound.code)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -1,597 +0,0 @@
|
||||
"""
|
||||
@file webdav.py
|
||||
@brief Classes to make manipulation of a webdav store easier.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import sys, os, httplib, urlparse
|
||||
import socket, time
|
||||
import xml.dom.minidom
|
||||
import syslog
|
||||
# import signal
|
||||
|
||||
__revision__ = '0'
|
||||
|
||||
dav_debug = False
|
||||
|
||||
|
||||
# def urlsafe_b64decode (enc):
|
||||
# return base64.decodestring (enc.replace ('_', '/').replace ('-', '+'))
|
||||
|
||||
# def urlsafe_b64encode (str):
|
||||
# return base64.encodestring (str).replace ('+', '-').replace ('/', '_')
|
||||
|
||||
|
||||
class DAVError (Exception):
|
||||
""" Base class for exceptions in this module. """
|
||||
def __init__ (self, status=0, message='', body='', details=''):
|
||||
self.status = status
|
||||
self.message = message
|
||||
self.body = body
|
||||
self.details = details
|
||||
Exception.__init__ (self, '%d:%s:%s%s' % (self.status, self.message,
|
||||
self.body, self.details))
|
||||
|
||||
def print_to_stderr (self):
|
||||
""" print_to_stderr docstring """
|
||||
print >> sys.stderr, str (self.status) + ' ' + self.message
|
||||
print >> sys.stderr, str (self.details)
|
||||
|
||||
|
||||
class Timeout (Exception):
|
||||
""" Timeout docstring """
|
||||
def __init__ (self, arg=''):
|
||||
Exception.__init__ (self, arg)
|
||||
|
||||
|
||||
def alarm_handler (signum, frame):
|
||||
""" alarm_handler docstring """
|
||||
raise Timeout ('caught alarm')
|
||||
|
||||
|
||||
class WebDAV:
|
||||
""" WebDAV docstring """
|
||||
def __init__ (self, url, proxy=None, retries_before_fail=6):
|
||||
self.init_url = url
|
||||
self.init_proxy = proxy
|
||||
self.retries_before_fail = retries_before_fail
|
||||
url_parsed = urlparse.urlsplit (url)
|
||||
|
||||
self.top_path = url_parsed[ 2 ]
|
||||
# make sure top_path has a trailing /
|
||||
if self.top_path == None or self.top_path == '':
|
||||
self.top_path = '/'
|
||||
elif len (self.top_path) > 1 and self.top_path[-1:] != '/':
|
||||
self.top_path += '/'
|
||||
|
||||
if dav_debug:
|
||||
syslog.syslog ('new WebDAV %s : %s' % (str (url), str (proxy)))
|
||||
|
||||
if proxy:
|
||||
proxy_parsed = urlparse.urlsplit (proxy)
|
||||
self.host_header = url_parsed[ 1 ]
|
||||
host_and_port = proxy_parsed[ 1 ].split (':')
|
||||
self.host = host_and_port[ 0 ]
|
||||
if len (host_and_port) > 1:
|
||||
self.port = int(host_and_port[ 1 ])
|
||||
else:
|
||||
self.port = 80
|
||||
else: # no proxy
|
||||
host_and_port = url_parsed[ 1 ].split (':')
|
||||
self.host_header = None
|
||||
self.host = host_and_port[ 0 ]
|
||||
if len (host_and_port) > 1:
|
||||
self.port = int(host_and_port[ 1 ])
|
||||
else:
|
||||
self.port = 80
|
||||
|
||||
self.connection = False
|
||||
self.connect ()
|
||||
|
||||
|
||||
def log (self, msg, depth=0):
|
||||
""" log docstring """
|
||||
if dav_debug and depth == 0:
|
||||
host = str (self.init_url)
|
||||
if host == 'http://int.tuco.lindenlab.com:80/asset/':
|
||||
host = 'tuco'
|
||||
if host == 'http://harriet.lindenlab.com/asset-keep/':
|
||||
host = 'harriet/asset-keep'
|
||||
if host == 'http://harriet.lindenlab.com/asset-flag/':
|
||||
host = 'harriet/asset-flag'
|
||||
if host == 'http://harriet.lindenlab.com/asset/':
|
||||
host = 'harriet/asset'
|
||||
if host == 'http://ozzy.lindenlab.com/asset/':
|
||||
host = 'ozzy/asset'
|
||||
if host == 'http://station11.lindenlab.com:12041/:':
|
||||
host = 'station11:12041'
|
||||
proxy = str (self.init_proxy)
|
||||
if proxy == 'None':
|
||||
proxy = ''
|
||||
if proxy == 'http://int.tuco.lindenlab.com:3128/':
|
||||
proxy = 'tuco'
|
||||
syslog.syslog ('WebDAV (%s:%s) %s' % (host, proxy, str (msg)))
|
||||
|
||||
|
||||
def connect (self):
|
||||
""" connect docstring """
|
||||
self.log ('connect')
|
||||
self.connection = httplib.HTTPConnection (self.host, self.port)
|
||||
|
||||
def __err (self, response, details):
|
||||
""" __err docstring """
|
||||
raise DAVError (response.status, response.reason, response.read (),
|
||||
str (self.init_url) + ':' + \
|
||||
str (self.init_proxy) + ':' + str (details))
|
||||
|
||||
def request (self, method, path, body=None, headers=None,
|
||||
read_all=True, body_hook = None, recurse=0, allow_cache=True):
|
||||
""" request docstring """
|
||||
# self.log ('request %s %s' % (method, path))
|
||||
if headers == None:
|
||||
headers = {}
|
||||
if not allow_cache:
|
||||
headers['Pragma'] = 'no-cache'
|
||||
headers['cache-control'] = 'no-cache'
|
||||
try:
|
||||
if method.lower () != 'purge':
|
||||
if path.startswith ('/'):
|
||||
path = path[1:]
|
||||
if self.host_header: # use proxy
|
||||
headers[ 'host' ] = self.host_header
|
||||
fullpath = 'http://%s%s%s' % (self.host_header,
|
||||
self.top_path, path)
|
||||
else: # no proxy
|
||||
fullpath = self.top_path + path
|
||||
else:
|
||||
fullpath = path
|
||||
|
||||
self.connection.request (method, fullpath, body, headers)
|
||||
if body_hook:
|
||||
body_hook ()
|
||||
|
||||
# signal.signal (signal.SIGALRM, alarm_handler)
|
||||
# try:
|
||||
# signal.alarm (120)
|
||||
# signal.alarm (0)
|
||||
# except Timeout, e:
|
||||
# if recurse < 6:
|
||||
# return self.retry_request (method, path, body, headers,
|
||||
# read_all, body_hook, recurse)
|
||||
# else:
|
||||
# raise DAVError (0, 'timeout', self.host,
|
||||
# (method, path, body, headers, recurse))
|
||||
|
||||
response = self.connection.getresponse ()
|
||||
|
||||
if read_all:
|
||||
while len (response.read (1024)) > 0:
|
||||
pass
|
||||
if (response.status == 500 or \
|
||||
response.status == 503 or \
|
||||
response.status == 403) and \
|
||||
recurse < self.retries_before_fail:
|
||||
return self.retry_request (method, path, body, headers,
|
||||
read_all, body_hook, recurse)
|
||||
return response
|
||||
except (httplib.ResponseNotReady,
|
||||
httplib.BadStatusLine,
|
||||
socket.error):
|
||||
# if the server hangs up on us (keepalive off, broken pipe),
|
||||
# we need to reconnect and try again.
|
||||
if recurse < self.retries_before_fail:
|
||||
return self.retry_request (method, path, body, headers,
|
||||
read_all, body_hook, recurse)
|
||||
raise DAVError (0, 'reconnect failed', self.host,
|
||||
(method, path, body, headers, recurse))
|
||||
|
||||
|
||||
def retry_request (self, method, path, body, headers,
|
||||
read_all, body_hook, recurse):
|
||||
""" retry_request docstring """
|
||||
time.sleep (10.0 * recurse)
|
||||
self.connect ()
|
||||
return self.request (method, path, body, headers,
|
||||
read_all, body_hook, recurse+1)
|
||||
|
||||
|
||||
|
||||
def propfind (self, path, body=None, depth=1):
|
||||
""" propfind docstring """
|
||||
# self.log ('propfind %s' % path)
|
||||
headers = {'Content-Type':'text/xml; charset="utf-8"',
|
||||
'Depth':str(depth)}
|
||||
response = self.request ('PROPFIND', path, body, headers, False)
|
||||
if response.status == 207:
|
||||
return response # Multi-Status
|
||||
self.__err (response, ('PROPFIND', path, body, headers, 0))
|
||||
|
||||
|
||||
def purge (self, path):
|
||||
""" issue a squid purge command """
|
||||
headers = {'Accept':'*/*'}
|
||||
response = self.request ('PURGE', path, None, headers)
|
||||
if response.status == 200 or response.status == 404:
|
||||
# 200 if it was purge, 404 if it wasn't there.
|
||||
return response
|
||||
self.__err (response, ('PURGE', path, None, headers))
|
||||
|
||||
|
||||
def get_file_size (self, path):
|
||||
"""
|
||||
Use propfind to ask a webdav server what the size of
|
||||
a file is. If used on a directory (collection) return 0
|
||||
"""
|
||||
self.log ('get_file_size %s' % path)
|
||||
# "getcontentlength" property
|
||||
# 8.1.1 Example - Retrieving Named Properties
|
||||
# http://docs.python.org/lib/module-xml.dom.html
|
||||
nsurl = 'http://apache.org/dav/props/'
|
||||
doc = xml.dom.minidom.Document ()
|
||||
propfind_element = doc.createElementNS (nsurl, "D:propfind")
|
||||
propfind_element.setAttributeNS (nsurl, 'xmlns:D', 'DAV:')
|
||||
doc.appendChild (propfind_element)
|
||||
prop_element = doc.createElementNS (nsurl, "D:prop")
|
||||
propfind_element.appendChild (prop_element)
|
||||
con_len_element = doc.createElementNS (nsurl, "D:getcontentlength")
|
||||
prop_element.appendChild (con_len_element)
|
||||
|
||||
response = self.propfind (path, doc.toxml ())
|
||||
doc.unlink ()
|
||||
|
||||
resp_doc = xml.dom.minidom.parseString (response.read ())
|
||||
cln = resp_doc.getElementsByTagNameNS ('DAV:','getcontentlength')[ 0 ]
|
||||
try:
|
||||
content_length = int (cln.childNodes[ 0 ].nodeValue)
|
||||
except IndexError:
|
||||
return 0
|
||||
resp_doc.unlink ()
|
||||
return content_length
|
||||
|
||||
|
||||
def file_exists (self, path):
|
||||
"""
|
||||
do an http head on the given file. return True if it succeeds
|
||||
"""
|
||||
self.log ('file_exists %s' % path)
|
||||
expect_gzip = path.endswith ('.gz')
|
||||
response = self.request ('HEAD', path)
|
||||
got_gzip = response.getheader ('Content-Encoding', '').strip ()
|
||||
if got_gzip.lower () == 'x-gzip' and expect_gzip == False:
|
||||
# the asset server fakes us out if we ask for the non-gzipped
|
||||
# version of an asset, but the server has the gzipped version.
|
||||
return False
|
||||
return response.status == 200
|
||||
|
||||
|
||||
def mkdir (self, path):
|
||||
""" mkdir docstring """
|
||||
self.log ('mkdir %s' % path)
|
||||
headers = {}
|
||||
response = self.request ('MKCOL', path, None, headers)
|
||||
if response.status == 201:
|
||||
return # success
|
||||
if response.status == 405:
|
||||
return # directory already existed?
|
||||
self.__err (response, ('MKCOL', path, None, headers, 0))
|
||||
|
||||
|
||||
def delete (self, path):
|
||||
""" delete docstring """
|
||||
self.log ('delete %s' % path)
|
||||
headers = {'Depth':'infinity'} # collections require infinity
|
||||
response = self.request ('DELETE', path, None, headers)
|
||||
if response.status == 204:
|
||||
return # no content
|
||||
if response.status == 404:
|
||||
return # hmm
|
||||
self.__err (response, ('DELETE', path, None, headers, 0))
|
||||
|
||||
|
||||
def list_directory (self, path, dir_filter=None, allow_cache=True,
|
||||
minimum_cache_time=False):
|
||||
"""
|
||||
Request an http directory listing and parse the filenames out of lines
|
||||
like: '<LI><A HREF="X"> X</A>'. If a filter function is provided,
|
||||
only return filenames that the filter returns True for.
|
||||
|
||||
This is sort of grody, but it seems faster than other ways of getting
|
||||
this information from an isilon.
|
||||
"""
|
||||
self.log ('list_directory %s' % path)
|
||||
|
||||
def try_match (lline, before, after):
|
||||
""" try_match docstring """
|
||||
try:
|
||||
blen = len (before)
|
||||
asset_start_index = lline.index (before)
|
||||
asset_end_index = lline.index (after, asset_start_index + blen)
|
||||
asset = line[ asset_start_index + blen : asset_end_index ]
|
||||
|
||||
if not dir_filter or dir_filter (asset):
|
||||
return [ asset ]
|
||||
return []
|
||||
except ValueError:
|
||||
return []
|
||||
|
||||
if len (path) > 0 and path[-1:] != '/':
|
||||
path += '/'
|
||||
|
||||
response = self.request ('GET', path, None, {}, False,
|
||||
allow_cache=allow_cache)
|
||||
|
||||
if allow_cache and minimum_cache_time: # XXX
|
||||
print response.getheader ('Date')
|
||||
# s = "2005-12-06T12:13:14"
|
||||
# from datetime import datetime
|
||||
# from time import strptime
|
||||
# datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6])
|
||||
# datetime.datetime(2005, 12, 6, 12, 13, 14)
|
||||
|
||||
if response.status != 200:
|
||||
self.__err (response, ('GET', path, None, {}, 0))
|
||||
assets = []
|
||||
for line in response.read ().split ('\n'):
|
||||
lline = line.lower ()
|
||||
if lline.find ("parent directory") == -1:
|
||||
# isilon file
|
||||
assets += try_match (lline, '<li><a href="', '"> ')
|
||||
# apache dir
|
||||
assets += try_match (lline, 'alt="[dir]"> <a href="', '/">')
|
||||
# apache file
|
||||
assets += try_match (lline, 'alt="[ ]"> <a href="', '">')
|
||||
return assets
|
||||
|
||||
|
||||
def __tmp_filename (self, path_and_file):
|
||||
""" __tmp_filename docstring """
|
||||
head, tail = os.path.split (path_and_file)
|
||||
if head != '':
|
||||
return head + '/.' + tail + '.' + str (os.getpid ())
|
||||
else:
|
||||
return head + '.' + tail + '.' + str (os.getpid ())
|
||||
|
||||
|
||||
def __put__ (self, filesize, body_hook, remotefile):
|
||||
""" __put__ docstring """
|
||||
headers = {'Content-Length' : str (filesize)}
|
||||
remotefile_tmp = self.__tmp_filename (remotefile)
|
||||
response = self.request ('PUT', remotefile_tmp, None,
|
||||
headers, True, body_hook)
|
||||
if not response.status in (201, 204): # created, no content
|
||||
self.__err (response, ('PUT', remotefile, None, headers, 0))
|
||||
if filesize != self.get_file_size (remotefile_tmp):
|
||||
try:
|
||||
self.delete (remotefile_tmp)
|
||||
except:
|
||||
pass
|
||||
raise DAVError (0, 'tmp upload error', remotefile_tmp)
|
||||
# move the file to its final location
|
||||
try:
|
||||
self.rename (remotefile_tmp, remotefile)
|
||||
except DAVError, exc:
|
||||
if exc.status == 403: # try to clean up the tmp file
|
||||
try:
|
||||
self.delete (remotefile_tmp)
|
||||
except:
|
||||
pass
|
||||
raise
|
||||
if filesize != self.get_file_size (remotefile):
|
||||
raise DAVError (0, 'file upload error', str (remotefile_tmp))
|
||||
|
||||
|
||||
def put_string (self, strng, remotefile):
|
||||
""" put_string docstring """
|
||||
self.log ('put_string %d -> %s' % (len (strng), remotefile))
|
||||
filesize = len (strng)
|
||||
def body_hook ():
|
||||
""" body_hook docstring """
|
||||
self.connection.send (strng)
|
||||
self.__put__ (filesize, body_hook, remotefile)
|
||||
|
||||
|
||||
def put_file (self, localfile, remotefile):
|
||||
"""
|
||||
Send a local file to a remote webdav store. First, upload to
|
||||
a temporary filename. Next make sure the file is the size we
|
||||
expected. Next, move the file to its final location. Next,
|
||||
check the file size at the final location.
|
||||
"""
|
||||
self.log ('put_file %s -> %s' % (localfile, remotefile))
|
||||
filesize = os.path.getsize (localfile)
|
||||
def body_hook ():
|
||||
""" body_hook docstring """
|
||||
handle = open (localfile)
|
||||
while True:
|
||||
data = handle.read (1300)
|
||||
if len (data) == 0:
|
||||
break
|
||||
self.connection.send (data)
|
||||
handle.close ()
|
||||
self.__put__ (filesize, body_hook, remotefile)
|
||||
|
||||
|
||||
def create_empty_file (self, remotefile):
|
||||
""" create an empty file """
|
||||
self.log ('touch_file %s' % (remotefile))
|
||||
headers = {'Content-Length' : '0'}
|
||||
response = self.request ('PUT', remotefile, None, headers)
|
||||
if not response.status in (201, 204): # created, no content
|
||||
self.__err (response, ('PUT', remotefile, None, headers, 0))
|
||||
if self.get_file_size (remotefile) != 0:
|
||||
raise DAVError (0, 'file upload error', str (remotefile))
|
||||
|
||||
|
||||
def __get_file_setup (self, remotefile, check_size=True):
|
||||
""" __get_file_setup docstring """
|
||||
if check_size:
|
||||
remotesize = self.get_file_size (remotefile)
|
||||
response = self.request ('GET', remotefile, None, {}, False)
|
||||
if response.status != 200:
|
||||
self.__err (response, ('GET', remotefile, None, {}, 0))
|
||||
try:
|
||||
content_length = int (response.getheader ("Content-Length"))
|
||||
except TypeError:
|
||||
content_length = None
|
||||
if check_size:
|
||||
if content_length != remotesize:
|
||||
raise DAVError (0, 'file DL size error', remotefile)
|
||||
return (response, content_length)
|
||||
|
||||
|
||||
def __get_file_read (self, writehandle, response, content_length):
|
||||
""" __get_file_read docstring """
|
||||
if content_length != None:
|
||||
so_far_length = 0
|
||||
while so_far_length < content_length:
|
||||
data = response.read (content_length - so_far_length)
|
||||
if len (data) == 0:
|
||||
raise DAVError (0, 'short file download')
|
||||
so_far_length += len (data)
|
||||
writehandle.write (data)
|
||||
while len (response.read ()) > 0:
|
||||
pass
|
||||
else:
|
||||
while True:
|
||||
data = response.read ()
|
||||
if (len (data) < 1):
|
||||
break
|
||||
writehandle.write (data)
|
||||
|
||||
|
||||
def get_file (self, remotefile, localfile, check_size=True):
|
||||
"""
|
||||
Get a remote file from a webdav server. Download to a local
|
||||
tmp file, then move into place. Sanity check file sizes as
|
||||
we go.
|
||||
"""
|
||||
self.log ('get_file %s -> %s' % (remotefile, localfile))
|
||||
(response, content_length) = \
|
||||
self.__get_file_setup (remotefile, check_size)
|
||||
localfile_tmp = self.__tmp_filename (localfile)
|
||||
handle = open (localfile_tmp, 'w')
|
||||
self.__get_file_read (handle, response, content_length)
|
||||
handle.close ()
|
||||
if check_size:
|
||||
if content_length != os.path.getsize (localfile_tmp):
|
||||
raise DAVError (0, 'file DL size error',
|
||||
remotefile+','+localfile)
|
||||
os.rename (localfile_tmp, localfile)
|
||||
|
||||
|
||||
def get_file_as_string (self, remotefile, check_size=True):
|
||||
"""
|
||||
download a file from a webdav server and return it as a string.
|
||||
"""
|
||||
self.log ('get_file_as_string %s' % remotefile)
|
||||
(response, content_length) = \
|
||||
self.__get_file_setup (remotefile, check_size)
|
||||
# (tmp_handle, tmp_filename) = tempfile.mkstemp ()
|
||||
tmp_handle = os.tmpfile ()
|
||||
self.__get_file_read (tmp_handle, response, content_length)
|
||||
tmp_handle.seek (0)
|
||||
ret = tmp_handle.read ()
|
||||
tmp_handle.close ()
|
||||
# os.unlink (tmp_filename)
|
||||
return ret
|
||||
|
||||
|
||||
def get_post_as_string (self, remotefile, body):
|
||||
"""
|
||||
Do an http POST, send body, get response and return it.
|
||||
"""
|
||||
self.log ('get_post_as_string %s' % remotefile)
|
||||
# headers = {'Content-Type':'application/x-www-form-urlencoded'}
|
||||
headers = {'Content-Type':'text/xml; charset="utf-8"'}
|
||||
# b64body = urlsafe_b64encode (asset_url)
|
||||
response = self.request ('POST', remotefile, body, headers, False)
|
||||
if response.status != 200:
|
||||
self.__err (response, ('POST', remotefile, body, headers, 0))
|
||||
try:
|
||||
content_length = int (response.getheader ('Content-Length'))
|
||||
except TypeError:
|
||||
content_length = None
|
||||
tmp_handle = os.tmpfile ()
|
||||
self.__get_file_read (tmp_handle, response, content_length)
|
||||
tmp_handle.seek (0)
|
||||
ret = tmp_handle.read ()
|
||||
tmp_handle.close ()
|
||||
return ret
|
||||
|
||||
|
||||
def __destination_command (self, verb, remotesrc, dstdav, remotedst):
|
||||
"""
|
||||
self and dstdav should point to the same http server.
|
||||
"""
|
||||
if len (remotedst) > 0 and remotedst[ 0 ] == '/':
|
||||
remotedst = remotedst[1:]
|
||||
headers = {'Destination': 'http://%s:%d%s%s' % (dstdav.host,
|
||||
dstdav.port,
|
||||
dstdav.top_path,
|
||||
remotedst)}
|
||||
response = self.request (verb, remotesrc, None, headers)
|
||||
if response.status == 201:
|
||||
return # created
|
||||
if response.status == 204:
|
||||
return # no content
|
||||
self.__err (response, (verb, remotesrc, None, headers, 0))
|
||||
|
||||
|
||||
def rename (self, remotesrc, remotedst):
|
||||
""" rename a file on a webdav server """
|
||||
self.log ('rename %s -> %s' % (remotesrc, remotedst))
|
||||
self.__destination_command ('MOVE', remotesrc, self, remotedst)
|
||||
def xrename (self, remotesrc, dstdav, remotedst):
|
||||
""" rename a file on a webdav server """
|
||||
self.log ('xrename %s -> %s' % (remotesrc, remotedst))
|
||||
self.__destination_command ('MOVE', remotesrc, dstdav, remotedst)
|
||||
|
||||
|
||||
def copy (self, remotesrc, remotedst):
|
||||
""" copy a file on a webdav server """
|
||||
self.log ('copy %s -> %s' % (remotesrc, remotedst))
|
||||
self.__destination_command ('COPY', remotesrc, self, remotedst)
|
||||
def xcopy (self, remotesrc, dstdav, remotedst):
|
||||
""" copy a file on a webdav server """
|
||||
self.log ('xcopy %s -> %s' % (remotesrc, remotedst))
|
||||
self.__destination_command ('COPY', remotesrc, dstdav, remotedst)
|
||||
|
||||
|
||||
def put_string (data, url):
|
||||
"""
|
||||
upload string s to a url
|
||||
"""
|
||||
url_parsed = urlparse.urlsplit (url)
|
||||
dav = WebDAV ('%s://%s/' % (url_parsed[ 0 ], url_parsed[ 1 ]))
|
||||
dav.put_string (data, url_parsed[ 2 ])
|
||||
|
||||
|
||||
def get_string (url, check_size=True):
|
||||
"""
|
||||
return the contents of a url as a string
|
||||
"""
|
||||
url_parsed = urlparse.urlsplit (url)
|
||||
dav = WebDAV ('%s://%s/' % (url_parsed[ 0 ], url_parsed[ 1 ]))
|
||||
return dav.get_file_as_string (url_parsed[ 2 ], check_size)
|
||||
@@ -1,273 +0,0 @@
|
||||
"""\
|
||||
@file xml_rpc.py
|
||||
@brief An implementation of a parser/generator for the XML-RPC xml format.
|
||||
|
||||
$LicenseInfo:firstyear=2006&license=mit$
|
||||
|
||||
Copyright (c) 2006-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
|
||||
from greenlet import greenlet
|
||||
|
||||
from mulib import mu
|
||||
|
||||
from xml.sax import handler
|
||||
from xml.sax import parseString
|
||||
|
||||
|
||||
# States
|
||||
class Expected(object):
|
||||
def __init__(self, tag):
|
||||
self.tag = tag
|
||||
|
||||
def __getattr__(self, name):
|
||||
return type(self)(name)
|
||||
|
||||
def __repr__(self):
|
||||
return '%s(%r)' % (
|
||||
type(self).__name__, self.tag)
|
||||
|
||||
|
||||
class START(Expected):
|
||||
pass
|
||||
|
||||
|
||||
class END(Expected):
|
||||
pass
|
||||
|
||||
|
||||
class STR(object):
|
||||
tag = ''
|
||||
|
||||
|
||||
START = START('')
|
||||
END = END('')
|
||||
|
||||
|
||||
class Malformed(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class XMLParser(handler.ContentHandler):
|
||||
def __init__(self, state_machine, next_states):
|
||||
handler.ContentHandler.__init__(self)
|
||||
self.state_machine = state_machine
|
||||
if not isinstance(next_states, tuple):
|
||||
next_states = (next_states, )
|
||||
self.next_states = next_states
|
||||
self._character_buffer = ''
|
||||
|
||||
def assertState(self, state, name, *rest):
|
||||
if not isinstance(self.next_states, tuple):
|
||||
self.next_states = (self.next_states, )
|
||||
for next in self.next_states:
|
||||
if type(state) == type(next):
|
||||
if next.tag and next.tag != name:
|
||||
raise Malformed(
|
||||
"Expected %s, got %s %s %s" % (
|
||||
next, state, name, rest))
|
||||
break
|
||||
else:
|
||||
raise Malformed(
|
||||
"Expected %s, got %s %s %s" % (
|
||||
self.next_states, state, name, rest))
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
self.assertState(START, name.lower(), attrs)
|
||||
self.next_states = self.state_machine.switch(START, (name.lower(), dict(attrs)))
|
||||
|
||||
def endElement(self, name):
|
||||
if self._character_buffer.strip():
|
||||
characters = self._character_buffer.strip()
|
||||
self._character_buffer = ''
|
||||
self.assertState(STR, characters)
|
||||
self.next_states = self.state_machine.switch(characters)
|
||||
self.assertState(END, name.lower())
|
||||
self.next_states = self.state_machine.switch(END, name.lower())
|
||||
|
||||
def error(self, exc):
|
||||
self.bozo = 1
|
||||
self.exc = exc
|
||||
|
||||
def fatalError(self, exc):
|
||||
self.error(exc)
|
||||
raise exc
|
||||
|
||||
def characters(self, characters):
|
||||
self._character_buffer += characters
|
||||
|
||||
|
||||
def parse(what):
|
||||
child = greenlet(xml_rpc)
|
||||
me = greenlet.getcurrent()
|
||||
startup_states = child.switch(me)
|
||||
parser = XMLParser(child, startup_states)
|
||||
try:
|
||||
parseString(what, parser)
|
||||
except Malformed:
|
||||
print what
|
||||
raise
|
||||
return child.switch()
|
||||
|
||||
|
||||
def xml_rpc(yielder):
|
||||
yielder.switch(START.methodcall)
|
||||
yielder.switch(START.methodname)
|
||||
methodName = yielder.switch(STR)
|
||||
yielder.switch(END.methodname)
|
||||
|
||||
yielder.switch(START.params)
|
||||
|
||||
root = None
|
||||
params = []
|
||||
while True:
|
||||
state, _ = yielder.switch(START.param, END.params)
|
||||
if state == END:
|
||||
break
|
||||
|
||||
yielder.switch(START.value)
|
||||
|
||||
params.append(
|
||||
handle(yielder))
|
||||
|
||||
yielder.switch(END.value)
|
||||
yielder.switch(END.param)
|
||||
|
||||
yielder.switch(END.methodcall)
|
||||
## Resume parse
|
||||
yielder.switch()
|
||||
## Return result to parse
|
||||
return methodName.strip(), params
|
||||
|
||||
|
||||
def handle(yielder):
|
||||
_, (tag, attrs) = yielder.switch(START)
|
||||
if tag in ['int', 'i4']:
|
||||
result = int(yielder.switch(STR))
|
||||
elif tag == 'boolean':
|
||||
result = bool(int(yielder.switch(STR)))
|
||||
elif tag == 'string':
|
||||
result = yielder.switch(STR)
|
||||
elif tag == 'double':
|
||||
result = float(yielder.switch(STR))
|
||||
elif tag == 'datetime.iso8601':
|
||||
result = yielder.switch(STR)
|
||||
elif tag == 'base64':
|
||||
result = base64.b64decode(yielder.switch(STR))
|
||||
elif tag == 'struct':
|
||||
result = {}
|
||||
while True:
|
||||
state, _ = yielder.switch(START.member, END.struct)
|
||||
if state == END:
|
||||
break
|
||||
|
||||
yielder.switch(START.name)
|
||||
key = yielder.switch(STR)
|
||||
yielder.switch(END.name)
|
||||
|
||||
yielder.switch(START.value)
|
||||
result[key] = handle(yielder)
|
||||
yielder.switch(END.value)
|
||||
|
||||
yielder.switch(END.member)
|
||||
## We already handled </struct> above, don't want to handle it below
|
||||
return result
|
||||
elif tag == 'array':
|
||||
result = []
|
||||
yielder.switch(START.data)
|
||||
while True:
|
||||
state, _ = yielder.switch(START.value, END.data)
|
||||
if state == END:
|
||||
break
|
||||
|
||||
result.append(handle(yielder))
|
||||
|
||||
yielder.switch(END.value)
|
||||
|
||||
yielder.switch(getattr(END, tag))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
VALUE = mu.tag_factory('value')
|
||||
BOOLEAN = mu.tag_factory('boolean')
|
||||
INT = mu.tag_factory('int')
|
||||
STRUCT = mu.tag_factory('struct')
|
||||
MEMBER = mu.tag_factory('member')
|
||||
NAME = mu.tag_factory('name')
|
||||
ARRAY = mu.tag_factory('array')
|
||||
DATA = mu.tag_factory('data')
|
||||
STRING = mu.tag_factory('string')
|
||||
DOUBLE = mu.tag_factory('double')
|
||||
METHODRESPONSE = mu.tag_factory('methodResponse')
|
||||
PARAMS = mu.tag_factory('params')
|
||||
PARAM = mu.tag_factory('param')
|
||||
|
||||
mu.inline_elements['string'] = True
|
||||
mu.inline_elements['boolean'] = True
|
||||
mu.inline_elements['name'] = True
|
||||
|
||||
|
||||
def _generate(something):
|
||||
if isinstance(something, dict):
|
||||
result = STRUCT()
|
||||
for key, value in something.items():
|
||||
result[
|
||||
MEMBER[
|
||||
NAME[key], _generate(value)]]
|
||||
return VALUE[result]
|
||||
elif isinstance(something, list):
|
||||
result = DATA()
|
||||
for item in something:
|
||||
result[_generate(item)]
|
||||
return VALUE[ARRAY[[result]]]
|
||||
elif isinstance(something, basestring):
|
||||
return VALUE[STRING[something]]
|
||||
elif isinstance(something, bool):
|
||||
if something:
|
||||
return VALUE[BOOLEAN['1']]
|
||||
return VALUE[BOOLEAN['0']]
|
||||
elif isinstance(something, int):
|
||||
return VALUE[INT[something]]
|
||||
elif isinstance(something, float):
|
||||
return VALUE[DOUBLE[something]]
|
||||
|
||||
def generate(*args):
|
||||
params = PARAMS()
|
||||
for arg in args:
|
||||
params[PARAM[_generate(arg)]]
|
||||
return METHODRESPONSE[params]
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print parse("""<?xml version="1.0"?> <methodCall> <methodName>examples.getStateName</methodName> <params> <param> <value><i4>41</i4></value> </param> </params> </methodCall>
|
||||
""")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
"""\
|
||||
@file fastest_elementtree.py
|
||||
@brief Concealing some gnarly import logic in here. This should export the interface of elementtree.
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
# The parsing exception raised by the underlying library depends
|
||||
# on the ElementTree implementation we're using, so we provide an
|
||||
# alias here.
|
||||
#
|
||||
# Use ElementTreeError as the exception type for catching parsing
|
||||
# errors.
|
||||
|
||||
|
||||
# Using cElementTree might cause some unforeseen problems, so here's a
|
||||
# convenient off switch.
|
||||
use_celementree = True
|
||||
|
||||
try:
|
||||
if not use_celementree:
|
||||
raise ImportError()
|
||||
# Python 2.3 and 2.4.
|
||||
from cElementTree import *
|
||||
ElementTreeError = SyntaxError
|
||||
except ImportError:
|
||||
try:
|
||||
if not use_celementree:
|
||||
raise ImportError()
|
||||
# Python 2.5 and above.
|
||||
from xml.etree.cElementTree import *
|
||||
ElementTreeError = SyntaxError
|
||||
except ImportError:
|
||||
# Pure Python code.
|
||||
try:
|
||||
# Python 2.3 and 2.4.
|
||||
from elementtree.ElementTree import *
|
||||
except ImportError:
|
||||
# Python 2.5 and above.
|
||||
from xml.etree.ElementTree import *
|
||||
|
||||
# The pure Python ElementTree module uses Expat for parsing.
|
||||
from xml.parsers.expat import ExpatError as ElementTreeError
|
||||
@@ -1,52 +0,0 @@
|
||||
"""\
|
||||
@file helpformatter.py
|
||||
@author Phoenix
|
||||
@brief Class for formatting optparse descriptions.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import optparse
|
||||
import textwrap
|
||||
|
||||
class Formatter(optparse.IndentedHelpFormatter):
|
||||
def __init__(
|
||||
self,
|
||||
p_indentIncrement = 2,
|
||||
p_maxHelpPosition = 24,
|
||||
p_width = 79,
|
||||
p_shortFirst = 1) :
|
||||
optparse.HelpFormatter.__init__(
|
||||
self,
|
||||
p_indentIncrement,
|
||||
p_maxHelpPosition,
|
||||
p_width,
|
||||
p_shortFirst)
|
||||
def format_description(self, p_description):
|
||||
t_descWidth = self.width - self.current_indent
|
||||
t_indent = " " * (self.current_indent + 2)
|
||||
return "\n".join(
|
||||
[textwrap.fill(descr, t_descWidth, initial_indent = t_indent,
|
||||
subsequent_indent = t_indent)
|
||||
for descr in p_description.split("\n")] )
|
||||
@@ -1,63 +0,0 @@
|
||||
"""\
|
||||
@file iterators.py
|
||||
@brief Useful general-purpose iterators.
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
from __future__ import nested_scopes
|
||||
|
||||
def iter_chunks(rows, aggregate_size=100):
|
||||
"""
|
||||
Given an iterable set of items (@p rows), produces lists of up to @p
|
||||
aggregate_size items at a time, for example:
|
||||
|
||||
iter_chunks([1,2,3,4,5,6,7,8,9,10], 3)
|
||||
|
||||
Values for @p aggregate_size < 1 will raise ValueError.
|
||||
|
||||
Will return a generator that produces, in the following order:
|
||||
- [1, 2, 3]
|
||||
- [4, 5, 6]
|
||||
- [7, 8, 9]
|
||||
- [10]
|
||||
"""
|
||||
if aggregate_size < 1:
|
||||
raise ValueError()
|
||||
|
||||
def iter_chunks_inner():
|
||||
row_iter = iter(rows)
|
||||
done = False
|
||||
agg = []
|
||||
while not done:
|
||||
try:
|
||||
row = row_iter.next()
|
||||
agg.append(row)
|
||||
except StopIteration:
|
||||
done = True
|
||||
if agg and (len(agg) >= aggregate_size or done):
|
||||
yield agg
|
||||
agg = []
|
||||
|
||||
return iter_chunks_inner()
|
||||
@@ -1,72 +0,0 @@
|
||||
"""\
|
||||
@file iterators_test.py
|
||||
@brief Test cases for iterators module.
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from indra.util.iterators import iter_chunks
|
||||
|
||||
class TestIterChunks(unittest.TestCase):
|
||||
"""Unittests for iter_chunks"""
|
||||
def test_bad_agg_size(self):
|
||||
rows = [1,2,3,4]
|
||||
self.assertRaises(ValueError, iter_chunks, rows, 0)
|
||||
self.assertRaises(ValueError, iter_chunks, rows, -1)
|
||||
|
||||
try:
|
||||
for i in iter_chunks(rows, 0):
|
||||
pass
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
self.fail()
|
||||
|
||||
try:
|
||||
result = list(iter_chunks(rows, 0))
|
||||
except ValueError:
|
||||
pass
|
||||
else:
|
||||
self.fail()
|
||||
def test_empty(self):
|
||||
rows = []
|
||||
result = list(iter_chunks(rows))
|
||||
self.assertEqual(result, [])
|
||||
def test_small(self):
|
||||
rows = [[1]]
|
||||
result = list(iter_chunks(rows, 2))
|
||||
self.assertEqual(result, [[[1]]])
|
||||
def test_size(self):
|
||||
rows = [[1],[2]]
|
||||
result = list(iter_chunks(rows, 2))
|
||||
self.assertEqual(result, [[[1],[2]]])
|
||||
def test_multi_agg(self):
|
||||
rows = [[1],[2],[3],[4],[5]]
|
||||
result = list(iter_chunks(rows, 2))
|
||||
self.assertEqual(result, [[[1],[2]],[[3],[4]],[[5]]])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -33,21 +33,26 @@ import filecmp
|
||||
import fnmatch
|
||||
import getopt
|
||||
import glob
|
||||
import itertools
|
||||
import operator
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import errno
|
||||
import subprocess
|
||||
|
||||
class ManifestError(RuntimeError):
|
||||
"""Use an exception more specific than generic Python RuntimeError"""
|
||||
pass
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
super(ManifestError, self).__init__(self.msg)
|
||||
|
||||
class MissingError(ManifestError):
|
||||
"""You specified a file that doesn't exist"""
|
||||
pass
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
super(MissingError, self).__init__(self.msg)
|
||||
|
||||
def path_ancestors(path):
|
||||
drive, path = os.path.splitdrive(os.path.normpath(path))
|
||||
@@ -88,7 +93,7 @@ DEFAULT_SRCTREE = os.path.dirname(sys.argv[0])
|
||||
CHANNEL_VENDOR_BASE = 'Singularity'
|
||||
RELEASE_CHANNEL = CHANNEL_VENDOR_BASE + ' Release'
|
||||
|
||||
ARGUMENTS=[
|
||||
BASE_ARGUMENTS=[
|
||||
dict(name='actions',
|
||||
description="""This argument specifies the actions that are to be taken when the
|
||||
script is run. The meaningful actions are currently:
|
||||
@@ -106,8 +111,17 @@ ARGUMENTS=[
|
||||
Example use: %(name)s --arch=i686
|
||||
On Linux this would try to use Linux_i686Manifest.""",
|
||||
default=""),
|
||||
dict(name='artwork', description='Artwork directory.', default=DEFAULT_SRCTREE),
|
||||
dict(name='branding_id', description="Identifier for the branding set to use.", default='singularity'),
|
||||
dict(name='build', description='Build directory.', default=DEFAULT_SRCTREE),
|
||||
dict(name='buildtype', description='Build type (i.e. Debug, Release, RelWithDebInfo).', default=None),
|
||||
dict(name='channel',
|
||||
description="""The channel to use for updates, packaging, settings name, etc.""",
|
||||
default='CHANNEL UNSET'),
|
||||
dict(name='channel_suffix',
|
||||
description="""Addition to the channel for packaging and channel value,
|
||||
but not application name (used internally)""",
|
||||
default=None),
|
||||
dict(name='configuration',
|
||||
description="""The build configuration used.""",
|
||||
default="Release"),
|
||||
@@ -115,12 +129,6 @@ ARGUMENTS=[
|
||||
dict(name='grid',
|
||||
description="""Which grid the client will try to connect to.""",
|
||||
default=None),
|
||||
dict(name='channel',
|
||||
description="""The channel to use for updates, packaging, settings name, etc.""",
|
||||
default='CHANNEL UNSET'),
|
||||
dict(name='channel_suffix',
|
||||
description="""Addition to the channel for packaging and channel value, but not application name (used internally)""",
|
||||
default=None),
|
||||
dict(name='installer_name',
|
||||
description=""" The name of the file that the installer should be
|
||||
packaged up into. Only used on Linux at the moment.""",
|
||||
@@ -132,13 +140,17 @@ ARGUMENTS=[
|
||||
description="""The current platform, to be used for looking up which
|
||||
manifest class to run.""",
|
||||
default=get_default_platform),
|
||||
dict(name='signature',
|
||||
description="""This specifies an identity to sign the viewer with, if any.
|
||||
If no value is supplied, the default signature will be used, if any. Currently
|
||||
only used on Mac OS X.""",
|
||||
default=None),
|
||||
dict(name='source',
|
||||
description='Source directory.',
|
||||
default=DEFAULT_SRCTREE),
|
||||
dict(name='standalone',
|
||||
description='Set to ON if this is a standalone build.',
|
||||
default="OFF"),
|
||||
dict(name='artwork', description='Artwork directory.', default=DEFAULT_SRCTREE),
|
||||
dict(name='touch',
|
||||
description="""File to touch when action is finished. Touch file will
|
||||
contain the name of the final package in a form suitable
|
||||
@@ -146,20 +158,15 @@ ARGUMENTS=[
|
||||
default=None),
|
||||
dict(name='versionfile',
|
||||
description="""The name of a file containing the full version number."""),
|
||||
dict(name='signature',
|
||||
description="""This specifies an identity to sign the viewer with, if any.
|
||||
If no value is supplied, the default signature will be used, if any. Currently
|
||||
only used on Mac OS X.""",
|
||||
default=None)
|
||||
]
|
||||
|
||||
def usage(srctree=""):
|
||||
def usage(arguments, srctree=""):
|
||||
nd = {'name':sys.argv[0]}
|
||||
print """Usage:
|
||||
%(name)s [options] [destdir]
|
||||
Options:
|
||||
""" % nd
|
||||
for arg in ARGUMENTS:
|
||||
for arg in arguments:
|
||||
default = arg['default']
|
||||
if hasattr(default, '__call__'):
|
||||
default = "(computed value) \"" + str(default(srctree)) + '"'
|
||||
@@ -170,11 +177,15 @@ def usage(srctree=""):
|
||||
default,
|
||||
arg['description'] % nd)
|
||||
|
||||
def main():
|
||||
## import itertools
|
||||
def main(extra=[]):
|
||||
## print ' '.join((("'%s'" % item) if ' ' in item else item)
|
||||
## for item in itertools.chain([sys.executable], sys.argv))
|
||||
option_names = [arg['name'] + '=' for arg in ARGUMENTS]
|
||||
# Supplement our default command-line switches with any desired by
|
||||
# application-specific caller.
|
||||
arguments = list(itertools.chain(BASE_ARGUMENTS, extra))
|
||||
# Alphabetize them by option name in case we display usage.
|
||||
arguments.sort(key=operator.itemgetter('name'))
|
||||
option_names = [arg['name'] + '=' for arg in arguments]
|
||||
option_names.append('help')
|
||||
options, remainder = getopt.getopt(sys.argv[1:], "", option_names)
|
||||
|
||||
@@ -197,11 +208,11 @@ def main():
|
||||
# early out for help
|
||||
if 'help' in args:
|
||||
# *TODO: it is a huge hack to pass around the srctree like this
|
||||
usage(args['source'])
|
||||
usage(arguments, srctree=args['source'])
|
||||
return
|
||||
|
||||
# defaults
|
||||
for arg in ARGUMENTS:
|
||||
for arg in arguments:
|
||||
if arg['name'] not in args:
|
||||
default = arg['default']
|
||||
if hasattr(default, '__call__'):
|
||||
@@ -230,101 +241,68 @@ def main():
|
||||
print "Option:", opt, "=", args[opt]
|
||||
|
||||
# pass in sourceid as an argument now instead of an environment variable
|
||||
try:
|
||||
args['sourceid'] = os.environ["sourceid"]
|
||||
except KeyError:
|
||||
args['sourceid'] = ""
|
||||
args['sourceid'] = os.environ.get("sourceid", "")
|
||||
|
||||
# Build base package.
|
||||
touch = args.get('touch')
|
||||
if touch:
|
||||
print 'Creating base package'
|
||||
args['package_id'] = "" # base package has no package ID
|
||||
print '================ Creating base package'
|
||||
else:
|
||||
print '================ Starting base copy'
|
||||
wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args)
|
||||
wm.do(*args['actions'])
|
||||
# Store package file for later if making touched file.
|
||||
base_package_file = ""
|
||||
if touch:
|
||||
print 'Created base package ', wm.package_file
|
||||
print '================ Created base package ', wm.package_file
|
||||
base_package_file = "" + wm.package_file
|
||||
else:
|
||||
print '================ Finished base copy'
|
||||
|
||||
# handle multiple packages if set
|
||||
try:
|
||||
additional_packages = os.environ["additional_packages"]
|
||||
except KeyError:
|
||||
additional_packages = ""
|
||||
# ''.split() produces empty list
|
||||
additional_packages = os.environ.get("additional_packages", "").split()
|
||||
if additional_packages:
|
||||
# Determine destination prefix / suffix for additional packages.
|
||||
base_dest_postfix = args['dest']
|
||||
base_dest_prefix = ""
|
||||
base_dest_parts = args['dest'].split(os.sep)
|
||||
if len(base_dest_parts) > 1:
|
||||
base_dest_postfix = base_dest_parts[len(base_dest_parts) - 1]
|
||||
base_dest_prefix = base_dest_parts[0]
|
||||
i = 1
|
||||
while i < len(base_dest_parts) - 1:
|
||||
base_dest_prefix = base_dest_prefix + os.sep + base_dest_parts[i]
|
||||
i = i + 1
|
||||
base_dest_parts = list(os.path.split(args['dest']))
|
||||
base_dest_parts.insert(-1, "{}")
|
||||
base_dest_template = os.path.join(*base_dest_parts)
|
||||
# Determine touched prefix / suffix for additional packages.
|
||||
base_touch_postfix = ""
|
||||
base_touch_prefix = ""
|
||||
if touch:
|
||||
base_touch_postfix = touch
|
||||
base_touch_parts = touch.split('/')
|
||||
base_touch_parts = list(os.path.split(touch))
|
||||
# Because of the special insert() logic below, we don't just want
|
||||
# [dirpath, basename]; we want [dirpath, directory, basename].
|
||||
# Further split the dirpath and replace it in the list.
|
||||
base_touch_parts[0:1] = os.path.split(base_touch_parts[0])
|
||||
if "arwin" in args['platform']:
|
||||
if len(base_touch_parts) > 1:
|
||||
base_touch_postfix = base_touch_parts[len(base_touch_parts) - 1]
|
||||
base_touch_prefix = base_touch_parts[0]
|
||||
i = 1
|
||||
while i < len(base_touch_parts) - 1:
|
||||
base_touch_prefix = base_touch_prefix + '/' + base_touch_parts[i]
|
||||
i = i + 1
|
||||
base_touch_parts.insert(-1, "{}")
|
||||
else:
|
||||
if len(base_touch_parts) > 2:
|
||||
base_touch_postfix = base_touch_parts[len(base_touch_parts) - 2] + '/' + base_touch_parts[len(base_touch_parts) - 1]
|
||||
base_touch_prefix = base_touch_parts[0]
|
||||
i = 1
|
||||
while i < len(base_touch_parts) - 2:
|
||||
base_touch_prefix = base_touch_prefix + '/' + base_touch_parts[i]
|
||||
i = i + 1
|
||||
# Store base channel name.
|
||||
base_channel_name = args['channel']
|
||||
# Build each additional package.
|
||||
package_id_list = additional_packages.split(" ")
|
||||
args['channel'] = base_channel_name
|
||||
for package_id in package_id_list:
|
||||
base_touch_parts.insert(-2, "{}")
|
||||
base_touch_template = os.path.join(*base_touch_parts)
|
||||
for package_id in additional_packages:
|
||||
args['channel_suffix'] = os.environ.get(package_id + "_viewer_channel_suffix")
|
||||
args['sourceid'] = os.environ.get(package_id + "_sourceid")
|
||||
args['dest'] = base_dest_template.format(package_id)
|
||||
if touch:
|
||||
print '================ Creating additional package for "', package_id, '" in ', args['dest']
|
||||
else:
|
||||
print '================ Starting additional copy for "', package_id, '" in ', args['dest']
|
||||
try:
|
||||
if package_id + "_viewer_channel_suffix" in os.environ:
|
||||
args['channel_suffix'] = os.environ[package_id + "_viewer_channel_suffix"]
|
||||
else:
|
||||
args['channel_suffix'] = None
|
||||
if package_id + "_sourceid" in os.environ:
|
||||
args['sourceid'] = os.environ[package_id + "_sourceid"]
|
||||
else:
|
||||
args['sourceid'] = None
|
||||
args['dest'] = base_dest_prefix + os.sep + package_id + os.sep + base_dest_postfix
|
||||
except KeyError:
|
||||
sys.stderr.write("Failed to create package for package_id: %s" % package_id)
|
||||
sys.stderr.flush()
|
||||
continue
|
||||
wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args)
|
||||
wm.do(*args['actions'])
|
||||
except Exception as err:
|
||||
sys.exit(str(err))
|
||||
if touch:
|
||||
print 'Creating additional package for "', package_id, '" in ', args['dest']
|
||||
wm = LLManifest.for_platform(args['platform'], args.get('arch'))(args)
|
||||
wm.do(*args['actions'])
|
||||
if touch:
|
||||
print 'Created additional package ', wm.package_file, ' for ', package_id
|
||||
faketouch = base_touch_prefix + '/' + package_id + '/' + base_touch_postfix
|
||||
fp = open(faketouch, 'w')
|
||||
fp.write('set package_file=%s\n' % wm.package_file)
|
||||
fp.close()
|
||||
|
||||
print '================ Created additional package ', wm.package_file, ' for ', package_id
|
||||
with open(base_touch_template.format(package_id), 'w') as fp:
|
||||
fp.write('set package_file=%s\n' % wm.package_file)
|
||||
else:
|
||||
print '================ Finished additional copy "', package_id, '" in ', args['dest']
|
||||
# Write out the package file in this format, so that it can easily be called
|
||||
# and used in a .bat file - yeah, it sucks, but this is the simplest...
|
||||
touch = args.get('touch')
|
||||
if touch:
|
||||
fp = open(touch, 'w')
|
||||
fp.write('set package_file=%s\n' % base_package_file)
|
||||
fp.close()
|
||||
with open(touch, 'w') as fp:
|
||||
fp.write('set package_file=%s\n' % base_package_file)
|
||||
print 'touched', touch
|
||||
return 0
|
||||
|
||||
@@ -370,22 +348,113 @@ class LLManifest(object):
|
||||
in the file list by path()."""
|
||||
self.excludes.append(glob)
|
||||
|
||||
def prefix(self, src='', build=None, dst=None):
|
||||
""" Pushes a prefix onto the stack. Until end_prefix is
|
||||
called, all relevant method calls (esp. to path()) will prefix
|
||||
paths with the entire prefix stack. Source and destination
|
||||
prefixes can be different, though if only one is provided they
|
||||
are both equal. To specify a no-op, use an empty string, not
|
||||
None."""
|
||||
if dst is None:
|
||||
dst = src
|
||||
if build is None:
|
||||
build = src
|
||||
def prefix(self, src='', build='', dst='', src_dst=None):
|
||||
"""
|
||||
Usage:
|
||||
|
||||
with self.prefix(...args as described...):
|
||||
self.path(...)
|
||||
|
||||
For the duration of the 'with' block, pushes a prefix onto the stack.
|
||||
Within that block, all relevant method calls (esp. to path()) will
|
||||
prefix paths with the entire prefix stack. Source and destination
|
||||
prefixes are independent; if omitted (or passed as the empty string),
|
||||
the prefix has no effect. Thus:
|
||||
|
||||
with self.prefix(src='foo'):
|
||||
# no effect on dst
|
||||
|
||||
with self.prefix(dst='bar'):
|
||||
# no effect on src
|
||||
|
||||
If you want to set both at once, use src_dst:
|
||||
|
||||
with self.prefix(src_dst='subdir'):
|
||||
# same as self.prefix(src='subdir', dst='subdir')
|
||||
# Passing src_dst makes any src or dst argument in the same
|
||||
# parameter list irrelevant.
|
||||
|
||||
Also supports the older (pre-Python-2.5) syntax:
|
||||
|
||||
if self.prefix(...args as described...):
|
||||
self.path(...)
|
||||
self.end_prefix(...)
|
||||
|
||||
Before the arrival of the 'with' statement, one was required to code
|
||||
self.prefix() and self.end_prefix() in matching pairs to push and to
|
||||
pop the prefix stacks, respectively. The older prefix() method
|
||||
returned True specifically so that the caller could indent the
|
||||
relevant block of code with 'if', just for aesthetic purposes.
|
||||
"""
|
||||
if src_dst is not None:
|
||||
src = src_dst
|
||||
dst = src_dst
|
||||
self.src_prefix.append(src)
|
||||
self.artwork_prefix.append(src)
|
||||
self.build_prefix.append(build)
|
||||
self.dst_prefix.append(dst)
|
||||
return True # so that you can wrap it in an if to get indentation
|
||||
|
||||
## self.display_stacks()
|
||||
|
||||
# The above code is unchanged from the original implementation. What's
|
||||
# new is the return value. We're going to return an instance of
|
||||
# PrefixManager that binds this LLManifest instance and Does The Right
|
||||
# Thing on exit.
|
||||
return self.PrefixManager(self)
|
||||
|
||||
def display_stacks(self):
|
||||
width = 1 + max(len(stack) for stack in self.PrefixManager.stacks)
|
||||
for stack in self.PrefixManager.stacks:
|
||||
print "{} {}".format((stack + ':').ljust(width),
|
||||
os.path.join(*getattr(self, stack)))
|
||||
|
||||
class PrefixManager(object):
|
||||
# stack attributes we manage in this LLManifest (sub)class
|
||||
# instance
|
||||
stacks = ("src_prefix", "artwork_prefix", "build_prefix", "dst_prefix")
|
||||
|
||||
def __init__(self, manifest):
|
||||
self.manifest = manifest
|
||||
# If the caller wrote:
|
||||
# with self.prefix(...):
|
||||
# as intended, then bind the state of each prefix stack as it was
|
||||
# just BEFORE the call to prefix(). Since prefix() appended an
|
||||
# entry to each prefix stack, capture len()-1.
|
||||
self.prevlen = { stack: len(getattr(self.manifest, stack)) - 1
|
||||
for stack in self.stacks }
|
||||
|
||||
def __nonzero__(self):
|
||||
# If the caller wrote:
|
||||
# if self.prefix(...):
|
||||
# then a value of this class had better evaluate as 'True'.
|
||||
return True
|
||||
|
||||
def __enter__(self):
|
||||
# nobody uses 'with self.prefix(...) as variable:'
|
||||
return None
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
# First, if the 'with' block raised an exception, just propagate.
|
||||
# Do NOT swallow it.
|
||||
if type is not None:
|
||||
return False
|
||||
|
||||
# Okay, 'with' block completed successfully. Restore previous
|
||||
# state of each of the prefix stacks in self.stacks.
|
||||
# Note that we do NOT simply call pop() on them as end_prefix()
|
||||
# does. This is to cope with the possibility that the coder
|
||||
# changed 'if self.prefix(...):' to 'with self.prefix(...):' yet
|
||||
# forgot to remove the self.end_prefix(...) call at the bottom of
|
||||
# the block. In that case, calling pop() again would be Bad! But
|
||||
# if we restore the length of each stack to what it was before the
|
||||
# current prefix() block, it doesn't matter whether end_prefix()
|
||||
# was called or not.
|
||||
for stack, prevlen in self.prevlen.items():
|
||||
# find the attribute in 'self.manifest' named by 'stack', and
|
||||
# truncate that list back to 'prevlen'
|
||||
del getattr(self.manifest, stack)[prevlen:]
|
||||
|
||||
## self.manifest.display_stacks()
|
||||
|
||||
def end_prefix(self, descr=None):
|
||||
"""Pops a prefix off the stack. If given an argument, checks
|
||||
@@ -432,6 +501,19 @@ class LLManifest(object):
|
||||
relative to the destination directory."""
|
||||
return os.path.join(self.get_dst_prefix(), relpath)
|
||||
|
||||
def _relative_dst_path(self, dstpath):
|
||||
"""
|
||||
Returns the path to a file or directory relative to the destination directory.
|
||||
This should only be used for generating diagnostic output in the path method.
|
||||
"""
|
||||
dest_root=self.dst_prefix[0]
|
||||
if dstpath.startswith(dest_root+os.path.sep):
|
||||
return dstpath[len(dest_root)+1:]
|
||||
elif dstpath.startswith(dest_root):
|
||||
return dstpath[len(dest_root):]
|
||||
else:
|
||||
return dstpath
|
||||
|
||||
def ensure_src_dir(self, reldir):
|
||||
"""Construct the path for a directory relative to the
|
||||
source path, and ensures that it exists. Returns the
|
||||
@@ -449,29 +531,17 @@ class LLManifest(object):
|
||||
return path
|
||||
|
||||
def run_command(self, command):
|
||||
""" Runs an external command, and returns the output. Raises
|
||||
an exception if the command returns a nonzero status code. For
|
||||
debugging/informational purposes, prints out the command's
|
||||
output as it is received."""
|
||||
"""
|
||||
Runs an external command.
|
||||
Raises ManifestError exception if the command returns a nonzero status.
|
||||
"""
|
||||
print "Running command:", command
|
||||
sys.stdout.flush()
|
||||
child = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
|
||||
shell=True)
|
||||
lines = []
|
||||
while True:
|
||||
lines.append(child.stdout.readline())
|
||||
if lines[-1] == '':
|
||||
break
|
||||
else:
|
||||
print lines[-1],
|
||||
output = ''.join(lines)
|
||||
child.stdout.close()
|
||||
status = child.wait()
|
||||
if status:
|
||||
raise ManifestError(
|
||||
"Command %s returned non-zero status (%s) \noutput:\n%s"
|
||||
% (command, status, output) )
|
||||
return output
|
||||
try:
|
||||
subprocess.check_call(command)
|
||||
except subprocess.CalledProcessError as err:
|
||||
raise ManifestError( "Command %s returned non-zero status (%s)"
|
||||
% (command, err.returncode) )
|
||||
|
||||
def created_path(self, path):
|
||||
""" Declare that you've created a path in order to
|
||||
@@ -484,6 +554,7 @@ class LLManifest(object):
|
||||
def put_in_file(self, contents, dst, src=None):
|
||||
# write contents as dst
|
||||
dst_path = self.dst_path_of(dst)
|
||||
self.cmakedirs(os.path.dirname(dst_path))
|
||||
f = open(dst_path, "wb")
|
||||
try:
|
||||
f.write(contents)
|
||||
@@ -545,9 +616,16 @@ class LLManifest(object):
|
||||
# *TODO is this gonna be useful?
|
||||
print "Cleaning up " + c
|
||||
|
||||
def process_either(self, src, dst):
|
||||
# If it's a real directory, recurse through it --
|
||||
# but not a symlink! Handle those like files.
|
||||
if os.path.isdir(src) and not os.path.islink(src):
|
||||
return self.process_directory(src, dst)
|
||||
else:
|
||||
return self.process_file(src, dst)
|
||||
|
||||
def process_file(self, src, dst):
|
||||
if self.includes(src, dst):
|
||||
# print src, "=>", dst
|
||||
for action in self.actions:
|
||||
methodname = action + "_action"
|
||||
method = getattr(self, methodname, None)
|
||||
@@ -572,10 +650,7 @@ class LLManifest(object):
|
||||
for name in names:
|
||||
srcname = os.path.join(src, name)
|
||||
dstname = os.path.join(dst, name)
|
||||
if os.path.isdir(srcname):
|
||||
count += self.process_directory(srcname, dstname)
|
||||
else:
|
||||
count += self.process_file(srcname, dstname)
|
||||
count += self.process_either(srcname, dstname)
|
||||
return count
|
||||
|
||||
def includes(self, src, dst):
|
||||
@@ -615,16 +690,21 @@ class LLManifest(object):
|
||||
# Don't recopy file if it's up-to-date.
|
||||
# If we seem to be not not overwriting files that have been
|
||||
# updated, set the last arg to False, but it will take longer.
|
||||
## reldst = (dst[len(self.dst_prefix[0]):]
|
||||
## if dst.startswith(self.dst_prefix[0])
|
||||
## else dst).lstrip(r'\/')
|
||||
if os.path.exists(dst) and filecmp.cmp(src, dst, True):
|
||||
## print "{} (skipping, {} exists)".format(src, reldst)
|
||||
return
|
||||
# only copy if it's not excluded
|
||||
if self.includes(src, dst):
|
||||
try:
|
||||
os.unlink(dst)
|
||||
except OSError, err:
|
||||
except OSError as err:
|
||||
if err.errno != errno.ENOENT:
|
||||
raise
|
||||
|
||||
## print "{} => {}".format(src, reldst)
|
||||
shutil.copy2(src, dst)
|
||||
|
||||
def ccopytree(self, src, dst):
|
||||
@@ -642,7 +722,7 @@ class LLManifest(object):
|
||||
dstname = os.path.join(dst, name)
|
||||
try:
|
||||
self.ccopymumble(srcname, dstname)
|
||||
except (IOError, os.error), why:
|
||||
except (IOError, os.error) as why:
|
||||
errors.append((srcname, dstname, why))
|
||||
if errors:
|
||||
raise ManifestError, errors
|
||||
@@ -723,13 +803,13 @@ class LLManifest(object):
|
||||
return self.path(os.path.join(path, file), file)
|
||||
|
||||
def path(self, src, dst=None):
|
||||
sys.stdout.write("Processing %s => %s ... " % (src, dst))
|
||||
sys.stdout.flush()
|
||||
if src == None:
|
||||
raise ManifestError("No source file, dst is " + dst)
|
||||
if dst == None:
|
||||
dst = src
|
||||
dst = os.path.join(self.get_dst_prefix(), dst)
|
||||
sys.stdout.write("Processing %s => %s ... " % (src, self._relative_dst_path(dst)))
|
||||
|
||||
def try_path(src):
|
||||
# expand globs
|
||||
@@ -742,29 +822,21 @@ class LLManifest(object):
|
||||
# if we're specifying a single path (not a glob),
|
||||
# we should error out if it doesn't exist
|
||||
self.check_file_exists(src)
|
||||
# if it's a directory, recurse through it
|
||||
if os.path.isdir(src):
|
||||
count += self.process_directory(src, dst)
|
||||
else:
|
||||
count += self.process_file(src, dst)
|
||||
count += self.process_either(src, dst)
|
||||
return count
|
||||
|
||||
for pfx in self.get_src_prefix(), self.get_artwork_prefix(), self.get_build_prefix():
|
||||
try_prefixes = [self.get_src_prefix(), self.get_artwork_prefix(), self.get_build_prefix()]
|
||||
tried=[]
|
||||
count=0
|
||||
while not count and try_prefixes:
|
||||
pfx = try_prefixes.pop(0)
|
||||
try:
|
||||
count = try_path(os.path.join(pfx, src))
|
||||
except MissingError:
|
||||
# If src isn't a wildcard, and if that file doesn't exist in
|
||||
# this pfx, try next pfx.
|
||||
count = 0
|
||||
continue
|
||||
|
||||
# Here try_path() didn't raise MissingError. Did it process any files?
|
||||
if count:
|
||||
break
|
||||
# Even though try_path() didn't raise MissingError, it returned 0
|
||||
# files. src is probably a wildcard meant for some other pfx. Loop
|
||||
# back to try the next.
|
||||
|
||||
tried.append(pfx)
|
||||
if not try_prefixes:
|
||||
# no more prefixes left to try
|
||||
print "unable to find '%s'; looked in:\n %s" % (src, '\n '.join(tried))
|
||||
print "%d files" % count
|
||||
|
||||
# Let caller check whether we processed as many files as expected. In
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""\
|
||||
@file llperformance.py
|
||||
|
||||
$LicenseInfo:firstyear=2010&license=viewerlgpl$
|
||||
Second Life Viewer Source Code
|
||||
Copyright (C) 2010-2011, Linden Research, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation;
|
||||
version 2.1 of the License only.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
# ------------------------------------------------
|
||||
# Sim metrics utility functions.
|
||||
|
||||
import glob, os, time, sys, stat, exceptions
|
||||
|
||||
from indra.base import llsd
|
||||
|
||||
gBlockMap = {} #Map of performance metric data with function hierarchy information.
|
||||
gCurrentStatPath = ""
|
||||
|
||||
gIsLoggingEnabled=False
|
||||
|
||||
class LLPerfStat:
|
||||
def __init__(self,key):
|
||||
self.mTotalTime = 0
|
||||
self.mNumRuns = 0
|
||||
self.mName=key
|
||||
self.mTimeStamp = int(time.time()*1000)
|
||||
self.mUTCTime = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
||||
|
||||
def __str__(self):
|
||||
return "%f" % self.mTotalTime
|
||||
|
||||
def start(self):
|
||||
self.mStartTime = int(time.time() * 1000000)
|
||||
self.mNumRuns += 1
|
||||
|
||||
def stop(self):
|
||||
execution_time = int(time.time() * 1000000) - self.mStartTime
|
||||
self.mTotalTime += execution_time
|
||||
|
||||
def get_map(self):
|
||||
results={}
|
||||
results['name']=self.mName
|
||||
results['utc_time']=self.mUTCTime
|
||||
results['timestamp']=self.mTimeStamp
|
||||
results['us']=self.mTotalTime
|
||||
results['count']=self.mNumRuns
|
||||
return results
|
||||
|
||||
class PerfError(exceptions.Exception):
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
def __Str__(self):
|
||||
print "","Unfinished LLPerfBlock"
|
||||
|
||||
class LLPerfBlock:
|
||||
def __init__( self, key ):
|
||||
global gBlockMap
|
||||
global gCurrentStatPath
|
||||
global gIsLoggingEnabled
|
||||
|
||||
#Check to see if we're running metrics right now.
|
||||
if gIsLoggingEnabled:
|
||||
self.mRunning = True #Mark myself as running.
|
||||
|
||||
self.mPreviousStatPath = gCurrentStatPath
|
||||
gCurrentStatPath += "/" + key
|
||||
if gCurrentStatPath not in gBlockMap:
|
||||
gBlockMap[gCurrentStatPath] = LLPerfStat(key)
|
||||
|
||||
self.mStat = gBlockMap[gCurrentStatPath]
|
||||
self.mStat.start()
|
||||
|
||||
def finish( self ):
|
||||
global gBlockMap
|
||||
global gIsLoggingEnabled
|
||||
|
||||
if gIsLoggingEnabled:
|
||||
self.mStat.stop()
|
||||
self.mRunning = False
|
||||
gCurrentStatPath = self.mPreviousStatPath
|
||||
|
||||
# def __del__( self ):
|
||||
# if self.mRunning:
|
||||
# #SPATTERS FIXME
|
||||
# raise PerfError
|
||||
|
||||
class LLPerformance:
|
||||
#--------------------------------------------------
|
||||
# Determine whether or not we want to log statistics
|
||||
|
||||
def __init__( self, process_name = "python" ):
|
||||
self.process_name = process_name
|
||||
self.init_testing()
|
||||
self.mTimeStamp = int(time.time()*1000)
|
||||
self.mUTCTime = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
|
||||
|
||||
def init_testing( self ):
|
||||
global gIsLoggingEnabled
|
||||
|
||||
host_performance_file = "/dev/shm/simperf/simperf_proc_config.llsd"
|
||||
|
||||
#If file exists, open
|
||||
if os.path.exists(host_performance_file):
|
||||
file = open (host_performance_file,'r')
|
||||
|
||||
#Read serialized LLSD from file.
|
||||
body = llsd.parse(file.read())
|
||||
|
||||
#Calculate time since file last modified.
|
||||
stats = os.stat(host_performance_file)
|
||||
now = time.time()
|
||||
mod = stats[stat.ST_MTIME]
|
||||
age = now - mod
|
||||
|
||||
if age < ( body['duration'] ):
|
||||
gIsLoggingEnabled = True
|
||||
|
||||
|
||||
def get ( self ):
|
||||
global gIsLoggingEnabled
|
||||
return gIsLoggingEnabled
|
||||
|
||||
#def output(self,ptr,path):
|
||||
# if 'stats' in ptr:
|
||||
# stats = ptr['stats']
|
||||
# self.mOutputPtr[path] = stats.get_map()
|
||||
|
||||
# if 'children' in ptr:
|
||||
# children=ptr['children']
|
||||
|
||||
# curptr = self.mOutputPtr
|
||||
# curchildren={}
|
||||
# curptr['children'] = curchildren
|
||||
|
||||
# for key in children:
|
||||
# curchildren[key]={}
|
||||
# self.mOutputPtr = curchildren[key]
|
||||
# self.output(children[key],path + '/' + key)
|
||||
|
||||
def done(self):
|
||||
global gBlockMap
|
||||
|
||||
if not self.get():
|
||||
return
|
||||
|
||||
output_name = "/dev/shm/simperf/%s_proc.%d.llsd" % (self.process_name, os.getpid())
|
||||
output_file = open(output_name, 'w')
|
||||
process_info = {
|
||||
"name" : self.process_name,
|
||||
"pid" : os.getpid(),
|
||||
"ppid" : os.getppid(),
|
||||
"timestamp" : self.mTimeStamp,
|
||||
"utc_time" : self.mUTCTime,
|
||||
}
|
||||
output_file.write(llsd.format_notation(process_info))
|
||||
output_file.write('\n')
|
||||
|
||||
for key in gBlockMap.keys():
|
||||
gBlockMap[key] = gBlockMap[key].get_map()
|
||||
output_file.write(llsd.format_notation(gBlockMap))
|
||||
output_file.write('\n')
|
||||
output_file.close()
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
"""\
|
||||
@file llsubprocess.py
|
||||
@author Phoenix
|
||||
@date 2008-01-18
|
||||
@brief The simplest possible wrapper for a common sub-process paradigm.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import os
|
||||
import popen2
|
||||
import time
|
||||
import select
|
||||
|
||||
class Timeout(RuntimeError):
|
||||
"Exception raised when a subprocess times out."
|
||||
pass
|
||||
|
||||
def run(command, args=None, data=None, timeout=None):
|
||||
"""\
|
||||
@brief Run command with arguments
|
||||
|
||||
This is it. This is the function I want to run all the time when doing
|
||||
subprocces, but end up copying the code everywhere. none of the
|
||||
standard commands are secure and provide a way to specify input, get
|
||||
all the output, and get the result.
|
||||
@param command A string specifying a process to launch.
|
||||
@param args Arguments to be passed to command. Must be list, tuple or None.
|
||||
@param data input to feed to the command.
|
||||
@param timeout Maximum number of many seconds to run.
|
||||
@return Returns (result, stdout, stderr) from process.
|
||||
"""
|
||||
cmd = [command]
|
||||
if args:
|
||||
cmd.extend([str(arg) for arg in args])
|
||||
#print "cmd: ","' '".join(cmd)
|
||||
child = popen2.Popen3(cmd, True)
|
||||
#print child.pid
|
||||
out = []
|
||||
err = []
|
||||
result = -1
|
||||
time_left = timeout
|
||||
tochild = [child.tochild.fileno()]
|
||||
while True:
|
||||
time_start = time.time()
|
||||
#print "time:",time_left
|
||||
p_in, p_out, p_err = select.select(
|
||||
[child.fromchild.fileno(), child.childerr.fileno()],
|
||||
tochild,
|
||||
[],
|
||||
time_left)
|
||||
if p_in:
|
||||
new_line = os.read(child.fromchild.fileno(), 32 * 1024)
|
||||
if new_line:
|
||||
#print "line:",new_line
|
||||
out.append(new_line)
|
||||
new_line = os.read(child.childerr.fileno(), 32 * 1024)
|
||||
if new_line:
|
||||
#print "error:", new_line
|
||||
err.append(new_line)
|
||||
if p_out:
|
||||
if data:
|
||||
#print "p_out"
|
||||
bytes = os.write(child.tochild.fileno(), data)
|
||||
data = data[bytes:]
|
||||
if len(data) == 0:
|
||||
data = None
|
||||
tochild = []
|
||||
child.tochild.close()
|
||||
result = child.poll()
|
||||
if result != -1:
|
||||
# At this point, the child process has exited and result
|
||||
# is the return value from the process. Between the time
|
||||
# we called select() and poll() the process may have
|
||||
# exited so read all the data left on the child process
|
||||
# stdout and stderr.
|
||||
last = child.fromchild.read()
|
||||
if last:
|
||||
out.append(last)
|
||||
last = child.childerr.read()
|
||||
if last:
|
||||
err.append(last)
|
||||
child.tochild.close()
|
||||
child.fromchild.close()
|
||||
child.childerr.close()
|
||||
break
|
||||
if time_left is not None:
|
||||
time_left -= (time.time() - time_start)
|
||||
if time_left < 0:
|
||||
raise Timeout
|
||||
#print "result:",result
|
||||
out = ''.join(out)
|
||||
#print "stdout:", out
|
||||
err = ''.join(err)
|
||||
#print "stderr:", err
|
||||
return result, out, err
|
||||
@@ -1,592 +0,0 @@
|
||||
"""\
|
||||
@file named_query.py
|
||||
@author Ryan Williams, Phoenix
|
||||
@date 2007-07-31
|
||||
@brief An API for running named queries.
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import errno
|
||||
import MySQLdb
|
||||
import MySQLdb.cursors
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import time
|
||||
|
||||
from indra.base import llsd
|
||||
from indra.base import config
|
||||
|
||||
DEBUG = False
|
||||
NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
|
||||
NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX)
|
||||
|
||||
_g_named_manager = None
|
||||
|
||||
def _init_g_named_manager(sql_dir = None):
|
||||
"""Initializes a global NamedManager object to point at a
|
||||
specified named queries hierarchy.
|
||||
|
||||
This function is intended entirely for testing purposes,
|
||||
because it's tricky to control the config from inside a test."""
|
||||
global NQ_FILE_SUFFIX
|
||||
NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
|
||||
global NQ_FILE_SUFFIX_LEN
|
||||
NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX)
|
||||
|
||||
if sql_dir is None:
|
||||
sql_dir = config.get('named-query-base-dir')
|
||||
|
||||
# extra fallback directory in case config doesn't return what we want
|
||||
if sql_dir is None:
|
||||
sql_dir = os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.realpath(os.path.dirname(__file__)), "..", "..", "..", "..", "web", "dataservice", "sql"))
|
||||
|
||||
global _g_named_manager
|
||||
_g_named_manager = NamedQueryManager(
|
||||
os.path.abspath(os.path.realpath(sql_dir)))
|
||||
|
||||
def get(name, schema = None):
|
||||
"Get the named query object to be used to perform queries"
|
||||
if _g_named_manager is None:
|
||||
_init_g_named_manager()
|
||||
return _g_named_manager.get(name).for_schema(schema)
|
||||
|
||||
def sql(connection, name, params):
|
||||
# use module-global NamedQuery object to perform default substitution
|
||||
return get(name).sql(connection, params)
|
||||
|
||||
def run(connection, name, params, expect_rows = None):
|
||||
"""\
|
||||
@brief given a connection, run a named query with the params
|
||||
|
||||
Note that this function will fetch ALL rows.
|
||||
@param connection The connection to use
|
||||
@param name The name of the query to run
|
||||
@param params The parameters passed into the query
|
||||
@param expect_rows The number of rows expected. Set to 1 if return_as_map is true. Raises ExpectationFailed if the number of returned rows doesn't exactly match. Kind of a hack.
|
||||
@return Returns the result set as a list of dicts.
|
||||
"""
|
||||
return get(name).run(connection, params, expect_rows)
|
||||
|
||||
class ExpectationFailed(Exception):
|
||||
""" Exception that is raised when an expectation for an sql query
|
||||
is not met."""
|
||||
def __init__(self, message):
|
||||
Exception.__init__(self, message)
|
||||
self.message = message
|
||||
|
||||
class NamedQuery(object):
|
||||
def __init__(self, name, filename):
|
||||
""" Construct a NamedQuery object. The name argument is an
|
||||
arbitrary name as a handle for the query, and the filename is
|
||||
a path to a file or a file-like object containing an llsd named
|
||||
query document."""
|
||||
self._stat_interval_seconds = 5 # 5 seconds
|
||||
self._name = name
|
||||
if (filename is not None and isinstance(filename, (str, unicode))
|
||||
and NQ_FILE_SUFFIX != filename[-NQ_FILE_SUFFIX_LEN:]):
|
||||
filename = filename + NQ_FILE_SUFFIX
|
||||
self._location = filename
|
||||
self._alternative = dict()
|
||||
self._last_mod_time = 0
|
||||
self._last_check_time = 0
|
||||
self.deleted = False
|
||||
self.load_contents()
|
||||
|
||||
def name(self):
|
||||
""" The name of the query. """
|
||||
return self._name
|
||||
|
||||
def get_modtime(self):
|
||||
""" Returns the mtime (last modified time) of the named query
|
||||
filename. For file-like objects, expect a modtime of 0"""
|
||||
if self._location and isinstance(self._location, (str, unicode)):
|
||||
return os.path.getmtime(self._location)
|
||||
return 0
|
||||
|
||||
def load_contents(self):
|
||||
""" Loads and parses the named query file into self. Does
|
||||
nothing if self.location is nonexistant."""
|
||||
if self._location:
|
||||
if isinstance(self._location, (str, unicode)):
|
||||
contents = llsd.parse(open(self._location).read())
|
||||
else:
|
||||
# we probably have a file-like object. Godspeed!
|
||||
contents = llsd.parse(self._location.read())
|
||||
self._reference_contents(contents)
|
||||
# Check for alternative implementations
|
||||
try:
|
||||
for name, alt in self._contents['alternative'].items():
|
||||
nq = NamedQuery(name, None)
|
||||
nq._reference_contents(alt)
|
||||
self._alternative[name] = nq
|
||||
except KeyError, e:
|
||||
pass
|
||||
self._last_mod_time = self.get_modtime()
|
||||
self._last_check_time = time.time()
|
||||
|
||||
def _reference_contents(self, contents):
|
||||
"Helper method which builds internal structure from parsed contents"
|
||||
self._contents = contents
|
||||
self._ttl = int(self._contents.get('ttl', 0))
|
||||
self._return_as_map = bool(self._contents.get('return_as_map', False))
|
||||
self._legacy_dbname = self._contents.get('legacy_dbname', None)
|
||||
|
||||
# reset these before doing the sql conversion because we will
|
||||
# read them there. reset these while loading so we pick up
|
||||
# changes.
|
||||
self._around = set()
|
||||
self._append = set()
|
||||
self._integer = set()
|
||||
self._options = self._contents.get('dynamic_where', {})
|
||||
for key in self._options:
|
||||
if isinstance(self._options[key], basestring):
|
||||
self._options[key] = self._convert_sql(self._options[key])
|
||||
elif isinstance(self._options[key], list):
|
||||
lines = []
|
||||
for line in self._options[key]:
|
||||
lines.append(self._convert_sql(line))
|
||||
self._options[key] = lines
|
||||
else:
|
||||
moreopt = {}
|
||||
for kk in self._options[key]:
|
||||
moreopt[kk] = self._convert_sql(self._options[key][kk])
|
||||
self._options[key] = moreopt
|
||||
self._base_query = self._convert_sql(self._contents['base_query'])
|
||||
self._query_suffix = self._convert_sql(
|
||||
self._contents.get('query_suffix', ''))
|
||||
|
||||
def _convert_sql(self, sql):
|
||||
"""convert the parsed sql into a useful internal structure.
|
||||
|
||||
This function has to turn the named query format into a pyformat
|
||||
style. It also has to look for %:name% and :name% and
|
||||
ready them for use in LIKE statements"""
|
||||
if sql:
|
||||
# This first sub is to properly escape any % signs that
|
||||
# are meant to be literally passed through to mysql in the
|
||||
# query. It leaves any %'s that are used for
|
||||
# like-expressions.
|
||||
expr = re.compile("(?<=[^a-zA-Z0-9_-])%(?=[^:])")
|
||||
sql = expr.sub('%%', sql)
|
||||
|
||||
# This should tackle the rest of the %'s in the query, by
|
||||
# converting them to LIKE clauses.
|
||||
expr = re.compile("(%?):([a-zA-Z][a-zA-Z0-9_-]*)%")
|
||||
sql = expr.sub(self._prepare_like, sql)
|
||||
expr = re.compile("#:([a-zA-Z][a-zA-Z0-9_-]*)")
|
||||
sql = expr.sub(self._prepare_integer, sql)
|
||||
expr = re.compile(":([a-zA-Z][a-zA-Z0-9_-]*)")
|
||||
sql = expr.sub("%(\\1)s", sql)
|
||||
return sql
|
||||
|
||||
def _prepare_like(self, match):
|
||||
"""This function changes LIKE statement replace behavior
|
||||
|
||||
It works by turning %:name% to %(_name_around)s and :name% to
|
||||
%(_name_append)s. Since a leading '_' is not a valid keyname
|
||||
input (enforced via unit tests), it will never clash with
|
||||
existing keys. Then, when building the statement, the query
|
||||
runner will generate corrected strings."""
|
||||
if match.group(1) == '%':
|
||||
# there is a leading % so this is treated as prefix/suffix
|
||||
self._around.add(match.group(2))
|
||||
return "%(" + self._build_around_key(match.group(2)) + ")s"
|
||||
else:
|
||||
# there is no leading %, so this is suffix only
|
||||
self._append.add(match.group(2))
|
||||
return "%(" + self._build_append_key(match.group(2)) + ")s"
|
||||
|
||||
def _build_around_key(self, key):
|
||||
return "_" + key + "_around"
|
||||
|
||||
def _build_append_key(self, key):
|
||||
return "_" + key + "_append"
|
||||
|
||||
def _prepare_integer(self, match):
|
||||
"""This function adjusts the sql for #:name replacements
|
||||
|
||||
It works by turning #:name to %(_name_as_integer)s. Since a
|
||||
leading '_' is not a valid keyname input (enforced via unit
|
||||
tests), it will never clash with existing keys. Then, when
|
||||
building the statement, the query runner will generate
|
||||
corrected strings."""
|
||||
self._integer.add(match.group(1))
|
||||
return "%(" + self._build_integer_key(match.group(1)) + ")s"
|
||||
|
||||
def _build_integer_key(self, key):
|
||||
return "_" + key + "_as_integer"
|
||||
|
||||
def _strip_wildcards_to_list(self, value):
|
||||
"""Take string, and strip out the LIKE special characters.
|
||||
|
||||
Technically, this is database dependant, but postgresql and
|
||||
mysql use the same wildcards, and I am not aware of a general
|
||||
way to handle this. I think you need a sql statement of the
|
||||
form:
|
||||
|
||||
LIKE_STRING( [ANY,ONE,str]... )
|
||||
|
||||
which would treat ANY as their any string, and ONE as their
|
||||
single glyph, and str as something that needs database
|
||||
specific encoding to not allow any % or _ to affect the query.
|
||||
|
||||
As it stands, I believe it's impossible to write a named query
|
||||
style interface which uses like to search the entire space of
|
||||
text available. Imagine the query:
|
||||
|
||||
% of brain used by average linden
|
||||
|
||||
In order to search for %, it must be escaped, so once you have
|
||||
escaped the string to not do wildcard searches, and be escaped
|
||||
for the database, and then prepended the wildcard you come
|
||||
back with one of:
|
||||
|
||||
1) %\% of brain used by average linden
|
||||
2) %%% of brain used by average linden
|
||||
|
||||
Then, when passed to the database to be escaped to be database
|
||||
safe, you get back:
|
||||
|
||||
1) %\\% of brain used by average linden
|
||||
: which means search for any character sequence, followed by a
|
||||
backslash, followed by any sequence, followed by ' of
|
||||
brain...'
|
||||
2) %%% of brain used by average linden
|
||||
: which (I believe) means search for a % followed by any
|
||||
character sequence followed by 'of brain...'
|
||||
|
||||
Neither of which is what we want!
|
||||
|
||||
So, we need a vendor (or extention) for LIKE_STRING. Anyone
|
||||
want to write it?"""
|
||||
if isinstance(value, unicode):
|
||||
utf8_value = value
|
||||
else:
|
||||
utf8_value = unicode(value, "utf-8")
|
||||
esc_list = []
|
||||
remove_chars = set(u"%_")
|
||||
for glyph in utf8_value:
|
||||
if glyph in remove_chars:
|
||||
continue
|
||||
esc_list.append(glyph.encode("utf-8"))
|
||||
return esc_list
|
||||
|
||||
def delete(self):
|
||||
""" Makes this query unusable by deleting all the members and
|
||||
setting the deleted member. This is desired when the on-disk
|
||||
query has been deleted but the in-memory copy remains."""
|
||||
# blow away all members except _name, _location, and deleted
|
||||
name, location = self._name, self._location
|
||||
for key in self.__dict__.keys():
|
||||
del self.__dict__[key]
|
||||
self.deleted = True
|
||||
self._name, self._location = name, location
|
||||
|
||||
def ttl(self):
|
||||
""" Estimated time to live of this query. Used for web
|
||||
services to set the Expires header."""
|
||||
return self._ttl
|
||||
|
||||
def legacy_dbname(self):
|
||||
return self._legacy_dbname
|
||||
|
||||
def return_as_map(self):
|
||||
""" Returns true if this query is configured to return its
|
||||
results as a single map (as opposed to a list of maps, the
|
||||
normal behavior)."""
|
||||
|
||||
return self._return_as_map
|
||||
|
||||
def for_schema(self, db_name):
|
||||
"Look trough the alternates and return the correct query"
|
||||
if db_name is None:
|
||||
return self
|
||||
try:
|
||||
return self._alternative[db_name]
|
||||
except KeyError, e:
|
||||
pass
|
||||
return self
|
||||
|
||||
def run(self, connection, params, expect_rows = None, use_dictcursor = True):
|
||||
"""given a connection, run a named query with the params
|
||||
|
||||
Note that this function will fetch ALL rows. We do this because it
|
||||
opens and closes the cursor to generate the values, and this
|
||||
isn't a generator so the cursor has no life beyond the method call.
|
||||
|
||||
@param cursor The connection to use (this generates its own cursor for the query)
|
||||
@param name The name of the query to run
|
||||
@param params The parameters passed into the query
|
||||
@param expect_rows The number of rows expected. Set to 1 if return_as_map is true. Raises ExpectationFailed if the number of returned rows doesn't exactly match. Kind of a hack.
|
||||
@param use_dictcursor Set to false to use a normal cursor and manually convert the rows to dicts.
|
||||
@return Returns the result set as a list of dicts, or, if the named query has return_as_map set to true, returns a single dict.
|
||||
"""
|
||||
if use_dictcursor:
|
||||
cursor = connection.cursor(MySQLdb.cursors.DictCursor)
|
||||
else:
|
||||
cursor = connection.cursor()
|
||||
|
||||
full_query, params = self._construct_sql(params)
|
||||
if DEBUG:
|
||||
print "SQL:", self.sql(connection, params)
|
||||
rows = cursor.execute(full_query, params)
|
||||
|
||||
# *NOTE: the expect_rows argument is a very cheesy way to get some
|
||||
# validation on the result set. If you want to add more expectation
|
||||
# logic, do something more object-oriented and flexible. Or use an ORM.
|
||||
if(self._return_as_map):
|
||||
expect_rows = 1
|
||||
if expect_rows is not None and rows != expect_rows:
|
||||
cursor.close()
|
||||
raise ExpectationFailed("Statement expected %s rows, got %s. Sql: '%s' %s" % (
|
||||
expect_rows, rows, full_query, params))
|
||||
|
||||
# convert to dicts manually if we're not using a dictcursor
|
||||
if use_dictcursor:
|
||||
result_set = cursor.fetchall()
|
||||
else:
|
||||
if cursor.description is None:
|
||||
# an insert or something
|
||||
x = cursor.fetchall()
|
||||
cursor.close()
|
||||
return x
|
||||
|
||||
names = [x[0] for x in cursor.description]
|
||||
|
||||
result_set = []
|
||||
for row in cursor.fetchall():
|
||||
converted_row = {}
|
||||
for idx, col_name in enumerate(names):
|
||||
converted_row[col_name] = row[idx]
|
||||
result_set.append(converted_row)
|
||||
|
||||
cursor.close()
|
||||
if self._return_as_map:
|
||||
return result_set[0]
|
||||
return result_set
|
||||
|
||||
def _construct_sql(self, params):
|
||||
""" Returns a query string and a dictionary of parameters,
|
||||
suitable for directly passing to the execute() method."""
|
||||
self.refresh()
|
||||
|
||||
# build the query from the options available and the params
|
||||
base_query = []
|
||||
base_query.append(self._base_query)
|
||||
for opt, extra_where in self._options.items():
|
||||
if type(extra_where) in (dict, list, tuple):
|
||||
if opt in params:
|
||||
base_query.append(extra_where[params[opt]])
|
||||
else:
|
||||
if opt in params and params[opt]:
|
||||
base_query.append(extra_where)
|
||||
if self._query_suffix:
|
||||
base_query.append(self._query_suffix)
|
||||
full_query = '\n'.join(base_query)
|
||||
|
||||
# Go through the query and rewrite all of the ones with the
|
||||
# @:name syntax.
|
||||
rewrite = _RewriteQueryForArray(params)
|
||||
expr = re.compile("@%\(([a-zA-Z][a-zA-Z0-9_-]*)\)s")
|
||||
full_query = expr.sub(rewrite.operate, full_query)
|
||||
params.update(rewrite.new_params)
|
||||
|
||||
# build out the params for like. We only have to do this
|
||||
# parameters which were detected to have ued the where syntax
|
||||
# during load.
|
||||
#
|
||||
# * treat the incoming string as utf-8
|
||||
# * strip wildcards
|
||||
# * append or prepend % as appropriate
|
||||
new_params = {}
|
||||
for key in params:
|
||||
if key in self._around:
|
||||
new_value = ['%']
|
||||
new_value.extend(self._strip_wildcards_to_list(params[key]))
|
||||
new_value.append('%')
|
||||
new_params[self._build_around_key(key)] = ''.join(new_value)
|
||||
if key in self._append:
|
||||
new_value = self._strip_wildcards_to_list(params[key])
|
||||
new_value.append('%')
|
||||
new_params[self._build_append_key(key)] = ''.join(new_value)
|
||||
if key in self._integer:
|
||||
new_params[self._build_integer_key(key)] = int(params[key])
|
||||
params.update(new_params)
|
||||
|
||||
return full_query, params
|
||||
|
||||
def sql(self, connection, params):
|
||||
""" Generates an SQL statement from the named query document
|
||||
and a dictionary of parameters.
|
||||
|
||||
*NOTE: Only use for debugging, because it uses the
|
||||
non-standard MySQLdb 'literal' method.
|
||||
"""
|
||||
if not DEBUG:
|
||||
import warnings
|
||||
warnings.warn("Don't use named_query.sql() when not debugging. Used on %s" % self._location)
|
||||
# do substitution using the mysql (non-standard) 'literal'
|
||||
# function to do the escaping.
|
||||
full_query, params = self._construct_sql(params)
|
||||
return full_query % connection.literal(params)
|
||||
|
||||
|
||||
def refresh(self):
|
||||
""" Refresh self from the file on the filesystem.
|
||||
|
||||
This is optimized to be callable as frequently as you wish,
|
||||
without adding too much load. It does so by only stat-ing the
|
||||
file every N seconds, where N defaults to 5 and is
|
||||
configurable through the member _stat_interval_seconds. If the stat
|
||||
reveals that the file has changed, refresh will re-parse the
|
||||
contents of the file and use them to update the named query
|
||||
instance. If the stat reveals that the file has been deleted,
|
||||
refresh will call self.delete to make the in-memory
|
||||
representation unusable."""
|
||||
now = time.time()
|
||||
if(now - self._last_check_time > self._stat_interval_seconds):
|
||||
self._last_check_time = now
|
||||
try:
|
||||
modtime = self.get_modtime()
|
||||
if(modtime > self._last_mod_time):
|
||||
self.load_contents()
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT: # file not found
|
||||
self.delete() # clean up self
|
||||
raise # pass the exception along to the caller so they know that this query disappeared
|
||||
|
||||
class NamedQueryManager(object):
|
||||
""" Manages the lifespan of NamedQuery objects, drawing from a
|
||||
directory hierarchy of named query documents.
|
||||
|
||||
In practice this amounts to a memory cache of NamedQuery objects."""
|
||||
|
||||
def __init__(self, named_queries_dir):
|
||||
""" Initializes a manager to look for named queries in a
|
||||
directory."""
|
||||
self._dir = os.path.abspath(os.path.realpath(named_queries_dir))
|
||||
self._cached_queries = {}
|
||||
|
||||
def sql(self, connection, name, params):
|
||||
nq = self.get(name)
|
||||
return nq.sql(connection, params)
|
||||
|
||||
def get(self, name):
|
||||
""" Returns a NamedQuery instance based on the name, either
|
||||
from memory cache, or by parsing from disk.
|
||||
|
||||
The name is simply a relative path to the directory associated
|
||||
with the manager object. Before returning the instance, the
|
||||
NamedQuery object is cached in memory, so that subsequent
|
||||
accesses don't have to read from disk or do any parsing. This
|
||||
means that NamedQuery objects returned by this method are
|
||||
shared across all users of the manager object.
|
||||
NamedQuery.refresh is used to bring the NamedQuery objects in
|
||||
sync with the actual files on disk."""
|
||||
nq = self._cached_queries.get(name)
|
||||
if nq is None:
|
||||
nq = NamedQuery(name, os.path.join(self._dir, name))
|
||||
self._cached_queries[name] = nq
|
||||
else:
|
||||
try:
|
||||
nq.refresh()
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOENT: # file not found
|
||||
del self._cached_queries[name]
|
||||
raise # pass exception along to caller so they know that the query disappeared
|
||||
|
||||
return nq
|
||||
|
||||
class _RewriteQueryForArray(object):
|
||||
"Helper class for rewriting queries with the @:name syntax"
|
||||
def __init__(self, params):
|
||||
self.params = params
|
||||
self.new_params = dict()
|
||||
|
||||
def operate(self, match):
|
||||
"Given a match, return the string that should be in use"
|
||||
key = match.group(1)
|
||||
value = self.params[key]
|
||||
if type(value) in (list,tuple):
|
||||
rv = []
|
||||
for idx in range(len(value)):
|
||||
# if the value@idx is array-like, we are
|
||||
# probably dealing with a VALUES
|
||||
new_key = "_%s_%s"%(key, str(idx))
|
||||
val_item = value[idx]
|
||||
if type(val_item) in (list, tuple, dict):
|
||||
if type(val_item) is dict:
|
||||
# this is because in Python, the order of
|
||||
# key, value retrieval from the dict is not
|
||||
# guaranteed to match what the input intended
|
||||
# and for VALUES, order is important.
|
||||
# TODO: Implemented ordered dict in LLSD parser?
|
||||
raise ExpectationFailed('Only lists/tuples allowed,\
|
||||
received dict')
|
||||
values_keys = []
|
||||
for value_idx, item in enumerate(val_item):
|
||||
# we want a key of the format :
|
||||
# key_#replacement_#value_row_#value_col
|
||||
# ugh... so if we are replacing 10 rows in user_note,
|
||||
# the first values clause would read (for @:user_notes) :-
|
||||
# ( :_user_notes_0_1_1, :_user_notes_0_1_2, :_user_notes_0_1_3 )
|
||||
# the input LLSD for VALUES will look like:
|
||||
# <llsd>...
|
||||
# <map>
|
||||
# <key>user_notes</key>
|
||||
# <array>
|
||||
# <array> <!-- row 1 for VALUES -->
|
||||
# <string>...</string>
|
||||
# <string>...</string>
|
||||
# <string>...</string>
|
||||
# </array>
|
||||
# ...
|
||||
# </array>
|
||||
# </map>
|
||||
# ... </llsd>
|
||||
values_key = "%s_%s"%(new_key, value_idx)
|
||||
self.new_params[values_key] = item
|
||||
values_keys.append("%%(%s)s"%values_key)
|
||||
# now collapse all these new place holders enclosed in ()
|
||||
# from [':_key_0_1_1', ':_key_0_1_2', ':_key_0_1_3,...]
|
||||
# rv will have [ '(:_key_0_1_1, :_key_0_1_2, :_key_0_1_3)', ]
|
||||
# which is flattened a few lines below join(rv)
|
||||
rv.append('(%s)' % ','.join(values_keys))
|
||||
else:
|
||||
self.new_params[new_key] = val_item
|
||||
rv.append("%%(%s)s"%new_key)
|
||||
return ','.join(rv)
|
||||
else:
|
||||
# not something that can be expanded, so just drop the
|
||||
# leading @ in the front of the match. This will mean that
|
||||
# the single value we have, be it a string, int, whatever
|
||||
# (other than dict) will correctly show up, eg:
|
||||
#
|
||||
# where foo in (@:foobar) -- foobar is a string, so we get
|
||||
# where foo in (:foobar)
|
||||
return match.group(0)[1:]
|
||||
@@ -1,84 +0,0 @@
|
||||
'''
|
||||
@file shutil2.py
|
||||
@brief a better shutil.copytree replacement
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
'''
|
||||
|
||||
#
|
||||
# shutil2.py
|
||||
# Taken from http://www.scons.org/wiki/AccumulateBuilder
|
||||
# the stock copytree sucks because it insists that the
|
||||
# target dir not exist
|
||||
#
|
||||
|
||||
import os.path
|
||||
import shutil
|
||||
|
||||
def copytree(src, dest, symlinks=False):
|
||||
"""My own copyTree which does not fail if the directory exists.
|
||||
|
||||
Recursively copy a directory tree using copy2().
|
||||
|
||||
If the optional symlinks flag is true, symbolic links in the
|
||||
source tree result in symbolic links in the destination tree; if
|
||||
it is false, the contents of the files pointed to by symbolic
|
||||
links are copied.
|
||||
|
||||
Behavior is meant to be identical to GNU 'cp -R'.
|
||||
"""
|
||||
def copyItems(src, dest, symlinks=False):
|
||||
"""Function that does all the work.
|
||||
|
||||
It is necessary to handle the two 'cp' cases:
|
||||
- destination does exist
|
||||
- destination does not exist
|
||||
|
||||
See 'cp -R' documentation for more details
|
||||
"""
|
||||
for item in os.listdir(src):
|
||||
srcPath = os.path.join(src, item)
|
||||
if os.path.isdir(srcPath):
|
||||
srcBasename = os.path.basename(srcPath)
|
||||
destDirPath = os.path.join(dest, srcBasename)
|
||||
if not os.path.exists(destDirPath):
|
||||
os.makedirs(destDirPath)
|
||||
copyItems(srcPath, destDirPath)
|
||||
elif os.path.islink(item) and symlinks:
|
||||
linkto = os.readlink(item)
|
||||
os.symlink(linkto, dest)
|
||||
else:
|
||||
shutil.copy2(srcPath, dest)
|
||||
|
||||
# case 'cp -R src/ dest/' where dest/ already exists
|
||||
if os.path.exists(dest):
|
||||
destPath = os.path.join(dest, os.path.basename(src))
|
||||
if not os.path.exists(destPath):
|
||||
os.makedirs(destPath)
|
||||
# case 'cp -R src/ dest/' where dest/ does not exist
|
||||
else:
|
||||
os.makedirs(dest)
|
||||
destPath = dest
|
||||
# actually copy the files
|
||||
copyItems(src, destPath)
|
||||
@@ -1,338 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""\
|
||||
@file simperf_host_xml_parser.py
|
||||
@brief Digest collector's XML dump and convert to simple dict/list structure
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import sys, os, getopt, time
|
||||
import simplejson
|
||||
from xml import sax
|
||||
|
||||
|
||||
def usage():
|
||||
print "Usage:"
|
||||
print sys.argv[0] + " [options]"
|
||||
print " Convert RRD's XML dump to JSON. Script to convert the simperf_host_collector-"
|
||||
print " generated RRD dump into JSON. Steps include converting selected named"
|
||||
print " fields from GAUGE type to COUNTER type by computing delta with preceding"
|
||||
print " values. Top-level named fields are:"
|
||||
print
|
||||
print " lastupdate Time (javascript timestamp) of last data sample"
|
||||
print " step Time in seconds between samples"
|
||||
print " ds Data specification (name/type) for each column"
|
||||
print " database Table of data samples, one time step per row"
|
||||
print
|
||||
print "Options:"
|
||||
print " -i, --in Input settings filename. (Default: stdin)"
|
||||
print " -o, --out Output settings filename. (Default: stdout)"
|
||||
print " -h, --help Print this message and exit."
|
||||
print
|
||||
print "Example: %s -i rrddump.xml -o rrddump.json" % sys.argv[0]
|
||||
print
|
||||
print "Interfaces:"
|
||||
print " class SimPerfHostXMLParser() # SAX content handler"
|
||||
print " def simperf_host_xml_fixup(parser) # post-parse value fixup"
|
||||
|
||||
class SimPerfHostXMLParser(sax.handler.ContentHandler):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def startDocument(self):
|
||||
self.rrd_last_update = 0 # public
|
||||
self.rrd_step = 0 # public
|
||||
self.rrd_ds = [] # public
|
||||
self.rrd_records = [] # public
|
||||
self._rrd_level = 0
|
||||
self._rrd_parse_state = 0
|
||||
self._rrd_chars = ""
|
||||
self._rrd_capture = False
|
||||
self._rrd_ds_val = {}
|
||||
self._rrd_data_row = []
|
||||
self._rrd_data_row_has_nan = False
|
||||
|
||||
def endDocument(self):
|
||||
pass
|
||||
|
||||
# Nasty little ad-hoc state machine to extract the elements that are
|
||||
# necessary from the 'rrdtool dump' XML output. The same element
|
||||
# name '<ds>' is used for two different data sets so we need to pay
|
||||
# some attention to the actual structure to get the ones we want
|
||||
# and ignore the ones we don't.
|
||||
|
||||
def startElement(self, name, attrs):
|
||||
self._rrd_level = self._rrd_level + 1
|
||||
self._rrd_capture = False
|
||||
if self._rrd_level == 1:
|
||||
if name == "rrd" and self._rrd_parse_state == 0:
|
||||
self._rrd_parse_state = 1 # In <rrd>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
elif self._rrd_level == 2:
|
||||
if self._rrd_parse_state == 1:
|
||||
if name == "lastupdate":
|
||||
self._rrd_parse_state = 2 # In <rrd><lastupdate>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
elif name == "step":
|
||||
self._rrd_parse_state = 3 # In <rrd><step>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
elif name == "ds":
|
||||
self._rrd_parse_state = 4 # In <rrd><ds>
|
||||
self._rrd_ds_val = {}
|
||||
self._rrd_chars = ""
|
||||
elif name == "rra":
|
||||
self._rrd_parse_state = 5 # In <rrd><rra>
|
||||
elif self._rrd_level == 3:
|
||||
if self._rrd_parse_state == 4:
|
||||
if name == "name":
|
||||
self._rrd_parse_state = 6 # In <rrd><ds><name>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
elif name == "type":
|
||||
self._rrd_parse_state = 7 # In <rrd><ds><type>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
elif self._rrd_parse_state == 5:
|
||||
if name == "database":
|
||||
self._rrd_parse_state = 8 # In <rrd><rra><database>
|
||||
elif self._rrd_level == 4:
|
||||
if self._rrd_parse_state == 8:
|
||||
if name == "row":
|
||||
self._rrd_parse_state = 9 # In <rrd><rra><database><row>
|
||||
self._rrd_data_row = []
|
||||
self._rrd_data_row_has_nan = False
|
||||
elif self._rrd_level == 5:
|
||||
if self._rrd_parse_state == 9:
|
||||
if name == "v":
|
||||
self._rrd_parse_state = 10 # In <rrd><rra><database><row><v>
|
||||
self._rrd_capture = True
|
||||
self._rrd_chars = ""
|
||||
|
||||
def endElement(self, name):
|
||||
self._rrd_capture = False
|
||||
if self._rrd_parse_state == 10:
|
||||
self._rrd_capture = self._rrd_level == 6
|
||||
if self._rrd_level == 5:
|
||||
if self._rrd_chars == "NaN":
|
||||
self._rrd_data_row_has_nan = True
|
||||
else:
|
||||
self._rrd_data_row.append(self._rrd_chars)
|
||||
self._rrd_parse_state = 9 # In <rrd><rra><database><row>
|
||||
elif self._rrd_parse_state == 9:
|
||||
if self._rrd_level == 4:
|
||||
if not self._rrd_data_row_has_nan:
|
||||
self.rrd_records.append(self._rrd_data_row)
|
||||
self._rrd_parse_state = 8 # In <rrd><rra><database>
|
||||
elif self._rrd_parse_state == 8:
|
||||
if self._rrd_level == 3:
|
||||
self._rrd_parse_state = 5 # In <rrd><rra>
|
||||
elif self._rrd_parse_state == 7:
|
||||
if self._rrd_level == 3:
|
||||
self._rrd_ds_val["type"] = self._rrd_chars
|
||||
self._rrd_parse_state = 4 # In <rrd><ds>
|
||||
elif self._rrd_parse_state == 6:
|
||||
if self._rrd_level == 3:
|
||||
self._rrd_ds_val["name"] = self._rrd_chars
|
||||
self._rrd_parse_state = 4 # In <rrd><ds>
|
||||
elif self._rrd_parse_state == 5:
|
||||
if self._rrd_level == 2:
|
||||
self._rrd_parse_state = 1 # In <rrd>
|
||||
elif self._rrd_parse_state == 4:
|
||||
if self._rrd_level == 2:
|
||||
self.rrd_ds.append(self._rrd_ds_val)
|
||||
self._rrd_parse_state = 1 # In <rrd>
|
||||
elif self._rrd_parse_state == 3:
|
||||
if self._rrd_level == 2:
|
||||
self.rrd_step = long(self._rrd_chars)
|
||||
self._rrd_parse_state = 1 # In <rrd>
|
||||
elif self._rrd_parse_state == 2:
|
||||
if self._rrd_level == 2:
|
||||
self.rrd_last_update = long(self._rrd_chars)
|
||||
self._rrd_parse_state = 1 # In <rrd>
|
||||
elif self._rrd_parse_state == 1:
|
||||
if self._rrd_level == 1:
|
||||
self._rrd_parse_state = 0 # At top
|
||||
|
||||
if self._rrd_level:
|
||||
self._rrd_level = self._rrd_level - 1
|
||||
|
||||
def characters(self, content):
|
||||
if self._rrd_capture:
|
||||
self._rrd_chars = self._rrd_chars + content.strip()
|
||||
|
||||
def _make_numeric(value):
|
||||
try:
|
||||
value = float(value)
|
||||
except:
|
||||
value = ""
|
||||
return value
|
||||
|
||||
def simperf_host_xml_fixup(parser, filter_start_time = None, filter_end_time = None):
|
||||
# Fixup for GAUGE fields that are really COUNTS. They
|
||||
# were forced to GAUGE to try to disable rrdtool's
|
||||
# data interpolation/extrapolation for non-uniform time
|
||||
# samples.
|
||||
fixup_tags = [ "cpu_user",
|
||||
"cpu_nice",
|
||||
"cpu_sys",
|
||||
"cpu_idle",
|
||||
"cpu_waitio",
|
||||
"cpu_intr",
|
||||
# "file_active",
|
||||
# "file_free",
|
||||
# "inode_active",
|
||||
# "inode_free",
|
||||
"netif_in_kb",
|
||||
"netif_in_pkts",
|
||||
"netif_in_errs",
|
||||
"netif_in_drop",
|
||||
"netif_out_kb",
|
||||
"netif_out_pkts",
|
||||
"netif_out_errs",
|
||||
"netif_out_drop",
|
||||
"vm_page_in",
|
||||
"vm_page_out",
|
||||
"vm_swap_in",
|
||||
"vm_swap_out",
|
||||
#"vm_mem_total",
|
||||
#"vm_mem_used",
|
||||
#"vm_mem_active",
|
||||
#"vm_mem_inactive",
|
||||
#"vm_mem_free",
|
||||
#"vm_mem_buffer",
|
||||
#"vm_swap_cache",
|
||||
#"vm_swap_total",
|
||||
#"vm_swap_used",
|
||||
#"vm_swap_free",
|
||||
"cpu_interrupts",
|
||||
"cpu_switches",
|
||||
"cpu_forks" ]
|
||||
|
||||
col_count = len(parser.rrd_ds)
|
||||
row_count = len(parser.rrd_records)
|
||||
|
||||
# Process the last row separately, just to make all values numeric.
|
||||
for j in range(col_count):
|
||||
parser.rrd_records[row_count - 1][j] = _make_numeric(parser.rrd_records[row_count - 1][j])
|
||||
|
||||
# Process all other row/columns.
|
||||
last_different_row = row_count - 1
|
||||
current_row = row_count - 2
|
||||
while current_row >= 0:
|
||||
# Check for a different value than the previous row. If everything is the same
|
||||
# then this is probably just a filler/bogus entry.
|
||||
is_different = False
|
||||
for j in range(col_count):
|
||||
parser.rrd_records[current_row][j] = _make_numeric(parser.rrd_records[current_row][j])
|
||||
if parser.rrd_records[current_row][j] != parser.rrd_records[last_different_row][j]:
|
||||
# We're good. This is a different row.
|
||||
is_different = True
|
||||
|
||||
if not is_different:
|
||||
# This is a filler/bogus entry. Just ignore it.
|
||||
for j in range(col_count):
|
||||
parser.rrd_records[current_row][j] = float('nan')
|
||||
else:
|
||||
# Some tags need to be converted into deltas.
|
||||
for j in range(col_count):
|
||||
if parser.rrd_ds[j]["name"] in fixup_tags:
|
||||
parser.rrd_records[last_different_row][j] = \
|
||||
parser.rrd_records[last_different_row][j] - parser.rrd_records[current_row][j]
|
||||
last_different_row = current_row
|
||||
|
||||
current_row -= 1
|
||||
|
||||
# Set fixup_tags in the first row to 'nan' since they aren't useful anymore.
|
||||
for j in range(col_count):
|
||||
if parser.rrd_ds[j]["name"] in fixup_tags:
|
||||
parser.rrd_records[0][j] = float('nan')
|
||||
|
||||
# Add a timestamp to each row and to the catalog. Format and name
|
||||
# chosen to match other simulator logging (hopefully).
|
||||
start_time = parser.rrd_last_update - (parser.rrd_step * (row_count - 1))
|
||||
# Build a filtered list of rrd_records if we are limited to a time range.
|
||||
filter_records = False
|
||||
if filter_start_time is not None or filter_end_time is not None:
|
||||
filter_records = True
|
||||
filtered_rrd_records = []
|
||||
if filter_start_time is None:
|
||||
filter_start_time = start_time * 1000
|
||||
if filter_end_time is None:
|
||||
filter_end_time = parser.rrd_last_update * 1000
|
||||
|
||||
for i in range(row_count):
|
||||
record_timestamp = (start_time + (i * parser.rrd_step)) * 1000
|
||||
parser.rrd_records[i].insert(0, record_timestamp)
|
||||
if filter_records:
|
||||
if filter_start_time <= record_timestamp and record_timestamp <= filter_end_time:
|
||||
filtered_rrd_records.append(parser.rrd_records[i])
|
||||
|
||||
if filter_records:
|
||||
parser.rrd_records = filtered_rrd_records
|
||||
|
||||
parser.rrd_ds.insert(0, {"type": "GAUGE", "name": "javascript_timestamp"})
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
opts, args = getopt.getopt(sys.argv[1:], "i:o:h", ["in=", "out=", "help"])
|
||||
input_file = sys.stdin
|
||||
output_file = sys.stdout
|
||||
for o, a in opts:
|
||||
if o in ("-i", "--in"):
|
||||
input_file = open(a, 'r')
|
||||
if o in ("-o", "--out"):
|
||||
output_file = open(a, 'w')
|
||||
if o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
# Using the SAX parser as it is at least 4X faster and far, far
|
||||
# smaller on this dataset than the DOM-based interface in xml.dom.minidom.
|
||||
# With SAX and a 5.4MB xml file, this requires about seven seconds of
|
||||
# wall-clock time and 32MB VSZ. With the DOM interface, about 22 seconds
|
||||
# and over 270MB VSZ.
|
||||
|
||||
handler = SimPerfHostXMLParser()
|
||||
sax.parse(input_file, handler)
|
||||
if input_file != sys.stdin:
|
||||
input_file.close()
|
||||
|
||||
# Various format fixups: string-to-num, gauge-to-counts, add
|
||||
# a time stamp, etc.
|
||||
simperf_host_xml_fixup(handler)
|
||||
|
||||
# Create JSONable dict with interesting data and format/print it
|
||||
print >>output_file, simplejson.dumps({ "step" : handler.rrd_step,
|
||||
"lastupdate": handler.rrd_last_update * 1000,
|
||||
"ds" : handler.rrd_ds,
|
||||
"database" : handler.rrd_records })
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,167 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""\
|
||||
@file simperf_oprof_interface.py
|
||||
@brief Manage OProfile data collection on a host
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
import sys, os, getopt
|
||||
import simplejson
|
||||
|
||||
|
||||
def usage():
|
||||
print "Usage:"
|
||||
print sys.argv[0] + " [options]"
|
||||
print " Digest the OProfile report forms that come out of the"
|
||||
print " simperf_oprof_ctl program's -r/--report command. The result"
|
||||
print " is an array of dictionaires with the following keys:"
|
||||
print
|
||||
print " symbol Name of sampled, calling, or called procedure"
|
||||
print " file Executable or library where symbol resides"
|
||||
print " percentage Percentage contribution to profile, calls or called"
|
||||
print " samples Sample count"
|
||||
print " calls Methods called by the method in question (full only)"
|
||||
print " called_by Methods calling the method (full only)"
|
||||
print
|
||||
print " For 'full' reports the two keys 'calls' and 'called_by' are"
|
||||
print " themselves arrays of dictionaries based on the first four keys."
|
||||
print
|
||||
print "Return Codes:"
|
||||
print " None. Aggressively digests everything. Will likely mung results"
|
||||
print " if a program or library has whitespace in its name."
|
||||
print
|
||||
print "Options:"
|
||||
print " -i, --in Input settings filename. (Default: stdin)"
|
||||
print " -o, --out Output settings filename. (Default: stdout)"
|
||||
print " -h, --help Print this message and exit."
|
||||
print
|
||||
print "Interfaces:"
|
||||
print " class SimPerfOProfileInterface()"
|
||||
|
||||
class SimPerfOProfileInterface:
|
||||
def __init__(self):
|
||||
self.isBrief = True # public
|
||||
self.isValid = False # public
|
||||
self.result = [] # public
|
||||
|
||||
def parse(self, input):
|
||||
in_samples = False
|
||||
for line in input:
|
||||
if in_samples:
|
||||
if line[0:6] == "------":
|
||||
self.isBrief = False
|
||||
self._parseFull(input)
|
||||
else:
|
||||
self._parseBrief(input, line)
|
||||
self.isValid = True
|
||||
return
|
||||
try:
|
||||
hd1, remain = line.split(None, 1)
|
||||
if hd1 == "samples":
|
||||
in_samples = True
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def _parseBrief(self, input, line1):
|
||||
try:
|
||||
fld1, fld2, fld3, fld4 = line1.split(None, 3)
|
||||
self.result.append({"samples" : fld1,
|
||||
"percentage" : fld2,
|
||||
"file" : fld3,
|
||||
"symbol" : fld4.strip("\n")})
|
||||
except ValueError:
|
||||
pass
|
||||
for line in input:
|
||||
try:
|
||||
fld1, fld2, fld3, fld4 = line.split(None, 3)
|
||||
self.result.append({"samples" : fld1,
|
||||
"percentage" : fld2,
|
||||
"file" : fld3,
|
||||
"symbol" : fld4.strip("\n")})
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def _parseFull(self, input):
|
||||
state = 0 # In 'called_by' section
|
||||
calls = []
|
||||
called_by = []
|
||||
current = {}
|
||||
for line in input:
|
||||
if line[0:6] == "------":
|
||||
if len(current):
|
||||
current["calls"] = calls
|
||||
current["called_by"] = called_by
|
||||
self.result.append(current)
|
||||
state = 0
|
||||
calls = []
|
||||
called_by = []
|
||||
current = {}
|
||||
else:
|
||||
try:
|
||||
fld1, fld2, fld3, fld4 = line.split(None, 3)
|
||||
tmp = {"samples" : fld1,
|
||||
"percentage" : fld2,
|
||||
"file" : fld3,
|
||||
"symbol" : fld4.strip("\n")}
|
||||
except ValueError:
|
||||
continue
|
||||
if line[0] != " ":
|
||||
current = tmp
|
||||
state = 1 # In 'calls' section
|
||||
elif state == 0:
|
||||
called_by.append(tmp)
|
||||
else:
|
||||
calls.append(tmp)
|
||||
if len(current):
|
||||
current["calls"] = calls
|
||||
current["called_by"] = called_by
|
||||
self.result.append(current)
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
opts, args = getopt.getopt(sys.argv[1:], "i:o:h", ["in=", "out=", "help"])
|
||||
input_file = sys.stdin
|
||||
output_file = sys.stdout
|
||||
for o, a in opts:
|
||||
if o in ("-i", "--in"):
|
||||
input_file = open(a, 'r')
|
||||
if o in ("-o", "--out"):
|
||||
output_file = open(a, 'w')
|
||||
if o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
oprof = SimPerfOProfileInterface()
|
||||
oprof.parse(input_file)
|
||||
if input_file != sys.stdin:
|
||||
input_file.close()
|
||||
|
||||
# Create JSONable dict with interesting data and format/print it
|
||||
print >>output_file, simplejson.dumps(oprof.result)
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -1,191 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""\
|
||||
@file simperf_proc_interface.py
|
||||
@brief Utility to extract log messages from *.<pid>.llsd files containing performance statistics.
|
||||
|
||||
$LicenseInfo:firstyear=2008&license=mit$
|
||||
|
||||
Copyright (c) 2008-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
"""
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Utility to extract log messages from *.<pid>.llsd
|
||||
# files that contain performance statistics.
|
||||
|
||||
# ----------------------------------------------------
|
||||
import sys, os
|
||||
|
||||
if os.path.exists("setup-path.py"):
|
||||
execfile("setup-path.py")
|
||||
|
||||
from indra.base import llsd
|
||||
|
||||
DEFAULT_PATH="/dev/shm/simperf/"
|
||||
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Pull out the stats and return a single document
|
||||
def parse_logfile(filename, target_column=None, verbose=False):
|
||||
full_doc = []
|
||||
# Open source temp log file. Let exceptions percolate up.
|
||||
sourcefile = open( filename,'r')
|
||||
|
||||
if verbose:
|
||||
print "Reading " + filename
|
||||
|
||||
# Parse and output all lines from the temp file
|
||||
for line in sourcefile.xreadlines():
|
||||
partial_doc = llsd.parse(line)
|
||||
if partial_doc is not None:
|
||||
if target_column is None:
|
||||
full_doc.append(partial_doc)
|
||||
else:
|
||||
trim_doc = { target_column: partial_doc[target_column] }
|
||||
if target_column != "fps":
|
||||
trim_doc[ 'fps' ] = partial_doc[ 'fps' ]
|
||||
trim_doc[ '/total_time' ] = partial_doc[ '/total_time' ]
|
||||
trim_doc[ 'utc_time' ] = partial_doc[ 'utc_time' ]
|
||||
full_doc.append(trim_doc)
|
||||
|
||||
sourcefile.close()
|
||||
return full_doc
|
||||
|
||||
# Extract just the meta info line, and the timestamp of the first/last frame entry.
|
||||
def parse_logfile_info(filename, verbose=False):
|
||||
# Open source temp log file. Let exceptions percolate up.
|
||||
sourcefile = open(filename, 'rU') # U is to open with Universal newline support
|
||||
|
||||
if verbose:
|
||||
print "Reading " + filename
|
||||
|
||||
# The first line is the meta info line.
|
||||
info_line = sourcefile.readline()
|
||||
if not info_line:
|
||||
sourcefile.close()
|
||||
return None
|
||||
|
||||
# The rest of the lines are frames. Read the first and last to get the time range.
|
||||
info = llsd.parse( info_line )
|
||||
info['start_time'] = None
|
||||
info['end_time'] = None
|
||||
first_frame = sourcefile.readline()
|
||||
if first_frame:
|
||||
try:
|
||||
info['start_time'] = int(llsd.parse(first_frame)['timestamp'])
|
||||
except:
|
||||
pass
|
||||
|
||||
# Read the file backwards to find the last two lines.
|
||||
sourcefile.seek(0, 2)
|
||||
file_size = sourcefile.tell()
|
||||
offset = 1024
|
||||
num_attempts = 0
|
||||
end_time = None
|
||||
if file_size < offset:
|
||||
offset = file_size
|
||||
while 1:
|
||||
sourcefile.seek(-1*offset, 2)
|
||||
read_str = sourcefile.read(offset)
|
||||
# Remove newline at the end
|
||||
if read_str[offset - 1] == '\n':
|
||||
read_str = read_str[0:-1]
|
||||
lines = read_str.split('\n')
|
||||
full_line = None
|
||||
if len(lines) > 2: # Got two line
|
||||
try:
|
||||
end_time = llsd.parse(lines[-1])['timestamp']
|
||||
except:
|
||||
# We couldn't parse this line. Try once more.
|
||||
try:
|
||||
end_time = llsd.parse(lines[-2])['timestamp']
|
||||
except:
|
||||
# Nope. Just move on.
|
||||
pass
|
||||
break
|
||||
if len(read_str) == file_size: # Reached the beginning
|
||||
break
|
||||
offset += 1024
|
||||
|
||||
info['end_time'] = int(end_time)
|
||||
|
||||
sourcefile.close()
|
||||
return info
|
||||
|
||||
|
||||
def parse_proc_filename(filename):
|
||||
try:
|
||||
name_as_list = filename.split(".")
|
||||
cur_stat_type = name_as_list[0].split("_")[0]
|
||||
cur_pid = name_as_list[1]
|
||||
except IndexError, ValueError:
|
||||
return (None, None)
|
||||
return (cur_pid, cur_stat_type)
|
||||
|
||||
# ----------------------------------------------------
|
||||
def get_simstats_list(path=None):
|
||||
""" Return stats (pid, type) listed in <type>_proc.<pid>.llsd """
|
||||
if path is None:
|
||||
path = DEFAULT_PATH
|
||||
simstats_list = []
|
||||
for file_name in os.listdir(path):
|
||||
if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd":
|
||||
simstats_info = parse_logfile_info(path + file_name)
|
||||
if simstats_info is not None:
|
||||
simstats_list.append(simstats_info)
|
||||
return simstats_list
|
||||
|
||||
def get_log_info_list(pid=None, stat_type=None, path=None, target_column=None, verbose=False):
|
||||
""" Return data from all llsd files matching the pid and stat type """
|
||||
if path is None:
|
||||
path = DEFAULT_PATH
|
||||
log_info_list = {}
|
||||
for file_name in os.listdir ( path ):
|
||||
if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd":
|
||||
(cur_pid, cur_stat_type) = parse_proc_filename(file_name)
|
||||
if cur_pid is None:
|
||||
continue
|
||||
if pid is not None and pid != cur_pid:
|
||||
continue
|
||||
if stat_type is not None and stat_type != cur_stat_type:
|
||||
continue
|
||||
log_info_list[cur_pid] = parse_logfile(path + file_name, target_column, verbose)
|
||||
return log_info_list
|
||||
|
||||
def delete_simstats_files(pid=None, stat_type=None, path=None):
|
||||
""" Delete *.<pid>.llsd files """
|
||||
if path is None:
|
||||
path = DEFAULT_PATH
|
||||
del_list = []
|
||||
for file_name in os.listdir(path):
|
||||
if file_name.endswith(".llsd") and file_name != "simperf_proc_config.llsd":
|
||||
(cur_pid, cur_stat_type) = parse_proc_filename(file_name)
|
||||
if cur_pid is None:
|
||||
continue
|
||||
if pid is not None and pid != cur_pid:
|
||||
continue
|
||||
if stat_type is not None and stat_type != cur_stat_type:
|
||||
continue
|
||||
del_list.append(cur_pid)
|
||||
# Allow delete related exceptions to percolate up if this fails.
|
||||
os.unlink(os.path.join(DEFAULT_PATH, file_name))
|
||||
return del_list
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
'''
|
||||
@file term.py
|
||||
@brief a better shutil.copytree replacement
|
||||
|
||||
$LicenseInfo:firstyear=2007&license=mit$
|
||||
|
||||
Copyright (c) 2007-2009, Linden Research, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
$/LicenseInfo$
|
||||
'''
|
||||
|
||||
#http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/475116
|
||||
|
||||
import sys, re
|
||||
|
||||
class TerminalController:
|
||||
"""
|
||||
A class that can be used to portably generate formatted output to
|
||||
a terminal.
|
||||
|
||||
`TerminalController` defines a set of instance variables whose
|
||||
values are initialized to the control sequence necessary to
|
||||
perform a given action. These can be simply included in normal
|
||||
output to the terminal:
|
||||
|
||||
>>> term = TerminalController()
|
||||
>>> print 'This is '+term.GREEN+'green'+term.NORMAL
|
||||
|
||||
Alternatively, the `render()` method can used, which replaces
|
||||
'${action}' with the string required to perform 'action':
|
||||
|
||||
>>> term = TerminalController()
|
||||
>>> print term.render('This is ${GREEN}green${NORMAL}')
|
||||
|
||||
If the terminal doesn't support a given action, then the value of
|
||||
the corresponding instance variable will be set to ''. As a
|
||||
result, the above code will still work on terminals that do not
|
||||
support color, except that their output will not be colored.
|
||||
Also, this means that you can test whether the terminal supports a
|
||||
given action by simply testing the truth value of the
|
||||
corresponding instance variable:
|
||||
|
||||
>>> term = TerminalController()
|
||||
>>> if term.CLEAR_SCREEN:
|
||||
... print 'This terminal supports clearning the screen.'
|
||||
|
||||
Finally, if the width and height of the terminal are known, then
|
||||
they will be stored in the `COLS` and `LINES` attributes.
|
||||
"""
|
||||
# Cursor movement:
|
||||
BOL = '' #: Move the cursor to the beginning of the line
|
||||
UP = '' #: Move the cursor up one line
|
||||
DOWN = '' #: Move the cursor down one line
|
||||
LEFT = '' #: Move the cursor left one char
|
||||
RIGHT = '' #: Move the cursor right one char
|
||||
|
||||
# Deletion:
|
||||
CLEAR_SCREEN = '' #: Clear the screen and move to home position
|
||||
CLEAR_EOL = '' #: Clear to the end of the line.
|
||||
CLEAR_BOL = '' #: Clear to the beginning of the line.
|
||||
CLEAR_EOS = '' #: Clear to the end of the screen
|
||||
|
||||
# Output modes:
|
||||
BOLD = '' #: Turn on bold mode
|
||||
BLINK = '' #: Turn on blink mode
|
||||
DIM = '' #: Turn on half-bright mode
|
||||
REVERSE = '' #: Turn on reverse-video mode
|
||||
NORMAL = '' #: Turn off all modes
|
||||
|
||||
# Cursor display:
|
||||
HIDE_CURSOR = '' #: Make the cursor invisible
|
||||
SHOW_CURSOR = '' #: Make the cursor visible
|
||||
|
||||
# Terminal size:
|
||||
COLS = None #: Width of the terminal (None for unknown)
|
||||
LINES = None #: Height of the terminal (None for unknown)
|
||||
|
||||
# Foreground colors:
|
||||
BLACK = BLUE = GREEN = CYAN = RED = MAGENTA = YELLOW = WHITE = ''
|
||||
|
||||
# Background colors:
|
||||
BG_BLACK = BG_BLUE = BG_GREEN = BG_CYAN = ''
|
||||
BG_RED = BG_MAGENTA = BG_YELLOW = BG_WHITE = ''
|
||||
|
||||
_STRING_CAPABILITIES = """
|
||||
BOL=cr UP=cuu1 DOWN=cud1 LEFT=cub1 RIGHT=cuf1
|
||||
CLEAR_SCREEN=clear CLEAR_EOL=el CLEAR_BOL=el1 CLEAR_EOS=ed BOLD=bold
|
||||
BLINK=blink DIM=dim REVERSE=rev UNDERLINE=smul NORMAL=sgr0
|
||||
HIDE_CURSOR=cinvis SHOW_CURSOR=cnorm""".split()
|
||||
_COLORS = """BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE""".split()
|
||||
_ANSICOLORS = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE".split()
|
||||
|
||||
def __init__(self, term_stream=sys.stdout):
|
||||
"""
|
||||
Create a `TerminalController` and initialize its attributes
|
||||
with appropriate values for the current terminal.
|
||||
`term_stream` is the stream that will be used for terminal
|
||||
output; if this stream is not a tty, then the terminal is
|
||||
assumed to be a dumb terminal (i.e., have no capabilities).
|
||||
"""
|
||||
# Curses isn't available on all platforms
|
||||
try: import curses
|
||||
except: return
|
||||
|
||||
# If the stream isn't a tty, then assume it has no capabilities.
|
||||
if not term_stream.isatty(): return
|
||||
|
||||
# Check the terminal type. If we fail, then assume that the
|
||||
# terminal has no capabilities.
|
||||
try: curses.setupterm()
|
||||
except: return
|
||||
|
||||
# Look up numeric capabilities.
|
||||
self.COLS = curses.tigetnum('cols')
|
||||
self.LINES = curses.tigetnum('lines')
|
||||
|
||||
# Look up string capabilities.
|
||||
for capability in self._STRING_CAPABILITIES:
|
||||
(attrib, cap_name) = capability.split('=')
|
||||
setattr(self, attrib, self._tigetstr(cap_name) or '')
|
||||
|
||||
# Colors
|
||||
set_fg = self._tigetstr('setf')
|
||||
if set_fg:
|
||||
for i,color in zip(range(len(self._COLORS)), self._COLORS):
|
||||
setattr(self, color, curses.tparm(set_fg, i) or '')
|
||||
set_fg_ansi = self._tigetstr('setaf')
|
||||
if set_fg_ansi:
|
||||
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
|
||||
setattr(self, color, curses.tparm(set_fg_ansi, i) or '')
|
||||
set_bg = self._tigetstr('setb')
|
||||
if set_bg:
|
||||
for i,color in zip(range(len(self._COLORS)), self._COLORS):
|
||||
setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '')
|
||||
set_bg_ansi = self._tigetstr('setab')
|
||||
if set_bg_ansi:
|
||||
for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS):
|
||||
setattr(self, 'BG_'+color, curses.tparm(set_bg_ansi, i) or '')
|
||||
|
||||
def _tigetstr(self, cap_name):
|
||||
# String capabilities can include "delays" of the form "$<2>".
|
||||
# For any modern terminal, we should be able to just ignore
|
||||
# these, so strip them out.
|
||||
import curses
|
||||
cap = curses.tigetstr(cap_name) or ''
|
||||
return re.sub(r'\$<\d+>[/*]?', '', cap)
|
||||
|
||||
def render(self, template):
|
||||
"""
|
||||
Replace each $-substitutions in the given template string with
|
||||
the corresponding terminal control string (if it's defined) or
|
||||
'' (if it's not).
|
||||
"""
|
||||
return re.sub(r'\$\$|\${\w+}', self._render_sub, template)
|
||||
|
||||
def _render_sub(self, match):
|
||||
s = match.group()
|
||||
if s == '$$': return s
|
||||
else: return getattr(self, s[2:-1])
|
||||
|
||||
#######################################################################
|
||||
# Example use case: progress bar
|
||||
#######################################################################
|
||||
|
||||
class ProgressBar:
|
||||
"""
|
||||
A 3-line progress bar, which looks like::
|
||||
|
||||
Header
|
||||
20% [===========----------------------------------]
|
||||
progress message
|
||||
|
||||
The progress bar is colored, if the terminal supports color
|
||||
output; and adjusts to the width of the terminal.
|
||||
"""
|
||||
BAR = '%3d%% ${GREEN}[${BOLD}%s%s${NORMAL}${GREEN}]${NORMAL}\n'
|
||||
HEADER = '${BOLD}${CYAN}%s${NORMAL}\n\n'
|
||||
|
||||
def __init__(self, term, header):
|
||||
self.term = term
|
||||
if not (self.term.CLEAR_EOL and self.term.UP and self.term.BOL):
|
||||
raise ValueError("Terminal isn't capable enough -- you "
|
||||
"should use a simpler progress dispaly.")
|
||||
self.width = self.term.COLS or 75
|
||||
self.bar = term.render(self.BAR)
|
||||
self.header = self.term.render(self.HEADER % header.center(self.width))
|
||||
self.cleared = 1 #: true if we haven't drawn the bar yet.
|
||||
self.update(0, '')
|
||||
|
||||
def update(self, percent, message):
|
||||
if self.cleared:
|
||||
sys.stdout.write(self.header)
|
||||
self.cleared = 0
|
||||
n = int((self.width-10)*percent)
|
||||
sys.stdout.write(
|
||||
self.term.BOL + self.term.UP + self.term.CLEAR_EOL +
|
||||
(self.bar % (100*percent, '='*n, '-'*(self.width-10-n))) +
|
||||
self.term.CLEAR_EOL + message.center(self.width))
|
||||
|
||||
def clear(self):
|
||||
if not self.cleared:
|
||||
sys.stdout.write(self.term.BOL + self.term.CLEAR_EOL +
|
||||
self.term.UP + self.term.CLEAR_EOL +
|
||||
self.term.UP + self.term.CLEAR_EOL)
|
||||
self.cleared = 1
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python2
|
||||
"""\
|
||||
@file test_win32_manifest.py
|
||||
@brief Test an assembly binding version and uniqueness in a windows dll or exe.
|
||||
|
||||
@@ -1,508 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
## $LicenseInfo:firstyear=2011&license=viewerlgpl$
|
||||
## Second Life Viewer Source Code
|
||||
## Copyright (C) 2011, Linden Research, Inc.
|
||||
##
|
||||
## This library is free software; you can redistribute it and/or
|
||||
## modify it under the terms of the GNU Lesser General Public
|
||||
## License as published by the Free Software Foundation;
|
||||
## version 2.1 of the License only.
|
||||
##
|
||||
## This library is distributed in the hope that it will be useful,
|
||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## Lesser General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU Lesser General Public
|
||||
## License along with this library; if not, write to the Free Software
|
||||
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
##
|
||||
## Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||
## $/LicenseInfo$
|
||||
r"""UUID objects (universally unique identifiers) according to RFC 4122.
|
||||
|
||||
This module provides immutable UUID objects (class UUID) and the functions
|
||||
uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5
|
||||
UUIDs as specified in RFC 4122.
|
||||
|
||||
If all you want is a unique ID, you should probably call uuid1() or uuid4().
|
||||
Note that uuid1() may compromise privacy since it creates a UUID containing
|
||||
the computer's network address. uuid4() creates a random UUID.
|
||||
|
||||
Typical usage:
|
||||
|
||||
>>> import uuid
|
||||
|
||||
# make a UUID based on the host ID and current time
|
||||
>>> uuid.uuid1()
|
||||
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
|
||||
|
||||
# make a UUID using an MD5 hash of a namespace UUID and a name
|
||||
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
|
||||
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
|
||||
|
||||
# make a random UUID
|
||||
>>> uuid.uuid4()
|
||||
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
|
||||
|
||||
# make a UUID using a SHA-1 hash of a namespace UUID and a name
|
||||
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
|
||||
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
|
||||
|
||||
# make a UUID from a string of hex digits (braces and hyphens ignored)
|
||||
>>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
|
||||
|
||||
# convert a UUID to a string of hex digits in standard form
|
||||
>>> str(x)
|
||||
'00010203-0405-0607-0809-0a0b0c0d0e0f'
|
||||
|
||||
# get the raw 16 bytes of the UUID
|
||||
>>> x.bytes
|
||||
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
|
||||
|
||||
# make a UUID from a 16-byte string
|
||||
>>> uuid.UUID(bytes=x.bytes)
|
||||
UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
|
||||
|
||||
This module works with Python 2.3 or higher."""
|
||||
|
||||
__author__ = 'Ka-Ping Yee <ping@zesty.ca>'
|
||||
__date__ = '$Date: 2006/06/12 23:15:40 $'.split()[1].replace('/', '-')
|
||||
__version__ = '$Revision: 1.30 $'.split()[1]
|
||||
|
||||
RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [
|
||||
'reserved for NCS compatibility', 'specified in RFC 4122',
|
||||
'reserved for Microsoft compatibility', 'reserved for future definition']
|
||||
|
||||
class UUID(object):
|
||||
"""Instances of the UUID class represent UUIDs as specified in RFC 4122.
|
||||
UUID objects are immutable, hashable, and usable as dictionary keys.
|
||||
Converting a UUID to a string with str() yields something in the form
|
||||
'12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts
|
||||
four possible forms: a similar string of hexadecimal digits, or a
|
||||
string of 16 raw bytes as an argument named 'bytes', or a tuple of
|
||||
six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and
|
||||
48-bit values respectively) as an argument named 'fields', or a single
|
||||
128-bit integer as an argument named 'int'.
|
||||
|
||||
UUIDs have these read-only attributes:
|
||||
|
||||
bytes the UUID as a 16-byte string
|
||||
|
||||
fields a tuple of the six integer fields of the UUID,
|
||||
which are also available as six individual attributes
|
||||
and two derived attributes:
|
||||
|
||||
time_low the first 32 bits of the UUID
|
||||
time_mid the next 16 bits of the UUID
|
||||
time_hi_version the next 16 bits of the UUID
|
||||
clock_seq_hi_variant the next 8 bits of the UUID
|
||||
clock_seq_low the next 8 bits of the UUID
|
||||
node the last 48 bits of the UUID
|
||||
|
||||
time the 60-bit timestamp
|
||||
clock_seq the 14-bit sequence number
|
||||
|
||||
hex the UUID as a 32-character hexadecimal string
|
||||
|
||||
int the UUID as a 128-bit integer
|
||||
|
||||
urn the UUID as a URN as specified in RFC 4122
|
||||
|
||||
variant the UUID variant (one of the constants RESERVED_NCS,
|
||||
RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE)
|
||||
|
||||
version the UUID version number (1 through 5, meaningful only
|
||||
when the variant is RFC_4122)
|
||||
"""
|
||||
|
||||
def __init__(self, hex=None, bytes=None, fields=None, int=None,
|
||||
version=None):
|
||||
r"""Create a UUID from either a string of 32 hexadecimal digits,
|
||||
a string of 16 bytes as the 'bytes' argument, a tuple of six
|
||||
integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version,
|
||||
8-bit clock_seq_hi_variant, 8-bit clock_seq_low, 48-bit node) as
|
||||
the 'fields' argument, or a single 128-bit integer as the 'int'
|
||||
argument. When a string of hex digits is given, curly braces,
|
||||
hyphens, and a URN prefix are all optional. For example, these
|
||||
expressions all yield the same UUID:
|
||||
|
||||
UUID('{12345678-1234-5678-1234-567812345678}')
|
||||
UUID('12345678123456781234567812345678')
|
||||
UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
|
||||
UUID(bytes='\x12\x34\x56\x78'*4)
|
||||
UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
|
||||
UUID(int=0x12345678123456781234567812345678)
|
||||
|
||||
Exactly one of 'hex', 'bytes', 'fields', or 'int' must be given.
|
||||
The 'version' argument is optional; if given, the resulting UUID
|
||||
will have its variant and version number set according to RFC 4122,
|
||||
overriding bits in the given 'hex', 'bytes', 'fields', or 'int'.
|
||||
"""
|
||||
|
||||
if [hex, bytes, fields, int].count(None) != 3:
|
||||
raise TypeError('need just one of hex, bytes, fields, or int')
|
||||
if hex is not None:
|
||||
hex = hex.replace('urn:', '').replace('uuid:', '')
|
||||
hex = hex.strip('{}').replace('-', '')
|
||||
if len(hex) != 32:
|
||||
raise ValueError('badly formed hexadecimal UUID string')
|
||||
int = long(hex, 16)
|
||||
if bytes is not None:
|
||||
if len(bytes) != 16:
|
||||
raise ValueError('bytes is not a 16-char string')
|
||||
int = long(('%02x'*16) % tuple(map(ord, bytes)), 16)
|
||||
if fields is not None:
|
||||
if len(fields) != 6:
|
||||
raise ValueError('fields is not a 6-tuple')
|
||||
(time_low, time_mid, time_hi_version,
|
||||
clock_seq_hi_variant, clock_seq_low, node) = fields
|
||||
if not 0 <= time_low < 1<<32L:
|
||||
raise ValueError('field 1 out of range (need a 32-bit value)')
|
||||
if not 0 <= time_mid < 1<<16L:
|
||||
raise ValueError('field 2 out of range (need a 16-bit value)')
|
||||
if not 0 <= time_hi_version < 1<<16L:
|
||||
raise ValueError('field 3 out of range (need a 16-bit value)')
|
||||
if not 0 <= clock_seq_hi_variant < 1<<8L:
|
||||
raise ValueError('field 4 out of range (need an 8-bit value)')
|
||||
if not 0 <= clock_seq_low < 1<<8L:
|
||||
raise ValueError('field 5 out of range (need an 8-bit value)')
|
||||
if not 0 <= node < 1<<48L:
|
||||
raise ValueError('field 6 out of range (need a 48-bit value)')
|
||||
clock_seq = (clock_seq_hi_variant << 8L) | clock_seq_low
|
||||
int = ((time_low << 96L) | (time_mid << 80L) |
|
||||
(time_hi_version << 64L) | (clock_seq << 48L) | node)
|
||||
if int is not None:
|
||||
if not 0 <= int < 1<<128L:
|
||||
raise ValueError('int is out of range (need a 128-bit value)')
|
||||
if version is not None:
|
||||
if not 1 <= version <= 5:
|
||||
raise ValueError('illegal version number')
|
||||
# Set the variant to RFC 4122.
|
||||
int &= ~(0xc000 << 48L)
|
||||
int |= 0x8000 << 48L
|
||||
# Set the version number.
|
||||
int &= ~(0xf000 << 64L)
|
||||
int |= version << 76L
|
||||
self.__dict__['int'] = int
|
||||
|
||||
def __cmp__(self, other):
|
||||
if isinstance(other, UUID):
|
||||
return cmp(self.int, other.int)
|
||||
return NotImplemented
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.int)
|
||||
|
||||
def __int__(self):
|
||||
return self.int
|
||||
|
||||
def __repr__(self):
|
||||
return 'UUID(%r)' % str(self)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
raise TypeError('UUID objects are immutable')
|
||||
|
||||
def __str__(self):
|
||||
hex = '%032x' % self.int
|
||||
return '%s-%s-%s-%s-%s' % (
|
||||
hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
|
||||
|
||||
def get_bytes(self):
|
||||
bytes = ''
|
||||
for shift in range(0, 128, 8):
|
||||
bytes = chr((self.int >> shift) & 0xff) + bytes
|
||||
return bytes
|
||||
|
||||
bytes = property(get_bytes)
|
||||
|
||||
def get_fields(self):
|
||||
return (self.time_low, self.time_mid, self.time_hi_version,
|
||||
self.clock_seq_hi_variant, self.clock_seq_low, self.node)
|
||||
|
||||
fields = property(get_fields)
|
||||
|
||||
def get_time_low(self):
|
||||
return self.int >> 96L
|
||||
|
||||
time_low = property(get_time_low)
|
||||
|
||||
def get_time_mid(self):
|
||||
return (self.int >> 80L) & 0xffff
|
||||
|
||||
time_mid = property(get_time_mid)
|
||||
|
||||
def get_time_hi_version(self):
|
||||
return (self.int >> 64L) & 0xffff
|
||||
|
||||
time_hi_version = property(get_time_hi_version)
|
||||
|
||||
def get_clock_seq_hi_variant(self):
|
||||
return (self.int >> 56L) & 0xff
|
||||
|
||||
clock_seq_hi_variant = property(get_clock_seq_hi_variant)
|
||||
|
||||
def get_clock_seq_low(self):
|
||||
return (self.int >> 48L) & 0xff
|
||||
|
||||
clock_seq_low = property(get_clock_seq_low)
|
||||
|
||||
def get_time(self):
|
||||
return (((self.time_hi_version & 0x0fffL) << 48L) |
|
||||
(self.time_mid << 32L) | self.time_low)
|
||||
|
||||
time = property(get_time)
|
||||
|
||||
def get_clock_seq(self):
|
||||
return (((self.clock_seq_hi_variant & 0x3fL) << 8L) |
|
||||
self.clock_seq_low)
|
||||
|
||||
clock_seq = property(get_clock_seq)
|
||||
|
||||
def get_node(self):
|
||||
return self.int & 0xffffffffffff
|
||||
|
||||
node = property(get_node)
|
||||
|
||||
def get_hex(self):
|
||||
return '%032x' % self.int
|
||||
|
||||
hex = property(get_hex)
|
||||
|
||||
def get_urn(self):
|
||||
return 'urn:uuid:' + str(self)
|
||||
|
||||
urn = property(get_urn)
|
||||
|
||||
def get_variant(self):
|
||||
if not self.int & (0x8000 << 48L):
|
||||
return RESERVED_NCS
|
||||
elif not self.int & (0x4000 << 48L):
|
||||
return RFC_4122
|
||||
elif not self.int & (0x2000 << 48L):
|
||||
return RESERVED_MICROSOFT
|
||||
else:
|
||||
return RESERVED_FUTURE
|
||||
|
||||
variant = property(get_variant)
|
||||
|
||||
def get_version(self):
|
||||
# The version bits are only meaningful for RFC 4122 UUIDs.
|
||||
if self.variant == RFC_4122:
|
||||
return int((self.int >> 76L) & 0xf)
|
||||
|
||||
version = property(get_version)
|
||||
|
||||
def _ifconfig_getnode():
|
||||
"""Get the hardware address on Unix by running ifconfig."""
|
||||
import os
|
||||
for dir in ['', '/sbin/', '/usr/sbin']:
|
||||
try:
|
||||
path = os.path.join(dir, 'ifconfig')
|
||||
if os.path.exists(path):
|
||||
pipe = os.popen(path)
|
||||
else:
|
||||
continue
|
||||
except IOError:
|
||||
continue
|
||||
for line in pipe:
|
||||
words = line.lower().split()
|
||||
for i in range(len(words)):
|
||||
if words[i] in ['hwaddr', 'ether']:
|
||||
return int(words[i + 1].replace(':', ''), 16)
|
||||
|
||||
def _ipconfig_getnode():
|
||||
"""Get the hardware address on Windows by running ipconfig.exe."""
|
||||
import os, re
|
||||
dirs = ['', r'c:\windows\system32', r'c:\winnt\system32']
|
||||
try:
|
||||
import ctypes
|
||||
buffer = ctypes.create_string_buffer(300)
|
||||
ctypes.windll.kernel32.GetSystemDirectoryA(buffer, 300)
|
||||
dirs.insert(0, buffer.value.decode('mbcs'))
|
||||
except:
|
||||
pass
|
||||
for dir in dirs:
|
||||
try:
|
||||
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
|
||||
except IOError:
|
||||
continue
|
||||
for line in pipe:
|
||||
value = line.split(':')[-1].strip().lower()
|
||||
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
|
||||
return int(value.replace('-', ''), 16)
|
||||
|
||||
def _netbios_getnode():
|
||||
"""Get the hardware address on Windows using NetBIOS calls.
|
||||
See http://support.microsoft.com/kb/118623 for details."""
|
||||
import win32wnet, netbios
|
||||
ncb = netbios.NCB()
|
||||
ncb.Command = netbios.NCBENUM
|
||||
ncb.Buffer = adapters = netbios.LANA_ENUM()
|
||||
adapters._pack()
|
||||
if win32wnet.Netbios(ncb) != 0:
|
||||
return
|
||||
adapters._unpack()
|
||||
for i in range(adapters.length):
|
||||
ncb.Reset()
|
||||
ncb.Command = netbios.NCBRESET
|
||||
ncb.Lana_num = ord(adapters.lana[i])
|
||||
if win32wnet.Netbios(ncb) != 0:
|
||||
continue
|
||||
ncb.Reset()
|
||||
ncb.Command = netbios.NCBASTAT
|
||||
ncb.Lana_num = ord(adapters.lana[i])
|
||||
ncb.Callname = '*'.ljust(16)
|
||||
ncb.Buffer = status = netbios.ADAPTER_STATUS()
|
||||
if win32wnet.Netbios(ncb) != 0:
|
||||
continue
|
||||
status._unpack()
|
||||
bytes = map(ord, status.adapter_address)
|
||||
return ((bytes[0]<<40L) + (bytes[1]<<32L) + (bytes[2]<<24L) +
|
||||
(bytes[3]<<16L) + (bytes[4]<<8L) + bytes[5])
|
||||
|
||||
# Thanks to Thomas Heller for ctypes and for his help with its use here.
|
||||
|
||||
# If ctypes is available, use it to find system routines for UUID generation.
|
||||
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None
|
||||
try:
|
||||
import ctypes, ctypes.util
|
||||
_buffer = ctypes.create_string_buffer(16)
|
||||
|
||||
# The uuid_generate_* routines are provided by libuuid on at least
|
||||
# Linux and FreeBSD, and provided by libc on Mac OS X.
|
||||
for libname in ['uuid', 'c']:
|
||||
try:
|
||||
lib = ctypes.CDLL(ctypes.util.find_library(libname))
|
||||
except:
|
||||
continue
|
||||
if hasattr(lib, 'uuid_generate_random'):
|
||||
_uuid_generate_random = lib.uuid_generate_random
|
||||
if hasattr(lib, 'uuid_generate_time'):
|
||||
_uuid_generate_time = lib.uuid_generate_time
|
||||
|
||||
# On Windows prior to 2000, UuidCreate gives a UUID containing the
|
||||
# hardware address. On Windows 2000 and later, UuidCreate makes a
|
||||
# random UUID and UuidCreateSequential gives a UUID containing the
|
||||
# hardware address. These routines are provided by the RPC runtime.
|
||||
try:
|
||||
lib = ctypes.windll.rpcrt4
|
||||
except:
|
||||
lib = None
|
||||
_UuidCreate = getattr(lib, 'UuidCreateSequential',
|
||||
getattr(lib, 'UuidCreate', None))
|
||||
except:
|
||||
pass
|
||||
|
||||
def _unixdll_getnode():
|
||||
"""Get the hardware address on Unix using ctypes."""
|
||||
_uuid_generate_time(_buffer)
|
||||
return UUID(bytes=_buffer.raw).node
|
||||
|
||||
def _windll_getnode():
|
||||
"""Get the hardware address on Windows using ctypes."""
|
||||
if _UuidCreate(_buffer) == 0:
|
||||
return UUID(bytes=_buffer.raw).node
|
||||
|
||||
def _random_getnode():
|
||||
"""Get a random node ID, with eighth bit set as suggested by RFC 4122."""
|
||||
import random
|
||||
return random.randrange(0, 1<<48L) | 0x010000000000L
|
||||
|
||||
_node = None
|
||||
|
||||
def getnode():
|
||||
"""Get the hardware address as a 48-bit integer. The first time this
|
||||
runs, it may launch a separate program, which could be quite slow. If
|
||||
all attempts to obtain the hardware address fail, we choose a random
|
||||
48-bit number with its eighth bit set to 1 as recommended in RFC 4122."""
|
||||
|
||||
global _node
|
||||
if _node is not None:
|
||||
return _node
|
||||
|
||||
import sys
|
||||
if sys.platform == 'win32':
|
||||
getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode]
|
||||
else:
|
||||
getters = [_unixdll_getnode, _ifconfig_getnode]
|
||||
|
||||
for getter in getters + [_random_getnode]:
|
||||
try:
|
||||
_node = getter()
|
||||
except:
|
||||
continue
|
||||
if _node is not None:
|
||||
return _node
|
||||
|
||||
def uuid1(node=None, clock_seq=None):
|
||||
"""Generate a UUID from a host ID, sequence number, and the current time.
|
||||
If 'node' is not given, getnode() is used to obtain the hardware
|
||||
address. If 'clock_seq' is given, it is used as the sequence number;
|
||||
otherwise a random 14-bit sequence number is chosen."""
|
||||
|
||||
# When the system provides a version-1 UUID generator, use it (but don't
|
||||
# use UuidCreate here because its UUIDs don't conform to RFC 4122).
|
||||
if _uuid_generate_time and node is clock_seq is None:
|
||||
_uuid_generate_time(_buffer)
|
||||
return UUID(bytes=_buffer.raw)
|
||||
|
||||
import time
|
||||
nanoseconds = int(time.time() * 1e9)
|
||||
# 0x01b21dd213814000 is the number of 100-ns intervals between the
|
||||
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
||||
timestamp = int(nanoseconds/100) + 0x01b21dd213814000L
|
||||
if clock_seq is None:
|
||||
import random
|
||||
clock_seq = random.randrange(1<<14L) # instead of stable storage
|
||||
time_low = timestamp & 0xffffffffL
|
||||
time_mid = (timestamp >> 32L) & 0xffffL
|
||||
time_hi_version = (timestamp >> 48L) & 0x0fffL
|
||||
clock_seq_low = clock_seq & 0xffL
|
||||
clock_seq_hi_variant = (clock_seq >> 8L) & 0x3fL
|
||||
if node is None:
|
||||
node = getnode()
|
||||
return UUID(fields=(time_low, time_mid, time_hi_version,
|
||||
clock_seq_hi_variant, clock_seq_low, node), version=1)
|
||||
|
||||
def uuid3(namespace, name):
|
||||
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
|
||||
try:
|
||||
# Python 2.6
|
||||
from hashlib import md5
|
||||
except ImportError:
|
||||
# Python 2.5 and earlier
|
||||
from md5 import new as md5
|
||||
|
||||
hash = md5(namespace.bytes + name).digest()
|
||||
return UUID(bytes=hash[:16], version=3)
|
||||
|
||||
def uuid4():
|
||||
"""Generate a random UUID."""
|
||||
|
||||
# When the system provides a version-4 UUID generator, use it.
|
||||
if _uuid_generate_random:
|
||||
_uuid_generate_random(_buffer)
|
||||
return UUID(bytes=_buffer.raw)
|
||||
|
||||
# Otherwise, get randomness from urandom or the 'random' module.
|
||||
try:
|
||||
import os
|
||||
return UUID(bytes=os.urandom(16), version=4)
|
||||
except:
|
||||
import random
|
||||
bytes = [chr(random.randrange(256)) for i in range(16)]
|
||||
return UUID(bytes=bytes, version=4)
|
||||
|
||||
def uuid5(namespace, name):
|
||||
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
|
||||
import sha
|
||||
hash = sha.sha(namespace.bytes + name).digest()
|
||||
return UUID(bytes=hash[:16], version=5)
|
||||
|
||||
# The following standard UUIDs are for use with uuid3() or uuid5().
|
||||
|
||||
NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
|
||||
NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8')
|
||||
NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8')
|
||||
NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8')
|
||||
@@ -436,7 +436,7 @@ public:
|
||||
|
||||
}
|
||||
|
||||
~MyMicroAllocator(void)
|
||||
virtual ~MyMicroAllocator()
|
||||
{
|
||||
if ( mMicroChunks )
|
||||
{
|
||||
@@ -746,7 +746,7 @@ public:
|
||||
mMicro = createMicroAllocator(this,defaultChunkSize);
|
||||
}
|
||||
|
||||
~MyHeapManager(void)
|
||||
virtual ~MyHeapManager()
|
||||
{
|
||||
releaseMicroAllocator(mMicro);
|
||||
}
|
||||
|
||||
@@ -33,3 +33,8 @@ set_source_files_properties(${libndhacd_HEADER_FILES}
|
||||
|
||||
add_library( nd_hacdConvexDecomposition STATIC ${libndhacd_SOURCE_FILES} ${libndhacd_HEADER_FILES})
|
||||
|
||||
target_link_libraries(
|
||||
nd_hacdConvexDecomposition
|
||||
PUBLIC
|
||||
llcommon
|
||||
)
|
||||
|
||||
@@ -26,6 +26,7 @@ set(openjpeg_SOURCE_FILES
|
||||
mct.c
|
||||
mqc.c
|
||||
openjpeg.c
|
||||
opj_malloc.c
|
||||
phix_manager.c
|
||||
pi.c
|
||||
ppix_manager.c
|
||||
|
||||
@@ -31,11 +31,16 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OPJ_SKIP_POISON
|
||||
#include "opj_includes.h"
|
||||
|
||||
#ifdef __SSE__
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "opj_includes.h"
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/** @defgroup DWT DWT - Implementation of a discrete wavelet transform */
|
||||
/*@{*/
|
||||
@@ -499,7 +504,7 @@ void dwt_calc_explicit_stepsizes(opj_tccp_t * tccp, int prec) {
|
||||
/* <summary> */
|
||||
/* Determine maximum computed resolution level for inverse wavelet transform */
|
||||
/* </summary> */
|
||||
static int dwt_decode_max_resolution(opj_tcd_resolution_t* restrict r, int i) {
|
||||
static int dwt_decode_max_resolution(opj_tcd_resolution_t* OPJ_RESTRICT r, int i) {
|
||||
int mr = 1;
|
||||
int w;
|
||||
while( --i ) {
|
||||
@@ -531,7 +536,7 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
|
||||
v.mem = h.mem;
|
||||
|
||||
while( --numres) {
|
||||
int * restrict tiledp = tilec->data;
|
||||
int * OPJ_RESTRICT tiledp = tilec->data;
|
||||
int j;
|
||||
|
||||
++tr;
|
||||
@@ -565,48 +570,49 @@ static void dwt_decode_tile(opj_tcd_tilecomp_t* tilec, int numres, DWT1DFN dwt_1
|
||||
opj_aligned_free(h.mem);
|
||||
}
|
||||
|
||||
static void v4dwt_interleave_h(v4dwt_t* restrict w, float* restrict a, int x, int size){
|
||||
float* restrict bi = (float*) (w->wavelet + w->cas);
|
||||
static void v4dwt_interleave_h(v4dwt_t* OPJ_RESTRICT w, float* OPJ_RESTRICT a, int x, int size) {
|
||||
float* OPJ_RESTRICT bi = (float*)(w->wavelet + w->cas);
|
||||
int count = w->sn;
|
||||
int i, k;
|
||||
for(k = 0; k < 2; ++k){
|
||||
if (count + 3 * x < size && ((size_t) a & 0x0f) == 0 && ((size_t) bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
for (k = 0; k < 2; ++k) {
|
||||
if (count + 3 * x < size && ((size_t)a & 0x0f) == 0 && ((size_t)bi & 0x0f) == 0 && (x & 0x0f) == 0) {
|
||||
/* Fast code path */
|
||||
for(i = 0; i < count; ++i){
|
||||
for (i = 0; i < count; ++i) {
|
||||
int j = i;
|
||||
bi[i*8 ] = a[j];
|
||||
bi[i * 8] = a[j];
|
||||
j += x;
|
||||
bi[i*8 + 1] = a[j];
|
||||
bi[i * 8 + 1] = a[j];
|
||||
j += x;
|
||||
bi[i*8 + 2] = a[j];
|
||||
bi[i * 8 + 2] = a[j];
|
||||
j += x;
|
||||
bi[i*8 + 3] = a[j];
|
||||
bi[i * 8 + 3] = a[j];
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* Slow code path */
|
||||
for(i = 0; i < count; ++i){
|
||||
int j = i;
|
||||
bi[i*8 ] = a[j];
|
||||
j += x;
|
||||
if(j > size) continue;
|
||||
bi[i*8 + 1] = a[j];
|
||||
j += x;
|
||||
if(j > size) continue;
|
||||
bi[i*8 + 2] = a[j];
|
||||
j += x;
|
||||
if(j > size) continue;
|
||||
bi[i*8 + 3] = a[j];
|
||||
for (i = 0; i < count; ++i) {
|
||||
int j = i;
|
||||
bi[i * 8] = a[j];
|
||||
j += x;
|
||||
if (j > size) continue;
|
||||
bi[i * 8 + 1] = a[j];
|
||||
j += x;
|
||||
if (j > size) continue;
|
||||
bi[i * 8 + 2] = a[j];
|
||||
j += x;
|
||||
if (j > size) continue;
|
||||
bi[i * 8 + 3] = a[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
bi = (float*) (w->wavelet + 1 - w->cas);
|
||||
bi = (float*)(w->wavelet + 1 - w->cas);
|
||||
a += w->sn;
|
||||
size -= w->sn;
|
||||
count = w->dn;
|
||||
}
|
||||
}
|
||||
|
||||
static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){
|
||||
v4* restrict bi = v->wavelet + v->cas;
|
||||
static void v4dwt_interleave_v(v4dwt_t* OPJ_RESTRICT v , float* OPJ_RESTRICT a , int x){
|
||||
v4* OPJ_RESTRICT bi = v->wavelet + v->cas;
|
||||
int i;
|
||||
for(i = 0; i < v->sn; ++i){
|
||||
memcpy(&bi[i*2], &a[i*x], 4 * sizeof(float));
|
||||
@@ -621,7 +627,7 @@ static void v4dwt_interleave_v(v4dwt_t* restrict v , float* restrict a , int x){
|
||||
#ifdef __SSE__
|
||||
|
||||
static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){
|
||||
__m128* restrict vw = (__m128*) w;
|
||||
__m128* OPJ_RESTRICT vw = (__m128*) w;
|
||||
int i;
|
||||
/* 4x unrolled loop */
|
||||
for(i = 0; i < count >> 2; ++i){
|
||||
@@ -642,22 +648,39 @@ static void v4dwt_decode_step1_sse(v4* w, int count, const __m128 c){
|
||||
}
|
||||
|
||||
static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){
|
||||
__m128* restrict vl = (__m128*) l;
|
||||
__m128* restrict vw = (__m128*) w;
|
||||
__m128* OPJ_RESTRICT vl = (__m128*) l;
|
||||
__m128* OPJ_RESTRICT vw = (__m128*) w;
|
||||
int i;
|
||||
__m128 tmp1, tmp2, tmp3;
|
||||
tmp1 = vl[0];
|
||||
for(i = 0; i < m; ++i){
|
||||
for (i = 0; i < m - 3; i += 4) {
|
||||
__m128 tmp4, tmp5, tmp6, tmp7, tmp8, tmp9;
|
||||
tmp2 = vw[-1];
|
||||
tmp3 = vw[0];
|
||||
tmp4 = vw[1];
|
||||
tmp5 = vw[2];
|
||||
tmp6 = vw[3];
|
||||
tmp7 = vw[4];
|
||||
tmp8 = vw[5];
|
||||
tmp9 = vw[6];
|
||||
vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c));
|
||||
vw[1] = _mm_add_ps(tmp4, _mm_mul_ps(_mm_add_ps(tmp3, tmp5), c));
|
||||
vw[3] = _mm_add_ps(tmp6, _mm_mul_ps(_mm_add_ps(tmp5, tmp7), c));
|
||||
vw[5] = _mm_add_ps(tmp8, _mm_mul_ps(_mm_add_ps(tmp7, tmp9), c));
|
||||
tmp1 = tmp9;
|
||||
vw += 8;
|
||||
}
|
||||
for ( ; i < m; ++i) {
|
||||
tmp2 = vw[-1];
|
||||
tmp3 = vw[ 0];
|
||||
vw[-1] = _mm_add_ps(tmp2, _mm_mul_ps(_mm_add_ps(tmp1, tmp3), c));
|
||||
tmp1 = tmp3;
|
||||
vw += 2;
|
||||
}
|
||||
vl = vw - 2;
|
||||
if(m >= k){
|
||||
return;
|
||||
}
|
||||
vl = vw - 2;
|
||||
c = _mm_add_ps(c, c);
|
||||
c = _mm_mul_ps(c, vl[0]);
|
||||
for(; m < k; ++m){
|
||||
@@ -670,7 +693,7 @@ static void v4dwt_decode_step2_sse(v4* l, v4* w, int k, int m, __m128 c){
|
||||
#else
|
||||
|
||||
static void v4dwt_decode_step1(v4* w, int count, const float c){
|
||||
float* restrict fw = (float*) w;
|
||||
float* OPJ_RESTRICT fw = (float*) w;
|
||||
int i;
|
||||
for(i = 0; i < count; ++i){
|
||||
float tmp1 = fw[i*8 ];
|
||||
@@ -685,8 +708,8 @@ static void v4dwt_decode_step1(v4* w, int count, const float c){
|
||||
}
|
||||
|
||||
static void v4dwt_decode_step2(v4* l, v4* w, int k, int m, float c){
|
||||
float* restrict fl = (float*) l;
|
||||
float* restrict fw = (float*) w;
|
||||
float* OPJ_RESTRICT fl = (float*) l;
|
||||
float* OPJ_RESTRICT fw = (float*) w;
|
||||
int i;
|
||||
for(i = 0; i < m; ++i){
|
||||
float tmp1_1 = fl[0];
|
||||
@@ -737,42 +760,44 @@ static void v4dwt_decode_step2(v4* l, v4* w, int k, int m, float c){
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 1-D. */
|
||||
/* </summary> */
|
||||
static void v4dwt_decode(v4dwt_t* restrict dwt){
|
||||
static void v4dwt_decode(v4dwt_t* OPJ_RESTRICT dwt){
|
||||
int a, b;
|
||||
if(dwt->cas == 0) {
|
||||
if(!((dwt->dn > 0) || (dwt->sn > 1))){
|
||||
if (dwt->dn <= 0 && dwt->sn <= 1) {
|
||||
return;
|
||||
}
|
||||
a = 0;
|
||||
b = 1;
|
||||
}else{
|
||||
if(!((dwt->sn > 0) || (dwt->dn > 1))) {
|
||||
if (dwt->sn <= 0 && dwt->dn <= 1) {
|
||||
return;
|
||||
}
|
||||
a = 1;
|
||||
b = 0;
|
||||
}
|
||||
v4* OPJ_RESTRICT waveleta = dwt->wavelet + a;
|
||||
v4* OPJ_RESTRICT waveletb = dwt->wavelet + b;
|
||||
#ifdef __SSE__
|
||||
v4dwt_decode_step1_sse(dwt->wavelet+a, dwt->sn, _mm_set1_ps(K));
|
||||
v4dwt_decode_step1_sse(dwt->wavelet+b, dwt->dn, _mm_set1_ps(c13318));
|
||||
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_delta));
|
||||
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
|
||||
v4dwt_decode_step2_sse(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
|
||||
v4dwt_decode_step2_sse(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
|
||||
v4dwt_decode_step1_sse(waveleta, dwt->sn, _mm_set1_ps(K));
|
||||
v4dwt_decode_step1_sse(waveletb, dwt->dn, _mm_set1_ps(c13318));
|
||||
v4dwt_decode_step2_sse(waveletb, waveleta + 1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_delta));
|
||||
v4dwt_decode_step2_sse(waveleta, waveletb + 1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_gamma));
|
||||
v4dwt_decode_step2_sse(waveletb, waveleta + 1, dwt->sn, int_min(dwt->sn, dwt->dn-a), _mm_set1_ps(dwt_beta));
|
||||
v4dwt_decode_step2_sse(waveleta, waveletb + 1, dwt->dn, int_min(dwt->dn, dwt->sn-b), _mm_set1_ps(dwt_alpha));
|
||||
#else
|
||||
v4dwt_decode_step1(dwt->wavelet+a, dwt->sn, K);
|
||||
v4dwt_decode_step1(dwt->wavelet+b, dwt->dn, c13318);
|
||||
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_delta);
|
||||
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
|
||||
v4dwt_decode_step2(dwt->wavelet+b, dwt->wavelet+a+1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
|
||||
v4dwt_decode_step2(dwt->wavelet+a, dwt->wavelet+b+1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
|
||||
v4dwt_decode_step1(waveleta, dwt->sn, K);
|
||||
v4dwt_decode_step1(waveletb, dwt->dn, c13318);
|
||||
v4dwt_decode_step2(waveletb, waveleta + 1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_delta);
|
||||
v4dwt_decode_step2(waveleta, waveletb + 1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_gamma);
|
||||
v4dwt_decode_step2(waveletb, waveleta + 1, dwt->sn, int_min(dwt->sn, dwt->dn-a), dwt_beta);
|
||||
v4dwt_decode_step2(waveleta, waveletb + 1, dwt->dn, int_min(dwt->dn, dwt->sn-b), dwt_alpha);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* <summary> */
|
||||
/* Inverse 9-7 wavelet transform in 2-D. */
|
||||
/* </summary> */
|
||||
void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
|
||||
void dwt_decode_real(opj_tcd_tilecomp_t* OPJ_RESTRICT tilec, int numres){
|
||||
v4dwt_t h;
|
||||
v4dwt_t v;
|
||||
|
||||
@@ -787,7 +812,7 @@ void dwt_decode_real(opj_tcd_tilecomp_t* restrict tilec, int numres){
|
||||
v.wavelet = h.wavelet;
|
||||
|
||||
while( --numres) {
|
||||
float * restrict aj = (float*) tilec->data;
|
||||
float * OPJ_RESTRICT aj = (float*) tilec->data;
|
||||
int bufsize = (tilec->x1 - tilec->x0) * (tilec->y1 - tilec->y0);
|
||||
int j;
|
||||
|
||||
|
||||
@@ -29,11 +29,16 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define OPJ_SKIP_POISON
|
||||
#include "opj_includes.h"
|
||||
|
||||
#ifdef __SSE__
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "opj_includes.h"
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
/* <summary> */
|
||||
/* This table contains the norms of the basis function of the reversible MCT. */
|
||||
@@ -49,17 +54,38 @@ static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
|
||||
/* Foward reversible MCT. */
|
||||
/* </summary> */
|
||||
void mct_encode(
|
||||
int* restrict c0,
|
||||
int* restrict c1,
|
||||
int* restrict c2,
|
||||
int* OPJ_RESTRICT c0,
|
||||
int* OPJ_RESTRICT c1,
|
||||
int* OPJ_RESTRICT c2,
|
||||
int n)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < n; ++i) {
|
||||
int i = 0;
|
||||
#ifdef __SSE2__
|
||||
/* Buffers are normally aligned on 16 bytes... */
|
||||
if (((size_t)c0 & 0xf) == 0 && ((size_t)c1 & 0xf) == 0 && ((size_t)c2 & 0xf) == 0) {
|
||||
const int cnt = n & ~3U;
|
||||
for (; i < cnt; i += 4) {
|
||||
__m128i y, u, v;
|
||||
__m128i r = _mm_load_si128((const __m128i*) & (c0[i]));
|
||||
__m128i g = _mm_load_si128((const __m128i*) & (c1[i]));
|
||||
__m128i b = _mm_load_si128((const __m128i*) & (c2[i]));
|
||||
y = _mm_add_epi32(g, g);
|
||||
y = _mm_add_epi32(y, b);
|
||||
y = _mm_add_epi32(y, r);
|
||||
y = _mm_srai_epi32(y, 2);
|
||||
u = _mm_sub_epi32(b, g);
|
||||
v = _mm_sub_epi32(r, g);
|
||||
_mm_store_si128((__m128i*) & (c0[i]), y);
|
||||
_mm_store_si128((__m128i*) & (c1[i]), u);
|
||||
_mm_store_si128((__m128i*) & (c2[i]), v);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (; i < n; ++i) {
|
||||
int r = c0[i];
|
||||
int g = c1[i];
|
||||
int b = c2[i];
|
||||
int y = (r + (g * 2) + b) >> 2;
|
||||
int y = (r + g + g + b) >> 2;
|
||||
int u = b - g;
|
||||
int v = r - g;
|
||||
c0[i] = y;
|
||||
@@ -72,13 +98,32 @@ void mct_encode(
|
||||
/* Inverse reversible MCT. */
|
||||
/* </summary> */
|
||||
void mct_decode(
|
||||
int* restrict c0,
|
||||
int* restrict c1,
|
||||
int* restrict c2,
|
||||
int* OPJ_RESTRICT c0,
|
||||
int* OPJ_RESTRICT c1,
|
||||
int* OPJ_RESTRICT c2,
|
||||
int n)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n; ++i) {
|
||||
int i = 0;
|
||||
#ifdef __SSE2__
|
||||
/* Buffers are normally aligned on 16 bytes... */
|
||||
if (((size_t)c0 & 0xf) == 0 && ((size_t)c1 & 0xf) == 0 && ((size_t)c2 & 0xf) == 0) {
|
||||
const int cnt = n & ~3U;
|
||||
for (; i < cnt; i += 4) {
|
||||
__m128i r, g, b;
|
||||
__m128i y = _mm_load_si128((const __m128i*) & (c0[i]));
|
||||
__m128i u = _mm_load_si128((const __m128i*) & (c1[i]));
|
||||
__m128i v = _mm_load_si128((const __m128i*) & (c2[i]));
|
||||
g = y;
|
||||
g = _mm_sub_epi32(g, _mm_srai_epi32(_mm_add_epi32(u, v), 2));
|
||||
r = _mm_add_epi32(v, g);
|
||||
b = _mm_add_epi32(u, g);
|
||||
_mm_store_si128((__m128i*) & (c0[i]), r);
|
||||
_mm_store_si128((__m128i*) & (c1[i]), g);
|
||||
_mm_store_si128((__m128i*) & (c2[i]), b);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (; i < n; ++i) {
|
||||
int y = c0[i];
|
||||
int u = c1[i];
|
||||
int v = c2[i];
|
||||
@@ -102,13 +147,119 @@ double mct_getnorm(int compno) {
|
||||
/* Foward irreversible MCT. */
|
||||
/* </summary> */
|
||||
void mct_encode_real(
|
||||
int* restrict c0,
|
||||
int* restrict c1,
|
||||
int* restrict c2,
|
||||
int* OPJ_RESTRICT c0,
|
||||
int* OPJ_RESTRICT c1,
|
||||
int* OPJ_RESTRICT c2,
|
||||
int n)
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i < n; ++i) {
|
||||
int i = 0;
|
||||
#ifdef __SSE4_1__
|
||||
/* Buffers are normally aligned on 16 bytes... */
|
||||
if (((size_t)c0 & 0xf) == 0 && ((size_t)c1 & 0xf) == 0 && ((size_t)c2 & 0xf) == 0) {
|
||||
const int cnt = n & ~3U;
|
||||
const __m128i ry = _mm_set1_epi32(2449);
|
||||
const __m128i gy = _mm_set1_epi32(4809);
|
||||
const __m128i by = _mm_set1_epi32(934);
|
||||
const __m128i ru = _mm_set1_epi32(1382);
|
||||
const __m128i gu = _mm_set1_epi32(2714);
|
||||
const __m128i gv = _mm_set1_epi32(3430);
|
||||
const __m128i bv = _mm_set1_epi32(666);
|
||||
const __m128i mulround = _mm_shuffle_epi32(_mm_cvtsi32_si128(4096), _MM_SHUFFLE(1, 0, 1, 0));
|
||||
for (; i < cnt; i += 4) {
|
||||
__m128i lo, hi, y, u, v;
|
||||
__m128i r = _mm_load_si128((const __m128i*) & (c0[i]));
|
||||
__m128i g = _mm_load_si128((const __m128i*) & (c1[i]));
|
||||
__m128i b = _mm_load_si128((const __m128i*) & (c2[i]));
|
||||
|
||||
hi = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(r, ry);
|
||||
hi = _mm_mul_epi32(hi, ry);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
y = _mm_blend_epi16(lo, hi, 0xCC);
|
||||
|
||||
hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(g, gy);
|
||||
hi = _mm_mul_epi32(hi, gy);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
y = _mm_add_epi32(y, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
|
||||
hi = _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(b, by);
|
||||
hi = _mm_mul_epi32(hi, by);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
y = _mm_add_epi32(y, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
_mm_store_si128((__m128i*) & (c0[i]), y);
|
||||
|
||||
lo = _mm_cvtepi32_epi64(_mm_shuffle_epi32(b, _MM_SHUFFLE(3, 2, 2, 0)));
|
||||
hi = _mm_cvtepi32_epi64(_mm_shuffle_epi32(b, _MM_SHUFFLE(3, 2, 3, 1)));
|
||||
lo = _mm_slli_epi64(lo, 12);
|
||||
hi = _mm_slli_epi64(hi, 12);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
u = _mm_blend_epi16(lo, hi, 0xCC);
|
||||
|
||||
hi = _mm_shuffle_epi32(r, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(r, ru);
|
||||
hi = _mm_mul_epi32(hi, ru);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
u = _mm_sub_epi32(u, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
|
||||
hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(g, gu);
|
||||
hi = _mm_mul_epi32(hi, gu);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
u = _mm_sub_epi32(u, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
_mm_store_si128((__m128i*) & (c1[i]), u);
|
||||
|
||||
lo = _mm_cvtepi32_epi64(_mm_shuffle_epi32(r, _MM_SHUFFLE(3, 2, 2, 0)));
|
||||
hi = _mm_cvtepi32_epi64(_mm_shuffle_epi32(r, _MM_SHUFFLE(3, 2, 3, 1)));
|
||||
lo = _mm_slli_epi64(lo, 12);
|
||||
hi = _mm_slli_epi64(hi, 12);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
v = _mm_blend_epi16(lo, hi, 0xCC);
|
||||
|
||||
hi = _mm_shuffle_epi32(g, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(g, gv);
|
||||
hi = _mm_mul_epi32(hi, gv);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
v = _mm_sub_epi32(v, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
|
||||
hi = _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 3, 1, 1));
|
||||
lo = _mm_mul_epi32(b, bv);
|
||||
hi = _mm_mul_epi32(hi, bv);
|
||||
lo = _mm_add_epi64(lo, mulround);
|
||||
hi = _mm_add_epi64(hi, mulround);
|
||||
lo = _mm_srli_epi64(lo, 13);
|
||||
hi = _mm_slli_epi64(hi, 32 - 13);
|
||||
v = _mm_sub_epi32(v, _mm_blend_epi16(lo, hi, 0xCC));
|
||||
_mm_store_si128((__m128i*) & (c2[i]), v);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (; i < n; ++i) {
|
||||
int r = c0[i];
|
||||
int g = c1[i];
|
||||
int b = c2[i];
|
||||
@@ -125,19 +276,21 @@ void mct_encode_real(
|
||||
/* Inverse irreversible MCT. */
|
||||
/* </summary> */
|
||||
void mct_decode_real(
|
||||
float* restrict c0,
|
||||
float* restrict c1,
|
||||
float* restrict c2,
|
||||
float* OPJ_RESTRICT c0,
|
||||
float* OPJ_RESTRICT c1,
|
||||
float* OPJ_RESTRICT c2,
|
||||
int n)
|
||||
{
|
||||
int i;
|
||||
#ifdef __SSE__
|
||||
int count;
|
||||
__m128 vrv, vgu, vgv, vbu;
|
||||
vrv = _mm_set1_ps(1.402f);
|
||||
vgu = _mm_set1_ps(0.34413f);
|
||||
vgv = _mm_set1_ps(0.71414f);
|
||||
vbu = _mm_set1_ps(1.772f);
|
||||
for (i = 0; i < (n >> 3); ++i) {
|
||||
count = n >> 3;
|
||||
for (i = 0; i < count; ++i) {
|
||||
__m128 vy, vu, vv;
|
||||
__m128 vr, vg, vb;
|
||||
|
||||
@@ -174,7 +327,7 @@ void mct_decode_real(
|
||||
float u = c1[i];
|
||||
float v = c2[i];
|
||||
float r = y + (v * 1.402f);
|
||||
float g = y - (u * 0.34413f) - (v * (0.71414f));
|
||||
float g = y - (u * 0.34413f) - (v * 0.71414f);
|
||||
float b = y + (u * 1.772f);
|
||||
c0[i] = r;
|
||||
c1[i] = g;
|
||||
|
||||
@@ -40,33 +40,71 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
The inline keyword is supported by C99 but not by C90.
|
||||
Most compilers implement their own version of this keyword ...
|
||||
*/
|
||||
#ifndef INLINE
|
||||
#if defined(_MSC_VER)
|
||||
#define INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#elif defined(__MWERKS__)
|
||||
#define INLINE inline
|
||||
#else
|
||||
/* add other compilers here ... */
|
||||
#define INLINE
|
||||
#endif /* defined(<Compiler>) */
|
||||
#endif /* INLINE */
|
||||
#if defined(OPJ_STATIC) || !defined(_WIN32)
|
||||
#define OPJ_API
|
||||
#define OPJ_CALLCONV
|
||||
#else
|
||||
#define OPJ_CALLCONV __stdcall
|
||||
/*
|
||||
The following ifdef block is the standard way of creating macros which make exporting
|
||||
The following ifdef block is the standard way of creating macros which make exporting
|
||||
from a DLL simpler. All files within this DLL are compiled with the OPJ_EXPORTS
|
||||
symbol defined on the command line. this symbol should not be defined on any project
|
||||
that uses this DLL. This way any other project whose source files include this file see
|
||||
OPJ_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||
that uses this DLL. This way any other project whose source files include this file see
|
||||
OPJ_API functions as being imported from a DLL, whereas this DLL sees symbols
|
||||
defined with this macro as being exported.
|
||||
*/
|
||||
#if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
|
||||
#define OPJ_API __declspec(dllexport)
|
||||
#else
|
||||
#define OPJ_API __declspec(dllimport)
|
||||
#endif /* OPJ_EXPORTS */
|
||||
# if defined(OPJ_EXPORTS) || defined(DLL_EXPORT)
|
||||
# define OPJ_API __declspec(dllexport)
|
||||
# else
|
||||
# define OPJ_API __declspec(dllimport)
|
||||
# endif /* OPJ_EXPORTS */
|
||||
#endif /* !OPJ_STATIC || !_WIN32 */
|
||||
|
||||
typedef int opj_bool;
|
||||
#define OPJ_TRUE 1
|
||||
#define OPJ_FALSE 0
|
||||
|
||||
typedef char OPJ_CHAR;
|
||||
typedef float OPJ_FLOAT32;
|
||||
typedef double OPJ_FLOAT64;
|
||||
typedef unsigned char OPJ_BYTE;
|
||||
|
||||
#include "opj_stdint.h"
|
||||
|
||||
typedef int8_t OPJ_INT8;
|
||||
typedef uint8_t OPJ_UINT8;
|
||||
typedef int16_t OPJ_INT16;
|
||||
typedef uint16_t OPJ_UINT16;
|
||||
typedef int32_t OPJ_INT32;
|
||||
typedef uint32_t OPJ_UINT32;
|
||||
typedef int64_t OPJ_INT64;
|
||||
typedef uint64_t OPJ_UINT64;
|
||||
|
||||
typedef int64_t OPJ_OFF_T; /* 64-bit file offset type */
|
||||
|
||||
#include <stdio.h>
|
||||
typedef size_t OPJ_SIZE_T;
|
||||
|
||||
/* Avoid compile-time warning because parameter is not used */
|
||||
#define OPJ_ARG_NOT_USED(x) (void)(x)
|
||||
/*
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
Useful constant definitions
|
||||
==========================================================
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
@@ -54,56 +56,115 @@
|
||||
==========================================================
|
||||
*/
|
||||
|
||||
/* Are restricted pointers available? (C99) */
|
||||
#if (__STDC_VERSION__ >= 199901L)
|
||||
#define OPJ_RESTRICT restrict
|
||||
#else
|
||||
/* Not a C99 compiler */
|
||||
#if defined(__GNUC__)
|
||||
#define OPJ_RESTRICT __restrict__
|
||||
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
#define OPJ_RESTRICT __restrict
|
||||
#else
|
||||
#define OPJ_RESTRICT /* restrict */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Ignore GCC attributes if this is not GCC */
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(x) /* __attribute__(x) */
|
||||
#endif
|
||||
|
||||
/*
|
||||
The inline keyword is supported by C99 but not by C90.
|
||||
Most compilers implement their own version of this keyword ...
|
||||
*/
|
||||
#ifndef INLINE
|
||||
#if defined(_MSC_VER)
|
||||
#define INLINE __forceinline
|
||||
#elif defined(__GNUC__)
|
||||
#define INLINE __inline__
|
||||
#elif defined(__MWERKS__)
|
||||
#define INLINE inline
|
||||
#else
|
||||
/* add other compilers here ... */
|
||||
#define INLINE
|
||||
#endif /* defined(<Compiler>) */
|
||||
#endif /* INLINE */
|
||||
|
||||
/* Are restricted pointers available? (C99) */
|
||||
#if (__STDC_VERSION__ != 199901L)
|
||||
/* Not a C99 compiler */
|
||||
#ifdef __GNUC__
|
||||
#define restrict __restrict__
|
||||
#else
|
||||
#define restrict /* restrict */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* MSVC and Borland C do not have lrintf */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
static INLINE long lrintf(float f){
|
||||
/* MSVC before 2013 and Borland C do not have lrintf */
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
static INLINE long opj_lrintf(float f)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f));
|
||||
#else
|
||||
return _mm_cvt_ss2si(_mm_load_ss(&f));
|
||||
|
||||
/* commented out line breaks many tests */
|
||||
/* return (long)((f>0.0f) ? (f + 0.5f):(f -0.5f)); */
|
||||
#elif defined(_M_IX86)
|
||||
int i;
|
||||
|
||||
_asm{
|
||||
fld f
|
||||
fistp i
|
||||
};
|
||||
|
||||
|
||||
return i;
|
||||
#else
|
||||
return (long)((f>0.0f) ? (f + 0.5f) : (f - 0.5f));
|
||||
#endif
|
||||
}
|
||||
#elif defined(__BORLANDC__)
|
||||
static INLINE long opj_lrintf(float f)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
return (long)((f > 0.0f) ? (f + 0.5f) : (f - 0.5f));
|
||||
#else
|
||||
int i;
|
||||
|
||||
_asm {
|
||||
fld f
|
||||
fistp i
|
||||
};
|
||||
|
||||
return i;
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static INLINE long opj_lrintf(float f)
|
||||
{
|
||||
return lrintf(f);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1400)
|
||||
#define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
/* MSVC x86 is really bad at doing int64 = int32 * int32 on its own. Use intrinsic. */
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400) && !defined(__INTEL_COMPILER) && defined(_M_IX86)
|
||||
# include <intrin.h>
|
||||
# pragma intrinsic(__emul)
|
||||
#endif
|
||||
|
||||
/* Apparently Visual Studio doesn't define __SSE__ / __SSE2__ macros */
|
||||
#if defined(_M_X64)
|
||||
/* Intel 64bit support SSE and SSE2 */
|
||||
# ifndef __SSE__
|
||||
# define __SSE__ 1
|
||||
# endif
|
||||
# ifndef __SSE2__
|
||||
# define __SSE2__ 1
|
||||
# endif
|
||||
# if !defined(__SSE4_1__) && defined(__AVX__)
|
||||
# define __SSE4_1__ 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* For x86, test the value of the _M_IX86_FP macro. */
|
||||
/* See https://msdn.microsoft.com/en-us/library/b0084kay.aspx */
|
||||
#if defined(_M_IX86_FP)
|
||||
# if _M_IX86_FP >= 1
|
||||
# ifndef __SSE__
|
||||
# define __SSE__ 1
|
||||
# endif
|
||||
# endif
|
||||
# if _M_IX86_FP >= 2
|
||||
# ifndef __SSE2__
|
||||
# define __SSE2__ 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Type to use for bit-fields in internal headers */
|
||||
typedef unsigned int OPJ_BITFIELD;
|
||||
|
||||
#define OPJ_UNUSED(x) (void)x
|
||||
|
||||
#include "j2k_lib.h"
|
||||
#include "opj_malloc.h"
|
||||
#include "event.h"
|
||||
|
||||
249
indra/libopenjpeg/opj_malloc.c
Normal file
249
indra/libopenjpeg/opj_malloc.c
Normal file
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2015, Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
* Copyright (c) 2015, Matthieu Darbois
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#define OPJ_SKIP_POISON
|
||||
#include "opj_includes.h"
|
||||
|
||||
#if defined(OPJ_HAVE_MALLOC_H) && defined(OPJ_HAVE_MEMALIGN)
|
||||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
#ifndef SIZE_MAX
|
||||
# define SIZE_MAX ((size_t) -1)
|
||||
#endif
|
||||
|
||||
static INLINE void *opj_aligned_alloc_n(size_t alignment, size_t size)
|
||||
{
|
||||
void* ptr;
|
||||
|
||||
/* alignment shall be power of 2 */
|
||||
assert((alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
|
||||
/* alignment shall be at least sizeof(void*) */
|
||||
assert(alignment >= sizeof(void*));
|
||||
|
||||
if (size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(OPJ_HAVE_POSIX_MEMALIGN)
|
||||
/* aligned_alloc requires c11, restrict to posix_memalign for now. Quote:
|
||||
* This function was introduced in POSIX 1003.1d. Although this function is
|
||||
* superseded by aligned_alloc, it is more portable to older POSIX systems
|
||||
* that do not support ISO C11. */
|
||||
if (posix_memalign(&ptr, alignment, size)) {
|
||||
ptr = NULL;
|
||||
}
|
||||
/* older linux */
|
||||
#elif defined(OPJ_HAVE_MEMALIGN)
|
||||
ptr = memalign(alignment, size);
|
||||
/* _MSC_VER */
|
||||
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||
ptr = _aligned_malloc(size, alignment);
|
||||
#else
|
||||
/*
|
||||
* Generic aligned malloc implementation.
|
||||
* Uses size_t offset for the integer manipulation of the pointer,
|
||||
* as uintptr_t is not available in C89 to do
|
||||
* bitwise operations on the pointer itself.
|
||||
*/
|
||||
alignment--;
|
||||
{
|
||||
size_t offset;
|
||||
OPJ_UINT8 *mem;
|
||||
|
||||
/* Room for padding and extra pointer stored in front of allocated area */
|
||||
size_t overhead = alignment + sizeof(void *);
|
||||
|
||||
/* let's be extra careful */
|
||||
assert(alignment <= (SIZE_MAX - sizeof(void *)));
|
||||
|
||||
/* Avoid integer overflow */
|
||||
if (size > (SIZE_MAX - overhead)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mem = (OPJ_UINT8*)malloc(size + overhead);
|
||||
if (mem == NULL) {
|
||||
return mem;
|
||||
}
|
||||
/* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
|
||||
/* Use the fact that alignment + 1U is a power of 2 */
|
||||
offset = ((alignment ^ ((size_t)(mem + sizeof(void*)) & alignment)) + 1U) &
|
||||
alignment;
|
||||
ptr = (void *)(mem + sizeof(void*) + offset);
|
||||
((void**) ptr)[-1] = mem;
|
||||
}
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
static INLINE void *opj_aligned_realloc_n(void *ptr, size_t alignment,
|
||||
size_t new_size)
|
||||
{
|
||||
void *r_ptr;
|
||||
|
||||
/* alignment shall be power of 2 */
|
||||
assert((alignment != 0U) && ((alignment & (alignment - 1U)) == 0U));
|
||||
/* alignment shall be at least sizeof(void*) */
|
||||
assert(alignment >= sizeof(void*));
|
||||
|
||||
if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* no portable aligned realloc */
|
||||
#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
|
||||
/* glibc doc states one can mix aligned malloc with realloc */
|
||||
r_ptr = realloc(ptr, new_size); /* fast path */
|
||||
/* we simply use `size_t` to cast, since we are only interest in binary AND
|
||||
* operator */
|
||||
if (((size_t)r_ptr & (alignment - 1U)) != 0U) {
|
||||
/* this is non-trivial to implement a portable aligned realloc, so use a
|
||||
* simple approach where we do not need a function that return the size of an
|
||||
* allocated array (eg. _msize on Windows, malloc_size on MacOS,
|
||||
* malloc_usable_size on systems with glibc) */
|
||||
void *a_ptr = opj_aligned_alloc_n(alignment, new_size);
|
||||
if (a_ptr != NULL) {
|
||||
memcpy(a_ptr, r_ptr, new_size);
|
||||
}
|
||||
free(r_ptr);
|
||||
r_ptr = a_ptr;
|
||||
}
|
||||
/* _MSC_VER */
|
||||
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||
r_ptr = _aligned_realloc(ptr, new_size, alignment);
|
||||
#else
|
||||
if (ptr == NULL) {
|
||||
return opj_aligned_alloc_n(alignment, new_size);
|
||||
}
|
||||
alignment--;
|
||||
{
|
||||
void *oldmem;
|
||||
OPJ_UINT8 *newmem;
|
||||
size_t overhead = alignment + sizeof(void *);
|
||||
|
||||
/* let's be extra careful */
|
||||
assert(alignment <= (SIZE_MAX - sizeof(void *)));
|
||||
|
||||
/* Avoid integer overflow */
|
||||
if (new_size > SIZE_MAX - overhead) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
oldmem = ((void**) ptr)[-1];
|
||||
newmem = (OPJ_UINT8*)realloc(oldmem, new_size + overhead);
|
||||
if (newmem == NULL) {
|
||||
return newmem;
|
||||
}
|
||||
|
||||
if (newmem == oldmem) {
|
||||
r_ptr = ptr;
|
||||
} else {
|
||||
size_t old_offset;
|
||||
size_t new_offset;
|
||||
|
||||
/* realloc created a new copy, realign the copied memory block */
|
||||
old_offset = (size_t)((OPJ_UINT8*)ptr - (OPJ_UINT8*)oldmem);
|
||||
|
||||
/* offset = ((alignment + 1U) - ((size_t)(mem + sizeof(void*)) & alignment)) & alignment; */
|
||||
/* Use the fact that alignment + 1U is a power of 2 */
|
||||
new_offset = ((alignment ^ ((size_t)(newmem + sizeof(void*)) & alignment)) +
|
||||
1U) & alignment;
|
||||
new_offset += sizeof(void*);
|
||||
r_ptr = (void *)(newmem + new_offset);
|
||||
|
||||
if (new_offset != old_offset) {
|
||||
memmove(newmem + new_offset, newmem + old_offset, new_size);
|
||||
}
|
||||
((void**) r_ptr)[-1] = newmem;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return r_ptr;
|
||||
}
|
||||
void * opj_malloc(size_t size)
|
||||
{
|
||||
if (size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
return malloc(size);
|
||||
}
|
||||
void * opj_calloc(size_t num, size_t size)
|
||||
{
|
||||
if (num == 0 || size == 0) {
|
||||
/* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
return calloc(num, size);
|
||||
}
|
||||
|
||||
void *opj_aligned_malloc(size_t size)
|
||||
{
|
||||
return opj_aligned_alloc_n(16U, size);
|
||||
}
|
||||
void * opj_aligned_realloc(void *ptr, size_t size)
|
||||
{
|
||||
return opj_aligned_realloc_n(ptr, 16U, size);
|
||||
}
|
||||
|
||||
void *opj_aligned_32_malloc(size_t size)
|
||||
{
|
||||
return opj_aligned_alloc_n(32U, size);
|
||||
}
|
||||
void * opj_aligned_32_realloc(void *ptr, size_t size)
|
||||
{
|
||||
return opj_aligned_realloc_n(ptr, 32U, size);
|
||||
}
|
||||
|
||||
void opj_aligned_free(void* ptr)
|
||||
{
|
||||
#if defined(OPJ_HAVE_POSIX_MEMALIGN) || defined(OPJ_HAVE_MEMALIGN)
|
||||
free(ptr);
|
||||
#elif defined(OPJ_HAVE__ALIGNED_MALLOC)
|
||||
_aligned_free(ptr);
|
||||
#else
|
||||
/* Generic implementation has malloced pointer stored in front of used area */
|
||||
if (ptr != NULL) {
|
||||
free(((void**) ptr)[-1]);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void * opj_realloc(void *ptr, size_t new_size)
|
||||
{
|
||||
if (new_size == 0U) { /* prevent implementation defined behavior of realloc */
|
||||
return NULL;
|
||||
}
|
||||
return realloc(ptr, new_size);
|
||||
}
|
||||
void opj_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2005, Herve Drolon, FreeImage Team
|
||||
* Copyright (c) 2007, Callum Lerwick <seg@haxxed.com>
|
||||
* All rights reserved.
|
||||
@@ -24,8 +29,10 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef __OPJ_MALLOC_H
|
||||
#define __OPJ_MALLOC_H
|
||||
#ifndef OPJ_MALLOC_H
|
||||
#define OPJ_MALLOC_H
|
||||
|
||||
#include <stddef.h>
|
||||
/**
|
||||
@file opj_malloc.h
|
||||
@brief Internal functions
|
||||
@@ -36,6 +43,17 @@ The functions in opj_malloc.h are internal utilities used for memory management.
|
||||
/** @defgroup MISC MISC - Miscellaneous internal functions */
|
||||
/*@{*/
|
||||
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef _WIN32
|
||||
#define OPJ_HAVE__ALIGNED_MALLOC
|
||||
#else /* Not _WIN32 */
|
||||
#if defined(__sun)
|
||||
#define OPJ_HAVE_MEMALIGN
|
||||
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#define OPJ_HAVE_POSIX_MEMALIGN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** @name Exported functions */
|
||||
/*@{*/
|
||||
/* ----------------------------------------------------------------------- */
|
||||
@@ -45,90 +63,32 @@ Allocate an uninitialized memory block
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_malloc(size_t size);
|
||||
#else
|
||||
#define opj_malloc(size) malloc(size)
|
||||
#endif
|
||||
void * opj_malloc(size_t size);
|
||||
|
||||
/**
|
||||
Allocate a memory block with elements initialized to 0
|
||||
@param num Blocks to allocate
|
||||
@param size Bytes per block to allocate
|
||||
@param numOfElements Blocks to allocate
|
||||
@param sizeOfElements Bytes per block to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_calloc(size_t _NumOfElements, size_t _SizeOfElements);
|
||||
#else
|
||||
#define opj_calloc(num, size) calloc(num, size)
|
||||
#endif
|
||||
void * opj_calloc(size_t numOfElements, size_t sizeOfElements);
|
||||
|
||||
/**
|
||||
Allocate memory aligned to a 16 byte boundry
|
||||
Allocate memory aligned to a 16 byte boundary
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
/* FIXME: These should be set with cmake tests, but we're currently not requiring use of cmake */
|
||||
#ifdef _WIN32
|
||||
/* Someone should tell the mingw people that their malloc.h ought to provide _mm_malloc() */
|
||||
#ifdef __GNUC__
|
||||
#include <mm_malloc.h>
|
||||
#define HAVE_MM_MALLOC
|
||||
#else /* MSVC, Intel C++ */
|
||||
#include <malloc.h>
|
||||
#ifdef _mm_malloc
|
||||
#define HAVE_MM_MALLOC
|
||||
#endif
|
||||
#endif
|
||||
#else /* Not _WIN32 */
|
||||
#if defined(__sun)
|
||||
#define HAVE_MEMALIGN
|
||||
#elif defined(__FreeBSD__)
|
||||
#define HAVE_POSIX_MEMALIGN
|
||||
/* Linux x86_64 and OSX always align allocations to 16 bytes */
|
||||
#elif !defined(__amd64__) && !defined(__APPLE__) && !defined(_AIX)
|
||||
#define HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#endif
|
||||
void * opj_aligned_malloc(size_t size);
|
||||
void * opj_aligned_realloc(void *ptr, size_t size);
|
||||
void opj_aligned_free(void* ptr);
|
||||
|
||||
#define opj_aligned_malloc(size) malloc(size)
|
||||
#define opj_aligned_free(m) free(m)
|
||||
|
||||
#ifdef HAVE_MM_MALLOC
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) _mm_malloc(size, 16)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) _mm_free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MEMALIGN
|
||||
extern void* memalign(size_t, size_t);
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) memalign(16, (size))
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POSIX_MEMALIGN
|
||||
#undef opj_aligned_malloc
|
||||
extern int posix_memalign(void**, size_t, size_t);
|
||||
|
||||
static INLINE void* __attribute__ ((malloc)) opj_aligned_malloc(size_t size){
|
||||
void* mem = NULL;
|
||||
posix_memalign(&mem, 16, size);
|
||||
return mem;
|
||||
}
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) free(m)
|
||||
#endif
|
||||
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
#undef opj_aligned_malloc
|
||||
#define opj_aligned_malloc(size) opj_malloc(size)
|
||||
#undef opj_aligned_free
|
||||
#define opj_aligned_free(m) opj_free(m)
|
||||
#endif
|
||||
/**
|
||||
Allocate memory aligned to a 32 byte boundary
|
||||
@param size Bytes to allocate
|
||||
@return Returns a void pointer to the allocated space, or NULL if there is insufficient memory available
|
||||
*/
|
||||
void * opj_aligned_32_malloc(size_t size);
|
||||
void * opj_aligned_32_realloc(void *ptr, size_t size);
|
||||
|
||||
/**
|
||||
Reallocate memory blocks.
|
||||
@@ -136,23 +96,15 @@ Reallocate memory blocks.
|
||||
@param s New size in bytes
|
||||
@return Returns a void pointer to the reallocated (and possibly moved) memory block
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void * OPJ_CALLCONV opj_realloc(void * m, size_t s);
|
||||
#else
|
||||
#define opj_realloc(m, s) realloc(m, s)
|
||||
#endif
|
||||
void * opj_realloc(void * m, size_t s);
|
||||
|
||||
/**
|
||||
Deallocates or frees a memory block.
|
||||
@param m Previously allocated memory block to be freed
|
||||
*/
|
||||
#ifdef ALLOC_PERF_OPT
|
||||
void OPJ_CALLCONV opj_free(void * m);
|
||||
#else
|
||||
#define opj_free(m) free(m)
|
||||
#endif
|
||||
void opj_free(void * m);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__GNUC__) && !defined(OPJ_SKIP_POISON)
|
||||
#pragma GCC poison malloc calloc realloc free
|
||||
#endif
|
||||
|
||||
@@ -161,5 +113,5 @@ void OPJ_CALLCONV opj_free(void * m);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#endif /* __OPJ_MALLOC_H */
|
||||
#endif /* OPJ_MALLOC_H */
|
||||
|
||||
|
||||
51
indra/libopenjpeg/opj_stdint.h
Normal file
51
indra/libopenjpeg/opj_stdint.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* The copyright in this software is being made available under the 2-clauses
|
||||
* BSD License, included below. This software may be subject to other third
|
||||
* party and contributor rights, including patent rights, and no such rights
|
||||
* are granted under this license.
|
||||
*
|
||||
* Copyright (c) 2012, Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef OPJ_STDINT_H
|
||||
#define OPJ_STDINT_H
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || _MSC_VER >= 1900
|
||||
#include <stdint.h>
|
||||
#else
|
||||
#if defined(_WIN32)
|
||||
typedef signed __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#error unsupported platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* OPJ_STDINT_H */
|
||||
@@ -1427,7 +1427,7 @@ void t1_encode_cblks(
|
||||
opj_tcd_resolution_t *res = &tilec->resolutions[resno];
|
||||
|
||||
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
||||
opj_tcd_band_t* restrict band = &res->bands[bandno];
|
||||
opj_tcd_band_t* OPJ_RESTRICT band = &res->bands[bandno];
|
||||
int bandconst = 8192 * 8192 / ((int) floor(band->stepsize * 8192));
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
||||
@@ -1435,8 +1435,8 @@ void t1_encode_cblks(
|
||||
|
||||
for (cblkno = 0; cblkno < prc->cw * prc->ch; ++cblkno) {
|
||||
opj_tcd_cblk_enc_t* cblk = &prc->cblks.enc[cblkno];
|
||||
int* restrict datap;
|
||||
int* restrict tiledp;
|
||||
int* OPJ_RESTRICT datap;
|
||||
int* OPJ_RESTRICT tiledp;
|
||||
int cblk_w;
|
||||
int cblk_h;
|
||||
int i, j;
|
||||
@@ -1517,14 +1517,14 @@ void t1_decode_cblks(
|
||||
opj_tcd_resolution_t* res = &tilec->resolutions[resno];
|
||||
|
||||
for (bandno = 0; bandno < res->numbands; ++bandno) {
|
||||
opj_tcd_band_t* restrict band = &res->bands[bandno];
|
||||
opj_tcd_band_t* OPJ_RESTRICT band = &res->bands[bandno];
|
||||
|
||||
for (precno = 0; precno < res->pw * res->ph; ++precno) {
|
||||
opj_tcd_precinct_t* precinct = &band->precincts[precno];
|
||||
|
||||
for (cblkno = 0; cblkno < precinct->cw * precinct->ch; ++cblkno) {
|
||||
opj_tcd_cblk_dec_t* cblk = &precinct->cblks.dec[cblkno];
|
||||
int* restrict datap;
|
||||
int* OPJ_RESTRICT datap;
|
||||
int cblk_w, cblk_h;
|
||||
int x, y;
|
||||
int i, j;
|
||||
@@ -1566,7 +1566,7 @@ void t1_decode_cblks(
|
||||
}
|
||||
|
||||
if (tccp->qmfbid == 1) {
|
||||
int* restrict tiledp = &tilec->data[(y * tile_w) + x];
|
||||
int* OPJ_RESTRICT tiledp = &tilec->data[(y * tile_w) + x];
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
int tmp = datap[(j * cblk_w) + i];
|
||||
@@ -1574,9 +1574,9 @@ void t1_decode_cblks(
|
||||
}
|
||||
}
|
||||
} else { /* if (tccp->qmfbid == 0) */
|
||||
float* restrict tiledp = (float*) &tilec->data[(y * tile_w) + x];
|
||||
float* OPJ_RESTRICT tiledp = (float*) &tilec->data[(y * tile_w) + x];
|
||||
for (j = 0; j < cblk_h; ++j) {
|
||||
float* restrict tiledp2 = tiledp;
|
||||
float* OPJ_RESTRICT tiledp2 = tiledp;
|
||||
for (i = 0; i < cblk_w; ++i) {
|
||||
float tmp = *datap * band->stepsize;
|
||||
*tiledp2 = tmp;
|
||||
|
||||
@@ -194,7 +194,7 @@ int main(){
|
||||
|
||||
printf("/* This file was automatically generated by t1_generate_luts.c */\n\n");
|
||||
|
||||
// lut_ctxno_zc
|
||||
/* lut_ctxno_zc */
|
||||
for (j = 0; j < 4; ++j) {
|
||||
for (i = 0; i < 256; ++i) {
|
||||
int orient = j;
|
||||
@@ -215,7 +215,7 @@ int main(){
|
||||
}
|
||||
printf("%i\n};\n\n", lut_ctxno_zc[1023]);
|
||||
|
||||
// lut_ctxno_sc
|
||||
/* lut_ctxno_sc */
|
||||
printf("static char lut_ctxno_sc[256] = {\n ");
|
||||
for (i = 0; i < 255; ++i) {
|
||||
printf("0x%x, ", t1_init_ctxno_sc(i << 4));
|
||||
@@ -224,7 +224,7 @@ int main(){
|
||||
}
|
||||
printf("0x%x\n};\n\n", t1_init_ctxno_sc(255 << 4));
|
||||
|
||||
// lut_spb
|
||||
/* lut_spb */
|
||||
printf("static char lut_spb[256] = {\n ");
|
||||
for (i = 0; i < 255; ++i) {
|
||||
printf("%i, ", t1_init_spb(i << 4));
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
#include "opj_includes.h"
|
||||
#include <assert.h>
|
||||
|
||||
/** @defgroup T2 T2 - Implementation of a tier-2 coding */
|
||||
/*@{*/
|
||||
@@ -340,13 +341,15 @@ static int t2_decode_packet(opj_t2_t* t2, unsigned char *src, int len, opj_tcd_t
|
||||
int precno = pi->precno; /* precinct value */
|
||||
int layno = pi->layno; /* quality layer value */
|
||||
|
||||
opj_tcd_resolution_t* res = &tile->comps[compno].resolutions[resno];
|
||||
|
||||
unsigned char *hd = NULL;
|
||||
int present;
|
||||
|
||||
opj_bio_t *bio = NULL; /* BIO component */
|
||||
|
||||
|
||||
opj_tcd_resolution_t* res;
|
||||
assert(&tile->comps[compno] != NULL);
|
||||
res = &tile->comps[compno].resolutions[resno];
|
||||
|
||||
if (layno == 0) {
|
||||
for (bandno = 0; bandno < res->numbands; bandno++) {
|
||||
opj_tcd_band_t *band = &res->bands[bandno];
|
||||
|
||||
@@ -1507,7 +1507,7 @@ opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno
|
||||
for(j = res->y0; j < res->y1; ++j) {
|
||||
for(i = res->x0; i < res->x1; ++i) {
|
||||
float tmp = ((float*)tilec->data)[i - res->x0 + (j - res->y0) * tw];
|
||||
int v = lrintf(tmp);
|
||||
int v = opj_lrintf(tmp);
|
||||
v += adjust;
|
||||
imagec->data[(i - offset_x) + (j - offset_y) * w] = int_clamp(v, min, max);
|
||||
}
|
||||
|
||||
@@ -30,3 +30,8 @@ set_source_files_properties(${libpathing_HEADER_FILES}
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE)
|
||||
|
||||
add_library(nd_Pathing STATIC ${libpathing_SOURCE_FILES} ${libpathing_HEADER_FILES} )
|
||||
|
||||
target_link_libraries(nd_Pathing
|
||||
PUBLIC
|
||||
llcommon
|
||||
)
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
* $/LicenseInfo$
|
||||
*/
|
||||
|
||||
#if LL_MSVC
|
||||
// disable warning about boost::lexical_cast returning uninitialized data
|
||||
// when it fails to parse the string
|
||||
#pragma warning (disable:4701)
|
||||
#endif
|
||||
|
||||
#include "linden_common.h"
|
||||
|
||||
@@ -44,6 +39,8 @@
|
||||
#include "llstl.h"
|
||||
#include "lltexglobalcolor.h"
|
||||
#include "llwearabledata.h"
|
||||
#include "boost/bind.hpp"
|
||||
#include "boost/tokenizer.hpp"
|
||||
|
||||
|
||||
#if LL_MSVC
|
||||
@@ -51,8 +48,6 @@
|
||||
#pragma warning (disable:4702)
|
||||
#endif
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
using namespace LLAvatarAppearanceDefines;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -87,8 +82,11 @@ public:
|
||||
|
||||
private:
|
||||
std::string mName;
|
||||
std::string mSupport;
|
||||
std::string mAliases;
|
||||
BOOL mIsJoint;
|
||||
LLVector3 mPos;
|
||||
LLVector3 mEnd;
|
||||
LLVector3 mRot;
|
||||
LLVector3 mScale;
|
||||
LLVector3 mPivot;
|
||||
@@ -118,6 +116,7 @@ public:
|
||||
private:
|
||||
S32 mNumBones;
|
||||
S32 mNumCollisionVolumes;
|
||||
LLAvatarAppearance::joint_alias_map_t mJointAliasMap;
|
||||
typedef std::vector<LLAvatarBoneInfo*> bone_info_list_t;
|
||||
bone_info_list_t mBoneInfoList;
|
||||
};
|
||||
@@ -180,7 +179,10 @@ LLAvatarAppearance::LLAvatarAppearance(LLWearableData* wearable_data) :
|
||||
mPelvisToFoot(0.f),
|
||||
mHeadOffset(),
|
||||
mRoot(NULL),
|
||||
mWearableData(wearable_data)
|
||||
mWearableData(wearable_data),
|
||||
mNumBones(0),
|
||||
mIsBuilt(FALSE),
|
||||
mInitFlags(0)
|
||||
{
|
||||
llassert_always(mWearableData);
|
||||
mBakedTextureDatas.resize(LLAvatarAppearanceDefines::BAKED_NUM_INDICES);
|
||||
@@ -193,8 +195,6 @@ LLAvatarAppearance::LLAvatarAppearance(LLWearableData* wearable_data) :
|
||||
mBakedTextureDatas[i].mMaskTexName = 0;
|
||||
mBakedTextureDatas[i].mTextureIndex = LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary::bakedToLocalTextureIndex((LLAvatarAppearanceDefines::EBakedTextureIndex)i);
|
||||
}
|
||||
|
||||
mIsBuilt = FALSE;
|
||||
}
|
||||
|
||||
// virtual
|
||||
@@ -206,8 +206,9 @@ void LLAvatarAppearance::initInstance()
|
||||
mRoot = createAvatarJoint();
|
||||
mRoot->setName( "mRoot" );
|
||||
|
||||
for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().begin();
|
||||
iter != LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().end();
|
||||
const auto& mesh_entries = LLAvatarAppearanceDictionary::getInstance()->getMeshEntries();
|
||||
for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = mesh_entries.begin();
|
||||
iter != mesh_entries.end();
|
||||
++iter)
|
||||
{
|
||||
const EMeshIndex mesh_index = iter->first;
|
||||
@@ -224,7 +225,7 @@ void LLAvatarAppearance::initInstance()
|
||||
for (U32 lod = 0; lod < mesh_dict->mLOD; lod++)
|
||||
{
|
||||
LLAvatarJointMesh* mesh = createAvatarJointMesh();
|
||||
std::string mesh_name = "m" + mesh_dict->mName + boost::lexical_cast<std::string>(lod);
|
||||
std::string mesh_name = fmt::format(FMT_STRING("m{:s}{:d}"), mesh_dict->mName, lod);
|
||||
// We pre-pended an m - need to capitalize first character for camelCase
|
||||
mesh_name[1] = toupper(mesh_name[1]);
|
||||
mesh->setName(mesh_name);
|
||||
@@ -252,8 +253,8 @@ void LLAvatarAppearance::initInstance()
|
||||
//-------------------------------------------------------------------------
|
||||
// associate baked textures with meshes
|
||||
//-------------------------------------------------------------------------
|
||||
for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().begin();
|
||||
iter != LLAvatarAppearanceDictionary::getInstance()->getMeshEntries().end();
|
||||
for (LLAvatarAppearanceDictionary::MeshEntries::const_iterator iter = mesh_entries.begin();
|
||||
iter != mesh_entries.end();
|
||||
++iter)
|
||||
{
|
||||
const EMeshIndex mesh_index = iter->first;
|
||||
@@ -277,6 +278,8 @@ void LLAvatarAppearance::initInstance()
|
||||
}
|
||||
buildCharacter();
|
||||
|
||||
mInitFlags |= 1<<0;
|
||||
|
||||
}
|
||||
|
||||
// virtual
|
||||
@@ -292,7 +295,7 @@ LLAvatarAppearance::~LLAvatarAppearance()
|
||||
mBakedTextureDatas[i].mJointMeshes.clear();
|
||||
|
||||
for (morph_list_t::iterator iter2 = mBakedTextureDatas[i].mMaskedMorphs.begin();
|
||||
iter2 != mBakedTextureDatas[i].mMaskedMorphs.end(); iter2++)
|
||||
iter2 != mBakedTextureDatas[i].mMaskedMorphs.end(); ++iter2)
|
||||
{
|
||||
LLMaskedMorph* masked_morph = (*iter2);
|
||||
delete masked_morph;
|
||||
@@ -327,36 +330,49 @@ LLAvatarAppearance::~LLAvatarAppearance()
|
||||
//static
|
||||
void LLAvatarAppearance::initClass()
|
||||
{
|
||||
std::string xmlFile;
|
||||
initClass("","");
|
||||
}
|
||||
|
||||
xmlFile = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR) + "_lad.xml";
|
||||
BOOL success = sXMLTree.parseFile( xmlFile, FALSE );
|
||||
//static
|
||||
void LLAvatarAppearance::initClass(const std::string& avatar_file_name_arg, const std::string& skeleton_file_name_arg)
|
||||
{
|
||||
std::string avatar_file_name;
|
||||
|
||||
if (!avatar_file_name_arg.empty())
|
||||
{
|
||||
avatar_file_name = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,avatar_file_name_arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar_file_name = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,AVATAR_DEFAULT_CHAR + "_lad.xml");
|
||||
}
|
||||
BOOL success = sXMLTree.parseFile( avatar_file_name, FALSE );
|
||||
if (!success)
|
||||
{
|
||||
LL_ERRS() << "Problem reading avatar configuration file:" << xmlFile << LL_ENDL;
|
||||
LL_ERRS() << "Problem reading avatar configuration file:" << avatar_file_name << LL_ENDL;
|
||||
}
|
||||
|
||||
// now sanity check xml file
|
||||
LLXmlTreeNode* root = sXMLTree.getRoot();
|
||||
if (!root)
|
||||
{
|
||||
LL_ERRS() << "No root node found in avatar configuration file: " << xmlFile << LL_ENDL;
|
||||
LL_ERRS() << "No root node found in avatar configuration file: " << avatar_file_name << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// <linden_avatar version="1.0"> (root)
|
||||
// <linden_avatar version="2.0"> (root)
|
||||
//-------------------------------------------------------------------------
|
||||
if( !root->hasName( "linden_avatar" ) )
|
||||
{
|
||||
LL_ERRS() << "Invalid avatar file header: " << xmlFile << LL_ENDL;
|
||||
LL_ERRS() << "Invalid avatar file header: " << avatar_file_name << LL_ENDL;
|
||||
}
|
||||
|
||||
std::string version;
|
||||
static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
|
||||
if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
|
||||
if( !root->getFastAttributeString( version_string, version ) || ((version != "1.0") && (version != "2.0")))
|
||||
{
|
||||
LL_ERRS() << "Invalid avatar file version: " << version << " in file: " << xmlFile << LL_ENDL;
|
||||
LL_ERRS() << "Invalid avatar file version: " << version << " in file: " << avatar_file_name << LL_ENDL;
|
||||
}
|
||||
|
||||
S32 wearable_def_version = 1;
|
||||
@@ -364,21 +380,22 @@ void LLAvatarAppearance::initClass()
|
||||
root->getFastAttributeS32( wearable_definition_version_string, wearable_def_version );
|
||||
LLWearable::setCurrentDefinitionVersion( wearable_def_version );
|
||||
|
||||
std::string mesh_file_name;
|
||||
|
||||
LLXmlTreeNode* skeleton_node = root->getChildByName( "skeleton" );
|
||||
if (!skeleton_node)
|
||||
{
|
||||
LL_ERRS() << "No skeleton in avatar configuration file: " << xmlFile << LL_ENDL;
|
||||
LL_ERRS() << "No skeleton in avatar configuration file: " << avatar_file_name << LL_ENDL;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string skeleton_file_name;
|
||||
static LLStdStringHandle file_name_string = LLXmlTree::addAttributeString("file_name");
|
||||
if (!skeleton_node->getFastAttributeString(file_name_string, skeleton_file_name))
|
||||
{
|
||||
LL_ERRS() << "No file name in skeleton node in avatar config file: " << xmlFile << LL_ENDL;
|
||||
}
|
||||
|
||||
std::string skeleton_file_name = skeleton_file_name_arg;
|
||||
if (skeleton_file_name.empty())
|
||||
{
|
||||
static LLStdStringHandle file_name_string = LLXmlTree::addAttributeString("file_name");
|
||||
if (!skeleton_node->getFastAttributeString(file_name_string, skeleton_file_name))
|
||||
{
|
||||
LL_ERRS() << "No file name in skeleton node in avatar config file: " << avatar_file_name << LL_ENDL;
|
||||
}
|
||||
}
|
||||
|
||||
std::string skeleton_path;
|
||||
skeleton_path = gDirUtilp->getExpandedFilename(LL_PATH_CHARACTER,skeleton_file_name);
|
||||
@@ -441,11 +458,56 @@ void LLAvatarAppearance::cleanupClass()
|
||||
|
||||
using namespace LLAvatarAppearanceDefines;
|
||||
|
||||
void LLAvatarAppearance::compareJointStateMaps(joint_state_map_t& last_state,
|
||||
joint_state_map_t& curr_state)
|
||||
{
|
||||
if (!last_state.empty() && (last_state != curr_state))
|
||||
{
|
||||
S32 diff_count = 0;
|
||||
joint_state_map_t::iterator it;
|
||||
for (it=last_state.begin(); it != last_state.end(); ++it)
|
||||
{
|
||||
const std::string& key = it->first;
|
||||
if (last_state[key] != curr_state[key])
|
||||
{
|
||||
LL_DEBUGS("AvatarBodySize") << "BodySize change " << key << " " << last_state[key] << "->" << curr_state[key] << LL_ENDL;
|
||||
diff_count++;
|
||||
}
|
||||
}
|
||||
if (diff_count > 0)
|
||||
{
|
||||
LL_DEBUGS("AvatarBodySize") << "Total of BodySize changes " << diff_count << LL_ENDL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// The viewer can only suggest a good size for the agent,
|
||||
// the simulator will keep it inside a reasonable range.
|
||||
void LLAvatarAppearance::computeBodySize()
|
||||
{
|
||||
mLastBodySizeState = mCurrBodySizeState;
|
||||
|
||||
mCurrBodySizeState["mPelvis scale"] = mPelvisp->getScale();
|
||||
mCurrBodySizeState["mSkull pos"] = mSkullp->getPosition();
|
||||
mCurrBodySizeState["mSkull scale"] = mSkullp->getScale();
|
||||
mCurrBodySizeState["mNeck pos"] = mNeckp->getPosition();
|
||||
mCurrBodySizeState["mNeck scale"] = mNeckp->getScale();
|
||||
mCurrBodySizeState["mChest pos"] = mChestp->getPosition();
|
||||
mCurrBodySizeState["mChest scale"] = mChestp->getScale();
|
||||
mCurrBodySizeState["mHead pos"] = mHeadp->getPosition();
|
||||
mCurrBodySizeState["mHead scale"] = mHeadp->getScale();
|
||||
mCurrBodySizeState["mTorso pos"] = mTorsop->getPosition();
|
||||
mCurrBodySizeState["mTorso scale"] = mTorsop->getScale();
|
||||
mCurrBodySizeState["mHipLeft pos"] = mHipLeftp->getPosition();
|
||||
mCurrBodySizeState["mHipLeft scale"] = mHipLeftp->getScale();
|
||||
mCurrBodySizeState["mKneeLeft pos"] = mKneeLeftp->getPosition();
|
||||
mCurrBodySizeState["mKneeLeft scale"] = mKneeLeftp->getScale();
|
||||
mCurrBodySizeState["mAnkleLeft pos"] = mAnkleLeftp->getPosition();
|
||||
mCurrBodySizeState["mAnkleLeft scale"] = mAnkleLeftp->getScale();
|
||||
mCurrBodySizeState["mFootLeft pos"] = mFootLeftp->getPosition();
|
||||
|
||||
LLVector3 pelvis_scale = mPelvisp->getScale();
|
||||
|
||||
// some of the joints have not been cached
|
||||
@@ -505,7 +567,8 @@ void LLAvatarAppearance::computeBodySize()
|
||||
if (new_body_size != mBodySize || old_offset != mAvatarOffset)
|
||||
{
|
||||
mBodySize = new_body_size;
|
||||
bodySizeChanged();
|
||||
|
||||
compareJointStateMaps(mLastBodySizeState, mCurrBodySizeState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,7 +604,7 @@ BOOL LLAvatarAppearance::parseSkeletonFile(const std::string& filename)
|
||||
|
||||
std::string version;
|
||||
static LLStdStringHandle version_string = LLXmlTree::addAttributeString("version");
|
||||
if( !root->getFastAttributeString( version_string, version ) || (version != "1.0") )
|
||||
if( !root->getFastAttributeString( version_string, version ) || ((version != "1.0") && (version != "2.0")))
|
||||
{
|
||||
LL_ERRS() << "Invalid avatar skeleton file version: " << version << " in file: " << filename << LL_ENDL;
|
||||
return FALSE;
|
||||
@@ -557,6 +620,12 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
|
||||
{
|
||||
LLJoint* joint = NULL;
|
||||
|
||||
LL_DEBUGS("BVH") << "bone info: name " << info->mName
|
||||
<< " isJoint " << info->mIsJoint
|
||||
<< " volume_num " << volume_num
|
||||
<< " joint_num " << joint_num
|
||||
<< LL_ENDL;
|
||||
|
||||
if (info->mIsJoint)
|
||||
{
|
||||
joint = getCharacterJoint(joint_num);
|
||||
@@ -571,7 +640,7 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
|
||||
{
|
||||
if (volume_num >= (S32)mCollisionVolumes.size())
|
||||
{
|
||||
LL_WARNS() << "Too many bones" << LL_ENDL;
|
||||
LL_WARNS() << "Too many collision volumes" << LL_ENDL;
|
||||
return FALSE;
|
||||
}
|
||||
joint = (mCollisionVolumes[volume_num]);
|
||||
@@ -579,26 +648,34 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
|
||||
}
|
||||
|
||||
// add to parent
|
||||
if (parent)
|
||||
if (parent && (joint->getParent()!=parent))
|
||||
{
|
||||
parent->addChild( joint );
|
||||
}
|
||||
|
||||
// SL-315
|
||||
joint->setPosition(info->mPos);
|
||||
joint->setDefaultPosition(info->mPos);
|
||||
joint->setRotation(mayaQ(info->mRot.mV[VX], info->mRot.mV[VY],
|
||||
info->mRot.mV[VZ], LLQuaternion::XYZ));
|
||||
joint->setScale(info->mScale);
|
||||
joint->setDefaultScale(info->mScale);
|
||||
joint->setSupport(info->mSupport);
|
||||
joint->setEnd(info->mEnd);
|
||||
|
||||
if (info->mIsJoint)
|
||||
{
|
||||
joint->setSkinOffset( info->mPivot );
|
||||
joint->setJointNum(joint_num);
|
||||
joint_num++;
|
||||
}
|
||||
else // collision volume
|
||||
{
|
||||
joint->setJointNum(mNumBones+volume_num);
|
||||
volume_num++;
|
||||
}
|
||||
|
||||
|
||||
// setup children
|
||||
LLAvatarBoneInfo::child_list_t::const_iterator iter;
|
||||
for (iter = info->mChildList.begin(); iter != info->mChildList.end(); ++iter)
|
||||
@@ -618,18 +695,12 @@ BOOL LLAvatarAppearance::setupBone(const LLAvatarBoneInfo* info, LLJoint* parent
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLAvatarAppearance::allocateCharacterJoints( U32 num )
|
||||
{
|
||||
clearSkeleton();
|
||||
|
||||
for(S32 joint_num = 0; joint_num < (S32)num; joint_num++)
|
||||
{
|
||||
mSkeleton.push_back(createAvatarJoint(joint_num));
|
||||
}
|
||||
|
||||
|
||||
if (mSkeleton.empty() || !mSkeleton[0])
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (mSkeleton.size() != num)
|
||||
{
|
||||
clearSkeleton();
|
||||
mSkeleton = avatar_joint_list_t(num,NULL);
|
||||
mNumBones = num;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -642,6 +713,8 @@ BOOL LLAvatarAppearance::buildSkeleton(const LLAvatarSkeletonInfo *info)
|
||||
{
|
||||
if (!info)
|
||||
return FALSE;
|
||||
LL_DEBUGS("BVH") << "numBones " << info->mNumBones << " numCollisionVolumes " << info->mNumCollisionVolumes << LL_ENDL;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// allocate joints
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -668,8 +741,8 @@ BOOL LLAvatarAppearance::buildSkeleton(const LLAvatarSkeletonInfo *info)
|
||||
LLAvatarSkeletonInfo::bone_info_list_t::const_iterator iter;
|
||||
for (iter = info->mBoneInfoList.begin(); iter != info->mBoneInfoList.end(); ++iter)
|
||||
{
|
||||
LLAvatarBoneInfo *info = *iter;
|
||||
if (!setupBone(info, NULL, current_volume_num, current_joint_num))
|
||||
LLAvatarBoneInfo *bone_info = *iter;
|
||||
if (!setupBone(bone_info, NULL, current_volume_num, current_joint_num))
|
||||
{
|
||||
LL_ERRS() << "Error parsing bone in skeleton file" << LL_ENDL;
|
||||
return FALSE;
|
||||
@@ -849,11 +922,11 @@ void LLAvatarAppearance::buildCharacter()
|
||||
//-----------------------------------------------------------------------------
|
||||
// loadAvatar()
|
||||
//-----------------------------------------------------------------------------
|
||||
//static LLFastTimer::DeclareTimer FTM_LOAD_AVATAR("Load Avatar");
|
||||
//static LLTrace::BlockTimerStatHandle FTM_LOAD_AVATAR("Load Avatar");
|
||||
|
||||
BOOL LLAvatarAppearance::loadAvatar()
|
||||
{
|
||||
// LLFastTimer t(FTM_LOAD_AVATAR);
|
||||
// LL_RECORD_BLOCK_TIME(FTM_LOAD_AVATAR);
|
||||
|
||||
// avatar_skeleton.xml
|
||||
if( !buildSkeleton(sAvatarSkeletonInfo) )
|
||||
@@ -969,7 +1042,7 @@ BOOL LLAvatarAppearance::loadAvatar()
|
||||
addVisualParam( driver_param );
|
||||
driver_param->setParamLocation(isSelf() ? LOC_AV_SELF : LOC_AV_OTHER);
|
||||
LLVisualParam*(LLAvatarAppearance::*avatar_function)(S32)const = &LLAvatarAppearance::getVisualParam;
|
||||
if( !driver_param->linkDrivenParams(boost::bind(avatar_function,(LLAvatarAppearance*)this,_1 ), false))
|
||||
if( !driver_param->linkDrivenParams(std::bind(avatar_function,(LLAvatarAppearance*)this, std::placeholders::_1 ), false))
|
||||
{
|
||||
LL_WARNS() << "could not link driven params for avatar " << getID().asString() << " param id: " << driver_param->getID() << LL_ENDL;
|
||||
continue;
|
||||
@@ -1128,6 +1201,7 @@ BOOL LLAvatarAppearance::loadMeshNodes()
|
||||
{
|
||||
// This should never happen
|
||||
LL_WARNS("Avatar") << "Could not find avatar mesh: " << info->mReferenceMeshName << LL_ENDL;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1143,7 +1217,7 @@ BOOL LLAvatarAppearance::loadMeshNodes()
|
||||
}
|
||||
|
||||
// Multimap insert
|
||||
mPolyMeshes.insert(std::make_pair(info->mMeshFileName, poly_mesh));
|
||||
mPolyMeshes.emplace(info->mMeshFileName, poly_mesh);
|
||||
|
||||
mesh->setMesh( poly_mesh );
|
||||
mesh->setLOD( info->mMinPixelArea );
|
||||
@@ -1264,6 +1338,10 @@ LLJoint *LLAvatarAppearance::getCharacterJoint( U32 num )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if (!mSkeleton[num])
|
||||
{
|
||||
mSkeleton[num] = createAvatarJoint();
|
||||
}
|
||||
return mSkeleton[num];
|
||||
}
|
||||
|
||||
@@ -1289,12 +1367,12 @@ LLVector3 LLAvatarAppearance::getVolumePos(S32 joint_index, LLVector3& volume_of
|
||||
//-----------------------------------------------------------------------------
|
||||
// findCollisionVolume()
|
||||
//-----------------------------------------------------------------------------
|
||||
LLJoint* LLAvatarAppearance::findCollisionVolume(U32 volume_id)
|
||||
LLJoint* LLAvatarAppearance::findCollisionVolume(S32 volume_id)
|
||||
{
|
||||
//SNOW-488: As mNumCollisionVolumes is a S32 and we are casting from a U32 to a S32
|
||||
//to compare we also need to be sure of the wrap around case producing (S32) <0
|
||||
//or in terms of the U32 an out of bounds index in the array.
|
||||
if ((S32)volume_id > (S32)mCollisionVolumes.size() || (S32)volume_id<0)
|
||||
if ((S32)volume_id > (S32)mCollisionVolumes.size() || volume_id<0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -1482,6 +1560,21 @@ BOOL LLAvatarAppearance::teToColorParams( ETextureIndex te, U32 *param_name )
|
||||
param_name[1] = 1072; //"tattoo_green";
|
||||
param_name[2] = 1073; //"tattoo_blue";
|
||||
break;
|
||||
case TEX_HEAD_UNIVERSAL_TATTOO:
|
||||
case TEX_UPPER_UNIVERSAL_TATTOO:
|
||||
case TEX_LOWER_UNIVERSAL_TATTOO:
|
||||
case TEX_SKIRT_TATTOO:
|
||||
case TEX_HAIR_TATTOO:
|
||||
case TEX_EYES_TATTOO:
|
||||
case TEX_LEFT_ARM_TATTOO:
|
||||
case TEX_LEFT_LEG_TATTOO:
|
||||
case TEX_AUX1_TATTOO:
|
||||
case TEX_AUX2_TATTOO:
|
||||
case TEX_AUX3_TATTOO:
|
||||
param_name[0] = 1238; //"tattoo_universal_red";
|
||||
param_name[1] = 1239; //"tattoo_universal_green";
|
||||
param_name[2] = 1240; //"tattoo_universal_blue";
|
||||
break;
|
||||
|
||||
default:
|
||||
llassert(0);
|
||||
@@ -1563,21 +1656,24 @@ LLTexLayerSet* LLAvatarAppearance::getAvatarLayerSet(EBakedTextureIndex baked_in
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL LLAvatarAppearance::allocateCollisionVolumes( U32 num )
|
||||
{
|
||||
delete_and_clear(mCollisionVolumes);
|
||||
mCollisionVolumes.reserve(num);
|
||||
|
||||
LLAvatarJointCollisionVolume* cv;
|
||||
for (U32 i = 0; i < num; ++i)
|
||||
if(num != mCollisionVolumes.size() )
|
||||
{
|
||||
cv = new LLAvatarJointCollisionVolume();
|
||||
if (cv)
|
||||
delete_and_clear(mCollisionVolumes);
|
||||
mCollisionVolumes.reserve(num);
|
||||
|
||||
LLAvatarJointCollisionVolume* cv;
|
||||
for (U32 i = 0; i < num; ++i)
|
||||
{
|
||||
mCollisionVolumes.push_back(cv);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete_and_clear(mCollisionVolumes);
|
||||
return false;
|
||||
cv = new LLAvatarJointCollisionVolume();
|
||||
if (cv)
|
||||
{
|
||||
mCollisionVolumes.push_back(cv);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete_and_clear(mCollisionVolumes);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@@ -1597,6 +1693,9 @@ BOOL LLAvatarBoneInfo::parseXml(LLXmlTreeNode* node)
|
||||
LL_WARNS() << "Bone without name" << LL_ENDL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle aliases_string = LLXmlTree::addAttributeString("aliases");
|
||||
node->getFastAttributeString(aliases_string, mAliases ); //Aliases are not required.
|
||||
}
|
||||
else if (node->hasName("collision_volume"))
|
||||
{
|
||||
@@ -1634,6 +1733,20 @@ BOOL LLAvatarBoneInfo::parseXml(LLXmlTreeNode* node)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle end_string = LLXmlTree::addAttributeString("end");
|
||||
if (!node->getFastAttributeVector3(end_string, mEnd))
|
||||
{
|
||||
LL_WARNS() << "Bone without end " << mName << LL_ENDL;
|
||||
mEnd = LLVector3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
static LLStdStringHandle support_string = LLXmlTree::addAttributeString("support");
|
||||
if (!node->getFastAttributeString(support_string,mSupport))
|
||||
{
|
||||
LL_WARNS() << "Bone without support " << mName << LL_ENDL;
|
||||
mSupport = "base";
|
||||
}
|
||||
|
||||
if (mIsJoint)
|
||||
{
|
||||
static LLStdStringHandle pivot_string = LLXmlTree::addAttributeString("pivot");
|
||||
@@ -1689,6 +1802,75 @@ BOOL LLAvatarSkeletonInfo::parseXml(LLXmlTreeNode* node)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//Make aliases for joint and push to map.
|
||||
void LLAvatarAppearance::makeJointAliases(LLAvatarBoneInfo *bone_info)
|
||||
{
|
||||
if (! bone_info->mIsJoint )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string bone_name = bone_info->mName;
|
||||
mJointAliasMap[bone_name] = bone_name; //Actual name is a valid alias.
|
||||
|
||||
std::string aliases = bone_info->mAliases;
|
||||
|
||||
boost::char_separator<char> sep(" ");
|
||||
boost::tokenizer<boost::char_separator<char> > tok(aliases, sep);
|
||||
for(boost::tokenizer<boost::char_separator<char> >::iterator i = tok.begin(); i != tok.end(); ++i)
|
||||
{
|
||||
if ( mJointAliasMap.find(*i) != mJointAliasMap.end() )
|
||||
{
|
||||
LL_WARNS() << "avatar skeleton: Joint alias \"" << *i << "\" remapped from " << mJointAliasMap[*i] << " to " << bone_name << LL_ENDL;
|
||||
}
|
||||
mJointAliasMap[*i] = bone_name;
|
||||
}
|
||||
|
||||
LLAvatarBoneInfo::child_list_t::const_iterator iter;
|
||||
for (iter = bone_info->mChildList.begin(); iter != bone_info->mChildList.end(); ++iter)
|
||||
{
|
||||
makeJointAliases( *iter );
|
||||
}
|
||||
}
|
||||
|
||||
const LLAvatarAppearance::joint_alias_map_t& LLAvatarAppearance::getJointAliases ()
|
||||
{
|
||||
LLAvatarAppearance::joint_alias_map_t alias_map;
|
||||
if (mJointAliasMap.empty())
|
||||
{
|
||||
|
||||
LLAvatarSkeletonInfo::bone_info_list_t::const_iterator iter;
|
||||
for (iter = sAvatarSkeletonInfo->mBoneInfoList.begin();
|
||||
iter != sAvatarSkeletonInfo->mBoneInfoList.end();
|
||||
++iter)
|
||||
{
|
||||
//LLAvatarBoneInfo *bone_info = *iter;
|
||||
makeJointAliases( *iter );
|
||||
}
|
||||
|
||||
LLAvatarXmlInfo::attachment_info_list_t::iterator attach_iter;
|
||||
for (attach_iter = sAvatarXmlInfo->mAttachmentInfoList.begin();
|
||||
attach_iter != sAvatarXmlInfo->mAttachmentInfoList.end();
|
||||
++attach_iter)
|
||||
{
|
||||
LLAvatarXmlInfo::LLAvatarAttachmentInfo *info = *attach_iter;
|
||||
std::string bone_name = info->mName;
|
||||
|
||||
// Also accept the name with spaces substituted with
|
||||
// underscores. This gives a mechanism for referencing such joints
|
||||
// in daes, which don't allow spaces.
|
||||
std::string sub_space_to_underscore = bone_name;
|
||||
LLStringUtil::replaceChar(sub_space_to_underscore, ' ', '_');
|
||||
if (sub_space_to_underscore != bone_name)
|
||||
{
|
||||
mJointAliasMap[sub_space_to_underscore] = bone_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mJointAliasMap;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// parseXmlSkeletonNode(): parses <skeleton> nodes from XML tree
|
||||
@@ -1719,7 +1901,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlSkeletonNode(LLXmlTreeNode* ro
|
||||
{
|
||||
LL_WARNS() << "Unknown param type." << LL_ENDL;
|
||||
}
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LLPolySkeletalDistortionInfo *info = new LLPolySkeletalDistortionInfo;
|
||||
@@ -1744,7 +1926,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlSkeletonNode(LLXmlTreeNode* ro
|
||||
{
|
||||
LL_WARNS() << "No name supplied for attachment point." << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle joint_string = LLXmlTree::addAttributeString("joint");
|
||||
@@ -1752,7 +1934,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlSkeletonNode(LLXmlTreeNode* ro
|
||||
{
|
||||
LL_WARNS() << "No bone declared in attachment point " << info->mName << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle position_string = LLXmlTree::addAttributeString("position");
|
||||
@@ -1778,7 +1960,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlSkeletonNode(LLXmlTreeNode* ro
|
||||
{
|
||||
LL_WARNS() << "No id supplied for attachment point " << info->mName << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle slot_string = LLXmlTree::addAttributeString("pie_slice");
|
||||
@@ -1864,7 +2046,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlMeshNodes(LLXmlTreeNode* root)
|
||||
{
|
||||
LL_WARNS() << "Unknown param type." << LL_ENDL;
|
||||
}
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LLPolyMorphTargetInfo *morphinfo = new LLPolyMorphTargetInfo();
|
||||
@@ -2025,7 +2207,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlMorphNodes(LLXmlTreeNode* root
|
||||
{
|
||||
LL_WARNS() << "No name supplied for morph mask." << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle region_string = LLXmlTree::addAttributeString("body_region");
|
||||
@@ -2033,7 +2215,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlMorphNodes(LLXmlTreeNode* root
|
||||
{
|
||||
LL_WARNS() << "No region supplied for morph mask." << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static LLStdStringHandle layer_string = LLXmlTree::addAttributeString("layer");
|
||||
@@ -2041,7 +2223,7 @@ BOOL LLAvatarAppearance::LLAvatarXmlInfo::parseXmlMorphNodes(LLXmlTreeNode* root
|
||||
{
|
||||
LL_WARNS() << "No layer supplied for morph mask." << LL_ENDL;
|
||||
delete info;
|
||||
continue;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// optional parameter. don't throw a warning if not present.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user