Esempio n. 1
0
def save_version_info(info_filename, project_file, project_output_folder,
                      plugin_version):
    ''' Save the version info of UnrealCV plugin and the game for easier issue tracking'''
    project_name = ue4util.get_project_name(project_file)
    project_folder = os.path.dirname(project_file)

    if gitutil.is_dirty(project_folder):
        return False

    # if gitutil.is_dirty(plugin_folder):
    #     return False
    # plugin_version = gitutil.get_short_version(plugin_folder)
    assert (len(plugin_version) == 7 or len(plugin_version) == 0)
    project_version = gitutil.get_short_version(project_folder)
    assert (len(project_version) == 7 or len(project_version) == 0)

    info = dict(
        project_name=project_name,
        project_version=project_version,
        plugin_version=plugin_version,
        platform=ue4util.get_platform_name(),
    )

    ue4util.mkdirp(os.path.dirname(info_filename))

    with open(info_filename, 'w') as f:
        json.dump(info, f, indent=4)

    print 'Save project info to file %s' % info_filename
    # print json.dumps(info, indent = 4)

    return True
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--dev',
        help='Continue doing build without checking git status',
        action='store_true')
    args = parser.parse_known_args()[0]

    # Files is relative to this python script
    cur_dir = os.path.dirname(os.path.abspath(__file__))

    plugin_file = ue4util.get_real_abspath(
        os.path.join(cur_dir, '../../UnrealCV.uplugin'))
    if args.dev:
        plugin_output_folder = os.path.join(cur_dir, 'tmp')
        build_plugin(plugin_file, plugin_output_folder)
    else:
        if not is_valid(plugin_file):
            return False

        plugin_version = gitutil.get_short_version(cur_dir)
        plugin_output_folder = ue4util.get_real_abspath(
            os.path.join(cur_dir, 'built_plugin/%s' % plugin_version))
        ue4util.mkdirp(plugin_output_folder)
        info_filename = os.path.join(plugin_output_folder, 'unrealcv-info.txt')

        # Build plugin to disk
        build_plugin(plugin_file, plugin_output_folder)
        save_version_info(info_filename, plugin_file)
Esempio n. 3
0
def save_version_info(info_filename, plugin_file):
    ''' Save version info of UnrealCV plugin '''
    plugin_folder = os.path.dirname(plugin_file)
    plugin_version = gitutil.get_short_version(plugin_folder)
    info = dict(plugin_version=plugin_version)
    print info
    with open(info_filename, 'w') as f:
        json.dump(info, f, indent=4)
Esempio n. 4
0
def main():
    git_version = gitutil.get_short_version('.', force=True)
    # r = list_releases(repo_url)
    # print r.text
    # return
    # print query_by_tag_name(release_data, 'nightly-build')
    release_data = query_by_tag_name1(repo_url, 'nightly-build')
    print 'Git version', git_version

    info = {
        'tag_name': 'nightly-build1',
        'name': 'A Nightly build',
        'target_commitish': 'master',
        # 'target_commitish': git_version,
        # 'body': 'Automatically build from the master branch',
        'draft': False,
        'prerelease': True,
    }

    if not release_data:
        # Create a new release
        release_data = create_release(repo_url, info)
    else:
        r = edit_release(repo_url, release_data['id'], info)
        print r.text

    # release_data = query_by_tag_name1(repo_url, 'master')
    assets = list_assets(repo_url, release_data['id'])
    # for v in assets:
    #     print '-' * 80
    #     print_asset(v)
    #     # pprint(v)

    # for v in assets:
    #     delete_asset(repo_url, v['id'])
    #     # patch_asset(repo_url, v['id'])
    #
    release_id = release_data['id']
    upload_url = release_data['upload_url']
    # # print upload_url
    # upload_asset(repo_url, release_id, upload_url, './index.html')

    version_file = '%s.txt' % git_version
    with open(version_file, 'w') as f:
        f.write(git_version)

    upload_asset(repo_url, release_id, upload_url, version_file)
Esempio n. 5
0
def main():
    # Files is relative to this python script
    cur_dir = os.path.dirname(os.path.abspath(__file__))

    plugin_file = ue4util.get_real_abspath(
        os.path.join(cur_dir, '../../UnrealCV.uplugin'))
    if not is_valid(plugin_file):
        return False

    plugin_version = gitutil.get_short_version(cur_dir)
    plugin_output_folder = ue4util.get_real_abspath(
        os.path.join(cur_dir, 'built_plugin/%s' % plugin_version))
    ue4util.mkdirp(plugin_output_folder)
    info_filename = os.path.join(plugin_output_folder, 'unrealcv-info.txt')

    # Build plugin to disk
    build_plugin(plugin_file, plugin_output_folder)
    save_version_info(info_filename, plugin_file)
