Просмотр исходного кода

Updating GameLift exporter with --package-gamelauncher option to create a new game client package in a folder called 'MultiplayerSampleGamePackage'

Signed-off-by: AMZN-Gene <[email protected]>
AMZN-Gene 2 лет назад
Родитель
Сommit
7f0ca3dba7
2 измененных файлов с 40 добавлено и 25 удалено
  1. 1 1
      Documentation/PackedAssetBuilds.md
  2. 39 24
      MPSGameLift/Scripts/export_gamelift_server_package.py

+ 1 - 1
Documentation/PackedAssetBuilds.md

@@ -115,7 +115,7 @@ build\non_mono\bin\profile\AssetBundler.exe --project-path="c:\your\path\to\o3de
 
 
 Follow steps for "Create a bundle for game assets", "Create a bundle for engine assets" and "Add bundles to the release game layout" from https://www.o3de.org/docs/user-guide/packaging/asset-bundler/bundle-assets-for-release/
 Follow steps for "Create a bundle for game assets", "Create a bundle for engine assets" and "Add bundles to the release game layout" from https://www.o3de.org/docs/user-guide/packaging/asset-bundler/bundle-assets-for-release/
 
 
-* The "default seed lists" choice should choose all but 4 seed lists to make the `engine_pc.pak`
+* The "default seed lists" choice should choose all but 3 seed lists to make the `engine_pc.pak`
 * The other [seed lists](https://github.com/o3de/o3de-multiplayersample/tree/development/AssetBundling/SeedLists) should all get selected to make the `game_pc.pak`.
 * The other [seed lists](https://github.com/o3de/o3de-multiplayersample/tree/development/AssetBundling/SeedLists) should all get selected to make the `game_pc.pak`.
 
 
 > It's important to make sure that the bootstrap.game.profile.setreg file has been added to one of the seed files. (also add debug if you want to support debug builds)
 > It's important to make sure that the bootstrap.game.profile.setreg file has been added to one of the seed files. (also add debug if you want to support debug builds)

+ 39 - 24
MPSGameLift/Scripts/export_gamelift_server_package.py

@@ -32,6 +32,7 @@ build_folder = os.path.join(o3de_context.project_path, "build", "windows")
 monolithic_build_folder = os.path.join(o3de_context.project_path, "build", "windows_mono")
 monolithic_build_folder = os.path.join(o3de_context.project_path, "build", "windows_mono")
 bundles_directory = os.path.join(o3de_context.project_path, "AssetBundling", "Bundles" )
 bundles_directory = os.path.join(o3de_context.project_path, "AssetBundling", "Bundles" )
 gamelift_package_folder_name = "GameLiftPackageWindows"
 gamelift_package_folder_name = "GameLiftPackageWindows"
+client_package_folder_name = "MultiplayerSampleGamePackage"
 
 
 o3de_logger.info(f"Exporting AWS GameLift Server Package for {project_name}")
 o3de_logger.info(f"Exporting AWS GameLift Server Package for {project_name}")
 
 
@@ -42,6 +43,7 @@ parser = argparse.ArgumentParser(
 
 
 parser.add_argument('--code', action='store_true', help='Build code')
 parser.add_argument('--code', action='store_true', help='Build code')
 parser.add_argument('--assets', action='store_true', help='Build assets')
 parser.add_argument('--assets', action='store_true', help='Build assets')
+parser.add_argument('--package-gamelauncher', action='store_true', help='Produce a client GameLauncher.exe release package along side the GameLift server package.')
 parser.add_argument('-g', '--generator', choices=['Visual Studio 16', 'Visual Studio 17'], help='Which compiler do you want to use?')
 parser.add_argument('-g', '--generator', choices=['Visual Studio 16', 'Visual Studio 17'], help='Which compiler do you want to use?')
 parser.add_argument('--no-clobber', action='store_true', dest='no_clobber', help='Do not create a new package if an existing GameLift server package exists.')
 parser.add_argument('--no-clobber', action='store_true', dest='no_clobber', help='Do not create a new package if an existing GameLift server package exists.')
 
 
@@ -112,6 +114,12 @@ if (args.code):
     if (process_command(["cmake", "--build", monolithic_build_folder, "--target", f"{project_name}.ServerLauncher", "--config", "release", "--", "/m"])):
     if (process_command(["cmake", "--build", monolithic_build_folder, "--target", f"{project_name}.ServerLauncher", "--config", "release", "--", "/m"])):
         quit()
         quit()
 
 
+    # Buld the monolithic game launcher build
+    if args.package_gamelauncher:
+        if (process_command(["cmake", "--build", monolithic_build_folder, "--target", f"{project_name}.GameLauncher", "--config", "release", "--", "/m"])):
+            quit()
+
+
 # Build Assets
 # Build Assets
 if (args.assets):
 if (args.assets):
     # Process assets
     # Process assets
@@ -151,7 +159,6 @@ if (args.assets):
     if (process_command([asset_bundler_batch, "assetLists", "--assetListFile", game_asset_list_path, "--platform", platform, "--allowOverwrites",
     if (process_command([asset_bundler_batch, "assetLists", "--assetListFile", game_asset_list_path, "--platform", platform, "--allowOverwrites",
                          "--seedListFile", os.path.join(seed_list_directory, "BasePopcornFxSeedList.seed"), 
                          "--seedListFile", os.path.join(seed_list_directory, "BasePopcornFxSeedList.seed"), 
                          "--seedListFile", os.path.join(seed_list_directory, "GameSeedList.seed"), 
                          "--seedListFile", os.path.join(seed_list_directory, "GameSeedList.seed"), 
-                         "--seedListFile", os.path.join(seed_list_directory, "ProfileOnlySeedList.seed"), 
                          "--seedListFile", os.path.join(seed_list_directory, "VFXSeedList.seed")]) != 0):
                          "--seedListFile", os.path.join(seed_list_directory, "VFXSeedList.seed")]) != 0):
         quit()
         quit()
 
 
@@ -172,26 +179,34 @@ if (args.assets):
                          "--assetListFile", engine_asset_list_path]) != 0):
                          "--assetListFile", engine_asset_list_path]) != 0):
         quit()
         quit()
 
 
