-
Notifications
You must be signed in to change notification settings - Fork 46
Firestore instructions and convinience script #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wu-hui
wants to merge
3
commits into
main
Choose a base branch
from
wuandy/FirestoreInstructions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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. | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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, | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
dconeybe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 hidden or 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 hidden or 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 hidden or 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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.