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)
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)
def create_directory_structure(target_dir, directories): from python.common import run_command _dry_run = _settings.dry _verbose = _settings.verbose if type(directories) == list: for d in directories: dname = '%s/%s' % (target_dir, d) run_command('mkdir', [dname], dry_run=_dry_run, verbose=_verbose) elif type(directories) == dict: for d in directories: dname = '%s/%s' % (target_dir, d) run_command('mkdir', [dname], dry_run=_dry_run, verbose=_verbose) else: return False return True
def __call__(self): from python.common import run_command target_dir = ProjectStep.get_target_dir() print(run_command('git', ['status'], target_dir, dry_run=_settings.dry, verbose=_settings.verbose ).stdout )
def __call__(self): from python.common import run_command target_dir = ProjectStep.get_target_dir() print( run_command('git', ['status'], target_dir, dry_run=_settings.dry, verbose=_settings.verbose).stdout)
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)
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)
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)