nmeum / android-tools

Unoffical CMake-based build system for android command line utilities
Apache License 2.0
177 stars 51 forks source link

How to compile with Cygwin64 #98

Open lars18th opened 1 year ago

lars18th commented 1 year ago

Hi,

I want to compile this project using Cygwin64. The reason is to obtain binaries based on Linux sources in Windows. I know that the Windows versions are included in the package. But the code is different, so I really need to have a Windows binary linked to cygwin1.dll

So, I've found some troubles, compiling it and I request your help:

  1. The missing go compiler in the Cygwin environment. Because this compiler is missing in the packages, I've installed the Windows version. It's accessible to the Cygwin shell and also to WSL (I want to check first compiling in WSL with the Go windows version). Here the command to configure the CMake with Go for windows:
    • WSL: cmake -DGO_EXECUTABLE=/mnt/e/Go/bin/go.exe ..
    • Cygwin64: cmake -DGO_EXECUTABLE=/cygdrive/E/Go/bin/go.exe ..
  2. This pass all the configuration phase when the needed libraries and tools are installed. However, when compiling in WSL I see this error: go: RLock \\wsl$\Ubuntu\home\dani\dev\android-tools\android-tools-33.0.3p1\vendor\boringssl\go.mod: Incorrect function. So I suspect that when the compiling will arrive to this point in the Cygwin64 environment the same error will appears. Any idea to fix this problem? Or almost how to compile with an external go compiler (missing in Cygwin64). Or how to overcome the compilation of the boringssl that is the only part that requires the Go compiler?
  3. Another problem is the compilation of some code with the Cygwin64 toolchain. For example, I obtain this:
    [  1%] Building CXX object vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o
    /home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp: In the function ‘int android_log_addFilterString(AndroidLogFormat*, const char*)’:
    /home/user/adb/android-tools-33.0.3p1/vendor/logging/liblog/logprint.cpp:465:27: error: ‘strsep’ was not declared in this scope; did you mean ‘strstr’?
    465 |   while (NULL != (p_ret = strsep(&p_cur, " \t,"))) {
      |                           ^~~~~~
      |                           strstr
    make[2]: *** [vendor/CMakeFiles/liblog.dir/build.make:160: vendor/CMakeFiles/liblog.dir/logging/liblog/logprint.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:539: vendor/CMakeFiles/liblog.dir/all] Error 2
    make: *** [Makefile:156: all] Error 2

    Any idea to fix this?

I hope you want to help me to compile this package with Cygwin. Thank you.

Biswa96 commented 1 year ago

Do you want native Windows executable?

lars18th commented 1 year ago

Do you want native Windows executable?

Native Windows? NO (for this the stock ADB.EXE from Google exists). Native using "cygwin1.dll", YES. It's not the same.

Biswa96 commented 1 year ago

I have compiled this project with mingw toolchain, cygwin is not required.

lars18th commented 1 year ago

I have compiled this project with mingw toolchain, cygwin is not required.

OK. Please, share the binaries. I'll test them.

Biswa96 commented 1 year ago

I can not provide it right now, maybe tomorrow. I have compiled this project in msys2/mingw toolchain. The android-tools programs depend on some of those shared libraries.

lars18th commented 1 year ago

OK, I'll wait until you provide them. Perhaps if you want then could share as release in your android-tools fork. Anyway, perhaps it will be interesting to provide a guide to compile with a msys2/mingw toolchain.

Thank you bro!

anatol commented 1 year ago

@Biswa96 is there any chance you could provide the patches and build instructions required for the mingw/windows port?

lars18th commented 1 year ago

Hi @Biswa96 ,

Any way, I feel it will be interesting to complete the compilation using the external go compiler. This will help to compile the full package (in fact only the boringssl package that is the only module that requires a go compiler) for other platforms that perhaps will not have accessible this compiler and can be compiled cross-compiling.

You agree?

Biswa96 commented 1 year ago

I did not understand what you are asking. msys2/mingw repository provides all the dependencies and tools we need for adb and fastboot.

lars18th commented 1 year ago

Hi @Biswa96 ,

I'm testing the binaries. After getting all correct .DLLs (from different mingw-w64-ucrt-x86_64-* packages) the ADB.EXE tool seems to work. However, I need to change some part to fix a bug. In order to compile your binaries: Do you have any docker image for it?

Thank you.

Biswa96 commented 1 year ago

The Windows port of android-tools package is now available in msys2 pacman repository. See https://packages.msys2.org/base/mingw-w64-android-tools

Some patches are added on top of this repository for the Windows port. Those patches can be added here. One of main blocker is the https://android.googlesource.com/platform/development.git repository. Only a fraction of that repository is used for Windows port. Should it be added as git submodule or as any other means? Here is that repo size.

$ du -d 0 -h development/
212M    development/  <--- not required entirely

$ du -d 0 -h development/host/windows/usb/
426K    development/host/windows/usb/  <--- requires only this
lars18th commented 1 year ago

Hi @Biswa96 ,

A step-by-step how to description of how to compile the package with msys2 will be desirable. I want to fully compile "android-tools" from scratch for Windows MSYS2 target. And I've no idea. What I need is to modify something in the source code of the adb tool. Please could do you help?

Thank you.

Biswa96 commented 1 year ago

A step-by-step how to description of how to compile the package with msys2 will be desirable.

That discussion would be huge and off-topic here. You have to be familiar with pacman packages and read most of the pages in https://wiki.archlinux.org/ and https://www.msys2.org/

lars18th commented 1 year ago

Hi @Biswa96 ,

The information that I'm searching it's already writed by you: https://github.com/msys2/MINGW-packages/issues/17531

Thanl you! 👍

lars18th commented 1 year ago

Hi,

To anyone that need this information, here a simple how to compile android-tools for Windows:

Note: These binaries are not statically linked. Therefore they can only run inside the MSYS2 environment.

I hope this helps. Regards.