Example #1
0
def cmd_metagen(args):
    if not os.path.isfile(args.project_file):
        error_project_not_found(args.project_file)

    project = cryproject.CryProject()
    try:
        project.load(args.project_file)
    except Exception:
        error_project_json_decode(args.project_file)

    exe_path = os.path.join(crypath.get_engine_path(), 'Tools/rc/rc.exe')
    if not os.path.isfile(exe_path):
        error_engine_tool_not_found(exe_path)

    job_path = os.path.join(crypath.get_engine_path(),
                            'Tools/cryassets/rcjob_cryassets.xml')
    if not os.path.isfile(job_path):
        error_engine_tool_not_found(job_path)

    project_path = os.path.dirname(os.path.abspath(args.project_file))
    asset_dir = project.asset_dir()
    asset_path = os.path.normpath(os.path.join(project_path, asset_dir))

    subcmd = (exe_path, ('/job=' + job_path), ('/src=' + asset_path))

    print_subprocess(subcmd)
    subprocess.Popen(subcmd)
Example #2
0
def cmd_projgen(args, open_cmake=False):
    if not os.path.isfile(args.project_file):
        error_project_not_found(args.project_file)

    project = cryproject.CryProject()
    try:
        project.load(args.project_file)
    except Exception:
        error_project_json_decode(args.project_file)

    project_path = os.path.abspath(os.path.dirname(args.project_file))
    engine_path = crypath.get_engine_path()

    cmakelists_dir = project.cmakelists_dir()

    if not cmakelists_dir:
        error_code_folder_not_specified()

    code_directory = os.path.join(project_path, cmakelists_dir)

    # Generate solutions
    crysolutiongenerator.generate_solution(args.project_file, code_directory,
                                           engine_path)

    # Skip on Crytek build agents
    if args.buildmachine:
        return

    cmakelists_path = os.path.join(os.path.join(project_path, cmakelists_dir),
                                   'CMakeLists.txt')

    # Generate the Solution
    if code_directory is not None and os.path.isfile(cmakelists_path):
        generate_project_solution(project_path, code_directory, open_cmake)
Example #3
0
def cmd_edit(args):
    if not os.path.isfile(args.project_file):
        error_project_not_found(args.project_file)

    project = cryproject.CryProject()
    try:
        project.load(args.project_file)
    except Exception:
        error_project_json_decode(args.project_file)

    exe_path = os.path.join(crypath.get_engine_path(), 'bin',
                            args.platform, 'Sandbox.exe')
    if not os.path.isfile(exe_path):
        error_engine_tool_not_found(exe_path)

    # ---

    subcmd = (
        exe_path,
        '-project',
        os.path.abspath(args.project_file)
    )

    print_subprocess(subcmd)
    subprocess.Popen(subcmd)
Example #4
0
def cmd_engine_gen(args):
    if not os.path.isfile(args.engine_file):
        error_engine_not_found(args.engine_file)

    engine_path = crypath.get_engine_path()

    # Check if the CrySystem folder is available, which indicates the
    # source code is available
    source_dir = os.path.join(engine_path, "Code", "CryEngine", "CrySystem")
    if not os.path.isdir(source_dir):
        error_missing_engine_source()

    # Generate the Solution, skip on Crytek build agents
    if not args.buildmachine:
        generate_engine_solution(engine_path)
Example #5
0
def run(project_file):
    """
    Entry point for setting up the process to release a packaged build.
    """
    # Path to the project file as created by the launcher
    # Engine and project path are derivable from this.
    project = cryproject.CryProject()
    try:
        project.load(project_file)
    except Exception:
        print("Unable to read project file %s" % (project_file))
        raise

    # The path the folder that contains the .cryproject file.
    project_path = os.path.normpath(os.path.dirname(project_file))
    project_path_long = LONG_PATH_PREFIX + project_path

    # The path to the engine that is being used by the project.
    engine_path = crypath.get_engine_path()
    engine_path_long = LONG_PATH_PREFIX + engine_path

    # Path to which the game is to be exported.
    export_path = os.path.join(
        project_path, '{}_package'.format(project.name()))

    configurations = get_available_configurations(engine_path)
    if not configurations:
        print("Unable to find a valid engine configuration. Make sure to "
              "build your engine to the following locations.")
        for key, value in DEFAULT_CONFIGURATIONS:
            print("Configuration: {} \n Location: {}".format(key, value))
        print("Press Enter to exit")
        input()
        return

    # configuration is returned as
    # (export_path, config_name, config_bin_folder, include_symbols)
    configuration = release_project_gui.configure_build(
        export_path, configurations)
    if not configuration:
        # No configuration selected. Most likely because the user closed
        # the window, so close this as well.
        return

    export_path = os.path.normpath(configuration[0])
    export_path_long = LONG_PATH_PREFIX + export_path
    config_type = configuration[1]
    bin_path = os.path.normpath(configuration[2])
    include_symbols = configuration[3]
    bit_type = CONFIGURATION_BUILD_TARGET_LOOKUP[config_type]

    print("Packaging project {}".format(project.name()))
    print("Configuration: {}".format(config_type))
    print("Debug symbols are {}".format(
        "included" if include_symbols else "excluded"))
    print("Building to: {}".format(export_path))

    task_list = []

    if os.path.exists(export_path_long):
        task_list.append(("Deleting previous build...",
                          delete_previous_build, export_path_long))

    task_list.append(("Packaging custom engine assets...",
                      package_engine_assets, engine_path, export_path))
    task_list.append(("Copying default engine assets...",
                      copy_engine_assets, engine_path_long, export_path_long))
    task_list.append(("Copying engine binaries...", copy_engine_binaries,
                      engine_path_long, export_path_long, bin_path,
                      include_symbols))

    if requires_mono(project, project_path_long):
        task_list.append((
            "Copying mono files...", copy_mono_files, engine_path_long,
            export_path_long))

    task_list.append((
        "Copying game binaries...", copy_project_plugins, project,
        project_path, export_path, bin_path, config_type, include_symbols))
    task_list.append((
        "Copying shared libraries...", copy_libs,
        project, project_path, export_path, bin_path, bit_type, include_symbols))
    task_list.append((
        "Copying existing game asset packages...",
        copy_assets, project, project_path_long, export_path_long))
    task_list.append((
        "Packaging game assets...", package_assets,
        project, engine_path, project_path, export_path))
    task_list.append((
        "Cleaning up temp folders...",
        delete_temp_folders, engine_path_long, project_path_long))
    task_list.append((
        "Creating config files...", create_config, project_file, export_path,
        bin_path, config_type))

    i = 0
    count = len(task_list)
    for task in task_list:
        description = task[0]
        print(description)
        set_title("{}% {}".format(int(get_percentage(i, count)), description))
        task[1](*task[2:])
        i += 1

    set_title("100% Build packaged successfully")
    print("Build packaged successfully")
    print("Press Enter to exit")
    input()