meson.build 2.9 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/controlevent.c',
R
Romain Vimont 已提交
5
    'src/controller.c',
R
Romain Vimont 已提交
6
    'src/convert.c',
R
Romain Vimont 已提交
7
    'src/decoder.c',
8
    'src/device.c',
R
Romain Vimont 已提交
9
    'src/fpscounter.c',
R
Romain Vimont 已提交
10
    'src/frames.c',
11
    'src/inputmanager.c',
R
Romain Vimont 已提交
12
    'src/lockutil.c',
13
    'src/net.c',
R
Romain Vimont 已提交
14
    'src/scrcpy.c',
15
    'src/screen.c',
R
Romain Vimont 已提交
16
    'src/server.c',
R
Romain Vimont 已提交
17
    'src/strutil.c',
R
Romain Vimont 已提交
18
    'src/tinyxpm.c',
R
Romain Vimont 已提交
19 20 21 22 23 24 25 26 27
]

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

28 29 30 31 32 33 34 35 36 37 38
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

39 40
conf = configuration_data()

41 42 43
# expose the build type
conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug')

R
Romain Vimont 已提交
44
# the version, updated on release
R
Romain Vimont 已提交
45
conf.set_quoted('SCRCPY_VERSION', '0.1')
R
Romain Vimont 已提交
46

R
Romain Vimont 已提交
47
# the prefix used during configuration (meson --prefix=PREFIX)
R
Romain Vimont 已提交
48
conf.set_quoted('PREFIX', get_option('prefix'))
R
Romain Vimont 已提交
49 50 51 52

# the path of the server, which will be appended to the prefix
# ignored if OVERRIDE_SERVER_JAR if defined
# must be consistent with the install_dir in server/meson.build
R
Romain Vimont 已提交
53
conf.set_quoted('PREFIXED_SERVER_JAR', '/share/scrcpy/scrcpy-server.jar')
R
Romain Vimont 已提交
54 55 56 57 58 59

# the path of the server to be used "as is"
# this is useful for building a "portable" version (with the server in the same
# directory as the client)
override_server_jar = get_option('override_server_jar')
if override_server_jar != ''
R
Romain Vimont 已提交
60 61 62 63
    conf.set_quoted('OVERRIDE_SERVER_JAR', override_server_jar)
else
    # undefine it
    conf.set('OVERRIDE_SERVER_JAR', false)
R
Romain Vimont 已提交
64 65
endif

66 67 68 69 70 71 72 73 74 75 76 77
# 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
conf.set('DEFAULT_BIT_RATE', '4000000')  # 4Mbps

78 79 80
# whether the app should always display the most recent available frame, even
# if the previous one has not been displayed
# SKIP_FRAMES improves latency at the cost of framerate
81
conf.set('SKIP_FRAMES', get_option('skip_frames'))
82

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

R
Romain Vimont 已提交
85
executable('scrcpy', src, dependencies: dependencies, install: true)
R
Romain Vimont 已提交
86 87 88 89 90 91


### TESTS

tests = [
    ['test_control_event_queue', ['tests/test_control_event_queue.c', 'src/controlevent.c']],
92
    ['test_control_event_serialize', ['tests/test_control_event_serialize.c', 'src/controlevent.c']],
R
Romain Vimont 已提交
93
    ['test_strutil', ['tests/test_strutil.c', 'src/strutil.c']],
R
Romain Vimont 已提交
94 95 96 97 98 99 100 101
]

src_dir = include_directories('src')

foreach t : tests
    exe = executable(t[0], t[1], include_directories: src_dir, dependencies: dependencies)
    test(t[0], exe)
endforeach