def clone(flux_dir): sdk_dir = get_sdk_dir(flux_dir) if not sdk_dir_exists(flux_dir): log.colored(log.YELLOW, '===== cloning "emscripten" SDK to "%s"' % sdk_dir) util.make_sdks_dirs(flux_dir) sdks_dir = util.get_sdks_dir(flux_dir) return git.clone(EMSDK_URL, None, 1, 'emsdk', sdks_dir)
def uninstall(flux_dir): sdk_dir = get_sdk_dir(flux_dir) log.colored(log.YELLOW, '=== uninstalling "emscripten" SDK at "%s"' % sdk_dir) clean(flux_dir) if sdk_dir_exists(flux_dir): log.info('deleting "%s"' % sdk_dir) shutil.rmtree(sdk_dir, onerror=util.remove_readonly) else: log.warn('emscripten SDK is not installed, nothing to do')
def usage(): log.text('(?) '+help()+'\n') log.optional('usage', 'emsdk <command>') log.colored(log.DEFAULT, '\ncommands: ') log.item(' list ', 'list emscripten SDKs') log.item(' install [sdk-version] ', 'install specified emsdk version. (defaults: latest if ommit)') log.item(' activate <sdk-version> ', 'activate installed emsdk version') log.item(' uninstall ', 'uninstall emscripten SDK') log.item(' show-config ', 'show emscripten configurations') #------------------------------------------------------------------------------
def install(flux_dir, sdk_version): res = False sdk_dir = get_sdk_dir(flux_dir) if sdk_dir_exists(flux_dir): res = update(flux_dir) else: res = clone(flux_dir) if not res: log.error('failed to install or update "emscripten" SDK') if sdk_version is None: sdk_version = EMSDK_DEFAULT_VERSION log.colored(log.YELLOW, '=== installing "emscripten" tools for "%s"' % sdk_version) run(flux_dir, 'install --shallow --disable-assertions %s' % sdk_version) activate(flux_dir, sdk_version)
def list_targets(flux_dir): log.colored(log.YELLOW, '===== targets =====') # verbs directory target_dir = util.get_targets_dir(flux_dir) if os.path.isdir(target_dir): # get all .py file in verb dir target_files = sorted(glob.glob(target_dir + '/*.yml')) if target_files: width = max(len(util.split_name(x)) for x in target_files) for target_file in target_files: target_name = util.split_name(target_file) if not target_name.startswith('__'): #if target_name in verb.verbs: log.text(log.style(log.CYAN, target_name).ljust(width+15)) # target['about'] else: log.error('no target was found in `targets` dir: `%s`' % target_dir) else: log.error('`targets` directory not found: `%s`' % target_dir)
def activate(flux_dir, sdk_version): if sdk_version is None: sdk_version = EMSDK_DEFAULT_VERSION log.colored(log.YELLOW, '=== activating "emscripten" SDK version "%s"' % sdk_version) run(flux_dir, 'activate --embedded %s' % sdk_version)
def update(flux_dir): sdk_dir = get_sdk_dir(flux_dir) if sdk_dir_exists(flux_dir): log.colored(log.YELLOW, '===== updating "emscripten" SDK at "%s"' % sdk_dir) return git.pull(sdk_dir)
def list_verbs(flux_dir): log.colored(log.YELLOW, '===== verbs =====') for verb_name in sorted(verb.verbs): log.item(verb_name, verb.verbs[verb_name].help())