|
@@ -12,6 +12,7 @@ import os
|
|
|
import time
|
|
|
import glob
|
|
|
import sys
|
|
|
+import platform
|
|
|
from o3de.validation import valid_o3de_project_json, valid_o3de_engine_json
|
|
|
from queue import Queue, Empty
|
|
|
from threading import Thread
|
|
@@ -21,13 +22,13 @@ from subprocess import Popen, PIPE
|
|
|
logger = logging.getLogger('o3de.mps_export')
|
|
|
LOG_FORMAT = '[%(levelname)s] %(name)s: %(message)s'
|
|
|
logging.basicConfig(format=LOG_FORMAT)
|
|
|
-# This is an export script for MPS on the Windows platform
|
|
|
+# This is an export script for MPS
|
|
|
# this has to be a complete standalone script, b/c project export doesnt exist in main branch yet
|
|
|
|
|
|
# View the argparse parameters for options available. An example invocation:
|
|
|
|
|
|
# @<O3DE_ENGINE_ROOT_PATH>
|
|
|
-# > python\python.cmd <O3DE_MPS_PROJECT_ROOT_PATH>\ExportScripts\export_standalone_monolithic_windows.py -pp <O3DE_MPS_PROJECT_ROOT_PATH> -ep <O3DE_ENGINE_ROOT_PATH> -bnmt -out <MPS_OUTPUT_RELEASE_DIR_PATH> -a -aof zip
|
|
|
+# > python\python.cmd <O3DE_MPS_PROJECT_ROOT_PATH>\ExportScripts\export_standalone_monolithic.py -pp <O3DE_MPS_PROJECT_ROOT_PATH> -ep <O3DE_ENGINE_ROOT_PATH> -bnmt -out <MPS_OUTPUT_RELEASE_DIR_PATH> -a -aof zip
|
|
|
|
|
|
def enqueue_output(out, queue):
|
|
|
for line in iter(out.readline, b''):
|
|
@@ -184,7 +185,7 @@ def process_command(args: list,
|
|
|
|
|
|
# EXPORT SCRIPT STARTS HERE!
|
|
|
if __name__ == "__main__":
|
|
|
- parser = argparse.ArgumentParser(prog='Exporter for MultiplayerSample on windows',
|
|
|
+ parser = argparse.ArgumentParser(prog='Exporter for MultiplayerSample as a standalone build',
|
|
|
description = "Exports O3DE's MultiplayerSample to the desired output directory with release layout. "
|
|
|
"In order to use this script, the engine and project must be setup and registered beforehand. "
|
|
|
"See this example on the MPS Github page: "
|
|
@@ -204,6 +205,10 @@ if __name__ == "__main__":
|
|
|
parser.add_argument('-bnmt', '--build-non-mono-tools', action='store_true')
|
|
|
parser.add_argument('-nmbp', '--non-mono-build-path', type=pathlib.Path, default=None)
|
|
|
parser.add_argument('-mbp', '--mono-build-path', type=pathlib.Path, default=None)
|
|
|
+ parser.add_argument('-nogame', '--no-game-launcher', action='store_true', help='this flag skips building the Game Launcher on a platform if not needed.')
|
|
|
+ parser.add_argument('-noserver', '--no-server-launcher', action='store_true', help='this flag skips building the Server Launcher on a platform if not needed.')
|
|
|
+ parser.add_argument('-nounified', '--no-unified-launcher', action='store_true', help='this flag skips building the Unified Launcher on a platform if not needed.')
|
|
|
+ parser.add_argument('-pl', '--platform', type=str, default=None, choices=['pc', 'linux', 'mac'])
|
|
|
parser.add_argument('-a', '--archive-output', action='store_true', help='This option places the final output of the build into a compressed archive')
|
|
|
parser.add_argument('-q', '--quiet', action='store_true', help='Suppresses logging information unless an error occurs.')
|
|
|
args = parser.parse_args()
|
|
@@ -222,14 +227,31 @@ if __name__ == "__main__":
|
|
|
|
|
|
#commands are based on
|
|
|
#https://github.com/o3de/o3de-multiplayersample/blob/development/Documentation/PackedAssetBuilds.md
|
|
|
-
|
|
|
+ selected_platform = args.platform
|
|
|
+
|
|
|
+ system_platform = platform.system().lower()
|
|
|
+
|
|
|
+ if not selected_platform:
|
|
|
+ logger.info("Platform not specified! Defaulting to Host platform...")
|
|
|
+ if not system_platform:
|
|
|
+ logger.error("Unable to identify host platform! Please supply the platform using '--platform'. Options are [pc, linux, mac].")
|
|
|
+ sys.exit(1)
|
|
|
+ if system_platform == "windows":
|
|
|
+ selected_platform = "pc"
|
|
|
+ elif system_platform == "linux":
|
|
|
+ selected_platform = "linux"
|
|
|
+ elif system_platform == "darwin":
|
|
|
+ selected_platform = "mac"
|
|
|
+ else:
|
|
|
+ logger.error(f"MPS exporting for {system_platform} is currently unsupported! Please use either a Windows, Mac or Linux machine to build project.")
|
|
|
+ sys.exit(1)
|
|
|
|
|
|
logger.info(f"Project path for MPS: {args.project_path}")
|
|
|
logger.info(f"Engine path to build MPS: {args.engine_path}")
|
|
|
logger.info(f"Build path for non-monolithic executables: {args.non_mono_build_path}")
|
|
|
logger.info(f"Build path for monolithic executables: {args.mono_build_path}")
|
|
|
|
|
|
- output_cache_path = args.output_path / 'Cache' / 'pc'
|
|
|
+ output_cache_path = args.output_path / 'Cache' / selected_platform
|
|
|
output_aws_gem_path = args.output_path / 'Gems' / 'AWSCore'
|
|
|
|
|
|
os.makedirs(output_cache_path, exist_ok=True)
|
|
@@ -246,10 +268,17 @@ if __name__ == "__main__":
|
|
|
#Build monolithic game
|
|
|
process_command(['cmake', '-S', '.', '-B', str(mono_build_path), '-DLY_MONOLITHIC_GAME=1', '-DALLOW_SETTINGS_REGISTRY_DEVELOPMENT_OVERRIDES=0', f'-DLY_PROJECTS={args.project_path}'], cwd=args.engine_path)
|
|
|
|
|
|
- process_command(['cmake', '--build', str(mono_build_path), '--target', 'MultiplayerSample.GameLauncher', 'MultiplayerSample.ServerLauncher', 'MultiplayerSample.UnifiedLauncher', '--config', args.config], cwd=args.engine_path)
|
|
|
+ if not args.no_game_launcher:
|
|
|
+ process_command(['cmake', '--build', str(mono_build_path), '--target', 'MultiplayerSample.GameLauncher', '--config', args.config], cwd=args.engine_path)
|
|
|
+
|
|
|
+ if not args.no_server_launcher:
|
|
|
+ process_command(['cmake', '--build', str(mono_build_path), '--target', 'MultiplayerSample.ServerLauncher', '--config', args.config], cwd=args.engine_path)
|
|
|
+
|
|
|
+ if not args.no_unified_launcher:
|
|
|
+ process_command(['cmake', '--build', str(mono_build_path), '--target', 'MultiplayerSample.UnifiedLauncher', '--config', args.config], cwd=args.engine_path)
|
|
|
|
|
|
#Before bundling content, make sure that the necessary executables exist
|
|
|
- asset_bundler_batch_path = non_mono_build_path / 'bin' / 'profile' / 'AssetBundlerBatch'
|
|
|
+ asset_bundler_batch_path = non_mono_build_path / 'bin' / 'profile' / ('AssetBundlerBatch' + ('.exe' if system_platform=='windows' else ''))
|
|
|
if not asset_bundler_batch_path.is_file():
|
|
|
logger.error(f"AssetBundlerBatch not found at path '{asset_bundler_batch_path}'. In order to bundle the data for MPS, this executable must be present!")
|
|
|
logger.error("To correct this issue, do 1 of the following: "
|
|
@@ -260,12 +289,12 @@ if __name__ == "__main__":
|
|
|
sys.exit(1)
|
|
|
|
|
|
#Bundle content
|
|
|
- engine_asset_list_path = args.project_path / 'AssetBundling' / 'AssetLists' / 'engine_pc.assetlist'
|
|
|
+ engine_asset_list_path = args.project_path / 'AssetBundling' / 'AssetLists' / f'engine_{selected_platform}.assetlist'
|
|
|
|
|
|
process_command([asset_bundler_batch_path, 'assetLists','--addDefaultSeedListFiles', '--assetListFile', engine_asset_list_path, '--project-path', args.project_path, '--allowOverwrites' ], cwd=args.engine_path)
|
|
|
|
|
|
|
|
|
- game_asset_list_path = args.project_path /'AssetBundling'/'AssetLists'/'game_pc.assetlist'
|
|
|
+ game_asset_list_path = args.project_path /'AssetBundling'/'AssetLists'/ f'game_{selected_platform}.assetlist'
|
|
|
seed_folder_path = args.project_path/'AssetBundling'/'SeedLists'
|
|
|
|
|
|
game_asset_list_command = [asset_bundler_batch_path, 'assetLists', '--assetListFile', game_asset_list_path,
|
|
@@ -283,13 +312,13 @@ if __name__ == "__main__":
|
|
|
|
|
|
process_command(game_asset_list_command, cwd=args.engine_path)
|
|
|
|
|
|
- engine_bundle_path = output_cache_path / 'engine_pc.pak'
|
|
|
+ engine_bundle_path = output_cache_path / f'engine_{selected_platform}.pak'
|
|
|
process_command([asset_bundler_batch_path, 'bundles', '--assetListFile', engine_asset_list_path, '--outputBundlePath', engine_bundle_path, '--project-path', args.project_path, '--allowOverwrites'], cwd=args.engine_path)
|
|
|
|
|
|
# This is to prevent any accidental file locking mechanism from failing subsequent bundling operations
|
|
|
time.sleep(1)
|
|
|
|
|
|
- game_bundle_path = output_cache_path / 'game_pc.pak'
|
|
|
+ game_bundle_path = output_cache_path / f'game_{selected_platform}.pak'
|
|
|
process_command([asset_bundler_batch_path, 'bundles', '--assetListFile', game_asset_list_path, '--outputBundlePath', game_bundle_path, '--project-path', args.project_path, '--allowOverwrites'], cwd=args.engine_path)
|
|
|
|
|
|
# Create Launcher Layout Directory
|
|
@@ -309,6 +338,3 @@ if __name__ == "__main__":
|
|
|
shutil.make_archive(args.output_path, args.archive_output_format, root_dir = args.output_path)
|
|
|
|
|
|
logger.info(f"Exporting project is complete! Release Directory can be found at {args.output_path}")
|
|
|
-
|
|
|
- if not args.quiet:
|
|
|
- process_command(['explorer', args.output_path])
|