def build_script(engine, script, configuration, buildtype, build, platform, clean, automated, buildexplicit): """ The Main call for build script execution. :param engine: The desired engine path, absolute or relative. :param script: The Project Script which defines the projects paths, build steps, and extra information. :param configuration: Build configuration, e.g. Shipping :param buildtype: Which type of build are you trying to create? Editor OR Package? :param build: Which build steps to execute? :param platform: Which platform to build for? :param clean: Causes all actions to consider cleaning up their workspaces before executing their action. :param automated: Configures the builder to recognize this build as being done by continuous integration and should not manipulate the system environment. :param buildexplicit: Should the build system only build what is requested? This prevents convienience cases like the package build building the editor before trying to package. By setting this to true, it is expected that the user has setup the proper state before building. """ # Fixup for old build type 'Game'. if buildtype == 'Game': buildtype = 'Editor' global is_automated if automated: is_automated = automated # Ensure Visual Studio is installed if get_visual_studio_version() not in [2015, 2017]: print_error('Cannot run build, valid visual studio install not found!') return False if not os.path.isfile(script): error_exit('No build script defined! Use the -s arg', not is_automated) with open(script, 'r') as fp: try: script_json = json.load(fp) except Exception as jsonError: error_exit('Build Script Syntax Error:\n{}'.format(jsonError), not is_automated) return config = ProjectConfig(configuration, platform, False, clean, automated) if not config.load_configuration(script_json, engine, buildexplicit): error_exit('Failed to load configuration. See errors above.', not config.automated) print_title('Unreal Project Builder') if config.automated: click.secho('\nAutomated flag set!') # Ensure the engine exists and we can build if not buildexplicit: ensure_engine(config, engine) click.secho('\nProject File Path: {}\nEngine Path: {}'.format( config.uproject_dir_path, config.UE4EnginePath)) # Ensure the unreal header tool exists. It is important for all Unreal projects if not buildexplicit: if not os.path.isfile( os.path.join(config.UE4EnginePath, 'Engine\\Binaries\\Win64\\UnrealHeaderTool.exe')): b = Build(config, build_name='UnrealHeaderTool') if not b.run(): error_exit(b.error, not config.automated) # Build required engine tools if config.should_build_engine_tools and not buildexplicit: clean_revert = config.clean if buildtype == "Package": config.clean = False # Don't clean if packaging, waste of time b = Build(config, build_names=config.build_engine_tools) if not b.run(): error_exit(b.error, not config.automated) config.clean = clean_revert # If a specific set of steps if being requested, only build those if build != '': steps = Buildsteps(config, steps_name=build) if not steps.run(): error_exit(steps.error, not config.automated) else: if buildtype == "Editor": if config.editor_running: error_exit( 'Cannot build the Editor while the editor is running!', not config.automated) if 'game_editor_steps' in config.script: steps = Buildsteps(config, steps_name='game_editor_steps') if not steps.run(): error_exit(steps.error, not config.automated) elif 'editor_steps' in config.script: steps = Buildsteps(config, steps_name='editor_steps') if not steps.run(): error_exit(steps.error, not config.automated) else: b = Build(config, build_name='{}Editor'.format(config.uproject_name)) if not b.run(): error_exit(b.error, not config.automated) elif buildtype == "Package": # We need to build the editor before we can run any cook commands. This seems important for blueprints # probably because it runs the engine and expects all of the native class RTTI to be up-to-date to be able # to compile the blueprints. Usually you would be starting a package build from the editor, so it makes # sense. Explicit builds ignore this however. if not buildexplicit: b = Build(config, build_name='{}Editor'.format(config.uproject_name)) if not b.run(): error_exit(b.error, not config.automated) if 'package_steps' in config.script: steps = Buildsteps(config, steps_name='package_steps') if not steps.run(): error_exit(steps.error, not config.automated) else: package = Package(config) if not package.run(): error_exit(package.error, not config.automated) print_action('SUCCESS!') if not config.automated: click.pause()
def build_script(engine, script, configuration, buildtype, build, platform, clean): """ The Main call for build script execution. :param engine: The desired engine path, absolute or relative. :param script: The Project Script which defines the projects paths, build steps, and extra information. :param configuration: Build configuration, e.g. Shipping :param buildtype: Which type of build are you trying to create? Editor OR Package? :param build: Which build steps to execute? :param platform: Which platform to build for? :param clean: Causes all actions to consider cleaning up their workspaces before executing their action. """ # Fixup for old build type 'Game'. if buildtype == 'Game': buildtype = 'Editor' # Ensure Visual Studio is installed if get_visual_studio_version() not in [2015, 2017]: print_error('Cannot run build, valid visual studio install not found!') return False if not os.path.isfile(script): error_exit('No build script defined! Use the -s arg') with open(script, 'r') as fp: try: script_json = json.load(fp) except Exception as jsonError: error_exit('Build Script Syntax Error:\n{}'.format(jsonError)) return config = ProjectConfig(configuration, platform, False, clean) if not config.load_configuration(script_json, engine, False): error_exit('Failed to load configuration. See errors above.') print_title('Unreal Project Builder') build_meta = BuildMeta('project_build_meta') if "meta" in config.script: build_meta.insert_meta(**config.script["meta"]) # Ensure the engine exists and we can build ensure_engine(config, engine) click.secho('\nProject File Path: {}\nEngine Path: {}'.format(config.uproject_dir_path, config.UE4EnginePath)) # Ensure the unreal header tool exists. It is important for all Unreal projects if not os.path.isfile(os.path.join(config.UE4EnginePath, 'Engine\\Binaries\\Win64\\UnrealHeaderTool.exe')): b = Build(config, build_name='UnrealHeaderTool') if not b.run(): error_exit(b.error) # Build required engine tools clean_revert = config.clean if buildtype == "Package": config.clean = False # Don't clean if packaging, waste of time for tool_name in config.build_engine_tools: b = Build(config, build_name=tool_name) if not b.run(): error_exit(b.error) config.clean = clean_revert # If a specific set of steps if being requested, only build those if build != '': run_build_steps(config, build_meta, build, True) else: # Ensure engine is built if not config.editor_running: clean_revert = config.clean if buildtype == "Package": config.clean = False # Don't clean if packaging, waste of time b = Build(config, build_name='UE4Editor') if not b.run(): error_exit(b.error) config.clean = clean_revert else: print_warning('Skipping engine build because engine is running!') run_build_steps(config, build_meta, 'pre_build_steps') if buildtype == "Editor": if config.editor_running: print_warning('Cannot build the Editor while the editor is running!') click.pause() sys.exit(1) if 'game_editor_steps' in config.script: run_build_steps(config, build_meta, 'game_editor_steps') elif 'editor_steps' in config.script: run_build_steps(config, build_meta, 'editor_steps') else: b = Build(config, build_name='{}Editor'.format(config.uproject_name)) if not b.run(): error_exit(b.error) elif buildtype == "Package": if 'package_steps' in config.script: run_build_steps(config, build_meta, 'package_steps') else: package = Package(config) if not package.run(): error_exit(package.error) run_build_steps(config, build_meta, 'post_build_steps') build_meta.save_meta() print_action('SUCCESS!') click.pause()