-
Notifications
You must be signed in to change notification settings - Fork 2
/
pr-3724.sh
572 lines (484 loc) · 29.4 KB
/
pr-3724.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#!/usr/bin/env bash
if [ ! -d include ] ; then mkdir include ; fi
if [ ! -d include/ts ] ; then git mv proxy/api/ts include ; fi
if [ ! -d include/tscore ] ; then mkdir include/tscore ; fi
if [ ! -d include/tscpp ] ; then mkdir include/tscpp ; fi
if [ ! -d include/tscpp/api ] ; then
git mv lib/cppapi/include/atscppapi include/tscpp
git mv include/tscpp/atscppapi include/tscpp/api
fi
if [ ! -d include/tscpp/util ] ; then mkdir include/tscpp/util ; fi
if [ ! -f include/tscore/IntrusiveDList.h ] ; then git mv lib/ts/*.h include/tscore ; fi
if [ -f include/tscore/TextView.h ] ; then git mv include/tscore/TextView.h include/tscpp/util ; fi
if [ -f include/tscore/PostScript.h ] ; then git mv include/tscore/PostScript.h include/tscpp/util ; fi
# Library source fixups
if [ -d lib/ts ] ; then git mv lib/ts src/tscore ; fi
if [ ! -d src/tscpp ] ; then mkdir src/tscpp ; fi
if [ ! -d src/tscpp/util ] ; then mkdir src/tscpp/util ; fi
if [ -f src/tscore/TextView.cc ] ; then git mv src/tscore/TextView.cc src/tscpp/util ; fi
if [ -f src/tscore/apidefs.h.in ] ; then git mv src/tscore/apidefs.h.in include/ts ; fi
if [ -f src/tscore/ink_config.h.in ] ; then git mv src/tscore/ink_config.h.in include/tscore ; fi
# Fix up unit-tests
if [ -d src/tscore/unit-tests ] ; then git mv src/tscore/unit-tests src/tscore/unit_tests ; fi
if [ -d iocore/eventsystem/unit-tests ] ; then git mv iocore/eventsystem/unit-tests iocore/eventsystem/unit_tests ; fi
if [ -d proxy/http/unit-tests ] ; then git mv proxy/http/unit-tests proxy/http/unit_tests ; fi
if [ -d plugins/s3_auth/unit-tests ] ; then git mv plugins/s3_auth/unit-tests plugins/s3_auth/unit_tests ; fi
if [ -d plugins/experimental/access_control/unit-tests ] ; then git mv plugins/experimental/access_control/unit-tests plugins/experimental/access_control/unit_tests ; fi
if [ ! -d src/tscpp/util/unit_tests ] ; then mkdir src/tscpp/util/unit_tests ; fi
if [ ! -f src/tscpp/util/unit_tests/unit_test_main.cc ] ; then cp src/tscore/unit_tests/unit_test_main.cc src/tscpp/util/unit_tests ; fi
if [ -f src/tscore/unit_tests/test_TextView.cc ] ; then git mv src/tscore/unit_tests/test_TextView.cc src/tscpp/util/unit_tests ; fi
if [ -f src/tscore/unit_tests/test_PostScript.cc ] ; then git mv src/tscore/unit_tests/test_PostScript.cc src/tscpp/util/unit_tests ; fi
if [ -d lib/cppapi ] ; then git mv lib/cppapi src/tscpp/ ; git mv src/tscpp/cppapi src/tscpp/api ; fi
if [ -f src/tscpp/api/include/logging_internal.h ] ; then
git mv src/tscpp/api/include/logging_internal.h src/tscpp/api
fi
if [ -f src/tscpp/api/include/utils_internal.h ] ; then
git mv src/tscpp/api/include/utils_internal.h src/tscpp/api
fi
if [ -d lib/wccp ] ; then git mv lib/wccp src/wccp ; fi
if [ ! -d include/wccp ] ; then mkdir include/wccp ; fi
if [ -f src/wccp/Wccp.h ] ; then git mv src/wccp/Wccp.h include/wccp ; fi
sed -i -e 's!libtsutil!libtscore!' CMakeLists.txt
sed -i -e 's!lib/ts/!src/tscore/!' CMakeLists.txt
sed -i -e 's!lib/wccp/!src/wccp/!' CMakeLists.txt
sed -i -e 's!proxy/api/ts!include/ts!' CMakeLists.txt
sed -i -e 's!src/wccp/Wccp.h!include/wccp/Wccp.h!' CMakeLists.txt
sed -i -e 's!unit-tests!unit_tests!' CMakeLists.txt
sed -i -E -e 's!src/tscore/([^.]+[.]h)!include/tscore/\1!' CMakeLists.txt
sed -i -E -e 's!test_tslib!test_tscore!' CMakeLists.txt
sed -i -E -e '\!lib/cppapi/!d' CMakeLists.txt
sed -i -e '/TextView.cc/d' CMakeLists.txt
sed -i -e '\!experimental/ssl_cert_loader!d' CMakeLists.txt
# Adjust makefiles
find . \( -name 'Makefile.am' -o -name 'Makefile.inc' \) -exec sed -i -E -e 's/unit-tests/unit_tests/g' {} \;
find . \( -name 'Makefile.am' -o -name 'Makefile.inc' \) -exec sed -i -E -e 's!-I[$][(]abs_top_srcdir[)]/lib!-I$(abs_top_srcdir)/include!g' {} \;
find . \( -name 'Makefile.am' -o -name 'Makefile.inc' \) -exec sed -i -E -e 's!lib/ts/libtsutil.la!src/tscore/libtscore.la!g' {} \;
find . \( -name 'Makefile.am' -o -name 'Makefile.inc' \) -exec sed -i -E -e 's!/lib/wccp/libwccp!/src/wccp/libwccp!g' {} \;
# One un-fixup for include paths.
sed -i -E -e '/-I/s!/include/yamlcpp!/lib/yamlcpp!' lib/yamlcpp/Makefile.am
sed -i -E -e '/^SUBDIRS/s! proxy/api/ts lib! src/tscpp/util lib src/tscore!' Makefile.am
sed -i -E -e '/^SUBDIRS/s!$! include!' Makefile.am
sed -i -E -e '\!proxy/api/ts!d' Makefile.am
if ! grep --quiet 'noinst_PROGRAMS' src/Makefile.am ; then
sed -i -E -e '/TESTS =/a\
noinst_PROGRAMS =' src/Makefile.am
fi
if ! grep --quiet 'lib_LTLIBRARIES' src/Makefile.am ; then
sed -i -E -e '/TESTS =/a\
lib_LTLIBRARIES =' src/Makefile.am
fi
sed -i -E -e 's!ts records tsconfig cppapi!records tsconfig!' lib/Makefile.am
sed -i -E -e '/if BUILD_WCCP/,+3d' lib/Makefile.am
if ! grep --quiet 'tscpp' src/Makefile.am ; then
sed -i -E -e '/noinst_PROGRAMS =/a\
\
SUBDIRS = tscpp/api' src/Makefile.am
fi
sed -i -E -e '/if BUILD_WCCP/,+4d' src/Makefile.am
sed -i -E -e '\!SUBDIRS!a\
\
if BUILD_WCCP \
SUBDIRS += wccp \
include traffic_wccp/Makefile.inc \
endif' src/Makefile.am
sed -i -E -e '/test_cache_SOURCES/,+8d' src/wccp/Makefile.am
sed -i -E -e '/library_include_HEADERS/,+1d' src/tscore/Makefile.am
sed -i -E -e 's/test_tsutil/test_libtscore/g' src/tscore/Makefile.am
sed -i -E -e 's/test_tslib/test_tscore/g' src/tscore/Makefile.am
sed -i -E -e 's/tsutil/tscore/g' src/tscore/Makefile.am
sed -i -E -e '/TextView/d' src/tscore/Makefile.am
sed -i -E -e '/PostScript/d' src/tscore/Makefile.am
sed -i -E -e 's!test_scoped_resource.cc \\!test_scoped_resource.cc!' src/tscore/Makefile.am
sed -i -E -e 's! api/ts Makefile.am! include/ts Makefile.am!' include/ts/Makefile.am
sed -i -E -e '\!ts[.]h!i\
\tapidefs.h \\' include/ts/Makefile.am
cat > src/tscpp/util/Makefile.am <<'HERE'
# tscpp/util Makefile.am
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
check_PROGRAMS = test_tscpputil
TESTS = $(check_PROGRAMS)
lib_LTLIBRARIES = libtscpputil.la
AM_CPPFLAGS += -I$(abs_top_srcdir)/include
libtscpputil_la_LDFLAGS = -no-undefined -version-info @TS_LIBTOOL_VERSION@
libtscpputil_la_SOURCES = \
PostScript.h \
TextView.h TextView.cc
test_tscpputil_CPPFLAGS = $(AM_CPPFLAGS)\
-I$(abs_top_srcdir)/tests/include
test_tscpputil_CXXFLAGS = -Wno-array-bounds $(AM_CXXFLAGS)
test_tscpputil_LDADD = libtscpputil.la
test_tscpputil_SOURCES = \
unit_tests/unit_test_main.cc \
unit_tests/test_PostScript.cc \
unit_tests/test_TextView.cc
clean-local:
rm -f ParseRulesCType ParseRulesCTypeToLower ParseRulesCTypeToUpper
clang-tidy-local: $(DIST_SOURCES)
$(CXX_Clang_Tidy)
HERE
# Older versions may not have PostScript.
if [! -f include/tscpp/util/PostScript.h ] ; then
set -i -E -e '/PostScript/d' Makefile.am
fi
cat > include/tscpp/util/Makefile.am << 'HERE'
# include/tscpp/util Makefile.am
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
library_includedir=$(includedir)/tscpp/util
library_include_HEADERS = \
PostScript.h \
TextView.h
HERE
# tscpp/api
if ! grep --quiet 'AM_CPPFLAGS' src/tscpp/api/Makefile.am ; then
sed -i -E -e '/lib_LTLIBRARIES/a \
\
libtscppapi_la_CPPFLAGS = $(AM_CPPFLAGS) -I $(abs_top_srcdir)/include \
' src/tscpp/api/Makefile.am
fi
sed -i -E -e 's/atscppapi/tscppapi/g' src/tscpp/api/Makefile.am
sed -i -E -e '/include ..top_srcdir/,+1d' src/tscpp/api/Makefile.am
sed -i -E -e '/tidy.mk/i\
MARKY_MARK' src/tscpp/api/Makefile.am
sed -i -E -e '/library_includedir/,/MARKY_MARK/d' src/tscpp/api/Makefile.am
## Get the include set up for install.
cat > include/Makefile.am << 'HERE'
# include Makefile.am
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
SUBDIRS = ts tscpp/api tscpp/util
HERE
cat > include/tscpp/api/Makefile.am << 'HERE'
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
library_includedir = $(includedir)/tscpp/api
library_include_HEADERS = \
Async.h \
AsyncHttpFetch.h \
AsyncTimer.h \
CaseInsensitiveStringComparator.h \
ClientRequest.h \
Continuation.h \
GlobalPlugin.h \
GzipDeflateTransformation.h \
GzipInflateTransformation.h \
Headers.h \
HttpMethod.h \
HttpStatus.h \
HttpVersion.h \
InterceptPlugin.h \
Logger.h \
Plugin.h \
PluginInit.h \
RemapPlugin.h \
Request.h \
Response.h \
Stat.h \
Transaction.h \
TransactionPlugin.h \
TransformationPlugin.h \
Url.h \
noncopyable.h \
utils.h
HERE
sed -i -E -e 's!lib/cppapi/Makefile!src/tscpp/api/Makefile!' configure.ac
sed -i -E -e '\!lib/ts/Makefile!d' configure.ac
sed -i -E -e '\!proxy/api/ts/Makefile!d' configure.ac
sed -i -E -e 's!lib/ts/apidefs.h!include/ts/apidefs.h!' configure.ac
sed -i -E -e 's!lib/ts/ink_config.h!include/tscore/ink_config.h!' configure.ac
sed -i -E -e '\!rc/trafficserver.xml!a\
src/tscpp/util/Makefile \
src/tscore/Makefile' configure.ac
sed -i -E -e 's!lib/wccp/Makefile!src/wccp/Makefile!' configure.ac
sed -i -E -e '\!example/Makefile!a\
include/Makefile \
include/ts/Makefile \
include/tscpp/api/Makefile \
include/tscpp/util/Makefile' configure.ac
# include path fixups - do top level dirs explicitly to avoid conflicts in plugins vs. core about "ts/".
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!api/ts/!ts/!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"atscppapi/!"tscpp/api/!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!<atscppapi/([_[:alnum:]]+)[.]h>!"tscpp/api/\1.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find tools \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find lib \( -name '*.cc' -o -name '*.h' -o -name '*.c' -o -name '*.y' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find include/tscore \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find include/wccp \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find iocore \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find mgmt \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!include .ts/([+_[:alnum:]]+)[.]h.!include "tscore/\1.h"!' {} \;
# file specific fixups.
find iocore \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!I_RecProcess.h!records/I_RecProcess.h!' {} \;
find iocore \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"I_RecHttp.h"!"records/I_RecHttp.h"!' {} \;
find iocore \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!P_RecCore.h!records/P_RecCore.h!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!I_RecCore.h!records/I_RecCore.h!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!P_RecCore.h!records/P_RecCore.h!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!P_RecProcess.h!records/P_RecProcess.h!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!P_RecUtils.h!records/P_RecUtils.h!' {} \;
find proxy \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"P_RecDefs.h"!"records/P_RecDefs.h"!' {} \;
find mgmt \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]P_RecCore.h[">]!"records/P_RecCore.h"!' {} \;
find mgmt \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"I_RecLocal.h"!"records/I_RecLocal.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"I_RecLocal.h"!"records/I_RecLocal.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"P_RecLocal.h"!"records/P_RecLocal.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"I_RecProcess.h"!"records/I_RecProcess.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!"I_RecCore.h"!"records/I_RecCore.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]P_RecUtils.h[">]!"records/P_RecUtils.h"!' {} \;
find src \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]I_RecDefs.h[">]!"records/I_RecDefs.h"!' {} \;
find doc \( -name '*.rst' \) -exec sed -i -E -e 's!lib/ts/unit-tests!src/tscore/unit_tests!' {} \;
# Easier to repair these than to get it right the first time.
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/TextView.h!tscpp/util/TextView.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/PostScript.h!tscpp/util/PostScript.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/ts[.]h!ts/ts.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/apidefs.h!ts/apidefs.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/InkAPIPrivateIOCore.h!ts/InkAPIPrivateIOCore.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/experimental.h!ts/experimental.h!' {} \;
find . \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's!tscore/remap.h!ts/remap.h!' {} \;
# Nasty little files that have to be hand done.
sed -i -E -e 's![.][.]/lib/ts/ink_hrtime.h!tscore/ink_hrtime.h!' proxy/Milestones.h
sed -i -E -e 's!"AcidPtr.h"!"tscore/AcidPtr.h"!' src/tscore/AcidPtr.cc
sed -i -E -e 's!"BaseLogFile.h"!"tscore/BaseLogFile.h"!' src/tscore/BaseLogFile.cc
sed -i -E -e 's!"ConsistentHash.h"!"tscore/ConsistentHash.h"!' src/tscore/ConsistentHash.cc
sed -i -E -e 's!"ContFlags.h"!"tscore/ContFlags.h"!' src/tscore/ContFlags.cc
sed -i -E -e 's!"ink_assert.h"!"tscore/ink_assert.h"!' src/tscore/InkErrno.cc
sed -i -E -e 's!"InkErrno.h"!"tscore/InkErrno.h"!' src/tscore/InkErrno.cc
sed -i -E -e '/"ink_inet.h"/d' src/tscore/ink_inet.cc
sed -i -E -e 's!"tscore/TextView.h"!"tscpp/util/TextView.h"!' src/tscpp/util/TextView.cc
sed -i -E -e 's!"ink_inet.h"!"tscore/ink_inet.h"!' src/tscore/IpMap.cc
sed -i -E -e 's!"tscore/TextView.h"!"tscore/tscpp/util/TextView.h"!' src/tscore/IpMap.cc
sed -i -E -e 's!"ink_defs.h"!"tscore/ink_defs.h"!' src/tscore/SourceLocation.cc
sed -i -E -e 's!"SourceLocation.h"!"tscore/SourceLocation.h"!' src/tscore/SourceLocation.cc
sed -i -E -e 's!"runroot.h"!"tscore/runroot.h"!' src/tscore/runroot.cc
sed -i -E -e 's!"tscore/TsException.h"!"ts/TsException.h"!' src/wccp/WccpMsg.cc
sed -i -E -e 's!"Wccp[.]h"!"wccp/Wccp.h"!' src/wccp/WccpLocal.h
sed -i -E -e 's!"Wccp[.]h"!"wccp/Wccp.h"!' src/wccp/WccpUtil.h
sed -i -E -e 's!"WccpUtil[.]h"!"wccp/WccpUtil.h"!' src/traffic_wccp/wccp_client.cc
sed -i -E -e 's!"[.][.]/[.][.]/proxy/IPAllow.h"!"IPAllow.h"!' proxy/http/remap/RemapConfig.cc
sed -i -E -e 's!"PriorityQueue.h"!"tscore/PriorityQueue.h"!' src/tscore/test_PriorityQueue.cc
sed -i -E -e 's!"BufferWriter.h"!"tscore/BufferWriter.h"!' src/tscore/unit_tests/test_History.cc
sed -i -E -e 's![.][.]/ts/libtsutil.la!$(top_builddir)/src/tscore/libtscore.la'
sed -i -E -e 's!([.][.]/)*ts/libtsutil.la!$(top_builddir)/src/tscore/libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la!' lib/tsconfig/Makefile.am
# Linking fixups
sed -i -E -e '\!traffic_api_cli_remote_LDADD!,\![$][(]top_builddir[])]/src/tscore/libtscore.la \\!a\
$(top_builddir)/src/tscpp/util/libtscpputil.la \\' mgmt/api/Makefile.am
sed -i -E -e '\!libtscore.la \\!a\
$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_via/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_manager/Makefile.inc
sed -i -E -e 's!..top_builddir./src/wccp/libwccp.a!wccp/libwccp.a!' src/traffic_manager/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_server/Makefile.inc
sed -i -E -e '\!libtscore.la$!s![.]la!.la \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' src/traffic_logstats/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_crashlog/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_ctl/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_layout/Makefile.inc
sed -i -E -e '\!libtscore.la$!s![.]la!.la \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' src/traffic_logcat/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_top/Makefile.inc
sed -i -E -e '\!libtscore.la \\!a\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la \\' src/traffic_wccp/Makefile.inc
sed -i -E -e 's!/lib/cppapi/libatscppapi.la!/src/tscpp/api/libtscppapi.la!' plugins/test_cppapi/Makefile.inc
sed -i -E -e '/_la_LDFLAGS/,$d' plugins/experimental/server_push_preload/Makefile.inc
sed -i -E -e '$ a\
experimental_server_push_preload_server_push_preload_la_LDFLAGS = \\\
$(AM_LDFLAGS) \
\
experimental_server_push_preload_server_push_preload_la_LIBADD = \\\
$(top_builddir)/src/tscpp/api/libtscppapi.la \
' plugins/experimental/server_push_preload/Makefile.inc
sed -i -E -e 's`/lib/ts/[.]libs`/src/tscore/.libs`' src/traffic_cache_tool/Makefile.inc
sed -i -E -e 's`/src/tscore/.libs/TextView.o`/src/tscpp/util/.libs/TextView.o`' src/traffic_cache_tool/Makefile.inc
sed -i -E -e 's`-I ..top_srcdir./lib`-I $(abs_top_srcdir)/include`' src/traffic_cache_tool/Makefile.inc
sed -i -E -e 's`[.][.]/[.][.]/lib/ts/apidefs.h`ts/apidefs.h`' plugins/header_rewrite/operators.cc
sed -i -E -e 's! -lssl! $(top_builddir)/src/tscpp/util/libtscpputil.la -lssl!' tools/Makefile.am
sed -i -E -e 's!^libatscppapi.*$!libtscppapi = $(top_builddir)/src/tscpp/api/libtscppapi.la!' example/Makefile.am
sed -i -E -e 's!(/src/tscore/libtscore.la)!\1 $(top_builddir)/src/tscpp/util/libtscpputil.la!' lib/tsconfig/Makefile.am
sed -i -E -e 's!LDADD = libtscore.la!LDADD = libtscore.la $(top_builddir)/src/tscpp/util/libtscpputil.la!' src/tscore/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 $(top_builddir)/src/tscpp/util/libtscpputil.la!' iocore/eventsystem/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 $(top_builddir)/src/tscpp/util/libtscpputil.la!' iocore/net/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' iocore/aio/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' iocore/hostdb/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' proxy/hdrs/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' proxy/http/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' proxy/http2/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' proxy/logging/Makefile.am
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' mgmt/utils/Makefile.am
## plugin fixups
# Things to to be fixed
find plugins \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_defs.h[">]!"tscore/ink_defs.h"!' {} \;
find example \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_defs.h[">]!"tscore/ink_defs.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_config.h[">]!"tscore/ink_config.h"!' {} \;
find example \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_config.h[">]!"tscore/ink_config.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ink_atomic.h[">]!"tscore/ink_atomic.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ink_string.h[">]!"tscore/ink_string.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ink_inet.h[">]!"tscore/ink_inet.h"!' {} \;
find example \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ink_inet.h[">]!"tscore/ink_inet.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_platform.h[">]!"tscore/ink_platform.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ParseRules.h[">]!"tscore/ParseRules.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"](ts/)?I_Version.h[">]!"tscore/I_Version.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"](ts/)?ink_memory.h[">]!"tscore/ink_memory.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/ink_time.h[">]!"tscore/ink_time.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"](ts/)?ink_hrtime.h[">]!"tscore/ink_hrtime.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/IpMap.h[">]!"tscore/IpMap.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/TextView.h[">]!"tscpp/util/TextView.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"](ts/)?CryptoHash.h[">]!"tscore/CryptoHash.h"!' {} \;
find example \( -name '*.cc' -o -name '*.h' -o -name '*.c' \) -exec sed -i -E -e 's![<"]ts/ink_assert.h[">]!"tscore/ink_assert.h"!' {} \;
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"](ts/)?TestBox.h[">]!"tscore/TestBox.h"!' {} \;
# Legit
find plugins \( -name '*.cc' -o -name '*.h' \) -exec sed -i -E -e 's![<"]ts/PostScript.h[">]!"tscpp/util/PostScript.h"!' {} \;
sed -i -E -e 's!unit-tests/!unit_tests/!' plugins/s3_auth/aws_auth_v4.h
sed -i -E -e 's!-I[$][(]abs_top_srcdir[)]/lib!-I$(abs_top_srcdir)/include!' build/plugins.mk
sed -i -E -e 's!(src/tscore/libtscore.la)!\1 \\\
\t$(top_builddir)/src/tscpp/util/libtscpputil.la!' plugins/experimental/sslheaders/Makefile.inc
# Need this to pass the dependency checks in tools
sed -i -E -e 's!iport = atoi[(]port[)];!iport = ts::svtoi(port);!' tools/jtest/jtest.cc
sed -i -E -e '63a\
#include "tscpp/util/TextView.h"' tools/jtest/jtest.cc
## fix up .gitignore
sed -i -E -e 's!^lib/ts/!src/tscore/!' .gitignore
sed -i -E -e 's!^src/tscore/test_tslib!src/tscore/test_libtscore!' .gitignore
sed -i -E -e 's!^src/tscore/test_tsutil!src/tscore/test_tscore!' .gitignore
sed -i -E -e 's!^src/tscore/apidefs.h!include/ts/apidefs.h!' .gitignore
sed -i -E -e 's!^src/tscore/ink_config.h!include/tscore/ink_config.h!' .gitignore
sed -i -E -e '\!^src/tscore/test_MemView!d' .gitignore
sed -i -E -e '\!^src/tscore/test_Scalar!d' .gitignore
sed -i -E -e '\!src/tscore/test_tscore!a\
src/tscpp/util/test_tscpputil' .gitignore
git add include/Makefile.am include/tscpp/api/Makefile.am
git add include/tscpp/util/Makefile.am src/tscpp/util/Makefile.am src/tscpp/util/unit_tests/unit_test_main.cc
git add lib/tsconfig/TsConfigGrammar.h lib/tsconfig/TsConfigGrammar.c
# Doc updates
sed -i -E -e '/breakdown of this guide:/a\
\
:ref:`developer-header-files` \
The header file directory structure, where to find headers for particular tasks.' doc/developer-guide/introduction/index.en.rst
sed -i -E -e '$a\
\
.. toctree::\
:hidden:\
\
header-file-structure.en' doc/developer-guide/introduction/index.en.rst
cat > doc/developer-guide/introduction/header-file-structure.en.rst <<'HERE'
.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license
agreements. See the NOTICE file distributed with this work for additional information regarding
copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the License. You may obtain a
copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the License for the specific language governing permissions and limitations under
the License.
.. include:: ../../common.defs
.. _developer-header-files:
Header Files
************
There are four header directories, each containing header files for different purposes. Three of these
are available to plugins.
"ts"
The C Plugin API. These call functions directly embedded in ``traffic_server`` and therefore have
no explicit linkage.
"tscpp/api"
The C++ Plugin API. These call functions in the ``libtscppapi.so`` library to directly interact with
the running |TS| instance.
"tscpp/util"
C++ utilities. These are standalone headers (although they may depend on other headers in the
same directory). These provide functionality that is used inside the |TS| core logic but has been
demonstrated to be useful for plugins as well [#]_. The functions are in the library
``libtscpputil.so``, although many of the utilities are header only. This library is linked in to
the ``traffic_server`` and ``traffic_manager`` binaries and so linkage may not be needed for a plugin.
This library is independent of the C++ API and can be used with or without that library.
"tscore"
|TS| core header files. These can only be used inside |TS| itself because they either depend on internal
data structures either directly or operationally. This is linked in to the ``traffic_server`` and
``traffic_manager`` binaries therefore has no explicit linkage when used in the core.
Historical
==========
This was a major restructuring the source code layout. The primary goal of this was to unify the include paths
for the core and plugins for these headers, and to make C++ support code used in the core also available to plugins.
Previously plugins in the |TS| codebase used these headers because they could reach over and include them, but
third party plugins could not because the headers were not installed.
"proxy/api/ts" was moved to "include/ts", along with a couple headers from "lib/ts". This consolidates the C plugin API.
The C++ API headers were split from the source and moved to "include/tscpp/api". The source files
were moved to "src/tscpp/api".
The contents of "lib/ts" were broken up and moved to different locations. The headers were moved to
"include/tscore" for core only headers, while headers to be made available to plugins were moved to
"include/tscpp/util". The corresponding source files were moved to "src/tscore" and "src/tscpp/util"
respectively. "libtsutil" was split in to "libtscore" for the core code and "libtscpputil" for shared
code.
Appendix
========
.. rubric:: Footnotes
.. [#]
Primarily by use in the plugins in the |TS| code base.
HERE
git add doc/developer-guide/introduction/index.en.rst
git add doc/developer-guide/introduction/header-file-structure.en.rst