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 vscode.match(cfg['build_tool']): vscode.run(proj_dir) return # check if this is a CLion project if clion.match(cfg['build_tool']): clion.run(proj_dir) return # try to open as Xcode project proj = glob.glob(build_dir + '/*.xcodeproj') if proj: subprocess.call('xed "{}"'.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 gen_project(fips_dir, proj_dir, cfg, force): """private: generate build files for one config""" proj_name = util.get_project_name_from_dir(proj_dir) deploy_dir = util.get_deploy_dir(fips_dir, proj_name, cfg['name']) build_dir = util.get_build_dir(fips_dir, proj_name, cfg['name']) defines = {} defines['FIPS_USE_CCACHE'] = 'ON' if settings.get(proj_dir, 'ccache') else 'OFF' defines['FIPS_AUTO_IMPORT'] = 'OFF' if dep.get_policy( proj_dir, 'no_auto_import') else 'ON' if cfg['generator'] in ['Ninja', 'Unix Makefiles']: defines['CMAKE_EXPORT_COMPILE_COMMANDS'] = 'ON' if cfg['platform'] == 'ios': defines['CMAKE_OSX_SYSROOT'] = xcrun.get_ios_sdk_sysroot() ios_team_id = settings.get(proj_dir, 'iosteam') if ios_team_id: defines['FIPS_IOS_TEAMID'] = ios_team_id if cfg['platform'] == 'osx': defines['CMAKE_OSX_SYSROOT'] = xcrun.get_macos_sdk_sysroot() if cfg['platform'] == 'emscripten': defines['EMSCRIPTEN_ROOT'] = emsdk.get_emscripten_root(fips_dir) if cfg['platform'] == 'wasisdk': defines['WASISDK_ROOT'] = wasisdk.get_wasisdk_root(fips_dir) do_it = force if not os.path.isdir(build_dir): os.makedirs(build_dir) if not os.path.isfile(build_dir + '/CMakeCache.txt'): do_it = True if do_it: # if Ninja build tool and on Windows, need to copy # the precompiled ninja.exe to the build dir log.colored(log.YELLOW, "=== generating: {}".format(cfg['name'])) log.info("config file: {}".format(cfg['path'])) toolchain_path = config.get_toolchain(fips_dir, proj_dir, cfg) if toolchain_path: log.info("Using Toolchain File: {}".format(toolchain_path)) is_local_build = settings.get(proj_dir, 'local') cmake_result = cmake.run_gen(cfg, fips_dir, proj_dir, build_dir, is_local_build, toolchain_path, defines) if vscode.match(cfg['build_tool']): vscode.write_workspace_settings( fips_dir, proj_dir, cfg, settings.get_all_settings(proj_dir)) if clion.match(cfg['build_tool']): clion.write_workspace_settings(fips_dir, proj_dir, cfg) return cmake_result else: return True