author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-02-11 23:34:25 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-02-11 23:34:25 (UTC) |
commit | 185949cb778dd13a566781bbfa8ef7ed344cc705 (patch) (side-by-side diff) | |
tree | 8fc4ff8cf1efead7610e4141041dd440eb9febbd /scripts/builder/main.py | |
parent | 17efce23d9f205f56f5ebbe8e4f4ca581ea47bcb (diff) | |
download | clipperz-185949cb778dd13a566781bbfa8ef7ed344cc705.zip clipperz-185949cb778dd13a566781bbfa8ef7ed344cc705.tar.gz clipperz-185949cb778dd13a566781bbfa8ef7ed344cc705.tar.bz2 |
Improved build scripts
Signed-off-by: Giulio Cesare Solaroli <giulio.cesare@clipperz.com>
-rwxr-xr-x | scripts/builder/main.py | 85 |
1 files changed, 48 insertions, 37 deletions
diff --git a/scripts/builder/main.py b/scripts/builder/main.py index 94f738f..6fce65d 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py @@ -3,12 +3,13 @@ -import sys, os, json +import sys +import os +import json import shutil import pprint -import frontendBuilder import codecs import itertools - from collections import deque -from phpBuilder import PhpBuilder -from pythonBuilder import PythonBuilder + +import frontendBuilder +import repository @@ -36,3 +37,3 @@ def createFolder (path): def loadSettings (component, module): - print "MODULE: " + module + # print "MODULE: " + module @@ -45,3 +46,4 @@ def loadSettings (component, module): - settings = codecs.open(projectBaseDir() + '/' + component + '/' + module + '/properties/' + submodule + '.properties.json', 'r', 'utf-8') + #settings = codecs.open(projectBaseDir() + os.sep + component + os.sep + module + os.sep + 'properties' + os.sep + submodule + '.properties.json', 'r', 'utf-8') + settings = codecs.open(os.path.join(projectBaseDir(), component, module, 'properties', submodule + '.properties.json'), 'r', 'utf-8') result = json.load(settings) @@ -73,11 +75,9 @@ def assembleBackend (backend, frontends, versions): - if backend == 'php': - backendBuilder = PhpBuilder(projectTargetDir(), frontends, versions, settings) - elif backend == 'python': - backendBuilder = PythonBuilder(projectTargetDir(), frontends, versions, settings) - #elif backend == 'java': - # buildJavaBackend (frontends, versions, settings) - else: - raise Exception('unrecognized backend: ' + backend) - + builderModuleName = backend + 'Builder' + builderClassName = backend.capitalize() + 'Builder' + + builderModule = __import__(builderModuleName) + builderClass = getattr(builderModule, builderClassName) + + backendBuilder = builderClass(projectTargetDir(), frontends, versions, settings) backendBuilder.run() @@ -86,7 +86,10 @@ def assembleBackend (backend, frontends, versions): -def build (settings): +def build (settings, repository): frontends = [] + if repository.areTherePendingChanges(): + print "\nWARNING: repository has pending changes\n" + for frontend in settings['frontends']: - frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend))) + frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version())) @@ -98,3 +101,3 @@ def build (settings): def clean (): - print "cleaning up …" + # print "cleaning up …" if os.path.exists(projectTargetDir()): @@ -109,9 +112,9 @@ def usage (message): print - print "build.py clean" - print "build.py clean install" - print "build.py install --ALL" - print "build.py install debug --ALL" - print "build.py clean install debug --ALL" - print "build.ph install, debug --backends php java --frontends beta gamma" - print "build.ph install, debug --backends php java --frontends beta gamma gamma.mobile" + # print "build clean" + # print "build clean install" + print "build install --ALL" + print "build install debug --ALL" + # print "build clean install debug --ALL" + print "build install debug --backends php python --frontends beta gamma" + print "build install debug development --backends php python --frontends beta gamma gamma.mobile" exit(1) @@ -120,2 +123,10 @@ def usage (message): +def allFrontends (): + return ['beta', 'gamma', 'mobile'] + +def allBackends (): + return ['php', 'python'] + +#-------------------------------------------------------------------- + def main (): @@ -123,10 +134,9 @@ def main (): parameters = list(itertools.islice(sys.argv, 1, None)) - - shouldClean = len(filter(lambda x: x == 'clean', parameters)) > 0 - if (shouldClean): - clean () - - parameters = filter(lambda x: x != 'clean', parameters) + + sys.path.append(os.path.join(scriptDir(), 'backends')) + currentRepository = repository.repositoryWithPath(projectBaseDir()) + + clean() versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) - settings['versions'] = versions; #['debug', 'install'] + settings['versions'] = versions; #['debug', 'install', 'development'] parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) @@ -136,4 +146,4 @@ def main (): if parameter == "--ALL": - settings['frontends'] = ['beta', 'gamma', 'mobile'] - settings['backends'] = ['php', 'python', 'java'] + settings['frontends'] = allFrontends() + settings['backends'] = allBackends() else: @@ -160,4 +170,5 @@ def main (): - build (settings) - + build(settings, currentRepository) + else: + usage("Suggestions on how to call the 'build' script:") |