-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
222 additions
and
384 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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
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']) | ||
|
||
|
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}/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('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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.