mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
[docs] update Android / Conan dev docs
This commit is contained in:
parent
61093ab027
commit
d139d093a6
4
CI/conan/android-32-ndk
Normal file
4
CI/conan/android-32-ndk
Normal file
@ -0,0 +1,4 @@
|
||||
include(android-32)
|
||||
|
||||
[tool_requires]
|
||||
android-ndk/r25c
|
4
CI/conan/android-64-ndk
Normal file
4
CI/conan/android-64-ndk
Normal file
@ -0,0 +1,4 @@
|
||||
include(android-64)
|
||||
|
||||
[tool_requires]
|
||||
android-ndk/r25c
|
@ -36,15 +36,8 @@ On the step where you need to replace **PROFILE**, choose:
|
||||
|
||||
Conan must be aware of the NDK location when you execute `conan install`. There're multiple ways to achieve that as written in the [Conan docs](https://docs.conan.io/1/integrations/cross_platform/android.html):
|
||||
|
||||
- the easiest is to download NDK from Conan (option 1 in the docs), then all the magic happens automatically. You need to create your own Conan profile that imports our Android profile and adds 2 new lines (you can of course just copy everything from our profile into yours without including) and then pass this new profile to `conan install`:
|
||||
|
||||
```
|
||||
include(/path/to/vcmi/CI/conan/android-64)
|
||||
[tool_requires]
|
||||
android-ndk/r25c
|
||||
```
|
||||
|
||||
- to use an already installed NDK, you can simply pass it on the command line to `conan install`:
|
||||
- the easiest is to download NDK from Conan (option 1 in the docs), then all the magic happens automatically. On the step where you need to replace **PROFILE**, choose _android-**X**-ndk_ where _**X**_ is either `32` or `64`.
|
||||
- to use an already installed NDK, you can simply pass it on the command line to `conan install`: (note that this will work only when consuming the pre-built binaries)
|
||||
|
||||
```
|
||||
conan install -c tools.android:ndk_path=/path/to/ndk ...
|
||||
@ -52,34 +45,23 @@ conan install -c tools.android:ndk_path=/path/to/ndk ...
|
||||
|
||||
## Build process
|
||||
|
||||
Building for Android is a 2-step process. First, native C++ code is compiled to a shared library (unlike executable on other platforms), then Java code is compiled to an actual executable which will be loading the native shared library at runtime.
|
||||
Building for Android is a 2-step process. First, native C++ code is compiled to a shared library (unlike an executable on other platforms), then Java code is compiled to an actual executable which will be loading the native shared library at runtime.
|
||||
|
||||
### C++ code
|
||||
This is a traditional CMake project, you can build it from command line or some IDE. You're not required to pass any custom options (except Conan toolchain file), defaults are already good. If you wish to use your own CMake presets, inherit them from our `build-with-conan` preset.
|
||||
|
||||
This is a traditional CMake project, you can build it from command line or some IDE. You're not required to pass any custom options (except Conan toolchain file), defaults are already good. If you wish to use your own CMake presets, inherit them from our `build-with-conan` preset. Example:
|
||||
The Java code (located in the `android` directory of the repo) will be built automatically after the native code using the `androiddeployqt` tool. But you must set `JAVA_HOME` and `ANDROID_HOME` environment variables.
|
||||
|
||||
```
|
||||
cmake -S . -B ../build -G Ninja -D CMAKE_BUILD_TYPE=Debug -D ENABLE_CCACHE:BOOL=ON --toolchain ...
|
||||
cmake --build ../build
|
||||
```
|
||||
APK will appear in `<build dir>/android-build/vcmi-app/build/outputs/apk/debug` directory which you can then install to your device with `adb install -r /path/to/apk` (`adb` command is from Android command line tools).
|
||||
|
||||
You can also see a more detailed walkthrough on CMake configuration at [How to build VCMI (macOS)](../developers/Building_macOS.md).
|
||||
|
||||
### Java code
|
||||
|
||||
After the C++ part is built, native shared libraries are copied to the appropriate location of the Java project (they will be packaged in the APK). You can either open the Java project located in `android` directory of the repo in Android studio and work with it as with any Android project or build from command line.
|
||||
|
||||
Example how to build from command line in Bash shell, assumes that current working directory is VCMI repository:
|
||||
### Example
|
||||
|
||||
```sh
|
||||
# the following environment variables must be set
|
||||
export JAVA_HOME=/path/to/jdk11
|
||||
export ANDROID_HOME=/path/to/android/sdk
|
||||
``
|
||||
cd android
|
||||
./gradlew assembleDebug
|
||||
|
||||
cmake -S . -B ../build -G Ninja -D CMAKE_BUILD_TYPE=Debug -D ENABLE_CCACHE:BOOL=ON --toolchain ...
|
||||
cmake --build ../build
|
||||
```
|
||||
|
||||
APK will appear in `android/vcmi-app/build/outputs/apk/debug` directory which you can then install to your device with `adb install -r /path/to/apk` (adb command is from Android command line tools).
|
||||
|
||||
If you wish to build and install to your device in single action, use `installDebug` instead of `assembleDebug`.
|
||||
You can also see a more detailed walkthrough on CMake configuration at [How to build VCMI (macOS)](./Building_macOS.md).
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
## Supported platforms
|
||||
|
||||
The following platforms are supported and known to work, others might require changes to our [conanfile.py](../conanfile.py) or upstream recipes.
|
||||
The following platforms are supported and known to work, others might require changes to our [conanfile.py](../../conanfile.py) or upstream recipes.
|
||||
|
||||
- **macOS**: x86_64 (Intel) - target 10.13 (High Sierra), arm64 (Apple Silicon) - target 11.0 (Big Sur)
|
||||
- **iOS**: arm64 - target 12.0
|
||||
@ -13,7 +13,7 @@ The following platforms are supported and known to work, others might require ch
|
||||
|
||||
## Getting started
|
||||
|
||||
1. [Install Conan](https://docs.conan.io/en/latest/installation.html). Currently we support only Conan v1, you can install it with `pip` like this: `pip3 install 'conan<2.0'`
|
||||
1. [Install Conan](https://docs.conan.io/1/installation.html). Currently we support only Conan v1, you can install it with `pip` like this: `pip3 install 'conan<2.0'`
|
||||
2. Execute in terminal: `conan profile new default --detect`
|
||||
|
||||
## Download dependencies
|
||||
@ -22,8 +22,8 @@ The following platforms are supported and known to work, others might require ch
|
||||
|
||||
1. Check if your build environment can use the prebuilt binaries: basically, that your compiler version (or Xcode major version) matches the information below. If you're unsure, simply advance to the next step.
|
||||
|
||||
- **macOS**: libraries are built with Apple clang 14 (Xcode 14.2), should be consumable by Xcode and Xcode CLT 14.x (older library versions are also available for Xcode 13, see Releases in the respective repo)
|
||||
- **iOS**: libraries are built with Apple clang 14 (Xcode 14.2), should be consumable by Xcode 14.x (older library versions are also available for Xcode 13, see Releases in the respective repo)
|
||||
- **macOS**: libraries are built with Apple clang 14 (Xcode 14.2), should be consumable by Xcode / Xcode CLT 14.x and later (older library versions are also available for Xcode 13, see Releases in the respective repo)
|
||||
- **iOS**: libraries are built with Apple clang 14 (Xcode 14.2), should be consumable by Xcode 14.x and later (older library versions are also available for Xcode 13, see Releases in the respective repo)
|
||||
- **Windows**: libraries are built with x86_64-mingw-w64-gcc version 10 (which is available in repositories of Ubuntu 22.04)
|
||||
- **Android**: libraries are built with NDK r25c (25.2.9519653)
|
||||
|
||||
@ -31,9 +31,8 @@ The following platforms are supported and known to work, others might require ch
|
||||
|
||||
- [macOS](https://github.com/vcmi/vcmi-deps-macos/releases/latest): pick **intel.txz** if you have Intel Mac, otherwise - **intel-cross-arm.txz**
|
||||
- [iOS](https://github.com/vcmi/vcmi-ios-deps/releases/latest)
|
||||
- [Windows](https://github.com/vcmi/vcmi-deps-windows-conan/releases/latest): pick **vcmi-deps-windows-conan-w64.tgz**
|
||||
if you want x86, otherwise pick **vcmi-deps-windows-conan.tgz**
|
||||
- [Android](https://github.com/vcmi/vcmi-dependencies/releases)
|
||||
- [Windows](https://github.com/vcmi/vcmi-deps-windows-conan/releases/latest): pick **vcmi-deps-windows-conan-w64.tgz** if you want x86_64, otherwise pick **vcmi-deps-windows-conan-w32.tgz**
|
||||
- [Android](https://github.com/vcmi/vcmi-dependencies/releases): current limitation is that building works only on a macOS host due to Qt 5 for Android being compiled on macOS. Simply delete directory `~/.conan/data/qt/5.15.x/_/_/package` (`5.15.x` is a placeholder) after unpacking the archive and build Qt from source. Alternatively, if you have (or are [willing to build](https://github.com/vcmi/vcmi-ios-deps#note-for-arm-macs)) Qt host tools for your platform, then simply replace those in the archive with yours and most probably it would work.
|
||||
|
||||
3. Only if you have Apple Silicon Mac and trying to build for macOS or iOS:
|
||||
|
||||
@ -42,7 +41,7 @@ The following platforms are supported and known to work, others might require ch
|
||||
|
||||
## Generate CMake integration
|
||||
|
||||
Conan needs to generate CMake toolchain file to make dependencies available to CMake. See `CMakeDeps` and `CMakeToolchain` [in the official documentation](https://docs.conan.io/en/latest/reference/conanfile/tools/cmake.html) for details.
|
||||
Conan needs to generate CMake toolchain file to make dependencies available to CMake. See `CMakeDeps` and `CMakeToolchain` [in the official documentation](https://docs.conan.io/1/reference/conanfile/tools/cmake.html) for details.
|
||||
|
||||
In terminal `cd` to the VCMI source directory and run the following command. Also check subsections for additional requirements on consuming prebuilt binaries.
|
||||
|
||||
@ -66,7 +65,7 @@ If you use `--build=never` and this command fails, then it means that you can't
|
||||
|
||||
VCMI "recipe" also has some options that you can specify. For example, if you don't care about game videos, you can disable FFmpeg dependency by passing `-o with_ffmpeg=False`. If you only want to make release build, you can use `GENERATE_ONLY_BUILT_CONFIG=1` environment variable to skip generating files for other configurations (our CI does this).
|
||||
|
||||
_Note_: you can find full reference of this command [in the official documentation](https://docs.conan.io/en/latest/reference/commands/consumer/install.html) or by executing `conan help install`.
|
||||
_Note_: you can find full reference of this command [in the official documentation](https://docs.conan.io/1/reference/commands/consumer/install.html) or by executing `conan help install`.
|
||||
|
||||
### Using our prebuilt binaries for macOS/iOS
|
||||
|
||||
@ -92,12 +91,26 @@ This subsection describes platform specifics to build libraries from source prop
|
||||
|
||||
#### Building for Android
|
||||
|
||||
Android has issues loading self-built shared Zlib library because binary name is identical to the system one, so we enforce using the OS-provided library. To achieve that, follow [below instructions](#using-recipes-for-system-libraries), you only need `zlib` directory.
|
||||
Android has issues loading self-built shared zlib library because binary name is identical to the system one, so we enforce using the OS-provided library. To achieve that, follow [below instructions](#using-recipes-for-system-libraries), you only need `zlib` directory.
|
||||
|
||||
Also, Android requires a few Qt patches. They are needed only for specific use cases, so you may evaluate whether you need them. The patches can be found [here](https://github.com/kambala-decapitator/Qt5-iOS-patches/tree/master/5.15.14/android). To apply selected patch(es), let Conan finish building dependencies first. Then `cd` to `qtbase` **source directory** (e.g. `~/.conan/data/qt/5.15.14/_/_/source/qt5/qtbase`) and run `patch -p1 < /path/to/patch` for each patch file (on Windows you'll need some sort of GNU environment like Git Bash to access `patch` utility).
|
||||
|
||||
1. [Safety measure for Xiaomi devices](https://github.com/kambala-decapitator/Qt5-iOS-patches/blob/master/5.15.14/android/xiaomi.diff). It's unclear whether it's really needed, but without it [I faced a crash once](https://bugreports.qt.io/browse/QTBUG-111960).
|
||||
2. [Fix running on Android 5.0-5.1](https://github.com/kambala-decapitator/Qt5-iOS-patches/blob/master/5.15.14/android/android-21-22.diff) (API level 21-22).
|
||||
3. [Enable running on Android 4.4](https://github.com/kambala-decapitator/Qt5-iOS-patches/blob/master/5.15.14/android/android-19-jar.diff) (API level 19-20, 32-bit only). You must also apply [one more patch](https://github.com/kambala-decapitator/Qt5-iOS-patches/blob/master/5.15.14/android/android-19-java.diff), but you must `cd` to the **package directory** for that, e.g. `~/.conan/data/qt/5.15.14/_/_/package/SOME_HASH`.
|
||||
|
||||
After applying patch(es):
|
||||
|
||||
1. `cd` to `qtbase/src/android/jar` in the **build directory**, e.g. `~/.conan/data/qt/5.15.14/_/_/build/SOME_HASH/build_folder/qtbase/src/android/jar`.
|
||||
2. Run `make`
|
||||
3. Copy file `qtbase/jar/QtAndroid.jar` from the build directory to the **package directory**, e.g. `~/.conan/data/qt/5.15.14/_/_/package/SOME_HASH/jar`.
|
||||
|
||||
_Note_: if you plan to build Qt from source again, then you don't need to perform the above _After applying patch(es)_ steps after building.
|
||||
|
||||
##### Using recipes for system libraries
|
||||
|
||||
1. Clone/download https://github.com/kambala-decapitator/conan-system-libs
|
||||
2. Execute `conan create PACKAGE vcmi/CHANNEL`, where `PACKAGE` is a directory path in that repository and `CHANNEL` is **apple** for macOS/iOS and **android** for Android.. Do it for each library you need.
|
||||
2. Execute `conan create PACKAGE vcmi/CHANNEL`, where `PACKAGE` is a directory path in that repository and `CHANNEL` is **apple** for macOS/iOS and **android** for Android. Do it for each library you need.
|
||||
3. Now you can execute `conan install` to build all dependencies.
|
||||
|
||||
## Configure project for building
|
||||
@ -183,12 +196,15 @@ cmake --preset ios-conan
|
||||
```
|
||||
|
||||
### Build VCMI with all deps for 32-bit windows in Ubuntu 22.04 WSL
|
||||
|
||||
```powershell
|
||||
wsl --install
|
||||
wsl --install -d Ubuntu
|
||||
ubuntu
|
||||
```
|
||||
|
||||
Next steps are identical both in WSL and in real Ubuntu 22.04
|
||||
|
||||
```bash
|
||||
sudo pip3 install conan
|
||||
sudo apt install cmake build-essential
|
||||
@ -205,4 +221,5 @@ conan install . \
|
||||
cmake --preset windows-mingw-conan-linux
|
||||
cmake --build --preset windows-mingw-conan-linux --target package
|
||||
```
|
||||
|
||||
After that, you will have functional VCMI installer for 32-bit windows.
|
||||
|
Loading…
Reference in New Issue
Block a user