From ff8370dc4d0d57f24b7b68bbe582d2dbbf76eda6 Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Fri, 28 Dec 2012 21:59:21 +0000 Subject: Add a run_build function to main This avoids duplication and circular deps --- diff --git a/commands/build b/commands/build index 9d8b51b..aa313b4 100755 --- a/commands/build +++ b/commands/build @@ -5,8 +5,7 @@ import sys import common -from devbot import build -from devbot import system +from devbot import main parser = argparse.ArgumentParser() parser.add_argument("module", nargs="?", help="name of the module to build") @@ -19,11 +18,5 @@ if args.module: if not build.build_one(args.module): sys.exit(1) else: - if not system.check(lazy=True): - sys.exit(1) - - if not build.pull(lazy=True): - sys.exit(1) - - if not build.build(full=args.full): + if not main.run_build(full=args.full): sys.exit(1) diff --git a/commands/check b/commands/check index 66e1ed5..5c29599 100755 --- a/commands/check +++ b/commands/check @@ -10,8 +10,7 @@ import common from devbot import run from devbot import check from devbot import command -from devbot import system -from devbot import build +from devbot import main def _get_profile(): profile_path = os.path.expanduser("~/.sugar/uitests") @@ -95,8 +94,15 @@ def _check_ui(): return result -def _check_modules(): - return check.check() +def _run_checks(): + if not _check_devbot(): + return False + + if not _check_modules(): + return False + + if not check.check(): + sys.exit(1) parser = argparse.ArgumentParser() @@ -113,20 +119,8 @@ if args.module: if not check.check_one(args.module): sys.exit(1) else: - if not system.check(lazy=True): - sys.exit(1) - - if not build.pull(lazy=True): - sys.exit(1) - - if not build.build(): - sys.exit(1) - - if not _check_devbot(): - sys.exit(1) - - if not _check_modules(): + if not main.run_build(full=False): sys.exit(1) - if not _check_ui(): + if not _run_checks(): sys.exit(1) diff --git a/commands/run b/commands/run index e3f311a..ef8e9af 100755 --- a/commands/run +++ b/commands/run @@ -5,18 +5,11 @@ import sys import common from devbot import run -from devbot import build -from devbot import system +from devbot import main common.setup(log_name="run") -if not system.check(lazy=True): - sys.exit(1) - -if not build.pull(lazy=True): - sys.exit(1) - -if not build.build(): +if not main.run_build(): sys.exit(1) run.run("sugar-runner") diff --git a/devbot/build.py b/devbot/build.py index d2be575..1e69e7d 100644 --- a/devbot/build.py +++ b/devbot/build.py @@ -52,12 +52,6 @@ def pull(lazy=False): def build(full=False): - if full or state.full_build_is_required(): - from devbot import clean - clean.clean(build_only=True) - - state.full_build_touch() - to_build = [] for module in config.load_modules(): if not state.built_module_is_unchanged(module): diff --git a/devbot/main.py b/devbot/main.py index 3e14a72..c368ca7 100644 --- a/devbot/main.py +++ b/devbot/main.py @@ -4,6 +4,25 @@ import imp from devbot import config from devbot import environ from devbot import plugins +from devbot import system +from devbot import build +from devbot import state +from devbot import clean + +def run_build(full=False): + if full or state.full_build_is_required(): + clean.clean(build_only=True) + + state.full_build_touch() + + if not system.check(lazy=True): + return False + + if not build.pull(lazy=True): + return False + + if not build.build(full=False): + return False def load_plugins(): -- cgit v0.9.1