|
| 1 | +--- |
| 2 | +name: firebase-cpp-builder |
| 3 | +description: |
| 4 | + Instructions and workflows for building the Firebase C++ SDK natively. Use |
| 5 | + this skill when you need to compile the C++ SDK per-product (e.g., auth, |
| 6 | + database) across different platforms (Desktop, iOS, Android). |
| 7 | +--- |
| 8 | + |
| 9 | +# Building the Firebase C++ SDK |
| 10 | + |
| 11 | +This skill provides instructions on how to build the Firebase C++ SDK directly |
| 12 | +from source, specifically tailored for building individual products (like |
| 13 | +`firebase_auth`, `firebase_database`, etc.). |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +Before building, ensure that your Python environment is set up with all required dependencies, especially if you plan to use helper scripts: |
| 18 | + |
| 19 | +- **Python Dependencies**: Run `pip install -r scripts/gha/python_requirements.txt` to install required libraries (such as `attrs`, `absl-py`, etc.). |
| 20 | + |
| 21 | +## 1. Desktop Builds (Mac, Linux, Windows) |
| 22 | + |
| 23 | +The easiest way to build for Desktop is to use the Python helper script from the |
| 24 | +repository root: |
| 25 | + |
| 26 | +```bash |
| 27 | +python3 scripts/gha/build_desktop.py -a <arch> --build_dir <dir> |
| 28 | +``` |
| 29 | + |
| 30 | +_(Plenty more options: run `python3 scripts/gha/build_desktop.py --help` for |
| 31 | +info.)_ |
| 32 | + |
| 33 | +Alternatively, you can build manually with CMake. The build process will |
| 34 | +automatically download necessary dependencies. |
| 35 | + |
| 36 | +```bash |
| 37 | +mkdir desktop_build |
| 38 | +cd desktop_build |
| 39 | +cmake .. |
| 40 | +cmake --build . --target firebase_<product> -j |
| 41 | +``` |
| 42 | + |
| 43 | +_Example: `cmake --build . --target firebase_auth -j`_ |
| 44 | + |
| 45 | +## 2. iOS Builds |
| 46 | + |
| 47 | +For iOS, you can use the convenience script from the repository root: |
| 48 | + |
| 49 | +```bash |
| 50 | +./build_scripts/ios/build.sh -b ios_build_dir -s . |
| 51 | +``` |
| 52 | + |
| 53 | +_(Run `./build_scripts/ios/build.sh -h` for more options.)_ |
| 54 | + |
| 55 | +Alternatively, you can use CMake's native Xcode generator manually. Ensure you |
| 56 | +have CocoaPods installed if building products that depend on iOS SDK Pods. |
| 57 | + |
| 58 | +```bash |
| 59 | +mkdir ios_build |
| 60 | +cd ios_build |
| 61 | +cmake .. -G Xcode -DCMAKE_SYSTEM_NAME=iOS |
| 62 | +cmake --build . --target firebase_<product> -j |
| 63 | +``` |
| 64 | + |
| 65 | +Alternatively, you can build XCFrameworks using the helper script: |
| 66 | + |
| 67 | +```bash |
| 68 | +python3 scripts/gha/build_ios_tvos.py -s . -b ios_tvos_build |
| 69 | +``` |
| 70 | + |
| 71 | +## 3. Android Builds |
| 72 | + |
| 73 | +For Android, use the convenience script from the repository root: |
| 74 | + |
| 75 | +```bash |
| 76 | +./build_scripts/android/build.sh android_build_dir . |
| 77 | +``` |
| 78 | + |
| 79 | +_(You can also specify an STL variant with the 3rd parameter. Run the script |
| 80 | +without any parameters to see the usage.)_ |
| 81 | + |
| 82 | +Alternatively, when building the Firebase C++ SDK manually for Android, the |
| 83 | +repository uses a Gradle wrapper where each product has its own subproject. |
| 84 | + |
| 85 | +To build a specific product's AARs, run the gradle build task for that module: |
| 86 | + |
| 87 | +```bash |
| 88 | +./gradlew :<product>:build |
| 89 | +``` |
| 90 | + |
| 91 | +_Example: `./gradlew :auth:build` or `./gradlew :database:build`_ |
| 92 | + |
| 93 | +Note that as part of the build process, each library generates a ProGuard file |
| 94 | +in its build directory (e.g., `<product>/build/<product>.pro`). |
| 95 | + |
| 96 | +## CMake Target Naming Convention |
| 97 | + |
| 98 | +When using CMake directly (for Desktop or iOS/tvOS), the targets are |
| 99 | +consistently named `firebase_<product>`. |
| 100 | + |
| 101 | +Common targets include: |
| 102 | + |
| 103 | +- `firebase_app` |
| 104 | +- `firebase_analytics` |
| 105 | +- `firebase_auth` |
| 106 | +- `firebase_database` |
| 107 | +- `firebase_firestore` |
| 108 | +- `firebase_functions` |
| 109 | +- `firebase_messaging` |
| 110 | +- `firebase_remote_config` |
| 111 | +- `firebase_storage` |
| 112 | + |
| 113 | +## Product Naming Disambiguation (`firebase_auth` vs `auth`) |
| 114 | + |
| 115 | +Different build tools use different naming conventions for products in this repository: |
| 116 | + |
| 117 | +- **CMake Targets (Desktop/iOS)**: Typically prefixed with `firebase_` (e.g., `firebase_auth`). |
| 118 | +- **Gradle Subprojects (Android)**: Typically use the raw module name (e.g., `:auth:build`). |
| 119 | +- **Python Scripts** (e.g., `build_desktop.py`, `build_testapps.py`): Typically use the raw module name (e.g., `--t auth`). |
| 120 | + |
| 121 | +> [!TIP] |
| 122 | +> If you are unsure about the exact product name or supported flags, run Python scripts with `--help` (e.g., `build_desktop.py --help`). For shell scripts, run without parameters (Android) or with `-h` (iOS) to see usage. |
0 commit comments