-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Firestore instructions and convinience script
- Loading branch information
Showing
5 changed files
with
197 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Overview | ||
|
||
This describes how Firestore Unity SDK works, and how to develop and test | ||
the SDK, targeting desktop/Android/iOS. | ||
|
||
# Prerequisites | ||
|
||
Building the Unity SDK requires building the underlying C++ SDK. Refer to | ||
[][this doc] for what the prerequisites are. | ||
|
||
On top of above, you also need Unity installed (obviously). If you use an | ||
apple silicon machine as host, be sure to install the right version of | ||
Unity! | ||
|
||
# Building Firestore Unity SDK | ||
|
||
Building Firestore into Unity Packages is a very involved process, mixed with | ||
multiple build tools working together. Therefore, we will rely on Python scripts | ||
to automate the process. The scripts live under `$REPO_ROOT/scripts/build_scripts`. | ||
|
||
```zsh | ||
# all scripts are run from the repo root. | ||
|
||
# Building for Mac. The build tools will try to find Unity automatically | ||
python scripts/build_scripts/build_zips.py -platform=macos -targets=auth -targets=firestore -use_boringssl | ||
|
||
# If above does not work, try specify Unity path direcly | ||
python scripts/build_scripts/build_zips.py -platform=macos -unity_root=<PATH_TO_UNITY> -targets=auth -targets=firestore -use_boringssl | ||
|
||
# Building for Android | ||
python scripts/build_scripts/build_zips.py -platform=android -targets=auth -targets=firestore -use_boringssl | ||
|
||
# Building for iOS. Incremental build for iOS is broken, so we use clean_build here. | ||
python scripts/build_scripts/build_zips.py -platform=android -targets=auth -targets=firestore -use_boringssl -clean_build | ||
|
||
# Other supported platforms are tvos,linux,windows | ||
``` | ||
|
||
After running above commands, some zip files for each platform are created under | ||
`$PLATFORM_unity` directories. Run below to put all of them into Unity packages: | ||
|
||
```zsh | ||
# Built Unity packages for all platforms are stored under ./package_dir | ||
python scripts/build_scripts/zips_to_packages.py --output package_dir | ||
``` | ||
|
||
# Running Firestore Desktop TestApp | ||
|
||
Test app for Firestore is under `firestore/testapp`, we need to copy a | ||
`google-services.json` or `GoogleServices-Info.plist` to `firestore/testapp/Assets/Firebase/Sample/Firestore` | ||
before we can run the test app. | ||
|
||
The testapp depends on a custom test runner, which is needs to be copied over unfortunately: | ||
|
||
```zsh | ||
cp ./scripts/gha/integration_testing/automated_testapp/AutomatedTestRunner.cs firestore/testapp/Assets/Firebase/Sample/ | ||
cp -r ./scripts/gha/integration_testing/automated_testapp/ftl_testapp_files firestore/testapp/Assets/Firebase/Sample/ | ||
``` | ||
|
||
To run the test app, open `firestore/testapp` from Unity Editor, and load the Unity packages we built above. | ||
Then open up `firestore/testapp/Assets/Firebase/Sample/Firestore/MainSceneAutomated.unity`, you should be | ||
able to run this scene which in turn runs all integration tests for Firestore. | ||
|
||
# Running Firestore Android TestApp | ||
|
||
You *probably* need to use `IL2CPP` as scripting backend instead of `Mono` for Android. To do this, | ||
you can go to `Edit->Project Setting->Player->Android->Scripting Backend` and select `IL2CPP`. | ||
|
||
You also need to turn on `minification` under on the same setting page, by turning on `R8` under `publish | ||
settings`. | ||
|
||
To run the Android testapp, go to `File->Build Settings`, select `Android` then click `Switch Platform`. After | ||
assets are loaded, click `Build and Run`. | ||
|
||
# Running Firestore iOS TestApp | ||
|
||
Similarly for iOS, go to `File-Build Settings` and select `iOS`. After you click `Build and Run`, it will prompt | ||
you to select a directory to save generated code and XCode project. | ||
|
||
After the code generation is done, go under the directory, and run `pod install` to generate | ||
a `xcworkspace`, then open it via `XCode`. From `XCode` you should be able to sign the testapp, build and run/debug | ||
the app with an actual iOS device, or as an iPad App on an Apple Silicon mac. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python | ||
# | ||
# Copyright 2022 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Collects built zips(built by build_zips.py) under current directory | ||
and packages them into Unity Packages using build_packages.py. | ||
Example usage: | ||
python zips_to_packages.py --ouput unity_packages | ||
""" | ||
import glob | ||
import os | ||
import shutil | ||
import subprocess | ||
import zipfile | ||
import tempfile | ||
import threading | ||
import sys | ||
|
||
from absl import app, flags, logging | ||
|
||
FLAGS = flags.FLAGS | ||
flags.DEFINE_string( | ||
'output', 'unity_packages', | ||
'Relative directory to save the generated unity packages') | ||
|
||
def main(argv): | ||
if len(argv) > 1: | ||
raise app.UsageError('Too many command-line arguments.') | ||
output = FLAGS.output | ||
|
||
if os.path.exists(output): | ||
shutil.rmtree(output) | ||
if not os.path.exists(output): | ||
os.makedirs(output) | ||
logging.info("Ready to build Unity packages to {}".format(output)) | ||
|
||
zip_temp_dir = tempfile.mkdtemp() | ||
|
||
try: | ||
candidates = glob.glob('./*_unity/firebase_unity*.zip') | ||
for candidate in candidates: | ||
shutil.copy(candidate, zip_temp_dir) | ||
|
||
if len(candidates) > 0: | ||
logging.info("Found zip files:\n {}".format("\n".join(candidates))) | ||
subprocess.call(["python", "scripts/build_scripts/build_package.py", | ||
"--zip_dir", zip_temp_dir, "-output", output]) | ||
finally: | ||
shutil.rmtree(zip_temp_dir) | ||
|
||
if __name__ == '__main__': | ||
app.run(main) |