def package_assets(project, engine_path, project_path, export_path):
    """
    Runs the Resource Compiler on the game assets following the
    instructions of rcjob_release_game_assets.xml. Outputs the
    .pak files in the Assets folder of the build that's specified
    in the project file.
    """
    rc_path = os.path.join(engine_path, "Tools", "rc", "rc.exe")
    rc_job_path = os.path.join(engine_path, "Tools", "CryVersionSelector",
                               "rc_jobs", "rcjob_release_game_assets.xml")

    if os.path.isfile(rc_path) and os.path.isfile(rc_job_path):
        asset_dir = cryproject.asset_dir(project)
        pwd = os.getcwd()
        os.chdir(project_path)
        rc_cmd = [
            '"{}"'.format(rc_path), '/job="{}"'.format(rc_job_path), '/p=PC',
            '/pak_root="{}"'.format(export_path), '/TargetHasEditor=0',
            '/game="{}"'.format(asset_dir), '/stripMetadata', '/skipmissing'
        ]
        run_command(rc_cmd)
        os.chdir(pwd)
    else:
        if not os.path.isfile(rc_path):
            print(
                "Unable to package the game assets with the resource compiler because '{}' is missing!"
                .format(rc_path))
        else:
            print(
                "Unable to package the game assets with the resource compiler because '{}' is missing!"
                .format(rc_job_path))
