Пример #1
0
    def copy_config_files(source_dir, target_dir, files):
        from os.path import isdir, isfile
        from glob import glob
        from python.common import run_command
        from python.git_common import git_add

        _dry_run = _settings.dry
        _verbose = _settings.verbose

        for file in files:
            src_name = '%s/%s' % (source_dir, file)
            if isdir(src_name):
                atype = type(files[file])
                if atype == list:
                    for e in files[file]:
                        src_name = '%s/%s/%s' % (source_dir, file, e)
                        trg_name = '%s/%s/%s' % (target_dir, file, e)
                        run_command('copy_dir', [src_name, trg_name],
                                    dry_run=_dry_run, verbose=_verbose)
                        if not _dry_run:
                            git_add(trg_name)
                elif atype == dict:
                    for e in files[file]:
                        src_name = '%s/%s/%s' % (source_dir, file, e)
                        trg_name = '%s/%s/%s' % (target_dir, file, files[file][e])
                        run_command('copy_dir', [src_name, trg_name],
                                    dry_run=_dry_run, verbose=_verbose)
                        if not _dry_run:
                            git_add(trg_name)
                elif files[file] is None:
                    src_name = '%s/%s' % (source_dir, file)
                    trg_name = '%s/%s' % (target_dir, file)
                    run_command('copy_dir', [src_name, trg_name],
                                dry_run=_dry_run, verbose=_verbose)
                    if not _dry_run:
                        git_add(trg_name)

            elif isfile(src_name):
                trg_name = None
                if type(files[file]) == str:
                    trg_name = '%s/%s' % (target_dir, files[file])
                elif files[file] is None:
                    trg_name = '%s/%s' % (target_dir, file)
                run_command('update_file', [src_name, trg_name],
                            dry_run=_dry_run, verbose=_verbose)
                if not _dry_run:
                    git_add(trg_name)
            else:
                assert ( type(files[file]) == str )
                glb_files = glob(src_name)
                trg_name = '%s/%s/' % (target_dir, files[file])
                if len(glb_files) > 1:
                    for g in glb_files:
                        run_command('update_file', [g, trg_name],
                                    dry_run=_dry_run, verbose=_verbose)
                    if not _dry_run:
                        git_add(trg_name)
Пример #2
0
    def configure_all_files(src_dir, trg_dir, files, variables):
        from python.common import configure_file
        from python.git_common import git_add

        for file in files:
            src_file = '%s/%s' % (src_dir, file)
            trg_file = '%s/%s' % (trg_dir, files[file])

            configure_file(src_file, trg_file, variables, _settings.verbose, _settings.dry)
            if not _settings.dry:
                git_add(trg_file)
Пример #3
0
    def __call__(self):
        from python.git_common import git_add
        from python.common import run_command

        target_dir = ProjectStep.get_target_dir()

        for f in ('%s/rebuild.py' % target_dir, '%s/toolchain/configure_ci.py' % target_dir):
            run_command('add_execute', [f],
                        dry_run=_settings.dry,
                        verbose=_settings.verbose)
            if not _settings.dry:
                git_add(f)
Пример #4
0
    def configure_all_files(src_dir, trg_dir, files, variables):
        from python.common import configure_file
        from python.git_common import git_add

        for file in files:
            src_file = '%s/%s' % (src_dir, file)
            trg_file = '%s/%s' % (trg_dir, files[file])

            configure_file(src_file, trg_file, variables, _settings.verbose,
                           _settings.dry)
            if not _settings.dry:
                git_add(trg_file)
Пример #5
0
    def __call__(self):
        from python.git_common import git_add
        from python.common import run_command

        target_dir = ProjectStep.get_target_dir()

        for f in ('%s/rebuild.py' % target_dir,
                  '%s/toolchain/configure_ci.py' % target_dir):
            run_command('add_execute', [f],
                        dry_run=_settings.dry,
                        verbose=_settings.verbose)
            if not _settings.dry:
                git_add(f)
Пример #6
0
    def __call__(self):
        from python.cmake_common import cmake_generate_findscript
        from configure_ci import try_get_key
        from python.git_common import git_add

        cmake_script = cmake_generate_findscript(
            try_get_key(_prev_build_data, 'exports', {}))

        pname = try_get_key(_prev_build_data, 'name', 'coffee_project')
        cmake_script = cmake_script.replace('@PROJECT_NAME@', pname)

        target_dir = ProjectStep.get_target_dir()
        script_name = '%s/Find%s.cmake' % (target_dir, pname)

        if _settings.dry or _settings.verbose:
            print('Writing %s:\n%s' % (script_name, cmake_script))

        if not _settings.dry:
            with open(script_name, mode='w') as f:
                f.write(cmake_script)
            git_add(script_name)
