summaryrefslogtreecommitdiff
path: root/scripts/builder/main.py
Unidiff
Diffstat (limited to 'scripts/builder/main.py') (more/less context) (show whitespace changes)
-rwxr-xr-xscripts/builder/main.py79
1 files changed, 45 insertions, 34 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 @@
3 3
4import sys, os, json 4import sys
5import os
6import json
5import shutil 7import shutil
6import pprint 8import pprint
7import frontendBuilder
8import codecs 9import codecs
9import itertools 10import itertools
10
11from collections import deque 11from collections import deque
12from phpBuilder import PhpBuilder 12
13from pythonBuilder import PythonBuilder 13import frontendBuilder
14import repository
14 15
@@ -36,3 +37,3 @@ def createFolder (path):
36def loadSettings (component, module): 37def loadSettings (component, module):
37 print "MODULE: " + module 38 # print "MODULE: " + module
38 39
@@ -45,3 +46,4 @@ def loadSettings (component, module):
45 46
46 settings = codecs.open(projectBaseDir() + '/' + component + '/' + module + '/properties/' + submodule + '.properties.json', 'r', 'utf-8') 47 #settings = codecs.open(projectBaseDir() + os.sep + component + os.sep + module + os.sep + 'properties' + os.sep + submodule + '.properties.json', 'r', 'utf-8')
48 settings = codecs.open(os.path.join(projectBaseDir(), component, module, 'properties', submodule + '.properties.json'), 'r', 'utf-8')
47 result = json.load(settings) 49 result = json.load(settings)
@@ -73,11 +75,9 @@ def assembleBackend (backend, frontends, versions):
73 75
74 if backend == 'php': 76 builderModuleName = backend + 'Builder'
75 backendBuilder = PhpBuilder(projectTargetDir(), frontends, versions, settings) 77 builderClassName = backend.capitalize() + 'Builder'
76 elif backend == 'python': 78
77 backendBuilder = PythonBuilder(projectTargetDir(), frontends, versions, settings) 79 builderModule = __import__(builderModuleName)
78 #elif backend == 'java': 80 builderClass = getattr(builderModule, builderClassName)
79 #buildJavaBackend (frontends, versions, settings)
80 else:
81 raise Exception('unrecognized backend: ' + backend)
82 81
82 backendBuilder = builderClass(projectTargetDir(), frontends, versions, settings)
83 backendBuilder.run() 83 backendBuilder.run()
@@ -86,7 +86,10 @@ def assembleBackend (backend, frontends, versions):
86 86
87def build (settings): 87def build (settings, repository):
88 frontends = [] 88 frontends = []
89 89
90 if repository.areTherePendingChanges():
91 print "\nWARNING: repository has pending changes\n"
92
90 for frontend in settings['frontends']: 93 for frontend in settings['frontends']:
91 frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend))) 94 frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version()))
92 95
@@ -98,3 +101,3 @@ def build (settings):
98def clean (): 101def clean ():
99 print "cleaning up …" 102 # print "cleaning up …"
100 if os.path.exists(projectTargetDir()): 103 if os.path.exists(projectTargetDir()):
@@ -109,9 +112,9 @@ def usage (message):
109 print 112 print
110 print "build.py clean" 113 # print "build clean"
111 print "build.py clean install" 114 # print "build clean install"
112 print "build.py install --ALL" 115 print "build install --ALL"
113 print "build.py install debug --ALL" 116 print "build install debug --ALL"
114 print "build.py clean install debug --ALL" 117 # print "build clean install debug --ALL"
115 print "build.ph install, debug --backends php java --frontends beta gamma" 118 print "build install debug --backends php python --frontends beta gamma"
116 print "build.ph install, debug --backends php java --frontends beta gamma gamma.mobile" 119 print "build install debug development --backends php python --frontends beta gamma gamma.mobile"
117 exit(1) 120 exit(1)
@@ -120,2 +123,10 @@ def usage (message):
120 123
124def allFrontends ():
125 return ['beta', 'gamma', 'mobile']
126
127def allBackends ():
128 return ['php', 'python']
129
130#--------------------------------------------------------------------
131
121def main (): 132def main ():
@@ -124,9 +135,8 @@ def main ():
124 135
125 shouldClean = len(filter(lambda x: x == 'clean', parameters)) > 0 136 sys.path.append(os.path.join(scriptDir(), 'backends'))
126 if (shouldClean): 137 currentRepository = repository.repositoryWithPath(projectBaseDir())
127 clean ()
128 138
129 parameters = filter(lambda x: x != 'clean', parameters) 139 clean()
130 versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) 140 versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters))
131 settings['versions'] = versions; #['debug', 'install'] 141 settings['versions'] = versions; #['debug', 'install', 'development']
132 parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) 142 parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters))
@@ -136,4 +146,4 @@ def main ():
136 if parameter == "--ALL": 146 if parameter == "--ALL":
137 settings['frontends'] = ['beta', 'gamma', 'mobile'] 147 settings['frontends'] = allFrontends()
138 settings['backends'] = ['php', 'python', 'java'] 148 settings['backends'] = allBackends()
139 else: 149 else:
@@ -160,4 +170,5 @@ def main ():
160 170
161 build (settings) 171 build(settings, currentRepository)
162 172 else:
173 usage("Suggestions on how to call the 'build' script:")
163 174