forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiche.genrule_cmd
71 lines (57 loc) · 3.92 KB
/
quiche.genrule_cmd
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
#!/bin/bash
set -e
# This script is invoked from quiche.BUILD to tweak QUICHE source files into a
# form usable by Envoy. Transformations performed here:
#
# - Move subtree under quiche/ base dir, for clarity in #include statements.
# - Rewrite include directives for platform/impl files to point to the directory
# containing Envoy's QUICHE platform implementation.
# - Fix include directives for non-platform/impl files to remove
# "net/third_party" from the path. (This is an artifact of Chromium source
# tree structure.)
# Determine base directory of unmodified QUICHE source files. In practice, this
# ends up being "external/com_googlesource_quiche".
src_base_dir=$$(dirname $$(dirname $$(dirname $(rootpath quic/core/quic_constants.h))))
# sed commands to apply to each source file.
cat <<EOF >sed_commands
# Rewrite include directives for testonly platform impl files.
/^#include/ s!net/http2/platform/impl/http2_reconstruct_object_impl.h!test/extensions/quic_listeners/quiche/platform/http2_reconstruct_object_impl.h!
/^#include/ s!net/quic/platform/impl/quic_expect_bug_impl.h!test/extensions/quic_listeners/quiche/platform/quic_expect_bug_impl.h!
/^#include/ s!net/quic/platform/impl/quic_mock_log_impl.h!test/extensions/quic_listeners/quiche/platform/quic_mock_log_impl.h!
/^#include/ s!net/quic/platform/impl/quic_port_utils_impl.h!test/extensions/quic_listeners/quiche/platform/quic_port_utils_impl.h!
/^#include/ s!net/quic/platform/impl/quic_sleep_impl.h!test/extensions/quic_listeners/quiche/platform/quic_sleep_impl.h!
/^#include/ s!net/quic/platform/impl/quic_system_event_loop_impl.h!test/extensions/quic_listeners/quiche/platform/quic_system_event_loop_impl.h!
/^#include/ s!net/quic/platform/impl/quic_test_impl.h!test/extensions/quic_listeners/quiche/platform/quic_test_impl.h!
/^#include/ s!net/quic/platform/impl/quic_test_mem_slice_vector_impl.h!test/extensions/quic_listeners/quiche/platform/quic_test_mem_slice_vector_impl.h!
/^#include/ s!net/quic/platform/impl/quic_test_output_impl.h!test/extensions/quic_listeners/quiche/platform/quic_test_output_impl.h!
/^#include/ s!net/quic/platform/impl/quic_thread_impl.h!test/extensions/quic_listeners/quiche/platform/quic_thread_impl.h!
/^#include/ s!net/quiche/common/platform/impl/quiche_test_impl.h!test/extensions/quic_listeners/quiche/platform/quiche_test_impl.h!
/^#include/ s!net/spdy/platform/impl/spdy_test_helpers_impl.h!test/extensions/quic_listeners/quiche/platform/spdy_test_helpers_impl.h!
/^#include/ s!net/spdy/platform/impl/spdy_test_impl.h!test/extensions/quic_listeners/quiche/platform/spdy_test_impl.h!
# Rewrite include directives for platform impl files.
/^#include/ s!net/(http2|spdy|quic|quiche/common)/platform/impl/!extensions/quic_listeners/quiche/platform/!
# Rewrite include directives for epoll_server platform impl files.
/^#include/ s!net/tools/epoll_server/platform/impl!test/extensions/quic_listeners/quiche/platform/!
# Strip "net/third_party" from include directives to other QUICHE files.
/^#include/ s!net/third_party/quiche/src/!quiche/!
# Rewrite gmock & gtest includes.
/^#include/ s!testing/gmock/include/gmock/!gmock/!
/^#include/ s!testing/gtest/include/gtest/!gtest/!
# Rewrite third_party includes.
/^#include/ s!third_party/boringssl/src/include/!!
/^#include/ s!third_party/zlib/zlib!zlib!
/^import/ s!cached_network_parameters!quiche/quic/core/proto/cached_network_parameters!
# Rewrite #pragma clang
/^#pragma/ s!clang!GCC!
/^#pragma/ s!-Weverything!-Wall!
EOF
for src_file in $(SRCS); do
# Extract relative path (e.g. "quic/core/quic_utils.cc") from full path in
# src_path (e.g. "external/com_googlesource_quiche/quic/core/quic_utils.cc").
src_path="$${src_file#$$src_base_dir/}"
# Map to output file with quiche/ base directory inserted in path.
out_file="$(@D)/quiche/$$src_path"
mkdir -p "$$(dirname "$$out_file")"
# Apply text substitutions. -E ensures consistent behavior on Linux vs. OS X.
sed -E -f sed_commands "$$src_file" > "$$out_file"
done