Пример #7
0
    def __call__(self):
        from python.cmake_common import cmake_generate_findscript
        from configure_ci import try_get_key
        from python.git_common import git_add

        cmake_script = cmake_generate_findscript(try_get_key(_prev_build_data,
                                                             'exports',
                                                             {})
                                                 )

        pname = try_get_key(_prev_build_data, 'name', 'coffee_project')
        cmake_script = cmake_script.replace('@PROJECT_NAME@',
                                            pname)

        target_dir = ProjectStep.get_target_dir()
        script_name = '%s/Find%s.cmake' % (target_dir, pname)

        if _settings.dry or _settings.verbose:
            print('Writing %s:\n%s' % (script_name, cmake_script))

        if not _settings.dry:
            with open(script_name, mode='w') as f:
                f.write(cmake_script)
            git_add(script_name)
Пример #8
0
    def __call__(self):
        from copy import deepcopy
        from python.git_common import git_add, git_get_commit, git_get_slug
        from python.common import run_command, build_yml_filespec
        from os.path import isfile
        import configure_ci

        src_dir = ProjectStep.get_source_dir()
        trg_dir = ProjectStep.get_target_dir()

        src_file = '%s/%s' % (src_dir, self.template)
        trg_file = '%s/%s' % (trg_dir, build_yml_filespec)
        old_trg_file = '%s/%s' % (trg_dir, 'build.yml')

        structure = None
        # Get current version of engine
        engine_version = git_get_commit(src_dir)
        engine_slug = git_get_slug(src_dir)

        # If file exists, update the contents
        if isfile(trg_file) or isfile(old_trg_file):
            if isfile(trg_file):
                structure = configure_ci.parse_yaml(trg_file)
            if isfile(old_trg_file):
                structure = configure_ci.parse_yaml(old_trg_file)
                run_command('remove_file', [old_trg_file],
                            dry_run=_settings.dry,
                            verbose=_settings.verbose)

            if 'dependencies' in structure:
                v = structure['dependencies']

                # If using a list, convert to dictionary
                if type(v) == list:
                    dv = {}
                    print('Updating %s structure' % (build_yml_filespec,))
                    structure.pop('engine_version', None)
                    for e in v:
                        try:
                            dv[e.split(':')[1]] = '*'
                        except IndexError:
                            pass
                    structure['dependencies'] = dv
                    v = dv

                if engine_slug in v:
                    structure['dependencies'][engine_slug] = engine_version
        # If it does not exist, configure a new one
        else:
            structure = configure_ci.parse_yaml(src_file)
            #configure_ci.parse_linux_targets()

            structure['dependencies'][engine_slug] = engine_version

            structure['name'] = _struct.name
            structure['display_name'] = _struct.display_name
            structure['version'] = {
                     "major": 0,
                     "minor": 0,
                     "release": 1,
                     "patch": 0,
                     "hotfix": 0,
                }

        config_files = configure_ci.generate_config_files(self.ci_services,
                                                          deepcopy(structure),
                                                          trg_dir)

        global _prev_build_data
        _prev_build_data = structure
        yaml_data = configure_ci.render_yaml(structure)

        if _settings.dry or _settings.verbose:
            for config in config_files:
                yaml_config = configure_ci.render_yaml(config_files[config])
                print('Writing file %s/%s:' % (trg_dir, config))
                print(yaml_config)
            print('Writing file %s:' % trg_file)
            print(yaml_data)
            if _settings.dry:
                return

        configure_ci.process_configs(config_files,
                                     print_config=_settings.verbose,
                                     cur_dir=trg_dir)

        if not _settings.dry:
            for config in config_files:
                git_add('%s/%s' % (trg_dir, config))
            with open(trg_file, mode='w') as f:
                f.write(yaml_data)
            git_add(trg_file)
Пример #9
0
    def __call__(self):
        from copy import deepcopy
        from python.git_common import git_add, git_get_commit, git_get_slug
        from python.common import run_command, build_yml_filespec
        from os.path import isfile
        import configure_ci

        src_dir = ProjectStep.get_source_dir()
        trg_dir = ProjectStep.get_target_dir()

        src_file = '%s/%s' % (src_dir, self.template)
        trg_file = '%s/%s' % (trg_dir, build_yml_filespec)
        old_trg_file = '%s/%s' % (trg_dir, 'build.yml')

        structure = None
        # Get current version of engine
        engine_version = git_get_commit(src_dir)
        engine_slug = git_get_slug(src_dir)

        # If file exists, update the contents
        if isfile(trg_file) or isfile(old_trg_file):
            if isfile(trg_file):
                structure = configure_ci.parse_yaml(trg_file)
            if isfile(old_trg_file):
                structure = configure_ci.parse_yaml(old_trg_file)
                run_command('remove_file', [old_trg_file],
                            dry_run=_settings.dry,
                            verbose=_settings.verbose)

            if 'dependencies' in structure:
                v = structure['dependencies']

                # If using a list, convert to dictionary
                if type(v) == list:
                    dv = {}
                    print('Updating %s structure' % (build_yml_filespec, ))
                    structure.pop('engine_version', None)
                    for e in v:
                        try:
                            dv[e.split(':')[1]] = '*'
                        except IndexError:
                            pass
                    structure['dependencies'] = dv
                    v = dv

                if engine_slug in v:
                    structure['dependencies'][engine_slug] = engine_version
        # If it does not exist, configure a new one
        else:
            structure = configure_ci.parse_yaml(src_file)
            #configure_ci.parse_linux_targets()

            structure['dependencies'][engine_slug] = engine_version

            structure['name'] = _struct.name
            structure['display_name'] = _struct.display_name
            structure['version'] = {
                "major": 0,
                "minor": 0,
                "release": 1,
                "patch": 0,
                "hotfix": 0,
            }

        config_files = configure_ci.generate_config_files(
            self.ci_services, deepcopy(structure), trg_dir)

        global _prev_build_data
        _prev_build_data = structure
        yaml_data = configure_ci.render_yaml(structure)

        if _settings.dry or _settings.verbose:
            for config in config_files:
                yaml_config = configure_ci.render_yaml(config_files[config])
                print('Writing file %s/%s:' % (trg_dir, config))
                print(yaml_config)
            print('Writing file %s:' % trg_file)
            print(yaml_data)
            if _settings.dry:
                return

        configure_ci.process_configs(config_files,
                                     print_config=_settings.verbose,
                                     cur_dir=trg_dir)

        if not _settings.dry:
            for config in config_files:
                git_add('%s/%s' % (trg_dir, config))
            with open(trg_file, mode='w') as f:
                f.write(yaml_data)
            git_add(trg_file)
Пример #10
0
    def copy_config_files(source_dir, target_dir, files):
        from os.path import isdir, isfile
        from glob import glob
        from python.common import run_command
        from python.git_common import git_add

        _dry_run = _settings.dry
        _verbose = _settings.verbose

        for file in files:
            src_name = '%s/%s' % (source_dir, file)
            if isdir(src_name):
                atype = type(files[file])
                if atype == list:
                    for e in files[file]:
                        src_name = '%s/%s/%s' % (source_dir, file, e)
                        trg_name = '%s/%s/%s' % (target_dir, file, e)
                        run_command('copy_dir', [src_name, trg_name],
                                    dry_run=_dry_run,
                                    verbose=_verbose)
                        if not _dry_run:
                            git_add(trg_name)
                elif atype == dict:
                    for e in files[file]:
                        src_name = '%s/%s/%s' % (source_dir, file, e)
                        trg_name = '%s/%s/%s' % (target_dir, file,
                                                 files[file][e])
                        run_command('copy_dir', [src_name, trg_name],
                                    dry_run=_dry_run,
                                    verbose=_verbose)
                        if not _dry_run:
                            git_add(trg_name)
                elif files[file] is None:
                    src_name = '%s/%s' % (source_dir, file)
                    trg_name = '%s/%s' % (target_dir, file)
                    run_command('copy_dir', [src_name, trg_name],
                                dry_run=_dry_run,
                                verbose=_verbose)
                    if not _dry_run:
                        git_add(trg_name)

            elif isfile(src_name):
                trg_name = None
                if type(files[file]) == str:
                    trg_name = '%s/%s' % (target_dir, files[file])
                elif files[file] is None:
                    trg_name = '%s/%s' % (target_dir, file)
                run_command('update_file', [src_name, trg_name],
                            dry_run=_dry_run,
                            verbose=_verbose)
                if not _dry_run:
                    git_add(trg_name)
            else:
                assert (type(files[file]) == str)
                glb_files = glob(src_name)
                trg_name = '%s/%s/' % (target_dir, files[file])
                if len(glb_files) > 1:
                    for g in glb_files:
                        run_command('update_file', [g, trg_name],
                                    dry_run=_dry_run,
                                    verbose=_verbose)
                    if not _dry_run:
                        git_add(trg_name)