Skip to content

Commit

Permalink
Cleanup includes
Browse files Browse the repository at this point in the history
Improved manually with the help of neovim LSP warnings and iwyu:

    iwyu -Ibuilddir/app/ -Iapp/src/ app/src/XXX.c
  • Loading branch information
rom1v committed Dec 23, 2024
1 parent 5b1229a commit af15c72
Show file tree
Hide file tree
Showing 110 changed files with 225 additions and 151 deletions.
5 changes: 3 additions & 2 deletions app/src/adb/adb.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include "adb_device.h"
#include "adb_parser.h"
#include "adb/adb_device.h"
#include "adb/adb_parser.h"
#include "util/env.h"
#include "util/file.h"
#include "util/log.h"
Expand Down
2 changes: 1 addition & 1 deletion app/src/adb/adb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdbool.h>
#include <inttypes.h>

#include "adb_device.h"
#include "adb/adb_device.h"
#include "util/intr.h"

#define SC_ADB_NO_STDOUT (1 << 0)
Expand Down
1 change: 0 additions & 1 deletion app/src/adb/adb_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "common.h"

#include <stdbool.h>
#include <stddef.h>

#include "util/vector.h"

Expand Down
1 change: 1 addition & 0 deletions app/src/adb/adb_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

#include "util/log.h"
#include "util/str.h"
Expand Down
4 changes: 2 additions & 2 deletions app/src/adb/adb_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include "common.h"

#include <stddef.h>
#include <stdbool.h>

#include "adb_device.h"
#include "adb/adb_device.h"

/**
* Parse the available devices from the output of `adb devices`
Expand Down
4 changes: 2 additions & 2 deletions app/src/adb/adb_tunnel.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "adb_tunnel.h"

#include <assert.h>
#include <inttypes.h>

#include "adb.h"
#include "adb/adb.h"
#include "util/log.h"
#include "util/net_intr.h"
#include "util/process_intr.h"

static bool
listen_on_port(struct sc_intr *intr, sc_socket socket, uint16_t port) {
Expand Down
4 changes: 1 addition & 3 deletions app/src/audio_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

#include "common.h"

#include <stdatomic.h>
#include <stdbool.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_audio.h>

#include "audio_regulator.h"
#include "trait/frame_sink.h"
Expand Down
4 changes: 4 additions & 0 deletions app/src/audio_regulator.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "audio_regulator.h"

#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>

Expand Down
2 changes: 2 additions & 0 deletions app/src/audio_regulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libswresample/swresample.h>
#include "util/audiobuf.h"
Expand Down
2 changes: 2 additions & 0 deletions app/src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "options.h"
Expand All @@ -13,6 +14,7 @@
#include "util/str.h"
#include "util/strbuf.h"
#include "util/term.h"
#include "util/tick.h"

#define STR_IMPL_(x) #x
#define STR(x) STR_IMPL_(x)
Expand Down
8 changes: 3 additions & 5 deletions app/src/decoder.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#include "decoder.h"

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/channel_layout.h>
#include <errno.h>
#include <libavcodec/packet.h>
#include <libavutil/avutil.h>

#include "events.h"
#include "trait/frame_sink.h"
#include "util/log.h"

/** Downcast packet_sink to decoder */
Expand Down
6 changes: 2 additions & 4 deletions app/src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

#include "common.h"

#include <libavcodec/avcodec.h>

#include "trait/frame_source.h"
#include "trait/packet_sink.h"

#include <stdbool.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