Ejemplo n.º 2
0
def cmd_metagen(argv):
    if not os.path.isfile (args.project_file):
        error_project_not_found (args.project_file)

    project= cryproject.load (args.project_file)
    if project is None:
        error_project_json_decode (args.project_file)

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

    job_path= os.path.join (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 = cryproject.asset_dir(project)
    asset_path = os.path.normpath (os.path.join (project_path, asset_dir))

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

    print_subprocess (subcmd)
    subprocess.Popen(subcmd)
Ejemplo n.º 3
0
def cmd_require (args):
    registry= cryregistry.load()
    project= cryproject.load (args.project_file)

    plugin_dependencies= {}
    require_getall (registry, cryproject.require_list(project), plugin_dependencies)
    plugin_list= require_sortedlist (plugin_dependencies)
    plugin_list= cryregistry.filter_plugin (registry, plugin_list)

    project_path= os.path.dirname (args.project_file)
    plugin_path= os.path.join (project_path, 'cryext.txt')
    if os.path.isfile (plugin_path):
        os.remove (plugin_path)

    plugin_file= open (plugin_path, 'w')
    for k in plugin_list:
        project_file= cryregistry.project_file (registry, k)
        project_path= os.path.dirname (project_file)
        project= cryproject.load (project_file)

        (m_extensionName, shared_path)= cryproject.shared_tuple (project, args.platform, args.config)
        asset_dir= cryproject.asset_dir (project)

        m_extensionBinaryPath= os.path.normpath (os.path.join (project_path, shared_path))
        m_extensionAssetDirectory= asset_dir and os.path.normpath (os.path.join (project_path, asset_dir)) or ''
        m_extensionClassName= 'EngineExtension_%s' % os.path.splitext (os.path.basename (m_extensionBinaryPath))[0]

        line= ';'.join ((m_extensionName, m_extensionClassName, m_extensionBinaryPath, m_extensionAssetDirectory))
        plugin_file.write  (line + os.linesep)

    plugin_file.close()
def requires_mono(project, project_path):
    """
    Returns true if the project requires Mono, false otherwise.
    """
    if cryproject.is_managed(project):
        return True

    asset_path = os.path.join(project_path, cryproject.asset_dir(project))
    return directory_contains_file(asset_path, ["*.cs"])
def copy_assets(project, project_path, export_path):
    """
    Copies existing .pak files from the assets directory to the
    export location. Other assets can be added to these pak files
    later on in package_assets().
    """
    asset_dir = cryproject.asset_dir(project)
    srcpath = os.path.join(project_path, asset_dir)
    dstpath = os.path.join(export_path, asset_dir)

    copy_directory_contents(srcpath, dstpath, ["*.pak"], ["*.cryasset.pak"])
Ejemplo n.º 6
0
def cmd_deploy(args):
    if not os.path.isfile(args.project_file):
        error_project_not_found(args)

    project = cryproject.load(args.project_file)
    if project is None:
        error_project_json_decode(args)

    project_dir = os.path.dirname(args.project_file)
    engine_id = cryproject.engine_id(project)

    engines = cryregistry.load_engines()
    engine_data = engines.get(engine_id)

    engine_file = engine_data['uri']
    engine_dir = os.path.dirname(engine_file)

    deployment_dir = os.path.join(project_dir, 'Build')
    rc_path = os.path.join(engine_dir, "Tools/rc/rc.exe")

    source_asset_dir = os.path.join(project_dir, cryproject.asset_dir(project))
    target_asset_dir = os.path.normcase(
        os.path.join(deployment_dir, cryproject.asset_dir(project)))

    if not os.path.exists(target_asset_dir):
        os.makedirs(target_asset_dir)

    # Copy plugin list
    copy_file(project_dir, deployment_dir, "cryplugin.csv")

    # Copy game binaries
    copy_file_formats_in_dir(os.path.join(project_dir, "bin"),
                             os.path.join(deployment_dir, "bin"),
                             ['*.dll', '*.exe'])

    # Start copying assets
    copy_file_formats_in_dir(source_asset_dir, target_asset_dir,
                             ['*.xml', '*.pak', '*.cgf', '*.mtl', '*.cfg'])

    # Convert textures in assets dir
    subprocess.check_call([
        rc_path, "*.tif", "/p=PC", "/sourceroot=" + source_asset_dir,
        "/targetroot=" + target_asset_dir, "refresh"
    ])

    # Convert animations in assets dir
    subprocess.check_call([
        rc_path, "*.i_caf", "/animConfigFolder=Animations", "/p=PC",
        "/sourceroot=" + source_asset_dir, "/targetroot=" + target_asset_dir,
        "refresh"
    ])

    # Copy engine directory
    source_engine_assets_dir = os.path.join(engine_dir, "Engine")
    target_engine_assets_dir = os.path.join(deployment_dir, "Engine")

    copy_file_formats_in_dir(
        source_engine_assets_dir, target_engine_assets_dir, [
            '*.cfg', '*.xml', '*.txt', '*.thread_config', '*.ttf', '*.dds',
            '*.mtl', '*.abc', '*.cbc', '*.cgf', '*.pfxp', '*.lut', '*.dat',
            '*.ext', '*.cfi', '*.cfx'
        ])

    # Convert textures in engine dir
    subprocess.check_call([
        rc_path, "*.tif", "/p=PC", "/sourceroot=" + source_engine_assets_dir,
        "/targetroot=" + target_engine_assets_dir, "refresh"
    ])

    # Copy engine binaries
    copy_file_formats_in_dir(os.path.join(engine_dir, "bin"),
                             os.path.join(deployment_dir, "bin"),
                             ['*.dll', '*.exe', '*.py', '*.pyc'])

    # Create system cfg
    system_cfg_file = open(os.path.join(deployment_dir, "system.cfg"), "w")
    system_cfg_file.write("sys_game_folder=" + cryproject.asset_dir(project) +
                          "\n")
    system_cfg_file.write("sys_dll_game=\"\"\n")
    system_cfg_file.close()
Ejemplo n.º 7
0
def copy_assets(project, project_path, export_path, silent):
    """
    Copies the assets of the project to the backup folder.
    """
    assets_dir = cryproject.asset_dir(project)
    copy_directory(project_path, export_path, assets_dir, silent=silent)
Ejemplo n.º 8
0
def requires_mono(project, project_path):
    if cryproject.is_managed(project):
        return True

    asset_path = os.path.join(project_path, cryproject.asset_dir(project))
    return directory_contains_file(asset_path, ["*.cs"])