Esempio n. 6
0
def main():
    plugin_file = ue4util.get_real_abspath('../../UnrealCV.uplugin')
    if not is_valid(plugin_file):
        return False

    plugin_version = gitutil.get_short_version('.')
    plugin_output_folder = ue4util.get_real_abspath('./built_plugin/%s' %
                                                    plugin_version)
    ue4util.mkdirp(plugin_output_folder)
    info_filename = os.path.join(plugin_output_folder, 'unrealcv-info.txt')

    # Build plugin to disk
    build_plugin(plugin_file, plugin_output_folder)
    save_version_info(info_filename, plugin_file)

    # Upload built plugin to upload location
    upload_confs = ue4config.conf['PluginOutput']
    for upload_conf in upload_confs:
        upload_plugin(plugin_output_folder, upload_conf)
Esempio n. 7
0
def main():
    # Files is relative to this python script
    cur_dir = os.path.dirname(os.path.abspath(__file__))

    # Parse command line arguments
    parser = argparse.ArgumentParser()
    parser.add_argument('project_file')
    parser.add_argument('--engine_path')  # Add here just as a placeholder
    # parser.add_argument('--clean', action='store_true')
    # args = parser.parse_args()
    args, _ = parser.parse_known_args()

    # Read project information
    project_file = ue4util.get_real_abspath(args.project_file)
    project_name = ue4util.get_project_name(project_file)

    # Get plugin information
    project_folder = os.path.dirname(project_file)
    plugin_infofile = os.path.join(project_folder, 'Plugins', 'unrealcv',
                                   'unrealcv-info.txt')
    if not os.path.isfile(plugin_infofile):
        exit('Plugin not exist in the project')
    else:
        with open(plugin_infofile, 'r') as f:
            plugin_info = json.load(f)
            plugin_version = plugin_info['plugin_version']

    project_version = gitutil.get_short_version(project_folder)
    project_output_folder = os.path.join(
        cur_dir, 'built_project/%s/%s-%s' %
        (project_name, project_version, plugin_version))
    info_filename = os.path.join(project_output_folder,
                                 '%s-info.txt' % project_name)

    # if args.clean and os.path.isdir(project_output_folder):
    #     # Use a very strict check to avoid acciently perform the delete
    #     # --force might be dangerous, use it with care
    #     project_output_folder = ue4util.get_real_abspath(project_output_folder)
    #     print 'Try to delete existing compiled project %s' % project_output_folder
    #     assert(project_name in project_output_folder)
    #     assert('*' not in project_output_folder)
    #     assert(project_output_folder.count('/') > 2)
    #     assert(len(project_output_folder) > 10)
    #     shutil.rmtree(project_output_folder)

    if os.path.isdir(project_output_folder):
        print 'Output directory %s exist, delete it first' % project_output_folder
    else:
        # Package game and save version info
        package(project_file, project_output_folder)

        # Save version info after build finished
        # Save one to version folder
        save_version_info(info_filename, project_file, project_output_folder,
                          plugin_version)

        # Save one to project folder
        project_root_folder = os.path.join(cur_dir,
                                           'built_project/%s' % project_name)
        root_info_filename = os.path.join(project_root_folder,
                                          '%s-info.txt' % project_name)
        save_version_info(root_info_filename, project_file,
                          project_output_folder, plugin_version)
Esempio n. 8
0
if __name__ == '__main__':
    # Copy binaries to a remote server with scp
    # Upload built plugin to upload location
    parser = argparse.ArgumentParser()
    parser.add_argument('remote')
    parser.add_argument('--version')
    parser.add_argument('--password', help = 'Account password')
    parser.add_argument('--pkey', help = 'Private key')

    cur_dir = os.path.dirname(os.path.abspath(__file__))

    args = parser.parse_args()
    if args.version:
        plugin_version = args.version
    else:
        plugin_version = gitutil.get_short_version(cur_dir)
    remote = args.remote
    # remote = '%s@%s:%s'

    plugin_output_folder = ue4util.get_real_abspath(os.path.join(cur_dir, 'built_plugin/%s' % plugin_version))
    if not os.path.isdir(plugin_output_folder):
        exit('Version %s of plugin does not exist, compile first' % plugin_version)

    print 'Upload plugin from %s -> %s' % (repr(plugin_output_folder), repr(remote))
    # Use repr so that I can correctly see the difference between / and \\
    local_root = os.path.join(cur_dir, 'built_plugin')
    uploadutil.upload_scp(remote, [plugin_output_folder], local_root,
        password=args.password,
        key_filename=args.pkey,
        DEBUG=False)
    # uploadutil.upload_scp()