Skip to content

Commit

Permalink
Overhaul devscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Voltstro committed Aug 24, 2024
1 parent 9c2b0db commit 63fd32d
Show file tree
Hide file tree
Showing 34 changed files with 222 additions and 384 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,5 @@ FodyWeavers.xsd
*.sln.iml

# MacOS
*.DS_Store
*.DS_Store

72 changes: 0 additions & 72 deletions src/DevScripts/build-cef-engine-macos64.py

This file was deleted.

6 changes: 0 additions & 6 deletions src/DevScripts/build-pages.ps1

This file was deleted.

25 changes: 25 additions & 0 deletions src/DevScripts/build_base.py
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'])


79 changes: 79 additions & 0 deletions src/DevScripts/build_base_macos.py
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)
3 changes: 3 additions & 0 deletions src/DevScripts/build_linux64.py
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')
3 changes: 3 additions & 0 deletions src/DevScripts/build_macosx64.py
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')
3 changes: 3 additions & 0 deletions src/DevScripts/build_windows64.py
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')
3 changes: 0 additions & 3 deletions src/DevScripts/download-all.ps1

This file was deleted.

171 changes: 0 additions & 171 deletions src/DevScripts/download-cef-base.ps1

This file was deleted.

Loading

0 comments on commit 63fd32d

Please sign in to comment.