Refactor build system
The client was built with Meson, the server with Gradle, and were run by
a Makefile.
Add a Meson script for the server (which delegates to Gradle), and a
parent script to build and install both the client and the server to the
system, typically with:
meson --buildtype release build
cd build
ninja
sudo ninja install
In addition, use a separate Makefile to build a "portable" version of
the application (where the client expects the server to be in the
current directory). Typically:
make release-portable
cd dist/scrcpy
./scrcpy
This is especially useful for Windows builds, which are not "installed".
This commit is contained in:
@@ -42,6 +42,22 @@ conf.set('BUILD_DEBUG', get_option('buildtype') == 'debug')
|
||||
# (conf.set_quoted() is not available on old versions of meson)
|
||||
conf.set('SCRCPY_VERSION', '"0.1"')
|
||||
|
||||
# the prefix used during configuration (meson --prefix=PREFIX)
|
||||
conf.set('PREFIX', '"' + get_option('prefix') + '"')
|
||||
|
||||
# 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
|
||||
conf.set('PREFIXED_SERVER_JAR', '"/share/scrcpy/scrcpy-server.jar"')
|
||||
|
||||
# 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 != ''
|
||||
conf.set('OVERRIDE_SERVER_JAR', '"' + override_server_jar + '"')
|
||||
endif
|
||||
|
||||
# the default client TCP port for the "adb reverse" tunnel
|
||||
# overridden by option --port
|
||||
conf.set('DEFAULT_LOCAL_PORT', '27183')
|
||||
@@ -61,7 +77,7 @@ conf.set('SKIP_FRAMES', true)
|
||||
|
||||
configure_file(configuration: conf, input: 'src/config.h.in', output: 'config.h')
|
||||
|
||||
executable('scrcpy', src, dependencies: dependencies)
|
||||
executable('scrcpy', src, dependencies: dependencies, install: true)
|
||||
|
||||
|
||||
### TESTS
|
||||
|
||||
1
app/meson_options.txt
Normal file
1
app/meson_options.txt
Normal file
@@ -0,0 +1 @@
|
||||
option('override_server_jar', type: 'string')
|
||||
@@ -1,5 +1,8 @@
|
||||
#mesondefine BUILD_DEBUG
|
||||
#mesondefine SCRCPY_VERSION
|
||||
#mesondefine PREFIX
|
||||
#mesondefine PREFIXED_SERVER_JAR
|
||||
#mesondefine OVERRIDE_SERVER_JAR
|
||||
#mesondefine DEFAULT_LOCAL_PORT
|
||||
#mesondefine DEFAULT_MAX_SIZE
|
||||
#mesondefine DEFAULT_BIT_RATE
|
||||
|
||||
@@ -4,17 +4,28 @@
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "netutil.h"
|
||||
|
||||
#define SOCKET_NAME "scrcpy"
|
||||
|
||||
static SDL_bool push_server(const char *serial) {
|
||||
#ifdef OVERRIDE_SERVER_JAR
|
||||
# define DEFAULT_SERVER_JAR OVERRIDE_SERVER_JAR
|
||||
#else
|
||||
# define DEFAULT_SERVER_JAR PREFIX PREFIXED_SERVER_JAR
|
||||
#endif
|
||||
|
||||
static const char *get_server_path(void) {
|
||||
const char *server_path = getenv("SCRCPY_SERVER_JAR");
|
||||
if (!server_path) {
|
||||
server_path = "scrcpy-server.jar";
|
||||
server_path = DEFAULT_SERVER_JAR;
|
||||
}
|
||||
process_t process = adb_push(serial, server_path, "/data/local/tmp/scrcpy-server.jar");
|
||||
return server_path;
|
||||
}
|
||||
|
||||
static SDL_bool push_server(const char *serial) {
|
||||
process_t process = adb_push(serial, get_server_path(), "/data/local/tmp/scrcpy-server.jar");
|
||||
return process_check_success(process, "adb push");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user