-# Add all the required exe's, dll's, and asset pak files into a folder to upload to GameLift
-gamelift_package_cache_dir = os.path.join(gamelift_package_folder_name, "Cache", "pc")
-gamelift_package_gems_dir = os.path.join(gamelift_package_folder_name, "Gems", "AWSCore")
+def create_exe_package(new_package_folder_name, exe_name):
+    # Add all the required exe's, dll's, and asset pak files into a folder to upload to GameLift
+    package_cache_dir = os.path.join(new_package_folder_name, "Cache", "pc")
 
 
-# Delete the old server package
-if os.path.exists(gamelift_package_folder_name):
-    shutil.rmtree(gamelift_package_folder_name)
+    # Delete the old server package
+    if os.path.exists(new_package_folder_name):
+        shutil.rmtree(new_package_folder_name)
 
 
-# Create the folders
-os.makedirs(gamelift_package_cache_dir, exist_ok=True)
-os.makedirs(gamelift_package_gems_dir, exist_ok=True)
+    # Create the folders
+    os.makedirs(package_cache_dir, exist_ok=True)
+
+    # Copy .exe and .dll files to GameLiftWindowsServerPackage directory
+    build_dir = os.path.join(monolithic_build_folder, "bin", "release")
+    for file_name in os.listdir(build_dir):
+        file_path = os.path.join(build_dir, file_name)
+        if os.path.isfile(file_path) and file_name.lower().endswith((exe_name.lower(), '.dll')):
+            shutil.copy(file_path, new_package_folder_name)
 
 
-# Copy .exe and .dll files to GameLiftWindowsServerPackage directory
-build_dir = os.path.join(monolithic_build_folder, "bin", "release")
-for file_name in os.listdir(build_dir):
-    file_path = os.path.join(build_dir, file_name)
-    if os.path.isfile(file_path) and file_name.lower().endswith(('.exe', '.dll')):
-        shutil.copy(file_path, gamelift_package_folder_name)
+    # Copy .pak files to Cache\pc directory
+    for file_name in os.listdir(bundles_directory):
+        if file_name.endswith(".pak"):
+            file_path = os.path.join(bundles_directory, file_name)
+            shutil.copy(file_path, package_cache_dir)
 
 
-# Copy launch_server.cfg file to GameLiftWindowsServerPackage directory
+# Create the GameLift server package
+create_exe_package(gamelift_package_folder_name, 'ServerLauncher.exe')
+
+# GameLift server package needs launch_server.cfg file
 launch_server_cfg_filepath = os.path.join(o3de_context.project_path, "launch_server.cfg")
 launch_server_cfg_filepath = os.path.join(o3de_context.project_path, "launch_server.cfg")
 if os.path.isfile(launch_server_cfg_filepath):
 if os.path.isfile(launch_server_cfg_filepath):
     shutil.copy(launch_server_cfg_filepath, gamelift_package_folder_name)
     shutil.copy(launch_server_cfg_filepath, gamelift_package_folder_name)
