Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run build-wrapper.sh within MSYS2 #2881

Closed
2 tasks done
wiryls opened this issue Dec 15, 2021 · 11 comments
Closed
2 tasks done

Failed to run build-wrapper.sh within MSYS2 #2881

wiryls opened this issue Dec 15, 2021 · 11 comments

Comments

@wiryls
Copy link

wiryls commented Dec 15, 2021

  • I have read the FAQ.
  • I have searched in existing issues.

Environment

  • OS: Windows 10
  • scrcpy version: 1.12 (master branch)
  • installation method: manual build
  • device model: none
  • Android version: none

Describe the bug

I am trying to build scrcpy from source without prebuilt server. Thanks to the docs, it is not painful to set up the environment. But still, I encountered something confusing when executing ninja -Cx.

MSYS2 reported errors:

SOMEBODY@SOMEWHERE MINGW64 /d/workspace/scrcpy_gh
$ ninja -Cx
ninja: Entering directory `x'
[26/45] Generating server/scrcpy-server with a custom command
/bin/bash: D:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh: No such file or directory
[31/45] Compiling C object app/scrcpy.exe.p/src_util_intr.c.obj
FAILED: server/scrcpy-server
"bash" "D:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh" "D:/workspace/scrcpy_gh/server" "server/scrcpy-server" "release"
[44/45] Compiling C object app/scrcpy.exe.p/src_sys_win_process.c.obj
ninja: build stopped: subcommand failed.

I dug it out and found some code in .\x\build.ninja that related to it:

build server/scrcpy-server: CUSTOM_COMMAND  | D$:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh PHONY
 pool = console
 COMMAND = "bash" "D:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh" "D:/workspace/scrcpy_gh/server" "server/scrcpy-server" "release"
 description = Generating$ server/scrcpy-server$ with$ a$ custom$ command

But if i run it manually, there was nothing wrong:

SOMEBODY@SOMEWHERE MINGW64 /d/workspace/scrcpy_gh
$ "bash" "D:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh" "D:/workspace/scrcpy_gh/server" "server/scrcpy-server" "release"
Downloading https://services.gradle.org/distributions/gradle-7.0.2-all.zip
..............10%...............20%...............30%..............40%...............50%...............60%...............70%..............80%...............90%...............100%

Welcome to Gradle 7.0.2!

Here are the highlights of this release:
 - File system watching enabled by default
 - Support for running with and building Java 16 projects
 - Native support for Apple Silicon processors
 - Dependency catalog feature preview

For more details see https://docs.gradle.org/7.0.2/release-notes.html

...

Can anyone give me some help? Why did the scripts fail here?

Update: It seems the path D$:/workspace/scrcpy_gh/server/scripts/build-wrapper.sh is not recognized correctly. But I still don't know why.

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2021

scrcpy version: 1.12 (master branch)

1.21?

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2021

I am trying to build scrcpy from source without prebuilt server.

Does it work at least with the prebuilt server? (for me it works)

However, I don't have a Windows VM with everything ready to build the server with Android currently.

@Biswa96, could you reproduce?

@rom1v
Copy link
Collaborator

rom1v commented Dec 15, 2021

@Biswa96 Sorry, I notified you because I remembered that you have some experience with MSYS2/Windows, without much context :)

The author of this issue reports that a full build (including the server) from MSYS2 fails.

On Windows, I can build with a prebuilt server without issue, but I currently could not test without a prebuilt server (i.e. building the Android server also from MSYS2).

I asked in case you already had an environment with everything available, but if you don't, I'll take time to install an Android environment in my Windows VM.

@Biswa96
Copy link
Contributor

Biswa96 commented Dec 15, 2021

After reading some Stackoverflow answers, I can now build scrcpy-server with AndroidStudio. I ran the commands as your documentation suggests. Ninja can successfully executes gradle build job.

@wiryls
Copy link
Author

wiryls commented Dec 16, 2021

@rom1v , thanks a lot, I often see your answers in scrcpy issues.

Does it work at least with the prebuilt server? (for me it works)

Right now, I build it with a prebuilt server and it works. (But for some reasons, I still need to build without the prebuilt server.)

SOMEBODY@SOMEWHERE MINGW64 /d/workspace/scrcpy_gh
$ meson x --buildtype release --strip -Db_lto=true -Dprebuilt_server="scrcpy-server-v1.21"
The Meson build system
Version: 0.60.2
Source dir: D:/workspace/scrcpy_gh
Build dir: D:/workspace/scrcpy_gh/x
Build type: native build
Project name: scrcpy
Project version: 1.21
C compiler for the host machine: cc (gcc 11.2.0 "cc (Rev5, Built by MSYS2 project) 11.2.0")
C linker for the host machine: cc ld.bfd 2.37
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: C:\tools\msys64\mingw64\bin/pkg-config.EXE (0.29.2)
Run-time dependency libavformat found: YES 58.76.100
Run-time dependency libavcodec found: YES 58.134.100
Run-time dependency libavutil found: YES 56.70.100
Run-time dependency sdl2 found: YES 2.0.18
Library ws2_32 found: YES
Checking for function "strdup" : YES
Checking for function "asprintf" : YES
Checking for function "vasprintf" : YES
Configuring config.h using configuration
Program cp found: YES (C:\tools\msys64\usr\bin/cp.EXE)
Program scripts/run-scrcpy.sh found: YES (bash D:/workspace/scrcpy_gh/scripts/run-scrcpy.sh)
Build targets in project: 3

scrcpy 1.21

  User defined options
    buildtype      : release
    strip          : True
    b_lto          : true
    prebuilt_server: scrcpy-server-v1.21

Found ninja-1.10.2 at C:\tools\msys64\mingw64\bin/ninja.EXE

SOMEBODY@SOMEWHERE MINGW64 /d/workspace/scrcpy_gh
$ ninja -Cx
ninja: Entering directory `x'
[45/45] Linking target app/scrcpy.exe