struct sc_decoder {
struct sc_packet_sink packet_sink; // packet sink trait
struct sc_frame_source frame_source; // frame source trait
Expand Down
4 changes: 1 addition & 3 deletions app/src/delay_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

#include <assert.h>
#include <stdlib.h>

#include <libavutil/avutil.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>

#include "util/log.h"

Expand Down
1 change: 1 addition & 0 deletions app/src/delay_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common.h"

#include <stdbool.h>
#include <libavutil/frame.h>

#include "clock.h"
#include "trait/frame_source.h"
Expand Down
7 changes: 2 additions & 5 deletions app/src/demuxer.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include "demuxer.h"

#include <assert.h>
#include <inttypes.h>
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/time.h>
#include <unistd.h>

#include "decoder.h"
#include "events.h"
#include "packet_merger.h"
#include "recorder.h"
#include "util/binary.h"
#include "util/log.h"

Expand Down
4 changes: 0 additions & 4 deletions app/src/demuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
#include "common.h"

#include <stdbool.h>
#include <stdint.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

#include "trait/packet_source.h"
#include "trait/packet_sink.h"
#include "util/net.h"
#include "util/thread.h"

Expand Down
4 changes: 2 additions & 2 deletions app/src/device_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include "common.h"

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/types.h>

#define DEVICE_MSG_MAX_SIZE (1 << 18) // 256k
// type: 1 byte; length: 4 bytes
Expand Down
2 changes: 2 additions & 0 deletions app/src/display.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "display.h"

#include <assert.h>
#include <inttypes.h>
#include <string.h>
#include <libavutil/pixfmt.h>

#include "util/log.h"
Expand Down
3 changes: 2 additions & 1 deletion app/src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include "common.h"

#include <stdbool.h>
#include <libavformat/avformat.h>
#include <stdint.h>
#include <libavutil/frame.h>
#include <SDL2/SDL.h>

#include "coords.h"
Expand Down
2 changes: 2 additions & 0 deletions app/src/events.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "events.h"

#include <assert.h>

#include "util/log.h"
#include "util/thread.h"

Expand Down
2 changes: 1 addition & 1 deletion app/src/file_pusher.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "file_pusher.h"

#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include "adb/adb.h"
#include "util/log.h"
#include "util/process_intr.h"

#define DEFAULT_PUSH_TARGET "/sdcard/Download/"

Expand Down
1 change: 1 addition & 0 deletions app/src/fps_counter.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "fps_counter.h"

#include <assert.h>
#include <stdint.h>

#include "util/log.h"

Expand Down
2 changes: 1 addition & 1 deletion app/src/fps_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include <stdatomic.h>
#include <stdbool.h>
#include <stdint.h>

#include "util/thread.h"
#include "util/tick.h"

struct sc_fps_counter {
sc_thread thread;
Expand Down
2 changes: 0 additions & 2 deletions app/src/frame_buffer.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "frame_buffer.h"

#include <assert.h>
#include <libavutil/avutil.h>
#include <libavformat/avformat.h>

#include "util/log.h"

Expand Down
1 change: 1 addition & 0 deletions app/src/frame_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common.h"

#include <stdbool.h>
#include <libavutil/frame.h>

#include "util/thread.h"

Expand Down
1 change: 1 addition & 0 deletions app/src/hid/hid_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "common.h"

#include <stddef.h>
#include <stdint.h>

#define SC_HID_MAX_SIZE 15
Expand Down
2 changes: 2 additions & 0 deletions app/src/hid/hid_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <assert.h>
#include <inttypes.h>
#include <stddef.h>
#include <sys/types.h>

#include "util/binary.h"
#include "util/log.h"
Expand Down
1 change: 1 addition & 0 deletions app/src/hid/hid_gamepad.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common.h"

#include <stdbool.h>
#include <stdint.h>

#include "hid/hid_event.h"
#include "input_events.h"
Expand Down
1 change: 1 addition & 0 deletions app/src/hid/hid_keyboard.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "hid_keyboard.h"

#include <assert.h>
#include <string.h>

#include "util/log.h"
Expand Down
1 change: 1 addition & 0 deletions app/src/hid/hid_keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common.h"

#include <stdbool.h>
#include <stdint.h>

#include "hid/hid_event.h"
#include "input_events.h"
Expand Down
2 changes: 2 additions & 0 deletions app/src/hid/hid_mouse.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "hid_mouse.h"

#include <stdint.h>

// 1 byte for buttons + padding, 1 byte for X position, 1 byte for Y position,
// 1 byte for wheel motion
#define SC_HID_MOUSE_INPUT_SIZE 4
Expand Down
2 changes: 0 additions & 2 deletions app/src/hid/hid_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

#include "common.h"

#include <stdbool.h>

#include "hid/hid_event.h"
#include "input_events.h"

Expand Down
11 changes: 8 additions & 3 deletions app/src/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@

#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavutil/pixdesc.h>
#include <libavutil/pixfmt.h>
#include <SDL2/SDL.h>

#include "config.h"
#include "compat.h"
#include "util/env.h"
#include "util/file.h"
#ifdef PORTABLE
# include "util/file.h"
#endif
#include "util/log.h"
#include "util/str.h"

#define SCRCPY_PORTABLE_ICON_FILENAME "icon.png"
#define SCRCPY_DEFAULT_ICON_PATH \
Expand Down
4 changes: 1 addition & 3 deletions app/src/icon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

#include "common.h"

#include <stdbool.h>
#include <SDL2/SDL.h>
#include <libavformat/avformat.h>
#include <SDL2/SDL_surface.h>

SDL_Surface *
scrcpy_icon_load(void);
Expand Down
1 change: 0 additions & 1 deletion app/src/input_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <SDL2/SDL_events.h>

#include "coords.h"
#include "options.h"

/* The representation of input events in scrcpy is very close to the SDL API,
* for simplicity.
Expand Down
6 changes: 5 additions & 1 deletion app/src/input_manager.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include "input_manager.h"

#include <assert.h>
#include <SDL2/SDL_keycode.h>
#include <stdlib.h>
#include <string.h>
#include <SDL2/SDL.h>

#include "android/input.h"
#include "android/keycodes.h"
#include "input_events.h"
#include "screen.h"
#include "shortcut_mod.h"
Expand Down
Loading

0 comments on commit af15c72

Please sign in to comment.