def installApp(self, child, app): self.installLibrary(child) if "PY_MAIN" in child["APP_OPTIONS"] and child.isRoot(): PyLog.log("application script") PyLog.increaseIndent() self.installApplication(child) PyLog.decreaseIndent()
def installApp(self, child, app): self.config = app self.installMisc(app) main_steps = [("startup script", self.genShellScript), ("environment script", self.genShellEnvScript), ("instance connect script", self.genShellConnectScript), ("bake cookie", self.genCookie), ("gen dirs", self.genDirs)] if app.name() == app["TOOL_OPTIONS"]["ERL_MAIN"] or ( "EXECUTABLE" in app["APP_OPTIONS"] and app["APP_OPTIONS"]["EXECUTABLE"] == True): for (label, step) in main_steps: PyLog.log(label) PyLog.increaseIndent() step(app) PyLog.decreaseIndent()
def runAction(self, app, action, function): PyLog.log("%s(%s)" % (self.name(), app.name())) PyLog.debug("%s(%s)[%s]" % (self.name(), app.name(), app._dir), log_level=6) PyLog.increaseIndent() file_stats = {} try: ## Check if we're up to date file_stats = app.fileStats() updated = FD.FileStats.updatedFiles(file_stats) if len(updated) == 0: PyLog.log("Up to date", log_level=-1) return True else: PyLog.log("OUT of date", count=len(updated), log_level=-1) #PyLog.decreaseIndent() cmds = [] ## If no children but we're being built ## We must just be a shallow app. for child in [app] + app.children: t_cmds = function(child, app) PyLog.debug("Returned", t_cmds, log_level=6) if t_cmds: cmds += t_cmds if not cmds: cmds = [] for cmd in cmds: if hasattr(cmd, "__call__"): cmd(app) elif isinstance(cmd, basestring): if PySH.cmd(cmd, stdout=True, stderr=True) != 0: raise ToolChainException( "Failure while performing action", action=action, app=app, cmd=cmd) else: raise ToolChainException( "Invalid %s cmd. Cmds must be string or fun: %s : %s" % (action, app, cmd)) except PyExcept.BaseException as e: raise e except Exception as e: raise ToolChainException(None, trace=sys.exc_info()) finally: PyLog.decreaseIndent() FD.FileStats.saveFileStats(file_stats) PyLog.decreaseIndent() return True
def retrieveCode(self, target, codebase, skip_update=False): (name, url) = codebase target_dir = PyPath.makeRelative(os.path.join(target, name)) if name not in self.updated_repos: self.updated_repos[name] = True if not os.path.isdir(target_dir): PyLog.log("Fetching", name) PyRCS.clone(url, target_dir) else: if not skip_update: PyLog.log("Updating", name) PyRCS.update(target_dir) else: PyLog.log("Skipping", name) return target_dir
def main(): cli = PyConfig.CLIConfig() PyLog.setLogLevel(0 if "LOG_LEVEL" not in cli else int(cli["LOG_LEVEL"])) fishmonger.addInternalToolChains(cli.get("INTERNAL_TOOL", [])) fishmonger.addExternalToolChains(cli.get("EXTERNAL_TOOL", [])) fishmonger.addCleanToolChains( cli.get("CLEAN_TOOL", [])) fishmonger.addGenerateToolChains(cli.get("GENERATE_TOOL", [])) fishmonger.addBuildToolChains( cli.get("BUILD_TOOL", [])) fishmonger.addLinkToolChains( cli.get("LINK_TOOL", [])) fishmonger.addInstallToolChains( cli.get("INSTALL_TOOL", [])) fishmonger.addDocumentToolChains(cli.get("DOC_TOOL", [])) fishmonger.addPackageToolChains( cli.get("PACKAGE_TOOL", [])) fish = FishMonger() tools_for_all = fishmonger.InternalToolChains actions = {} actions["clean"] = [(fish.clean, tools_for_all | fishmonger.CleanToolChains)] actions["build"] = [ (fish.generate, tools_for_all | fishmonger.GenerateToolChains), (fish.build, tools_for_all | fishmonger.BuildToolChains), (fish.link, tools_for_all | fishmonger.LinkToolChains) ] actions["compile"] = actions["build"] actions["install"] = [(fish.install, tools_for_all | fishmonger.InstallToolChains)] actions["doc"] = [(fish.document, tools_for_all | fishmonger.DocumentToolChains)] actions["document"] = actions["doc"] actions["package"] = [(fish.packageConfigure, None)] + actions["clean"] + actions["build"] + actions["install"] + [(fish.package, tools_for_all | fishmonger.PackageToolChains)] actions["test"] = [(None, [])] x = 0; if x not in cli: PyLog.error("Usage: fishmonger <clean|build|compile|install|doc|document|package>") return 1 PyLog.log("Configuring") PyLog.increaseIndent() fish.configure(fishmonger.AllToolChains) PyLog.decreaseIndent() cli_actions = [] while x in cli: if cli[x] not in actions: PyLog.error("Invalid action", cli[x]) PyLog.error("Usage: fishmonger <clean|build|compile|install|doc|document|package>") return 1 cli_actions.append(cli[x]) x += 1 if "package" in cli_actions: cli_actions = ["package"] global_args = { "max_cores" : int(cli["MAX_CORES"]) if "MAX_CORES" in cli else multiprocessing.cpu_count() } run_actions = [] for action in cli_actions: tasks = actions[action] for (task, tools) in tasks: if task not in run_actions: run_actions.append(task) task((fishmonger.ExternalToolChains, tools), **global_args)
def package(self, tools, **kwargs): PyLog.log("Packaging") PyLog.increaseIndent() self.configureAction(tools, "package") self.runAction(**kwargs) PyLog.decreaseIndent()
def link(self, tools, **kwargs): PyLog.log("Linking") PyLog.increaseIndent() self.configureAction(tools, "link") self.runAction(**kwargs) PyLog.decreaseIndent()
def generate(self, tools, **kwargs): PyLog.log("Generating") PyLog.increaseIndent() self.configureAction(tools, "generate") self.runAction(**kwargs) PyLog.decreaseIndent()
def clean(self, tools, **kwargs): PyLog.log("Cleaning") PyLog.increaseIndent() self.configureAction(tools, "clean") self.runAction(**kwargs) PyLog.decreaseIndent()
def document(self, tools, **kwargs): PyLog.log("Documenting") PyLog.increaseIndent() self.configureAction(tools, "document") self.runAction(**kwargs) PyLog.decreaseIndent()
def install(self, tools, **kwargs): PyLog.log("Installing") PyLog.increaseIndent() self.configureAction(tools, "install") self.runAction(**kwargs) PyLog.decreaseIndent()
def build(self, tools, **kwargs): PyLog.log("Building") PyLog.increaseIndent() self.configureAction(tools, "build") self.runAction(**kwargs) PyLog.decreaseIndent()
def ctrl_c(signal, frame): PyLog.log("Exiting on CTRL+C") sys.exit(0)