1.21?

Sorry, I should leave the commit id: 5704ec6967c03510dd7d206e5f59c1e4fd6e10a0 (on master branch)

@wiryls
Copy link
Author

wiryls commented Dec 16, 2021

After reading some Stackoverflow answers, I can now build scrcpy-server with AndroidStudio. I ran the commands as your documentation suggests. Ninja can successfully executes gradle build job.

@Biswa96 Sounds like good news to me! Thanks for your support, and would you like to share the steps or problems encountered?

(I encountered a bunch of things such as OpenJDK 17 is not supported by Gradle 7.0.x. And it also takes me some time to find out and purge the .gradle cache files.)

@Biswa96
Copy link
Contributor

Biswa96 commented Dec 16, 2021

These command may differ in your case. I have installed Android Studio from ZIP file. I just added these environments.

export ANDROID_SDK_ROOT=/d/AndroidSDK
export JAVA_HOME=/d/AndroidStudio/jre
export PATH=/d/AndroidStudio/jre:$PATH

And then run meson and ninja command as mentioned in docs.

@wiryls
Copy link
Author

wiryls commented Dec 16, 2021

@rom1v @Biswa96 thank you two for helping me. After reading ninja docs and do some tests, finally, I find the reason.

When running the following scripts (.\x\build.ninja):

build server/scrcpy-server: CUSTOM_COMMAND  | D$:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh PHONY
 pool = console
 COMMAND = "bash" "D:/workspace/scrcpy_gh/server/./scripts/build-wrapper.sh" "D:/workspace/scrcpy_gh/server" "server/scrcpy-server" "release"
 description = Generating$ server/scrcpy-server$ with$ a$ custom$ command

Ninja strangely starts using the bash from WSL2 instead of MSYS2, so it fails to locate build-wrapper.sh and reports No such file or directory.

@wiryls wiryls closed this as completed Dec 16, 2021
@Biswa96
Copy link
Contributor

Biswa96 commented Dec 16, 2021

I don't have a Windows VM with everything ready to build the server with Android currently.

Would it be better if a CI script is added for msys2 windows build? Though the .exe file will be dynamically linked with ffmpeg and sdl.

@rom1v
Copy link
Collaborator

rom1v commented Dec 18, 2021

In theory, maybe, but I don't have a CI yet (for any platform). There is #1709, but there were still issues (if checkstyle was enabled it did not work for some reason), and I did not work on it since then.

@Biswa96
Copy link
Contributor

Biswa96 commented Dec 25, 2021

Just realized that I can reproduce this issue in my PC. I generally delete bash, ssh etc. from System32 to workaround any conflict with msys2 and cygwin. Here is the output if system32/bash.exe present:

Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit https://aka.ms/wsl2-install
FAILED: server/scrcpy-server
"bash" "D:/scrcpy/server/./scripts/build-wrapper.sh" "D:/scrcpy/server" "server/scrcpy-server" "release"
ninja: build stopped: subcommand failed.

GitHub Actions CI also shows same error with msys2 environment. I assume that the issue comes from find_program() in server/meson.build file. Is it possible to invoke gradle from meson instead of going through a shell script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants