Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/build.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-25 23:04:31 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-25 23:04:31 (GMT)
commit91ea798d316865135643a569799f96f98de68ef8 (patch)
tree0c22e6dee60cc9c72d7e35c3c153640f3f78c2eb /devbot/build.py
parenta0b65ee79f9f5abdee931aa02a3018cb308f6c51 (diff)
Split state out of build script so we can reuse it
Diffstat (limited to 'devbot/build.py')
-rw-r--r--devbot/build.py41
1 files changed, 5 insertions, 36 deletions
diff --git a/devbot/build.py b/devbot/build.py
index f117667..74ff7bf 100644
--- a/devbot/build.py
+++ b/devbot/build.py
@@ -1,8 +1,4 @@
-#!/usr/bin/python -u
-
-from distutils import sysconfig
import fnmatch
-import json
import os
import multiprocessing
import shutil
@@ -12,31 +8,7 @@ import subprocess
from devbot import command
from devbot import config
from devbot import environ
-
-state = { "built_modules": {} }
-
-def get_state_path():
- return os.path.join(config.home_dir, "state.json")
-
-def load_state():
- global state
-
- state_path = get_state_path()
- if os.path.exists(state_path):
- state = json.load(open(state_path))
-
-def save_state():
- json.dump(state, open(get_state_path(), "w+"))
-
-def add_path(name, path):
- if name not in os.environ:
- os.environ[name] = path
- return
-
- splitted = os.environ[name].split(":")
- splitted.append(path)
-
- os.environ[name] = ":".join(splitted)
+from devbot import state
def get_module_commit_id(module):
orig_cwd = os.getcwd()
@@ -118,15 +90,13 @@ def build_module(module):
print "Unknown build system"
sys.exit(1)
- state["built_modules"][module.name] = get_module_commit_id(module)
- save_state()
+ state.add_built_module(module.name, get_module_commit_id(module))
def clear_built_modules(modules, index):
if index < len(modules) - 1:
for module in modules[index + 1:]:
- name = module.name
- if name in state["built_modules"]:
- del state["built_modules"][name]
+ if state.get_built_module(module.name) is not None:
+ state.remove_built_module(module.name)
def rmtree(dir):
print "Deleting %s" % dir
@@ -134,7 +104,6 @@ def rmtree(dir):
def build():
environ.setup()
- load_state()
modules = config.load_modules()
@@ -144,7 +113,7 @@ def build():
try:
pull_source(module)
- old_commit_id = state["built_modules"].get(module.name, None)
+ old_commit_id = state.get_built_module(module.name)
new_commit_id = get_module_commit_id(module)
if old_commit_id is None or old_commit_id != new_commit_id: