Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
103.02k stars 10.01k forks source link

Manual installation instructions #4896

Closed jaybeers closed 2 weeks ago

jaybeers commented 2 weeks ago

Is your feature request related to a problem? Please describe. Currently, the only way to install a locally-built version of scrcpy is to run ./install_release.sh, which then runs sudo ninja install. This results in a system-wide installation without using the distribution's package management.

Describe the solution you'd like I'd like documentation describing the process of installing locally (i.e., within the user's home directory). Ideally this would just mean copying a file or two once the actual build is finished; if it's too complicated for that, then a way to pass an installation prefix directory to the build systems (ninja and meson).

Describe alternatives you've considered I tried running ninga -n -Cbuild-auto install, but the output wasn't helpful:

~/build/scrcpy % ninja -n -Cbuild-auto install
ninja: Entering directory `build-auto'
[0/1] Installing files.
~/build/scrcpy %

Additional context I'm currently using the distribution-packaged (Ubuntu) version of scrcpy, but I've got a second, newer phone that requires a newer version of scrcpy (due to the new phone's newer Android version). I don't mind running them alongside each other, but I don't want to run an arbitrary "make install"-type command that puts who knows what files in who knows which directories. :) The actual build process runs fine, from what I can tell (I'm not familiar with ninja or meson, but I know an obvious error message when I see one and none of those are coming out), and I tried just running the built binary by hand...but it looks like it's got at least one hardcoded path:

~/build/scrcpy % ./build-auto/app/scrcpy -s xxxxxxxxxxx
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO:     -->   (usb)  xxxxxxxxxxx                     device  xxxxxxxxx
INFO:           (usb)  yyyyyyyy                        device  yyyyyyyyyyyyyyyy
stat: No such file or directory
ERROR: '/usr/local/share/scrcpy/scrcpy-server' does not exist or is not a regular file
ERROR: Server connection failed
rom1v commented 2 weeks ago

I'm currently using the distribution-packaged (Ubuntu) version of scrcpy

The packaged version is very very old. You should always run the latest version :wink:

a way to pass an installation prefix directory to the build systems (ninja and meson).

During your meson setup:

meson setup builddir --prefix=/your/prefix/directory
./build-auto/app/scrcpy -s xxxxxxxxxxx

You can run without installing:

./run build-auto -s xxxxxxxxxxx

(check the content of the run script)

jaybeers commented 2 weeks ago

I actually worked this out while I was opening the issue, but it occurred to me that somebody else might benefit from the answer, and having the full question in there would make the whole thing more discoverable, so...

Turns out you can run the executable right out of the build directory; you just have to specify the path to the scrcpy-server file. This file is provided in the build directory, but the scrcpy invocation doesn't look for it there. If you just want a quick and dirty way to run, you can just run this in the build directory:

SCRCPY_SERVER_PATH="./scrcpy-server" ./build-auto/app/scrcpy

I wrote up this simple shell script which should make things a little friendlier; I put mine in ${HOME}/.local/bin/scrcpy-homedir, but it'll work from any directory.

#!/bin/sh

base_directory="${HOME}/build/scrcpy"

###############################################################################
###############################################################################

SCRCPY_SERVER_PATH="${base_directory}/scrcpy-server" ${base_directory}/build-auto/app/scrcpy ${*}

## EOF
########
jaybeers commented 2 weeks ago

You can run without installing:

./run build-auto -s xxxxxxxxxxx

Ah, OK. That seems to produce the same result, but less fiddly than my version. :) Thanks for the help! So, just to close the loop, this is what I'm updating the shell script to:

#!/bin/sh

base_directory="${HOME}/build/scrcpy"

###############################################################################
###############################################################################

${base_directory}/run build-auto ${*}

## EOF
########
rom1v commented 2 weeks ago

But it is still better to build and install.

If x is your builddir:

ninja -Cx
sudo ninja -Cx install

I don't want to run an arbitrary "make install"-type command that puts who knows what files in who knows which directories.

It installs the files documented here

Here are the relevant lines in meson:

https://github.com/Genymobile/scrcpy/blob/206809a99affad9a7aa58fcf7593cea71f48954d/app/meson.build#L177-L193 https://github.com/Genymobile/scrcpy/blob/206809a99affad9a7aa58fcf7593cea71f48954d/server/meson.build#L12-L13

jaybeers commented 2 weeks ago

Ah OK...yeah, that's the info I was looking for.

I made it as far as https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md; too bad I didn't go one more link 'cause "build.md" is linked on that page. :smile:

Excellent; so, it looks like what I'm after is probably to add something to the meson command line so it installs into my ${HOME}/.local prefix.