@@ -199,19 +214,19 @@ else:
     o3de_logger.error(f"Could not find serverlauncher.cfg! Launch_server.cfg is required because there's a bug with multiplayer when calling --loadlevel in the command-line. See https://github.com/o3de/o3de/issues/15773.")
     o3de_logger.error(f"Could not find serverlauncher.cfg! Launch_server.cfg is required because there's a bug with multiplayer when calling --loadlevel in the command-line. See https://github.com/o3de/o3de/issues/15773.")
     quit()
     quit()
 
 
-# Copy .pak files to Cache\pc directory
-for file_name in os.listdir(bundles_directory):
-    if file_name.endswith(".pak"):
-        file_path = os.path.join(bundles_directory, file_name)
-        shutil.copy(file_path, gamelift_package_cache_dir)
-
-# Copy files to Gems\AWSCore directory
+# GameLift server needs Gems\AWSCore
+gamelift_package_gems_dir = os.path.join(gamelift_package_folder_name, "Gems", "AWSCore")
+os.makedirs(gamelift_package_gems_dir, exist_ok=True)
 gems_files_dir = os.path.join(monolithic_build_folder, "bin", "release", "Gems", "AWSCore")
 gems_files_dir = os.path.join(monolithic_build_folder, "bin", "release", "Gems", "AWSCore")
 for file_name in os.listdir(gems_files_dir):
 for file_name in os.listdir(gems_files_dir):
     file_path = os.path.join(gems_files_dir, file_name)
     file_path = os.path.join(gems_files_dir, file_name)
     if os.path.isfile(file_path):
     if os.path.isfile(file_path):
         shutil.copy(file_path, gamelift_package_gems_dir)
         shutil.copy(file_path, gamelift_package_gems_dir)
 
 
+# Create the Client Package
+if args.package_gamelauncher:
+    create_exe_package(client_package_folder_name, 'GameLauncher.exe')
+
 o3de_logger.info("Export Successful!\n"
 o3de_logger.info("Export Successful!\n"
                  "Test the server locally and upload the server package to GameLift.\n"
                  "Test the server locally and upload the server package to GameLift.\n"
                  f"Example: aws gamelift upload-build --server-sdk-version 5.0.0 --operating-system WINDOWS_2016 --build-root .\GameLiftPackageWindows\ --name {project_name} --build-version v1.0 --region us-west-2")
                  f"Example: aws gamelift upload-build --server-sdk-version 5.0.0 --operating-system WINDOWS_2016 --build-root .\GameLiftPackageWindows\ --name {project_name} --build-version v1.0 --region us-west-2")