-rwxr-xr-x | scripts/builder/main.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/scripts/builder/main.py b/scripts/builder/main.py index 6fce65d..b9fe04a 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py | |||
@@ -7,13 +7,13 @@ import json | |||
7 | import shutil | 7 | import shutil |
8 | import pprint | 8 | import pprint |
9 | import codecs | 9 | import codecs |
10 | import itertools | 10 | import itertools |
11 | from collections import deque | 11 | from collections import deque |
12 | 12 | ||
13 | import frontendBuilder | 13 | #import frontendBuilder |
14 | import repository | 14 | import repository |
15 | 15 | ||
16 | pp = pprint.PrettyPrinter(indent=4, depth=4) | 16 | pp = pprint.PrettyPrinter(indent=4, depth=4) |
17 | 17 | ||
18 | #-------------------------------------------------------------------- | 18 | #-------------------------------------------------------------------- |
19 | 19 | ||
@@ -72,29 +72,41 @@ def loadSettings (component, module): | |||
72 | 72 | ||
73 | def assembleBackend (backend, frontends, versions): | 73 | def assembleBackend (backend, frontends, versions): |
74 | settings = loadSettings('backend', backend) | 74 | settings = loadSettings('backend', backend) |
75 | 75 | ||
76 | builderModuleName = backend + 'Builder' | 76 | builderModuleName = backend + 'Builder' |
77 | builderClassName = backend.capitalize() + 'Builder' | 77 | builderClassName = backend.capitalize() + 'Builder' |
78 | 78 | #print ("BUILD BACKENDS - module: " + builderModuleName + " , class: " + builderClassName) | |
79 | builderModule = __import__(builderModuleName) | 79 | builderModule = __import__(builderModuleName) |
80 | builderClass = getattr(builderModule, builderClassName) | 80 | builderClass = getattr(builderModule, builderClassName) |
81 | 81 | ||
82 | backendBuilder = builderClass(projectTargetDir(), frontends, versions, settings) | 82 | backendBuilder = builderClass(projectTargetDir(), frontends, versions, settings) |
83 | backendBuilder.run() | 83 | backendBuilder.run() |
84 | 84 | ||
85 | #==================================================================== | 85 | #==================================================================== |
86 | 86 | ||
87 | def build (settings, repository): | 87 | def build (settings, repository): |
88 | frontends = [] | 88 | frontends = [] |
89 | 89 | ||
90 | if repository.areTherePendingChanges(): | 90 | if repository.areTherePendingChanges(): |
91 | print "\nWARNING: repository has pending changes\n" | 91 | if 'install' in settings['versions']: |
92 | raise Exception("repository has pending changes, can't 'install'") | ||
93 | else: | ||
94 | print "\nWARNING: repository has pending changes\n" | ||
92 | 95 | ||
93 | for frontend in settings['frontends']: | 96 | for frontend in settings['frontends']: |
94 | frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version())) | 97 | normalizedFrontendName = frontend.replace(".", "_") |
98 | builderModuleName = normalizedFrontendName + 'Builder' | ||
99 | builderClassName = normalizedFrontendName.title() + 'Builder' | ||
100 | |||
101 | #print ("BUILD FRONTEND - module: " + builderModuleName + " , class: " + builderClassName) | ||
102 | builderModule = __import__(builderModuleName) | ||
103 | builderClass = getattr(builderModule, builderClassName) | ||
104 | builder = builderClass(frontend, loadSettings('frontend', frontend), repository.version()) | ||
105 | #builder = frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend), repository.version()) | ||
106 | frontends.append(builder) | ||
95 | 107 | ||
96 | for backend in settings['backends']: | 108 | for backend in settings['backends']: |
97 | assembleBackend(backend, frontends, settings['versions']) | 109 | assembleBackend(backend, frontends, settings['versions']) |
98 | 110 | ||
99 | #-------------------------------------------------------------------- | 111 | #-------------------------------------------------------------------- |
100 | 112 | ||
@@ -111,32 +123,34 @@ def usage (message): | |||
111 | 123 | ||
112 | 124 | ||
113 | # print "build clean" | 125 | # print "build clean" |
114 | # print "build clean install" | 126 | # print "build clean install" |
115 | print "build install --ALL" | 127 | print "build install --ALL" |
116 | print "build install debug --ALL" | 128 | print "build install debug --ALL" |
129 | print "build install debug development --ALL" | ||
117 | # print "build clean install debug --ALL" | 130 | # print "build clean install debug --ALL" |
118 | print "build install debug --backends php python --frontends beta gamma" | 131 | print "build install debug --backends php python --frontends beta gamma" |
119 | print "build install debug development --backends php python --frontends beta gamma gamma.mobile" | 132 | print "build install debug development --backends php python --frontends beta gamma gamma.mobile" |
120 | exit(1) | 133 | exit(1) |
121 | 134 | ||
122 | #-------------------------------------------------------------------- | 135 | #-------------------------------------------------------------------- |
123 | 136 | ||
124 | def allFrontends (): | 137 | def allFrontends (): |
125 | return ['beta', 'gamma', 'mobile'] | 138 | return ['beta', 'gamma', 'gamma.mobile'] |
126 | 139 | ||
127 | def allBackends (): | 140 | def allBackends (): |
128 | return ['php', 'python'] | 141 | return ['php', 'python'] |
129 | 142 | ||
130 | #-------------------------------------------------------------------- | 143 | #-------------------------------------------------------------------- |
131 | 144 | ||
132 | def main (): | 145 | def main (): |
133 | settings = {} | 146 | settings = {} |
134 | parameters = list(itertools.islice(sys.argv, 1, None)) | 147 | parameters = list(itertools.islice(sys.argv, 1, None)) |
135 | 148 | ||
136 | sys.path.append(os.path.join(scriptDir(), 'backends')) | 149 | sys.path.append(os.path.join(scriptDir(), 'backends')) |
150 | sys.path.append(os.path.join(scriptDir(), 'frontends')) | ||
137 | currentRepository = repository.repositoryWithPath(projectBaseDir()) | 151 | currentRepository = repository.repositoryWithPath(projectBaseDir()) |
138 | 152 | ||
139 | clean() | 153 | clean() |
140 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) | 154 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) |
141 | settings['versions'] = versions; #['debug', 'install', 'development'] | 155 | settings['versions'] = versions; #['debug', 'install', 'development'] |
142 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) | 156 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) |
@@ -171,7 +185,7 @@ def main (): | |||
171 | build(settings, currentRepository) | 185 | build(settings, currentRepository) |
172 | else: | 186 | else: |
173 | usage("Suggestions on how to call the 'build' script:") | 187 | usage("Suggestions on how to call the 'build' script:") |
174 | 188 | ||
175 | 189 | ||
176 | if __name__ == "__main__": | 190 | if __name__ == "__main__": |
177 | main() | 191 | main() |