-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/cef-sandbox' into 'master'
MacOS, Dev Script Overhaul and Sandbox See merge request voltstro-studios/uwb/unitywebbrowser!3
- Loading branch information
Showing
89 changed files
with
1,102 additions
and
633 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -385,4 +385,5 @@ FodyWeavers.xsd | |
*.sln.iml | ||
|
||
# MacOS | ||
*.DS_Store | ||
*.DS_Store | ||
|
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,22 @@ | ||
# UnityWebBrowser Docs | ||
|
||
UnityWebBrowser's docs are built from here. | ||
|
||
UWB docs are generated using [DocFx](https://dotnet.github.io/docfx/). See the DocFx site for setup of the tool. | ||
|
||
## Building Locally | ||
|
||
``` | ||
docfx metadata | ||
docfx build | ||
``` | ||
|
||
To preview locally, use: | ||
|
||
``` | ||
docfx serve _site/ | ||
``` | ||
|
||
## Publishing | ||
|
||
The [publicly hosted docs](https://projects.voltstro.dev/UnityWebBrowser/latest/) are automatically published using [VoltProjects](https://github.com/Voltstro/VoltProjects). |
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,22 @@ | ||
# Dev Scripts | ||
|
||
UWB contains all of its dev scripts in `src/DevScripts/`. Dev scripts are used for automating tasks like downloading external files or building projects. | ||
|
||
## Usage | ||
|
||
There are three main scripts you will want to use. | ||
|
||
1. `download_cef_<platform>.py` | ||
- Used for downloading the required version of CEF and extracting it. | ||
2. `build_cef_<platform>.py` | ||
- Builds the `UnityWebBrowser.Engine.Cef` project in publish mode and outputs the built files into `src/Packages/UnityWebBrowser.Engine.Cef.<Platform>/Engine~/`. Needs to be ran if the CEF engine project has any changes made to it. | ||
3. `build_shared.py` | ||
- Builds the `VoltstroStudios.UnityWebBrowser.Shared` project in `ReleaseUnity` configuration mode, which will place the built files into `src/Packages/UnityWebBrowser/Plugins`. Needs to be ran if the shared project has any changes made to it. | ||
|
||
## Base Scripts | ||
|
||
There are a couple of scripts with `_base` in it's name. These scripts are shared modules that are used by the scripts that the user executes. | ||
|
||
## Why Python | ||
|
||
In older versions of UWB, we used PowerShell as the language of choice for our dev scripts. PowerShell has one main advantage, its cross-platform. But so is Python. Python's runtime also includes a lot of useful utilities like archive extraction. While in PowerShell technically this is possible (you can call .NET methods), its a bit of a pain to do. |
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
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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
import subprocess | ||
import os | ||
|
||
package_rid_mapping = { | ||
'win-x64': 'Win-x64', | ||
'linux-x64': 'Linux-x64' | ||
} | ||
|
||
def build_cef_engine(platform: str) -> None: | ||
""" | ||
Base CEF engine build for Windows and Linux | ||
""" | ||
if platform not in package_rid_mapping: | ||
raise Exception('Platform {0} is not valid!'.format(platform)) | ||
|
||
platform_folder = package_rid_mapping[platform] | ||
|
||
cef_project_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/Main/UnityWebBrowser.Engine.Cef.csproj')) | ||
cef_publish_path = os.path.abspath(os.path.join(__file__, '../../Packages/UnityWebBrowser.Engine.Cef.{0}/Engine~'.format(platform_folder))) | ||
|
||
print('Build CEF project \'{0}\' to \'{1}\''.format(cef_project_path, cef_publish_path)) | ||
|
||
subprocess.run(['dotnet', 'publish', cef_project_path, '-r=' + platform, '-p:PublishDir=' + cef_publish_path, '--nologo']) | ||
|
||
|
||
def build_project(project: str) -> None: | ||
project_path = os.path.abspath(os.path.join(__file__, '../../{0}/{0}.csproj'.format(project))) | ||
|
||
subprocess.run(['dotnet', 'build', project_path, '-c=ReleaseUnity']) | ||
|
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,79 @@ | ||
import subprocess | ||
import shutil | ||
import os | ||
|
||
def build_cef_engine_macos(arch) -> None: | ||
""" | ||
MacOS custom build script. | ||
MacOS needs a custom build process because of the .plist files and specific folder layout the build needs to be in | ||
""" | ||
|
||
# Project path | ||
cef_engine_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/Main')) | ||
cef_engine_subprocess_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/SubProcess')) | ||
cef_engine_macos_path = os.path.abspath(os.path.join(__file__, '../../Packages/UnityWebBrowser.Engine.Cef.MacOS-{0}/Engine~/'.format(arch))) | ||
|
||
# Delete build dir | ||
cef_engine_build_path = os.path.abspath(os.path.join(__file__, '../../UnityWebBrowser.Engine.Cef/bin/Release/publish/osx-{0}/'.format(arch))) | ||
if os.path.exists(cef_engine_build_path): | ||
shutil.rmtree(cef_engine_build_path) | ||
|
||
# First, build main CEF engine project | ||
print('Building CEF Engine from {0}'.format(cef_engine_path)) | ||
subprocess.run(['dotnet', 'publish', '-r=osx-{0}'.format(arch), '-c=Release'], cwd=cef_engine_path) | ||
|
||
# Build SubProcess | ||
print('Building CEF Engine SubProcess from {0}'.format(cef_engine_subprocess_path)) | ||
subprocess.run(['dotnet', 'publish', '-r=osx-{0}'.format(arch), '-c=Release'], cwd=cef_engine_subprocess_path) | ||
|
||
cef_framework_path = os.path.abspath(os.path.join(__file__, '../../ThirdParty/Libs/cef/macos{0}/Release/Chromium Embedded Framework.framework'.format(arch))) | ||
|
||
cef_engine_app_path = os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef.app') | ||
cef_engine_app_contents_path = os.path.join(cef_engine_app_path, 'Contents') | ||
cef_engine_app_macos_path = os.path.join(cef_engine_app_contents_path, 'MacOS') | ||
cef_engine_app_resources_path = os.path.join(cef_engine_app_contents_path, 'Resources') | ||
cef_engine_app_frameworks_path = os.path.join(cef_engine_app_contents_path, 'Frameworks/') | ||
|
||
os.makedirs(cef_engine_app_macos_path, exist_ok=True) | ||
os.makedirs(cef_engine_app_resources_path, exist_ok=True) | ||
os.makedirs(cef_engine_app_frameworks_path, exist_ok=True) | ||
|
||
shutil.copy(os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef'), cef_engine_app_macos_path) | ||
shutil.copy(os.path.join(cef_engine_build_path, 'info.plist'), cef_engine_app_contents_path) | ||
shutil.copy(os.path.join(cef_engine_build_path, 'icon.icns'), cef_engine_app_resources_path) | ||
shutil.copytree(cef_framework_path, os.path.join(cef_engine_app_frameworks_path, 'Chromium Embedded Framework.framework')) | ||
|
||
# Copy the many different helper apps needed | ||
subprocess_types = [ | ||
None, | ||
'GPU', | ||
'Plugin', | ||
'Renderer' | ||
] | ||
|
||
for type in subprocess_types: | ||
if not type: | ||
name = '' | ||
plist_file = 'info-subprocess.plist' | ||
else: | ||
name = ' ({0})'.format(type) | ||
plist_file = 'info-subprocess-{0}.plist'.format(type.lower()) | ||
|
||
bundle_name = 'UnityWebBrowser.Engine.Cef.SubProcess{0}.app/Contents'.format(name) | ||
cef_engine_subprocess_app_path = os.path.join(cef_engine_app_frameworks_path, bundle_name) | ||
cef_engine_subprocess_macos_path = os.path.join(cef_engine_subprocess_app_path, 'MacOS') | ||
|
||
os.makedirs(cef_engine_subprocess_macos_path, exist_ok=True) | ||
shutil.copy(os.path.join(cef_engine_build_path, plist_file), os.path.join(cef_engine_subprocess_app_path, 'info.plist')) | ||
shutil.copy(os.path.join(cef_engine_build_path, 'UnityWebBrowser.Engine.Cef.SubProcess'), os.path.join(cef_engine_subprocess_macos_path, 'UnityWebBrowser.Engine.Cef.SubProcess{0}'.format(name))) | ||
|
||
# Copy final app bundle to MacOS package | ||
if not os.path.exists(cef_engine_macos_path): | ||
os.makedirs(cef_engine_macos_path, exist_ok=True) | ||
|
||
cef_app_final_path = os.path.join(cef_engine_macos_path, 'UnityWebBrowser.Engine.Cef.app') | ||
if os.path.exists(cef_app_final_path): | ||
shutil.rmtree(cef_app_final_path) | ||
|
||
shutil.copytree(cef_engine_app_path, cef_app_final_path) |
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,3 @@ | ||
from build_base import build_cef_engine | ||
|
||
build_cef_engine('linux-x64') |
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,3 @@ | ||
from build_base_macos import build_cef_engine_macos | ||
|
||
build_cef_engine_macos('arm64') |
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,3 @@ | ||
from build_base_macos import build_cef_engine_macos | ||
|
||
build_cef_engine_macos('x64') |
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,3 @@ | ||
from build_base import build_cef_engine | ||
|
||
build_cef_engine('win-x64') |
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,4 @@ | ||
|
||
from build_base import build_project | ||
|
||
build_project('VoltstroStudios.UnityWebBrowser.Shared') |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.