1src = [ 2 'src/main.c', 3 'src/command.c', 4 'src/control_msg.c', 5 'src/controller.c', 6 'src/convert.c', 7 'src/decoder.c', 8 'src/device.c', 9 'src/device_msg.c', 10 'src/file_handler.c', 11 'src/fps_counter.c', 12 'src/input_manager.c', 13 'src/net.c', 14 'src/receiver.c', 15 'src/recorder.c', 16 'src/scrcpy.c', 17 'src/screen.c', 18 'src/server.c', 19 'src/str_util.c', 20 'src/tiny_xpm.c', 21 'src/stream.c', 22 'src/video_buffer.c', 23] 24 25if not get_option('crossbuild_windows') 26 27 # native build 28 dependencies = [ 29 dependency('libavformat'), 30 dependency('libavcodec'), 31 dependency('libavutil'), 32 dependency('sdl2'), 33 ] 34 35else 36 37 # cross-compile mingw32 build (from Linux to Windows) 38 cc = meson.get_compiler('c') 39 40 prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2') 41 sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/bin' 42 sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/lib' 43 sdl2_include_dir = '../prebuilt-deps/' + prebuilt_sdl2 + '/include' 44 45 sdl2 = declare_dependency( 46 dependencies: [ 47 cc.find_library('SDL2', dirs: sdl2_bin_dir), 48 cc.find_library('SDL2main', dirs: sdl2_lib_dir), 49 ], 50 include_directories: include_directories(sdl2_include_dir) 51 ) 52 53 prebuilt_ffmpeg_shared = meson.get_cross_property('prebuilt_ffmpeg_shared') 54 prebuilt_ffmpeg_dev = meson.get_cross_property('prebuilt_ffmpeg_dev') 55 ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_ffmpeg_shared + '/bin' 56 ffmpeg_include_dir = '../prebuilt-deps/' + prebuilt_ffmpeg_dev + '/include' 57 ffmpeg = declare_dependency( 58 dependencies: [ 59 cc.find_library('avcodec-58', dirs: ffmpeg_bin_dir), 60 cc.find_library('avformat-58', dirs: ffmpeg_bin_dir), 61 cc.find_library('avutil-56', dirs: ffmpeg_bin_dir), 62 ], 63 include_directories: include_directories(ffmpeg_include_dir) 64 ) 65 66 dependencies = [ 67 ffmpeg, 68 sdl2, 69 cc.find_library('mingw32') 70 ] 71 72endif 73 74cc = meson.get_compiler('c') 75 76if host_machine.system() == 'windows' 77 src += [ 'src/sys/win/command.c' ] 78 src += [ 'src/sys/win/net.c' ] 79 dependencies += cc.find_library('ws2_32') 80else 81 src += [ 'src/sys/unix/command.c' ] 82 src += [ 'src/sys/unix/net.c' ] 83endif 84 85conf = configuration_data() 86 87# expose the build type 88conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug') 89 90# the version, updated on release 91conf.set_quoted('SCRCPY_VERSION', meson.project_version()) 92 93# the prefix used during configuration (meson --prefix=PREFIX) 94conf.set_quoted('PREFIX', get_option('prefix')) 95 96# build a "portable" version (with scrcpy-server.jar accessible from the same 97# directory as the executable) 98conf.set('PORTABLE', get_option('portable')) 99 100# the default client TCP port for the "adb reverse" tunnel 101# overridden by option --port 102conf.set('DEFAULT_LOCAL_PORT', '27183') 103 104# the default max video size for both dimensions, in pixels 105# overridden by option --max-size 106conf.set('DEFAULT_MAX_SIZE', '0') # 0: unlimited 107 108# the default video bitrate, in bits/second 109# overridden by option --bit-rate 110conf.set('DEFAULT_BIT_RATE', '8000000') # 8Mbps 111 112# enable High DPI support 113conf.set('HIDPI_SUPPORT', get_option('hidpi_support')) 114 115# disable console on Windows 116conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole')) 117 118configure_file(configuration: conf, output: 'config.h') 119 120src_dir = include_directories('src') 121 122if get_option('windows_noconsole') 123 c_args = [ '-mwindows' ] 124 link_args = [ '-mwindows' ] 125else 126 c_args = [] 127 link_args = [] 128endif 129 130executable('scrcpy', src, 131 dependencies: dependencies, 132 include_directories: src_dir, 133 install: true, 134 c_args: c_args, 135 link_args: link_args) 136 137 138### TESTS 139 140tests = [ 141 ['test_cbuf', [ 142 'tests/test_cbuf.c', 143 ]], 144 ['test_control_event_serialize', [ 145 'tests/test_control_msg_serialize.c', 146 'src/control_msg.c', 147 'src/str_util.c' 148 ]], 149 ['test_device_event_deserialize', [ 150 'tests/test_device_msg_deserialize.c', 151 'src/device_msg.c' 152 ]], 153 ['test_strutil', [ 154 'tests/test_strutil.c', 155 'src/str_util.c' 156 ]], 157] 158 159foreach t : tests 160 exe = executable(t[0], t[1], 161 include_directories: src_dir, 162 dependencies: dependencies) 163 test(t[0], exe) 164endforeach 165