save state
This commit is contained in:
210
BUILD.md
Normal file
210
BUILD.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# MosisService Build Configuration
|
||||
|
||||
## Overview
|
||||
This document outlines the build configuration and toolchain information for the MosisService project, optimized for maximum compiler feedback and debugging capabilities on Windows.
|
||||
|
||||
## Gradle Build Configuration
|
||||
|
||||
### Build Flags and Options
|
||||
The project uses Gradle with Android build system that includes the following optimization flags:
|
||||
|
||||
### Android Build Configuration
|
||||
In `build.gradle.kts`:
|
||||
- Compile SDK: API level 36 (Android 14)
|
||||
- Target SDK: API level 36
|
||||
- Min SDK: API level 34 (Android 14)
|
||||
- ndkVersion: 29.0.14206865
|
||||
- ABI: arm64-v8a only
|
||||
|
||||
### Optimization and Debug Flags
|
||||
- JVM target: JDK 11
|
||||
- C++ standard: C++23
|
||||
- Debug builds include full symbol information
|
||||
- Release builds include optimization flags (-O2)
|
||||
|
||||
## CMake Build Configuration
|
||||
|
||||
### CMake Flags for Maximum Feedback
|
||||
In `CMakeLists.txt`:
|
||||
```
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
```
|
||||
|
||||
### Compiler Flags for Windows
|
||||
```
|
||||
# Debug flags for maximum feedback
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wextra -Wpedantic -Werror")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
# Enable all warnings
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-unused-variable")
|
||||
```
|
||||
|
||||
### C++23 Features and Debugging
|
||||
- Enabled C++23 standard with std::span, std::format
|
||||
- Debug build includes full debug symbols
|
||||
- Address Sanitizer enabled in debug builds
|
||||
- Undefined Behavior Sanitizer enabled in debug builds
|
||||
|
||||
## Windows Build Toolchain
|
||||
|
||||
### Required Tools
|
||||
1. **Android Studio with Android NDK**
|
||||
- Android SDK
|
||||
- Android NDK (version 29.0.14206865)
|
||||
- CMake (version 3.22.1 or higher)
|
||||
|
||||
2. **Visual Studio 2022**
|
||||
- C++ development tools
|
||||
- Windows SDK
|
||||
- CMake tools for Visual Studio
|
||||
|
||||
3. **vcpkg**
|
||||
- Package manager for dependencies
|
||||
- RmlUi with Lua support (if available)
|
||||
|
||||
### Environment Variables
|
||||
```
|
||||
ANDROID_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk
|
||||
ANDROID_NDK_HOME=C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\29.0.14206865
|
||||
VCPKG_ROOT=C:\Tools\vcpkg
|
||||
```
|
||||
|
||||
### Build Commands
|
||||
For maximum feedback:
|
||||
|
||||
#### Debug Build with All Warnings
|
||||
```
|
||||
./gradlew assembleDebug -Pandroid.jetifier.enable=true -Pandroid.build.legacyBundleTool=false
|
||||
```
|
||||
|
||||
#### Release Build with Optimization
|
||||
```
|
||||
./gradlew assembleRelease -Pandroid.jetifier.enable=true -Pandroid.build.legacyBundleTool=false
|
||||
```
|
||||
|
||||
## Build Process Steps
|
||||
|
||||
### 1. Prerequisites Setup
|
||||
- Install Android Studio with NDK
|
||||
- Install Visual Studio 2022 with C++ tools
|
||||
- Set up vcpkg and install required dependencies
|
||||
- Configure environment variables
|
||||
|
||||
### 2. Build Configuration
|
||||
```
|
||||
# Clean previous builds
|
||||
./gradlew clean
|
||||
|
||||
# Build with verbose output for maximum feedback
|
||||
./gradlew build --info --stacktrace --configure-on-demand
|
||||
|
||||
# Build with all warnings enabled
|
||||
./gradlew compileDebugKotlin --warning-mode all
|
||||
```
|
||||
|
||||
### 3. CMake Configuration
|
||||
To enable full compiler feedback in CMake:
|
||||
```
|
||||
# Debug configuration with all warnings
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug
|
||||
-DCMAKE_CXX_FLAGS_DEBUG="-g -O0 -Wall -Wextra -Wpedantic -Werror -fsanitize=address,undefined"
|
||||
-DCMAKE_CXX_STANDARD=23
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
.
|
||||
|
||||
# Release configuration
|
||||
cmake -DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -DNDEBUG -flto=full"
|
||||
.
|
||||
```
|
||||
|
||||
## Output Locations
|
||||
|
||||
### Android APKs
|
||||
```
|
||||
build\outputs\apk\debug\app-debug.apk
|
||||
build\outputs\apk\release\app-release-unsigned.apk
|
||||
```
|
||||
|
||||
### Native Libraries
|
||||
```
|
||||
build\intermediates\cmake\debug\obj\arm64-v8a\libmosis-service.so
|
||||
build\intermediates\cmake\debug\obj\arm64-v8a\libmosis-test.so
|
||||
```
|
||||
|
||||
### Build Artifacts
|
||||
```
|
||||
build\intermediates\cxx\Debug\1r2562ic\arm64-v8a\
|
||||
build\intermediates\cmake\debug\output\lib\arm64-v8a\
|
||||
```
|
||||
|
||||
## Troubleshooting Build Issues
|
||||
|
||||
### Common Debug Flags
|
||||
```
|
||||
# Enable verbose C++ compilation
|
||||
./gradlew compileDebugCpp --info
|
||||
|
||||
# Enable all warnings and stop on first error
|
||||
./gradlew build -PcompileDebugCpp.warningMode=all
|
||||
|
||||
# Show compiler output
|
||||
./gradlew build --console=plain
|
||||
```
|
||||
|
||||
### Debugging Symbols
|
||||
To include debugging symbols:
|
||||
```
|
||||
# In CMakeLists.txt
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -ggdb")
|
||||
```
|
||||
|
||||
### Compiler-Specific Flags
|
||||
```
|
||||
# For MSVC (if using Visual Studio)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4 /WX /Od /Zi")
|
||||
|
||||
# For Clang (if building with clang)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstandalone-debug -fexceptions -frtti")
|
||||
```
|
||||
|
||||
## Toolchain Locations
|
||||
|
||||
### Android SDK
|
||||
```
|
||||
C:\Users\%USERNAME%\AppData\Local\Android\Sdk
|
||||
```
|
||||
|
||||
### Android NDK
|
||||
```
|
||||
C:\Users\%USERNAME%\AppData\Local\Android\Sdk\ndk\29.0.14206865
|
||||
```
|
||||
|
||||
### Visual Studio Tools
|
||||
```
|
||||
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\
|
||||
```
|
||||
|
||||
### CMake Location
|
||||
```
|
||||
C:\Program Files\CMake\bin\cmake.exe
|
||||
```
|
||||
|
||||
## Recommended Build Commands
|
||||
|
||||
### For Development with Maximum Feedback
|
||||
```
|
||||
# Clean and build with maximum warnings
|
||||
./gradlew clean && ./gradlew build --warning-mode all --info --stacktrace
|
||||
|
||||
# Debug build with sanitizer
|
||||
./gradlew assembleDebug -Pandroid.jetifier.enable=true
|
||||
```
|
||||
|
||||
### For Release Builds
|
||||
```
|
||||
# Release build with optimization
|
||||
./gradlew assembleRelease -Pandroid.jetifier.enable=true
|
||||
```
|
||||
Reference in New Issue
Block a user