meson.build 4.6 KB
Newer Older
R
Romain Vimont 已提交
1
src = [
R
Romain Vimont 已提交
2
    'src/main.c',
R
Romain Vimont 已提交
3
    'src/command.c',
R
Romain Vimont 已提交
4
    'src/control_msg.c',
R
Romain Vimont 已提交
5
    'src/controller.c',
R
Romain Vimont 已提交
6
    'src/decoder.c',
7
    'src/device.c',
R
Romain Vimont 已提交
8
    'src/device_msg.c',
9
    'src/event_converter.c',
N
npes87184 已提交
10
    'src/file_handler.c',
11 12
    'src/fps_counter.c',
    'src/input_manager.c',
13
    'src/net.c',
R
Romain Vimont 已提交
14
    'src/receiver.c',
R
Romain Vimont 已提交
15
    'src/recorder.c',
R
Romain Vimont 已提交
16
    'src/scrcpy.c',
17
    'src/screen.c',
R
Romain Vimont 已提交
18
    'src/server.c',
19 20
    'src/str_util.c',
    'src/tiny_xpm.c',
R
Romain Vimont 已提交
21
    'src/stream.c',
22
    'src/video_buffer.c',
R
Romain Vimont 已提交
23 24
]

25
if not get_option('crossbuild_windows')
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

    # native build
    dependencies = [
        dependency('libavformat'),
        dependency('libavcodec'),
        dependency('libavutil'),
        dependency('sdl2'),
    ]

else

    # cross-compile mingw32 build (from Linux to Windows)
    cc = meson.get_compiler('c')

    prebuilt_sdl2 = meson.get_cross_property('prebuilt_sdl2')
    sdl2_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/bin'
    sdl2_lib_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_sdl2 + '/lib'
    sdl2_include_dir = '../prebuilt-deps/' + prebuilt_sdl2 + '/include'

    sdl2 = declare_dependency(
        dependencies: [
            cc.find_library('SDL2', dirs: sdl2_bin_dir),
            cc.find_library('SDL2main', dirs: sdl2_lib_dir),
        ],
        include_directories: include_directories(sdl2_include_dir)
    )

    prebuilt_ffmpeg_shared = meson.get_cross_property('prebuilt_ffmpeg_shared')
    prebuilt_ffmpeg_dev = meson.get_cross_property('prebuilt_ffmpeg_dev')
    ffmpeg_bin_dir = meson.current_source_dir() + '/../prebuilt-deps/' + prebuilt_ffmpeg_shared + '/bin'
    ffmpeg_include_dir = '../prebuilt-deps/' + prebuilt_ffmpeg_dev + '/include'
    ffmpeg = declare_dependency(
        dependencies: [
            cc.find_library('avcodec-58', dirs: ffmpeg_bin_dir),
            cc.find_library('avformat-58', dirs: ffmpeg_bin_dir),
            cc.find_library('avutil-56', dirs: ffmpeg_bin_dir),
        ],
        include_directories: include_directories(ffmpeg_include_dir)
    )

    dependencies = [
        ffmpeg,
        sdl2,
        cc.find_library('mingw32')
    ]

endif
R
Romain Vimont 已提交
73

74 75 76 77 78 79 80 81 82 83 84
cc = meson.get_compiler('c')

if host_machine.system() == 'windows'
    src += [ 'src/sys/win/command.c' ]
    src += [ 'src/sys/win/net.c' ]
    dependencies += cc.find_library('ws2_32')
else
    src += [ 'src/sys/unix/command.c' ]
    src += [ 'src/sys/unix/net.c' ]
endif

85 86
conf = configuration_data()

87 88 89
# expose the build type
conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug')

R
Romain Vimont 已提交
90
# the version, updated on release
91
conf.set_quoted('SCRCPY_VERSION', meson.project_version())
R
Romain Vimont 已提交
92

R
Romain Vimont 已提交
93
# the prefix used during configuration (meson --prefix=PREFIX)
R
Romain Vimont 已提交
94
conf.set_quoted('PREFIX', get_option('prefix'))
R
Romain Vimont 已提交
95

96
# build a "portable" version (with scrcpy-server accessible from the same
R
Romain Vimont 已提交
97
# directory as the executable)
98
conf.set('PORTABLE', get_option('portable'))
R
Romain Vimont 已提交
99

100 101 102 103 104 105 106 107 108 109
# the default client TCP port for the "adb reverse" tunnel
# overridden by option --port
conf.set('DEFAULT_LOCAL_PORT', '27183')

# the default max video size for both dimensions, in pixels
# overridden by option --max-size
conf.set('DEFAULT_MAX_SIZE', '0')  # 0: unlimited

# the default video bitrate, in bits/second
# overridden by option --bit-rate
R
Romain Vimont 已提交
110
conf.set('DEFAULT_BIT_RATE', '8000000')  # 8Mbps
111

112 113 114
# enable High DPI support
conf.set('HIDPI_SUPPORT', get_option('hidpi_support'))

115 116 117
# disable console on Windows
conf.set('WINDOWS_NOCONSOLE', get_option('windows_noconsole'))

118 119 120
# run a server debugger and wait for a client to be attached
conf.set('SERVER_DEBUGGER', get_option('server_debugger'))

R
Romain Vimont 已提交
121
configure_file(configuration: conf, output: 'config.h')
122

R
Romain Vimont 已提交
123
src_dir = include_directories('src')
124 125 126 127 128 129 130 131 132

if get_option('windows_noconsole')
    c_args = [ '-mwindows' ]
    link_args = [ '-mwindows' ]
else
    c_args = []
    link_args = []
endif

133 134 135 136 137 138
executable('scrcpy', src,
           dependencies: dependencies,
           include_directories: src_dir,
           install: true,
           c_args: c_args,
           link_args: link_args)
R
Romain Vimont 已提交
139

Y
yangfl 已提交
140 141
install_man('scrcpy.1')

R
Romain Vimont 已提交
142 143 144 145

### TESTS

tests = [
R
Romain Vimont 已提交
146 147 148
    ['test_cbuf', [
        'tests/test_cbuf.c',
    ]],
149
    ['test_control_event_serialize', [
R
Romain Vimont 已提交
150 151
        'tests/test_control_msg_serialize.c',
        'src/control_msg.c',
152
        'src/str_util.c'
153
    ]],
R
Romain Vimont 已提交
154
    ['test_device_event_deserialize', [
R
Romain Vimont 已提交
155 156
        'tests/test_device_msg_deserialize.c',
        'src/device_msg.c'
R
Romain Vimont 已提交
157
    ]],
R
Romain Vimont 已提交
158 159 160
    ['test_queue', [
        'tests/test_queue.c',
    ]],
161 162 163 164
    ['test_strutil', [
        'tests/test_strutil.c',
        'src/str_util.c'
    ]],
R
Romain Vimont 已提交
165 166 167
]

foreach t : tests
168 169 170
    exe = executable(t[0], t[1],
                     include_directories: src_dir,
                     dependencies: dependencies)
R
Romain Vimont 已提交
171 172
    test(t[0], exe)
endforeach