def check_imports(fips_dir, proj_dir) : """recursively check imports""" log.colored(log.YELLOW, '=== imports:') if util.is_valid_project_dir(proj_dir) : dep.check_imports(fips_dir, proj_dir) else : log.warn('currently not in a project directory')
def check_imports(fips_dir, proj_dir): """recursively check imports""" log.colored(log.YELLOW, '=== imports:') if util.is_valid_project_dir(proj_dir): dep.check_imports(fips_dir, proj_dir) else: log.warn('currently not in a project directory')
def list_targets(fips_dir, proj_dir, args): log.colored(log.YELLOW, "=== targets:") if util.is_valid_project_dir(proj_dir): # get config name if len(args) == 0: cfg_name = settings.get(proj_dir, 'config') else: cfg_name = args[0] log.info('{} config:{} {}'.format(log.BLUE, log.DEF, cfg_name)) # get the target list success, targets = project.get_target_list(fips_dir, proj_dir, cfg_name) if success: # split targets by type for type in ['lib', 'module', 'sharedlib', 'app']: type_targets = [tgt for tgt in targets if targets[tgt] == type] if len(type_targets) > 0: log.colored(log.BLUE, ' {}:'.format(type)) for tgt in type_targets: log.info(' ' + tgt) else: log.info( " can't fetch project target list, please run 'fips gen' first!" ) else: log.info(' currently not in a valid project directory')
def check_local_changes(fips_dir, proj_dir): """check if any imports have local, uncommitted changes""" log.colored(log.YELLOW, '=== local changes:') if util.is_valid_project_dir(proj_dir): dep.check_local_changes(fips_dir, proj_dir) else: log.warn('currently not in a project directory')
def run(fips_dir, proj_dir, args) : if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') if len(args) > 0: if args[0] == 'clean': vscode.cleanup(fips_dir, proj_dir) else: log.error("invalid noun '{}' (expected: clean)".format(noun))
def run(fips_dir, proj_dir, args): if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') if len(args) > 0: if args[0] == 'clean': vscode.cleanup(fips_dir, proj_dir) else: log.error("invalid noun '{}' (expected: clean)".format(args[0]))
def run(fips_dir, proj_dir, args): if util.is_valid_project_dir(proj_dir): cfg_name = settings.get(proj_dir, 'config') cfg = config.load(fips_dir, proj_dir, cfg_name)[0] res = cmake.get_codemodel(fips_dir, proj_dir, cfg) if res is not None: print(json.dumps(res, indent=2, separators=(',', ':'))) else: log.error("must be run from a project directory")
def run(fips_dir, proj_dir, args): """run the 'open' verb (opens project in IDE)""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') proj_name = util.get_project_name_from_dir(proj_dir) cfg_name = None if len(args) > 0: cfg_name = args[0] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') # check the cmake generator of this config configs = config.load(fips_dir, proj_dir, cfg_name) if configs: # hmm, only look at first match, 'open' doesn't # make sense with config-patterns cfg = configs[0] # find build dir, if it doesn't exist, generate it build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name']) if not os.path.isdir(build_dir): log.warn("build dir not found, generating...") project.gen(fips_dir, proj_dir, cfg['name']) # first check if this is a VSCode project if cfg['build_tool'] == 'vscode_cmake': vscode.run(proj_dir) return # check if this is a CLion project if cfg['build_tool'] == 'clion': clion.run(proj_dir) return # try to open as Xcode project proj = glob.glob(build_dir + '/*.xcodeproj') if proj: subprocess.call('open "{}"'.format(proj[0]), shell=True) return # try to open as VS project proj = glob.glob(build_dir + '/*.sln') if proj: subprocess.call('cmd /c start {}'.format(proj[0]), shell=True) return # try to open as eclipse project proj = glob.glob(build_dir + '/.cproject') if proj: subprocess.call( 'eclipse -nosplash --launcher.timeout 60 -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import "{}"' .format(build_dir), shell=True) subprocess.call('eclipse', shell=True) return log.error("don't know how to open a '{}' project in {}".format( cfg['generator'], build_dir)) else: log.error("config '{}' not found".format(cfg_name))
def run(fips_dir, proj_dir, args): """configure fips project""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') cfg_name = None if len(args) > 0: cfg_name = args[0] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') project.configure(fips_dir, proj_dir, cfg_name)
def run(fips_dir, proj_dir, args) : """build fips project""" if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') cfg_name = None if len(args) > 0 : cfg_name = args[0] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') project.build(fips_dir, proj_dir, cfg_name)
def list_settings(proj_dir) : """list settings file content""" log.colored(log.YELLOW, '=== settings:') if util.is_valid_project_dir(proj_dir) : all_settings = settings.get_all_settings(proj_dir) for key, value in all_settings.items(): is_default = ' (default value)' if value == settings.get_default(key) else '' if type(value) is bool: value = 'on' if value else 'off' log.info(' {}{}:{} {}{}'.format(log.BLUE, key, log.DEF, value, is_default)) else : log.info(' currently not in a valid project directory')
def run(fips_dir, proj_dir, args): """clean generated files""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') cfg_name = None if len(args) > 0: cfg_name = args[0] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') if cfg_name == 'all': cfg_name = '*' project.clean(fips_dir, proj_dir, cfg_name)
def run(fips_dir, proj_dir, args) : """clean generated files""" if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') cfg_name = None if len(args) > 0 : cfg_name = args[0] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') if cfg_name == 'all' : cfg_name = '*' project.clean(fips_dir, proj_dir, cfg_name)
def list_settings(proj_dir) : """list settings file content""" log.colored(log.YELLOW, '=== settings:') if util.is_valid_project_dir(proj_dir) : for key in ['config', 'target', 'jobs', 'ccache'] : value = settings.get(proj_dir, key) if type(value) is bool : value = 'on' if value else 'off' default = ' (default value)' if value == settings.get_default(key) else '' log.info(' {}{}:{} {}{}'.format(log.BLUE, key, log.DEF, value, default)) else : log.info(' currently not in a valid project directory')
def get_imports(fips_dir, proj_dir): """get the imports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with imports (can be empty) """ proj_name = util.get_project_name_from_dir(proj_dir) imports = {} if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'imports' in dic: imports = dic['imports'] # warn if this is an old-style list instead of new style dict if imports: if type(imports) is list: log.warn("imports in '{}/fips.yml' uses obsolete array format". format(proj_dir)) # convert old style to new dict format # FIXME: should be removed after a while new_imports = {} for dep in imports: dep_url = registry.get_url(fips_dir, dep) if not util.is_git_url(dep_url): log.error( "'{}' cannot be resolved into a git url (in project '{}')" .format(dep_url, proj_name)) dep_proj_name = util.get_project_name_from_url(dep_url) new_imports[dep_proj_name] = {} new_imports[dep_proj_name][ 'git'] = util.get_giturl_from_url(dep_url) new_imports[dep_proj_name][ 'branch'] = util.get_gitbranch_from_url(dep_url) imports = new_imports elif type(imports) is dict: for dep in imports: if not 'branch' in imports[dep]: imports[dep]['branch'] = 'master' if not 'cond' in imports[dep]: imports[dep]['cond'] = None if not 'git' in imports[dep]: log.error( "no git URL in import '{}' in '{}/fips.yml'!\n". format(dep, proj_dir)) if not 'group' in imports[dep]: imports[dep]['group'] = None else: log.error( "imports in '{}/fips.yml' must be a dictionary!".format( proj_dir)) return imports
def run(fips_dir, proj_dir, args) : """run the 'open' verb (opens project in IDE)""" if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') proj_name = util.get_project_name_from_dir(proj_dir) cfg_name = None if len(args) > 0 : cfg_name = args[0] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') # check the cmake generator of this config configs = config.load(fips_dir, proj_dir, cfg_name) if configs : # hmm, only look at first match, 'open' doesn't # make sense with config-patterns cfg = configs[0] # find build dir, if it doesn't exist, generate it build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name']) if not os.path.isdir(build_dir) : log.warn("build dir not found, generating...") project.gen(fips_dir, proj_dir, cfg['name']) # first check if this is a VSCode project if cfg['build_tool'] == 'vscode_cmake': vscode.run(proj_dir) return # check if this is a CLion project if cfg['build_tool'] == 'clion': clion.run(proj_dir) return # try to open as Xcode project proj = glob.glob(build_dir + '/*.xcodeproj') if proj : subprocess.call('open "{}"'.format(proj[0]), shell=True) return # try to open as VS project proj = glob.glob(build_dir + '/*.sln') if proj : subprocess.call('cmd /c start {}'.format(proj[0]), shell=True) return # try to open as eclipse project proj = glob.glob(build_dir + '/.cproject') if proj : subprocess.call('eclipse -nosplash --launcher.timeout 60 -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import "{}"'.format(build_dir), shell=True) subprocess.call('eclipse', shell=True) return log.error("don't know how to open a '{}' project in {}".format(cfg['generator'], build_dir)) else : log.error("config '{}' not found".format(cfg_name))
def list_settings(proj_dir): """list settings file content""" log.colored(log.YELLOW, '=== settings:') if util.is_valid_project_dir(proj_dir): for key in ['config', 'target', 'jobs', 'ccache', 'iosteam']: value = settings.get(proj_dir, key) if type(value) is bool: value = 'on' if value else 'off' default = ' (default value)' if value == settings.get_default( key) else '' log.info(' {}{}:{} {}{}'.format(log.BLUE, key, log.DEF, value, default)) else: log.info(' currently not in a valid project directory')
def get_fips_yml_defines(proj_dir): """loads FIPS defines from fips.yml file, or None if none are specified. :param proj_dir: the project directory :returns: true/false """ if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'defines' in dic and type(dic['defines']) is dict: return dic['defines'] return None
def run(fips_dir, proj_dir, args): """build fips project""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') cfg_name = None build_tool_args = None if '--' in args: idx = args.index('--') build_tool_args = args[(idx + 1):] args = args[:idx] if len(args) > 0: cfg_name = args[0] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') project.build(fips_dir, proj_dir, cfg_name, None, build_tool_args)
def run(fips_dir, proj_dir, args): if len(args) > 0: if len(args) > 1: proj_name = args[1] proj_dir = util.get_project_dir(fips_dir, proj_name) if not util.is_valid_project_dir(proj_dir): log.error('{} is not a valid fips project!'.format(proj_name)) if args[0] == 'build': markdeep.build(fips_dir, proj_dir) elif args[0] == 'view': # view also build the markdown docs first markdeep.build(fips_dir, proj_dir) markdeep.view(fips_dir, proj_dir) else: log.error("expected 'build' or 'serve' arg") else: log.error("expected 'build' or 'serve' arg")
def run(fips_dir, proj_dir, args): if len(args) > 0: if len(args) > 1: proj_name = args[1] proj_dir = util.get_project_dir(fips_dir, proj_name) if not util.is_valid_project_dir(proj_dir): log.error('{} is not a valid fips project!'.format(proj_name)) if args[0] == 'build': markdeep.build(fips_dir, proj_dir) elif args[0] == 'view': # view also build the markdown docs first markdeep.build(fips_dir, proj_dir) markdeep.view(fips_dir, proj_dir) else: log.error("expected 'build' or 'view' arg") else: log.error("expected 'build' or 'view' arg")
def run(fips_dir, proj_dir, args): """build a single target""" if not util.is_valid_project_dir(proj_dir): log.error("must be run in a project directory") tgt_name = None cfg_name = None if len(args) > 0: tgt_name = args[0] if len(args) > 1: cfg_name = args[1] if not cfg_name: cfg_name = settings.get(proj_dir, "config") if not tgt_name: tgt_name = settings.get(proj_dir, "target") if tgt_name == "clean": project.make_clean(fips_dir, proj_dir, cfg_name) else: project.build(fips_dir, proj_dir, cfg_name, tgt_name)
def run(fips_dir, proj_dir, args): """build a single target""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') tgt_name = None cfg_name = None if len(args) > 0: tgt_name = args[0] if len(args) > 1: cfg_name = args[1] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') if not tgt_name: tgt_name = settings.get(proj_dir, 'target') if tgt_name == 'clean': project.make_clean(fips_dir, proj_dir, cfg_name) else: project.build(fips_dir, proj_dir, cfg_name, tgt_name)
def get_imports(fips_dir, proj_dir) : """get the imports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with imports (can be empty) """ proj_name = util.get_project_name_from_dir(proj_dir) imports = {} if util.is_valid_project_dir(proj_dir) : dic = util.load_fips_yml(proj_dir) if 'imports' in dic : imports = dic['imports'] # warn if this is an old-style list instead of new style dict if imports : if type(imports) is list : log.warn("imports in '{}/fips.yml' uses obsolete array format".format(proj_dir)) # convert old style to new dict format # FIXME: should be removed after a while new_imports = {} for dep in imports : dep_url = registry.get_url(fips_dir, dep) if not util.is_git_url(dep_url) : log.error("'{}' cannot be resolved into a git url (in project '{}')".format(dep_url, proj_name)) dep_proj_name = util.get_project_name_from_url(dep_url) new_imports[dep_proj_name] = {} new_imports[dep_proj_name]['git'] = util.get_giturl_from_url(dep_url) new_imports[dep_proj_name]['branch'] = util.get_gitbranch_from_url(dep_url) imports = new_imports elif type(imports) is dict : for dep in imports : if not 'branch' in imports[dep] : imports[dep]['branch'] = 'master' if not 'cond' in imports[dep] : imports[dep]['cond'] = None if not 'git' in imports[dep] : log.error("no git URL in import '{}' in '{}/fips.yml'!\n".format(dep, proj_dir)) if not 'group' in imports[dep] : imports[dep]['group'] = None else : log.error("imports in '{}/fips.yml' must be a dictionary!".format(proj_dir)) return imports
def run(fips_dir, proj_dir, args): """run fips project build targets""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') cfg_name = settings.get(proj_dir, 'config') target_name = settings.get(proj_dir, 'target') target_args = [] if '--' in args: idx = args.index('--') target_args = args[(idx + 1):] args = args[:idx] if len(args) > 0: target_name = args[0] if len(args) > 1: cfg_name = args[1] if target_name: project.run(fips_dir, proj_dir, cfg_name, target_name, target_args) else: log.error('no target provided')
def list_exports(fips_dir, proj_dir): """list project exports""" log.colored(log.YELLOW, '=== exports:') if util.is_valid_project_dir(proj_dir): success, result = dep.get_all_imports_exports(fips_dir, proj_dir) if not success: log.warn( "missing import project directories, please un 'fips fetch'") for dep_proj_name in result: cur_dep = result[dep_proj_name] log.colored(log.BLUE, "project '{}' exports:".format(dep_proj_name)) cur_modules = cur_dep['exports']['modules'] cur_hdrs = cur_dep['exports']['header-dirs'] cur_libs = cur_dep['exports']['lib-dirs'] cur_defs = cur_dep['exports']['defines'] if not (cur_modules or cur_hdrs or cur_libs or cur_defs): log.info(" nothing") if cur_modules: log.info(" modules:") for mod in cur_modules: log.info(" {} => {}".format(mod, cur_modules[mod])) if cur_hdrs: log.info(" header search dirs:") for hdr in cur_hdrs: log.info(" {}".format(hdr)) if cur_libs: log.info(" lib search dirs:") for lib in cur_libs: log.info(" {}".format(lib)) if cur_defs: log.info(" defines:") for define in cur_defs: log.info(" {} => {}".format(define, cur_defs[define])) else: log.info(' currently not in a valid project directory')
def get_exports(proj_dir): """get the exports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with exports (can be empty) """ exports = {} if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'exports' in dic: exports = dic['exports'] if not 'header-dirs' in exports: exports['header-dirs'] = [] if not 'lib-dirs' in exports: exports['lib-dirs'] = [] if not 'defines' in exports: exports['defines'] = {} if not 'modules' in exports: exports['modules'] = {} return exports
def get_exports(proj_dir) : """get the exports from the fips.yml file in proj_dir :param proj_dir: the project directory :returns: dictionary object with exports (can be empty) """ exports = {} if util.is_valid_project_dir(proj_dir) : dic = util.load_fips_yml(proj_dir) if 'exports' in dic : exports = dic['exports'] if not 'header-dirs' in exports : exports['header-dirs'] = [] if not 'lib-dirs' in exports : exports['lib-dirs'] = [] if not 'defines' in exports : exports['defines'] = {} if not 'modules' in exports : exports['modules'] = {} return exports
def run(fips_dir, proj_dir, args): """run fips project build targets""" if not util.is_valid_project_dir(proj_dir): log.error("must be run in a project directory") cfg_name = settings.get(proj_dir, "config") target_name = settings.get(proj_dir, "target") target_args = [] if "--" in args: idx = args.index("--") target_args = args[(idx + 1) :] args = args[:idx] if len(args) > 0: target_name = args[0] if len(args) > 1: cfg_name = args[1] if target_name: target_cwd = util.lookup_target_cwd(proj_dir, target_name) retcode = project.run(fips_dir, proj_dir, cfg_name, target_name, target_args, target_cwd) sys.exit(retcode) else: log.error("no target provided")
def list_imports(fips_dir, proj_dir) : """list project imports""" log.colored(log.YELLOW, '=== imports:') if util.is_valid_project_dir(proj_dir) : success, result = dep.get_all_imports_exports(fips_dir, proj_dir) if not success : log.warn("missing import project directories, please run 'fips fetch'") for dep_proj_name in result : # top level project is in result, but has no URL set, filter # this from the output log.colored(log.BLUE, "project '{}' imports:".format(dep_proj_name)) cur_dep = result[dep_proj_name] if cur_dep['imports'] : for imp_proj in cur_dep['imports'] : git_url = cur_dep['imports'][imp_proj]['git'] git_branch = cur_dep['imports'][imp_proj]['branch'] log.info(" '{}' from '{}' at branch '{}'".format(imp_proj, git_url, git_branch)) else : log.info(" nothing") else : log.info(' currently not in a valid project directory')
def get_policy(proj_dir, policy): """checks whether a policy is defined in the projects fips.yml and returns its bool value, or the default if not defined. :param proj_dir: the project directory :param policy: the policy string name :returns: true/false """ def_policies = {'no_auto_import': False} if util.is_valid_project_dir(proj_dir): dic = util.load_fips_yml(proj_dir) if 'policies' in dic and type(dic['policies']) is dict: if policy in dic['policies']: return dic['policies'][policy] # not found, return default if policy in def_policies: return def_policies[policy] else: # unknown policy, return None log.error("unknown policy name: '{}'".format(policy)) return None
def list_exports(fips_dir, proj_dir) : """list project exports""" log.colored(log.YELLOW, '=== exports:') if util.is_valid_project_dir(proj_dir) : success, result = dep.get_all_imports_exports(fips_dir, proj_dir) if not success : log.warn("missing import project directories, please un 'fips fetch'") for dep_proj_name in result : cur_dep = result[dep_proj_name] log.colored(log.BLUE, "project '{}' exports:".format(dep_proj_name)) cur_modules = cur_dep['exports']['modules'] cur_hdrs = cur_dep['exports']['header-dirs'] cur_libs = cur_dep['exports']['lib-dirs'] cur_defs = cur_dep['exports']['defines'] if not (cur_modules or cur_hdrs or cur_libs or cur_defs) : log.info(" nothing") if cur_modules : log.info(" modules:") for mod in cur_modules : log.info(" {} => {}".format(mod, cur_modules[mod])) if cur_hdrs : log.info(" header search dirs:") for hdr in cur_hdrs : log.info(" {}".format(hdr)) if cur_libs : log.info(" lib search dirs:") for lib in cur_libs : log.info(" {}".format(lib)) if cur_defs : log.info(" defines:") for define in cur_defs : log.info(" {} => {}".format(define, cur_defs[define])) else : log.info(' currently not in a valid project directory')
def run(fips_dir, proj_dir, args) : """debug a single target with valgrind""" if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') tgt_name = None cfg_name = None tgt_args = [] if '--' in args : idx = args.index('--') tgt_args = args[(idx + 1):] args = args[:idx] if len(args) > 0 : tgt_name = args[0] if len(args) > 1 : cfg_name = args[1] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') if not tgt_name : tgt_name = settings.get(proj_dir, 'target') if not tgt_name : log.error('no target specified') valgrind(fips_dir, proj_dir, cfg_name, tgt_name, tgt_args)
def run(fips_dir, proj_dir, args): """debug a single target with valgrind""" if not util.is_valid_project_dir(proj_dir): log.error("must be run in a project directory") tgt_name = None cfg_name = None tgt_args = [] if "--" in args: idx = args.index("--") tgt_args = args[(idx + 1) :] args = args[:idx] if len(args) > 0: tgt_name = args[0] if len(args) > 1: cfg_name = args[1] if not cfg_name: cfg_name = settings.get(proj_dir, "config") if not tgt_name: tgt_name = settings.get(proj_dir, "target") if not tgt_name: log.error("no target specified") valgrind(fips_dir, proj_dir, cfg_name, tgt_name, tgt_args)
def get_policy(proj_dir, policy) : """checks whether a policy is defined in the projects fips.yml and returns its bool value, or the default if not defined. :param proj_dir: the project directory :param policy: the policy string name :returns: true/false """ def_policies = { 'no_auto_import': False } if util.is_valid_project_dir(proj_dir) : dic = util.load_fips_yml(proj_dir) if 'policies' in dic and type(dic['policies']) is dict: if policy in dic['policies'] : return dic['policies'][policy] # not found, return default if policy in def_policies : return def_policies[policy] else : # unknown policy, return None log.error("unknown policy name: '{}'".format(policy)) return None
def run(fips_dir, proj_dir, args): """run the 'open' verb (opens project in IDE)""" if not util.is_valid_project_dir(proj_dir): log.error('must be run in a project directory') proj_name = util.get_project_name_from_dir(proj_dir) cfg_name = None if len(args) > 0: cfg_name = args[0] if not cfg_name: cfg_name = settings.get(proj_dir, 'config') # check the cmake generator of this config configs = config.load(fips_dir, proj_dir, cfg_name) if configs: # hmm, only look at first match, 'open' doesn't # make sense with config-patterns cfg = configs[0] # find build dir, if it doesn't exist, generate it build_dir = util.get_build_dir(fips_dir, proj_name, cfg) if not os.path.isdir(build_dir): log.warn("build dir not found, generating...") project.gen(fips_dir, proj_dir, cfg['name']) if 'Xcode' in cfg['generator']: # find the Xcode project proj = glob.glob(build_dir + '/*.xcodeproj') subprocess.call(['open', proj[0]]) elif 'Visual Studio' in cfg['generator']: # find the VisualStudio project file proj = glob.glob(build_dir + '/*.sln') subprocess.call(['cmd', '/c', 'start', proj[0]]) else: log.error("don't know how to open a '{}' project".format( cfg['generator'])) else: log.error("config '{}' not found".format(cfg_name))
def run(fips_dir, proj_dir, args) : """run the 'open' verb (opens project in IDE)""" if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') proj_name = util.get_project_name_from_dir(proj_dir) cfg_name = None if len(args) > 0 : cfg_name = args[0] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') # check the cmake generator of this config configs = config.load(fips_dir, proj_dir, cfg_name) if configs : # hmm, only look at first match, 'open' doesn't # make sense with config-patterns cfg = configs[0] # find build dir, if it doesn't exist, generate it build_dir = util.get_build_dir(fips_dir, proj_name, cfg) if not os.path.isdir(build_dir) : log.warn("build dir not found, generating...") project.gen(fips_dir, proj_dir, cfg['name']) # try to open as Xcode project proj = glob.glob(build_dir + '/*.xcodeproj') if proj : subprocess.call('open {}'.format(proj[0]), shell=True) else : # try to open as VS project proj = glob.glob(build_dir + '/*.sln') if proj : subprocess.call('cmd /c start {}'.format(proj[0]), shell=True) else : log.error("don't know how to open a '{}' project".format(cfg['generator'])) else : log.error("config '{}' not found".format(cfg_name))
def run(fips_dir, proj_dir, args) : if not util.is_valid_project_dir(proj_dir) : log.error('must be run in a project directory') proj_name = util.get_project_name_from_dir(proj_dir) cfg_name = None if len(args) > 0 : cfg_name = args[0] if not cfg_name : cfg_name = settings.get(proj_dir, 'config') build_dir = util.get_build_dir(fips_dir, proj_name, cfg_name) cache_file = build_dir + '/CMakeCache.txt' if not os.path.isfile(cache_file) : log.error('generate project first!') if sys.platform == "win32" : os.startfile(cache_file) else : opener ="open" if sys.platform == "darwin" else "xdg-open" subprocess.call([opener, cache_file])
def list_targets(fips_dir, proj_dir, args) : log.colored(log.YELLOW, "=== targets:") if util.is_valid_project_dir(proj_dir) : # get config name if len(args) == 0 : cfg_name = settings.get(proj_dir, 'config') else : cfg_name = args[0] log.info('{} config:{} {}'.format(log.BLUE, log.DEF, cfg_name)) # get the target list success, targets = project.get_target_list(fips_dir, proj_dir, cfg_name) if success : # split targets by type for type in ['lib', 'module', 'sharedlib', 'app'] : type_targets = [tgt for tgt in targets if targets[tgt] == type] if len(type_targets) > 0 : log.colored(log.BLUE, ' {}:'.format(type)) for tgt in type_targets : log.info(' ' + tgt) else : log.info(" can't fetch project target list, please run 'fips gen' first!") else : log.info(' currently not in a valid project directory')