Пример #1
0
def genloc(config):
    """ Generate localization """
    print_action('Generating Localization')
    cmd_args = [
        config.uproject_file_path, '-Run=GatherText',
        '-config={}'.format(config.proj_localization_script), '-log'
    ]
    if launch(config.UE4EditorPath, cmd_args) != 0:
        error_exit('Failed to generate localization, see errors...')

    click.pause()
Пример #2
0
def genproj(config):
    """ Generate project file """
    print_action('Generating Project Files')

    cmd_args = [
        '-ProjectFiles', '-project={}'.format(config.uproject_file_path),
        '-game', '-engine'
    ]
    if get_visual_studio_version() == 2017:
        cmd_args.append('-2017')
    if launch(config.UE4UBTPath, cmd_args) != 0:
        error_exit('Failed to generate project files, see errors...')
Пример #3
0
    def do_build(self, build_name):
        # If the build starts with the project name, we know this is a game project being built
        is_game_project = build_name.startswith(self.config.uproject_name)

        print_action('{} {}'.format(
            'Building' if not self.config.clean else 'Cleaning', build_name))

        cmd_args = [
            build_name, self.config.platform, self.config.configuration
        ]
        if is_game_project:
            cmd_args.append(self.config.uproject_file_path)
        cmd_args += ['-NoHotReload', '-waitmutex']
        if self.config.engine_minor_version <= 25:
            cmd_args.append('-VS{}'.format(
                get_visual_studio_version(
                    self.config.get_suitable_vs_versions())))
        else:
            # Engine versions greater than 25 can determine visual studios location and will do it automatically.
            # We include -FromMsBuild which is common beyond version 25 but it is just a format specifier.
            cmd_args.append('-FromMsBuild')

        # Do any pre cleaning
        if self.config.clean or self.force_clean:
            if is_game_project:
                self.clean_game_project_folder()
            else:
                if launch(self.config.UE4CleanBatchPath, cmd_args) != 0:
                    self.error = 'Failed to clean project {}'.format(
                        build_name)
                    return False

        # Do the actual build
        if launch(self.config.UE4BuildBatchPath, cmd_args) != 0:
            self.error = 'Failed to build "{}"!'.format(build_name)
            return False
        return True
Пример #4
0
    def run(self):
        if not self.config.automated:
            # First make sure we actually have git credentials
            ssh_path = os.path.join(os.environ['USERPROFILE'], '.ssh')
            if not os.path.exists(ssh_path) and self.rsa_path != '':
                rsa_file = os.path.join(self.config.uproject_dir_path, self.rsa_path)
                if not os.path.isfile(rsa_file):
                    self.error = 'No git credentials exists at rsa_path! ' \
                                 'Check rsa_path is relative to the project path and exists.'
                    return False
                os.mkdir(ssh_path)
                shutil.copy2(rsa_file, ssh_path)

            # To get around the annoying user prompt, lets just set github to be trusted, no key checking
            if self.disable_strict_hostkey_check:
                if not os.path.isfile(os.path.join(ssh_path, 'config')):
                    with open(os.path.join(ssh_path, 'config'), 'w') as fp:
                        fp.write('Host github.com\nStrictHostKeyChecking no')

        output_dir = os.path.join(self.config.uproject_dir_path, self.output_folder)

        if self.force_repull and os.path.exists(output_dir):
            print_action("Deleting Unreal Engine Folder for a complete re-pull")

            def on_rm_error(func, path, exc_info):
                # path contains the path of the file that couldn't be removed
                # let's just assume that it's read-only and unlink it.
                del func  # unused
                if exc_info[0] is not FileNotFoundError:
                    os.chmod(path, stat.S_IWRITE)
                    os.unlink(path)

            # Forcing a re-pull, delete the whole engine directory!
            shutil.rmtree(output_dir, onerror=on_rm_error)

        if not os.path.isdir(output_dir):
            os.makedirs(output_dir)

        if not os.path.isdir(os.path.join(output_dir, '.git')):
            print_action("Cloning from Git '{}' branch '{}'".format(self.repo_name, self.branch_name))
            cmd_args = ['clone', '-b', self.branch_name, self.repo_name, output_dir]
            err = launch('git', cmd_args)
            if err != 0:
                self.error = 'Git clone failed!'
                return False
        else:
            with push_directory(output_dir):
                print_action("Pulling from Git '{}' branch '{}'".format(self.repo_name, self.branch_name))
                err = launch('git', ['pull', 'origin', self.branch_name], silent=True)
                if err != 0:
                    self.error = 'Git pull failed!'
                    return False
        return True