Add a header-reduction argument to IWYU
This allows to delete non-needed headers from .h files. Ran this on peer_connection.cc to demonstrate. Bug: none Change-Id: I69ce48be25a9778297e521282898c6ac31e7ea6c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254600 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#36170}
This commit is contained in:
parent
d9f6846757
commit
c2a2bef4f7
@ -865,7 +865,6 @@ rtc_source_set("peer_connection") {
|
||||
":usage_pattern",
|
||||
":webrtc_session_description_factory",
|
||||
"../api:async_dns_resolver",
|
||||
"../api:audio_options_api",
|
||||
"../api:libjingle_logging_api",
|
||||
"../api:libjingle_peerconnection_api",
|
||||
"../api:media_stream_interface",
|
||||
@ -876,6 +875,7 @@ rtc_source_set("peer_connection") {
|
||||
"../api:rtp_transceiver_direction",
|
||||
"../api:scoped_refptr",
|
||||
"../api:sequence_checker",
|
||||
"../api:webrtc_key_value_config",
|
||||
"../api/adaptation:resource_adaptation_api",
|
||||
"../api/crypto:options",
|
||||
"../api/rtc_event_log:rtc_event_log",
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/algorithm/container.h"
|
||||
@ -26,7 +25,6 @@
|
||||
#include "api/jsep_ice_candidate.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/rtp_transceiver_direction.h"
|
||||
#include "api/transport/webrtc_key_value_config.h"
|
||||
#include "api/uma_metrics.h"
|
||||
#include "api/video/video_codec_constants.h"
|
||||
#include "call/audio_state.h"
|
||||
|
||||
@ -18,14 +18,11 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/adaptation/resource.h"
|
||||
#include "api/async_dns_resolver.h"
|
||||
#include "api/async_resolver_factory.h"
|
||||
#include "api/audio_options.h"
|
||||
#include "api/candidate.h"
|
||||
#include "api/crypto/crypto_options.h"
|
||||
#include "api/data_channel_interface.h"
|
||||
@ -34,12 +31,10 @@
|
||||
#include "api/jsep.h"
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "api/media_types.h"
|
||||
#include "api/packet_socket_factory.h"
|
||||
#include "api/peer_connection_interface.h"
|
||||
#include "api/rtc_error.h"
|
||||
#include "api/rtc_event_log/rtc_event_log.h"
|
||||
#include "api/rtc_event_log_output.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/rtp_receiver_interface.h"
|
||||
#include "api/rtp_sender_interface.h"
|
||||
#include "api/rtp_transceiver_interface.h"
|
||||
@ -53,15 +48,12 @@
|
||||
#include "api/transport/data_channel_transport_interface.h"
|
||||
#include "api/transport/enums.h"
|
||||
#include "api/turn_customizer.h"
|
||||
#include "api/video/video_bitrate_allocator_factory.h"
|
||||
#include "api/webrtc_key_value_config.h"
|
||||
#include "call/call.h"
|
||||
#include "media/base/media_channel.h"
|
||||
#include "media/base/media_engine.h"
|
||||
#include "p2p/base/ice_transport_internal.h"
|
||||
#include "p2p/base/port.h"
|
||||
#include "p2p/base/port_allocator.h"
|
||||
#include "p2p/base/transport_description.h"
|
||||
#include "pc/channel.h"
|
||||
#include "pc/channel_interface.h"
|
||||
#include "pc/channel_manager.h"
|
||||
#include "pc/connection_context.h"
|
||||
@ -72,23 +64,18 @@
|
||||
#include "pc/peer_connection_internal.h"
|
||||
#include "pc/peer_connection_message_handler.h"
|
||||
#include "pc/rtc_stats_collector.h"
|
||||
#include "pc/rtp_receiver.h"
|
||||
#include "pc/rtp_sender.h"
|
||||
#include "pc/rtp_transceiver.h"
|
||||
#include "pc/rtp_transmission_manager.h"
|
||||
#include "pc/rtp_transport_internal.h"
|
||||
#include "pc/sctp_data_channel.h"
|
||||
#include "pc/sctp_transport.h"
|
||||
#include "pc/sdp_offer_answer.h"
|
||||
#include "pc/session_description.h"
|
||||
#include "pc/stats_collector.h"
|
||||
#include "pc/stream_collection.h"
|
||||
#include "pc/transceiver_list.h"
|
||||
#include "pc/transport_stats.h"
|
||||
#include "pc/usage_pattern.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/copy_on_write_buffer.h"
|
||||
#include "rtc_base/network/sent_packet.h"
|
||||
#include "rtc_base/rtc_certificate.h"
|
||||
#include "rtc_base/ssl_certificate.h"
|
||||
#include "rtc_base/ssl_stream_adapter.h"
|
||||
@ -96,7 +83,6 @@
|
||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||
#include "rtc_base/thread.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
#include "rtc_base/unique_id_generator.h"
|
||||
#include "rtc_base/weak_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
# Set this to 1 to get more debug information.
|
||||
# Set this to 2 to also get a dump of the iwyu tool output.
|
||||
DEBUG=2
|
||||
DEBUG=0
|
||||
|
||||
set -e
|
||||
if [ $DEBUG -gt 0 ]; then
|
||||
@ -26,6 +26,7 @@ fi
|
||||
|
||||
IWYU_TOOL="${IWYU_TOOL:-/usr/bin/iwyu_tool}"
|
||||
FIX_INCLUDE="${FIX_INCLUDE:-/usr/bin/fix_include}"
|
||||
FIX_INCLUDE_ARGS=''
|
||||
IWYU_TOOL_DIR="${IWYU_TOOL_DIR:-tools_webrtc/iwyu}"
|
||||
COMPILE_COMMANDS=''
|
||||
|
||||
@ -34,9 +35,22 @@ error() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts 'c:r' opts; do
|
||||
usage() {
|
||||
echo "Usage: $0 [ -c compile-commands-file.json ] [-r] file.cc"
|
||||
echo "Runs the IWYU and fix-include on a CC file and its associated .h file"
|
||||
echo "Arguments:"
|
||||
echo " -c compile-commands: Compiler command file"
|
||||
echo " -r : Remove non-required includes from .h file"
|
||||
echo " -h : Print this help message"
|
||||
echo "(default command file: out/Default/compile_commands.json - this"
|
||||
echo "will be generated if not present"
|
||||
}
|
||||
|
||||
while getopts 'c:rh' opts; do
|
||||
case "${opts}" in
|
||||
c) COMPILE_COMMANDS="${OPTARG}" ;;
|
||||
r) FIX_INCLUDE_ARGS="${FIX_INCLUDE_ARGS} --nosafe_headers" ;;
|
||||
h) usage; exit 1 ;;
|
||||
*) error "Unexpected option ${opts}" ;;
|
||||
esac
|
||||
done
|
||||
@ -84,7 +98,7 @@ else
|
||||
# In compile_commands.json, the file name is recorded
|
||||
# as a relative path to the build directory.
|
||||
pushd "$(dirname "$COMPILE_COMMANDS")" || error "pushd failed"
|
||||
"$FIX_INCLUDE" < /tmp/includefixes$$ || echo "Some files modified"
|
||||
"$FIX_INCLUDE" $FIX_INCLUDE_ARGS < /tmp/includefixes$$ || echo "Some files modified"
|
||||
popd
|
||||
rm /tmp/includefixes$$
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user