author | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-05 22:54:04 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@solaroli.it> | 2011-10-05 22:54:04 (UTC) |
commit | 13ebf1b1987a1566d081ff1ba89b4dca197b7d2e (patch) (unidiff) | |
tree | dcd7121febab3bd2c1436d2f55a5a2ac07ad2e83 | |
parent | bbd415769410aac765f889e74a28992bc8483f94 (diff) | |
parent | 2a98e81b954ab84efc8d3f4e1d837bf190f77d7d (diff) | |
download | clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.zip clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.gz clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.bz2 |
Merge pull request #7 from themiurgo/master
Fixes shebang for python builder scripts
-rw-r--r-- | scripts/builder/backendBuilder.py | 2 | ||||
-rw-r--r-- | scripts/builder/frontendBuilder.py | 2 | ||||
-rwxr-xr-x | scripts/builder/main.py | 4 | ||||
-rw-r--r-- | scripts/builder/phpBuilder.py | 2 | ||||
-rw-r--r-- | scripts/builder/pythonBuilder.py | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index f5dc7b2..16dbe2f 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py | |||
@@ -1,89 +1,89 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, json | 4 | import sys, os, json |
5 | import shutil | 5 | import shutil |
6 | import main | 6 | import main |
7 | import hashlib | 7 | import hashlib |
8 | 8 | ||
9 | class BackendBuilder: | 9 | class BackendBuilder: |
10 | 10 | ||
11 | def __init__ (self, projectTargetDir, frontends, versions, settings): | 11 | def __init__ (self, projectTargetDir, frontends, versions, settings): |
12 | self.projectTargetDir = projectTargetDir | 12 | self.projectTargetDir = projectTargetDir |
13 | self.frontends = frontends | 13 | self.frontends = frontends |
14 | self.versions = versions | 14 | self.versions = versions |
15 | self.settings = settings | 15 | self.settings = settings |
16 | 16 | ||
17 | def name (self): | 17 | def name (self): |
18 | raise NotImplementedError() | 18 | raise NotImplementedError() |
19 | 19 | ||
20 | def relativePath (self): | 20 | def relativePath (self): |
21 | raise NotImplementedError() | 21 | raise NotImplementedError() |
22 | 22 | ||
23 | def compileCode (self): | 23 | def compileCode (self): |
24 | pass | 24 | pass |
25 | 25 | ||
26 | def copyCompiledCodeToTargetDir (self): | 26 | def copyCompiledCodeToTargetDir (self): |
27 | src = self.sourceFolder() | 27 | src = self.sourceFolder() |
28 | dst = self.targetFolder() | 28 | dst = self.targetFolder() |
29 | main.createFolder(os.path.dirname(dst)) | 29 | main.createFolder(os.path.dirname(dst)) |
30 | shutil.copytree(src, dst) | 30 | shutil.copytree(src, dst) |
31 | 31 | ||
32 | def sourceFolder (self): | 32 | def sourceFolder (self): |
33 | return main.projectBaseDir() + '/backend/' + self.relativePath() + '/src' | 33 | return main.projectBaseDir() + '/backend/' + self.relativePath() + '/src' |
34 | 34 | ||
35 | 35 | ||
36 | def targetFolder (self): | 36 | def targetFolder (self): |
37 | return self.projectTargetDir + self.relativePath() | 37 | return self.projectTargetDir + self.relativePath() |
38 | 38 | ||
39 | def createTargetFolder (self): | 39 | def createTargetFolder (self): |
40 | main.createFolder(self.targetFolder()) | 40 | main.createFolder(self.targetFolder()) |
41 | 41 | ||
42 | 42 | ||
43 | #def copyFrontendResources (self, frontend): | 43 | #def copyFrontendResources (self, frontend): |
44 | # print "copying resources for frontend: " + frontend | 44 | # print "copying resources for frontend: " + frontend |
45 | # print "SETTINGS: " + str(self.settings) | 45 | # print "SETTINGS: " + str(self.settings) |
46 | 46 | ||
47 | 47 | ||
48 | def writeToTargetFolder (self, filename, content): | 48 | def writeToTargetFolder (self, filename, content): |
49 | file = open(self.targetFolder() + '/' + filename, 'w') | 49 | file = open(self.targetFolder() + '/' + filename, 'w') |
50 | file.write(content.encode('utf-8')) | 50 | file.write(content.encode('utf-8')) |
51 | file.close() | 51 | file.close() |
52 | 52 | ||
53 | 53 | ||
54 | def configureIndexContent (self, indexContent): | 54 | def configureIndexContent (self, indexContent): |
55 | result = indexContent | 55 | result = indexContent |
56 | result = result.replace( '@request.path@', self.settings['request.path'] ) | 56 | result = result.replace( '@request.path@', self.settings['request.path'] ) |
57 | result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) | 57 | result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) |
58 | 58 | ||
59 | return result | 59 | return result |
60 | 60 | ||
61 | 61 | ||
62 | def logChecksums (self, content, message): | 62 | def logChecksums (self, content, message): |
63 | md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest() | 63 | md5Digest = hashlib.md5(content.encode('utf-8')).hexdigest() |
64 | shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest() | 64 | shaDigest = hashlib.sha1(content.encode('utf-8')).hexdigest() |
65 | sha256Digest= hashlib.sha256(content.encode('utf-8')).hexdigest() | 65 | sha256Digest= hashlib.sha256(content.encode('utf-8')).hexdigest() |
66 | print message + ": " + md5Digest + " (md5)" | 66 | print message + ": " + md5Digest + " (md5)" |
67 | print message + ": " + shaDigest + " (sha1)" | 67 | print message + ": " + shaDigest + " (sha1)" |
68 | print message + ": " + sha256Digest + " (sha256)" | 68 | print message + ": " + sha256Digest + " (sha256)" |
69 | 69 | ||
70 | 70 | ||
71 | 71 | ||
72 | def run (self): | 72 | def run (self): |
73 | print self.name() + " - RUN" | 73 | print self.name() + " - RUN" |
74 | 74 | ||
75 | self.compileCode() | 75 | self.compileCode() |
76 | self.copyCompiledCodeToTargetDir() | 76 | self.copyCompiledCodeToTargetDir() |
77 | 77 | ||
78 | for frontend in self.frontends: | 78 | for frontend in self.frontends: |
79 | frontendPath = frontend.module + '/' | 79 | frontendPath = frontend.module + '/' |
80 | if 'debug' in self.versions: | 80 | if 'debug' in self.versions: |
81 | frontend.copyResourcesToTargetFolder(self.targetFolder()) | 81 | frontend.copyResourcesToTargetFolder(self.targetFolder()) |
82 | #self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assembleDebugVersion())) | 82 | #self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assembleDebugVersion())) |
83 | self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))) | 83 | self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))) |
84 | 84 | ||
85 | if 'install' in self.versions: | 85 | if 'install' in self.versions: |
86 | index = self.configureIndexContent(frontend.assemble()) | 86 | index = self.configureIndexContent(frontend.assemble()) |
87 | self.writeToTargetFolder(frontendPath + 'index.html', index) | 87 | self.writeToTargetFolder(frontendPath + 'index.html', index) |
88 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") | 88 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") |
89 | 89 | ||
diff --git a/scripts/builder/frontendBuilder.py b/scripts/builder/frontendBuilder.py index b796438..55054ee 100644 --- a/scripts/builder/frontendBuilder.py +++ b/scripts/builder/frontendBuilder.py | |||
@@ -1,398 +1,398 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, re | 4 | import sys, os, re |
5 | import cssmin | 5 | import cssmin |
6 | import jsmin | 6 | import jsmin |
7 | import codecs | 7 | import codecs |
8 | import shutil | 8 | import shutil |
9 | import StringIO | 9 | import StringIO |
10 | import urllib | 10 | import urllib |
11 | 11 | ||
12 | #from mercurial import ui, hg | 12 | #from mercurial import ui, hg |
13 | #from mercurial.node import hex | 13 | #from mercurial.node import hex |
14 | from dulwich.repo import Repo | 14 | from dulwich.repo import Repo |
15 | 15 | ||
16 | import main | 16 | import main |
17 | 17 | ||
18 | 18 | ||
19 | 19 | ||
20 | class FrontendBuilder: | 20 | class FrontendBuilder: |
21 | 21 | ||
22 | def __init__ (self, frontend, settings): | 22 | def __init__ (self, frontend, settings): |
23 | if '.' in frontend: | 23 | if '.' in frontend: |
24 | moduleComponents = frontend.split('.') | 24 | moduleComponents = frontend.split('.') |
25 | self.module = moduleComponents[0] | 25 | self.module = moduleComponents[0] |
26 | self.submodule = moduleComponents[1] | 26 | self.submodule = moduleComponents[1] |
27 | else: | 27 | else: |
28 | self.module = frontend | 28 | self.module = frontend |
29 | self.submodule = frontend | 29 | self.submodule = frontend |
30 | 30 | ||
31 | self.settings = settings | 31 | self.settings = settings |
32 | self.projectDir = main.projectBaseDir() | 32 | self.projectDir = main.projectBaseDir() |
33 | self.processedFiles = {} | 33 | self.processedFiles = {} |
34 | 34 | ||
35 | 35 | ||
36 | def mercurialRepositoryVersion (self): | 36 | def mercurialRepositoryVersion (self): |
37 | repo = hg.repository(ui.ui(), self.projectDir) | 37 | repo = hg.repository(ui.ui(), self.projectDir) |
38 | context = repo['tip'] | 38 | context = repo['tip'] |
39 | result = str(context) | 39 | result = str(context) |
40 | 40 | ||
41 | return result | 41 | return result |
42 | 42 | ||
43 | 43 | ||
44 | def gitRepositoryVersion (self): | 44 | def gitRepositoryVersion (self): |
45 | repo = Repo(self.projectDir) | 45 | repo = Repo(self.projectDir) |
46 | #if repo.is_dirty(): | 46 | #if repo.is_dirty(): |
47 | #print "WARNING: build run with dirty repository" | 47 | #print "WARNING: build run with dirty repository" |
48 | result = repo.refs['HEAD'] | 48 | result = repo.refs['HEAD'] |
49 | 49 | ||
50 | return result | 50 | return result |
51 | 51 | ||
52 | 52 | ||
53 | 53 | ||
54 | def repositoryVersion (self): | 54 | def repositoryVersion (self): |
55 | cacheKey = 'repositoryVersion' | 55 | cacheKey = 'repositoryVersion' |
56 | if not self.processedFiles.has_key(cacheKey): | 56 | if not self.processedFiles.has_key(cacheKey): |
57 | #result = self.mercurialRepositoryVersion() | 57 | #result = self.mercurialRepositoryVersion() |
58 | result = self.gitRepositoryVersion() | 58 | result = self.gitRepositoryVersion() |
59 | self.processedFiles[cacheKey] = result | 59 | self.processedFiles[cacheKey] = result |
60 | else: | 60 | else: |
61 | result = self.processedFiles[cacheKey] | 61 | result = self.processedFiles[cacheKey] |
62 | 62 | ||
63 | return result | 63 | return result |
64 | 64 | ||
65 | 65 | ||
66 | #def relativePath (self): | 66 | #def relativePath (self): |
67 | #return self.module | 67 | #return self.module |
68 | # | 68 | # |
69 | 69 | ||
70 | def log (self, message): | 70 | def log (self, message): |
71 | print "frontend [" + self.module + "]: " + message | 71 | print "frontend [" + self.module + "]: " + message |
72 | 72 | ||
73 | 73 | ||
74 | def absolutePathForSourceFile (self, folder, basePath, file): | 74 | def absolutePathForSourceFile (self, folder, basePath, file): |
75 | return folder + '/frontend/' + self.module + '/' + basePath + '/' + file | 75 | return folder + '/frontend/' + self.module + '/' + basePath + '/' + file |
76 | 76 | ||
77 | 77 | ||
78 | def absolutePathForTargetFile (self, folder, basePath, file): | 78 | def absolutePathForTargetFile (self, folder, basePath, file): |
79 | return folder + '/' + self.module + '/' + basePath + '/' + file | 79 | return folder + '/' + self.module + '/' + basePath + '/' + file |
80 | 80 | ||
81 | def filterFiles (self, files): | 81 | def filterFiles (self, files): |
82 | result = [] | 82 | result = [] |
83 | 83 | ||
84 | for file in files: | 84 | for file in files: |
85 | if file.startswith('--'): | 85 | if file.startswith('--'): |
86 | pass | 86 | pass |
87 | else: | 87 | else: |
88 | result.append(file) | 88 | result.append(file) |
89 | 89 | ||
90 | return result | 90 | return result |
91 | 91 | ||
92 | 92 | ||
93 | def copyResources (self, sourceFolder, destinationFolder, fileType): | 93 | def copyResources (self, sourceFolder, destinationFolder, fileType): |
94 | for file in self.filterFiles(self.settings[fileType]): | 94 | for file in self.filterFiles(self.settings[fileType]): |
95 | src = self.absolutePathForSourceFile(sourceFolder, fileType, file) | 95 | src = self.absolutePathForSourceFile(sourceFolder, fileType, file) |
96 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) | 96 | dst = self.absolutePathForTargetFile(destinationFolder, fileType, file) |
97 | main.createFolder(os.path.dirname(dst)) | 97 | main.createFolder(os.path.dirname(dst)) |
98 | shutil.copy2(src, dst) | 98 | shutil.copy2(src, dst) |
99 | 99 | ||
100 | 100 | ||
101 | def copyResourcesToTargetFolder (self, targetFolder): | 101 | def copyResourcesToTargetFolder (self, targetFolder): |
102 | self.copyResources(self.projectDir, targetFolder, 'css') | 102 | self.copyResources(self.projectDir, targetFolder, 'css') |
103 | self.copyResources(self.projectDir, targetFolder, 'js') | 103 | self.copyResources(self.projectDir, targetFolder, 'js') |
104 | 104 | ||
105 | 105 | ||
106 | def loadFilesContent (self, basePath, files): | 106 | def loadFilesContent (self, basePath, files): |
107 | result = "" | 107 | result = "" |
108 | 108 | ||
109 | for file in self.filterFiles(files): | 109 | for file in self.filterFiles(files): |
110 | try: | 110 | try: |
111 | fileHandler = codecs.open(self.absolutePathForSourceFile(self.projectDir, basePath, file), 'r', 'utf-8') | 111 | fileHandler = codecs.open(self.absolutePathForSourceFile(self.projectDir, basePath, file), 'r', 'utf-8') |
112 | except: | 112 | except: |
113 | print "FILE: " + file | 113 | print "FILE: " + file |
114 | 114 | ||
115 | result += fileHandler.read() + '\n' | 115 | result += fileHandler.read() + '\n' |
116 | fileHandler.close() | 116 | fileHandler.close() |
117 | 117 | ||
118 | return result | 118 | return result |
119 | 119 | ||
120 | 120 | ||
121 | def template (self): | 121 | def template (self): |
122 | processedFile = 'html_template' | 122 | processedFile = 'html_template' |
123 | if not self.processedFiles.has_key(processedFile): | 123 | if not self.processedFiles.has_key(processedFile): |
124 | self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) | 124 | self.processedFiles[processedFile] = self.loadFilesContent('html', ['index_template.html']) |
125 | 125 | ||
126 | return self.processedFiles[processedFile] | 126 | return self.processedFiles[processedFile] |
127 | 127 | ||
128 | 128 | ||
129 | def cssminCompressor (self, css): | 129 | def cssminCompressor (self, css): |
130 | # package found here: | 130 | # package found here: |
131 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 | 131 | # - http://stackoverflow.com/questions/222581/python-script-for-minifying-css/2396777#2396777 |
132 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 | 132 | # actual downloaded version: http://pypi.python.org/pypi/cssmin/0.1.4 |
133 | return cssmin.cssmin(css) | 133 | return cssmin.cssmin(css) |
134 | 134 | ||
135 | 135 | ||
136 | def regexCssCompressor (self, css): | 136 | def regexCssCompressor (self, css): |
137 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 | 137 | # http://stackoverflow.com/questions/222581/python-script-for-minifying-css/223689#223689 |
138 | 138 | ||
139 | # remove comments - this will break a lot of hacks :-P | 139 | # remove comments - this will break a lot of hacks :-P |
140 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack | 140 | css = re.sub( r'\s*/\*\s*\*/', "$$HACK1$$", css ) # preserve IE<6 comment hack |
141 | css = re.sub( r'/\*[\s\S]*?\*/', "", css ) | 141 | css = re.sub( r'/\*[\s\S]*?\*/', "", css ) |
142 | css = css.replace( "$$HACK1$$", '/**/' ) # preserve IE<6 comment hack | 142 | css = css.replace( "$$HACK1$$", '/**/' ) # preserve IE<6 comment hack |
143 | 143 | ||
144 | # url() doesn't need quotes | 144 | # url() doesn't need quotes |
145 | css = re.sub( r'url\((["\'])([^)]*)\1\)', r'url(\2)', css ) | 145 | css = re.sub( r'url\((["\'])([^)]*)\1\)', r'url(\2)', css ) |
146 | 146 | ||
147 | # spaces may be safely collapsed as generated content will collapse them anyway | 147 | # spaces may be safely collapsed as generated content will collapse them anyway |
148 | css = re.sub( r'\s+', ' ', css ) | 148 | css = re.sub( r'\s+', ' ', css ) |
149 | 149 | ||
150 | # shorten collapsable colors: #aabbcc to #abc | 150 | # shorten collapsable colors: #aabbcc to #abc |
151 | css = re.sub( r'#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)', r'#\1\2\3\4', css ) | 151 | css = re.sub( r'#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)', r'#\1\2\3\4', css ) |
152 | 152 | ||
153 | # fragment values can loose zeros | 153 | # fragment values can loose zeros |
154 | css = re.sub( r':\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;', r':\1;', css ) | 154 | css = re.sub( r':\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;', r':\1;', css ) |
155 | 155 | ||
156 | for rule in re.findall( r'([^{]+){([^}]*)}', css ): | 156 | for rule in re.findall( r'([^{]+){([^}]*)}', css ): |
157 | 157 | ||
158 | # we don't need spaces around operators | 158 | # we don't need spaces around operators |
159 | selectors = [re.sub( r'(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])', r'', selector.strip() ) for selector in rule[0].split( ',' )] | 159 | selectors = [re.sub( r'(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])', r'', selector.strip() ) for selector in rule[0].split( ',' )] |
160 | 160 | ||
161 | # order is important, but we still want to discard repetitions | 161 | # order is important, but we still want to discard repetitions |
162 | properties = {} | 162 | properties = {} |
163 | porder = [] | 163 | porder = [] |
164 | for prop in re.findall( '(.*?):(.*?)(;|$)', rule[1] ): | 164 | for prop in re.findall( '(.*?):(.*?)(;|$)', rule[1] ): |
165 | key = prop[0].strip().lower() | 165 | key = prop[0].strip().lower() |
166 | if key not in porder: porder.append( key ) | 166 | if key not in porder: porder.append( key ) |
167 | properties[ key ] = prop[1].strip() | 167 | properties[ key ] = prop[1].strip() |
168 | 168 | ||
169 | # output rule if it contains any declarations | 169 | # output rule if it contains any declarations |
170 | if properties: | 170 | if properties: |
171 | print "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) | 171 | print "%s{%s}" % ( ','.join( selectors ), ''.join(['%s:%s;' % (key, properties[key]) for key in porder])[:-1] ) |
172 | 172 | ||
173 | return css | 173 | return css |
174 | 174 | ||
175 | 175 | ||
176 | def compressCSS (self, css): | 176 | def compressCSS (self, css): |
177 | self.log("compressing CSS") | 177 | self.log("compressing CSS") |
178 | #return self.regexCssCompressor(css) | 178 | #return self.regexCssCompressor(css) |
179 | return self.cssminCompressor(css) | 179 | return self.cssminCompressor(css) |
180 | 180 | ||
181 | 181 | ||
182 | #========================================================================== | 182 | #========================================================================== |
183 | 183 | ||
184 | def compressJS_jsmin (self, js): | 184 | def compressJS_jsmin (self, js): |
185 | self.log("compressing JS code") | 185 | self.log("compressing JS code") |
186 | original = StringIO.StringIO(js) | 186 | original = StringIO.StringIO(js) |
187 | output = StringIO.StringIO() | 187 | output = StringIO.StringIO() |
188 | 188 | ||
189 | jsMinifier = jsmin.JavascriptMinify() | 189 | jsMinifier = jsmin.JavascriptMinify() |
190 | jsMinifier.minify(original, output) | 190 | jsMinifier.minify(original, output) |
191 | 191 | ||
192 | result = output.getvalue() | 192 | result = output.getvalue() |
193 | 193 | ||
194 | original.close() | 194 | original.close() |
195 | output.close() | 195 | output.close() |
196 | 196 | ||
197 | return result | 197 | return result |
198 | 198 | ||
199 | def compressJS_closureCompiler (self, js): | 199 | def compressJS_closureCompiler (self, js): |
200 | #Googles Closure compiler | 200 | #Googles Closure compiler |
201 | #java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js | 201 | #java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js |
202 | 202 | ||
203 | result = js | 203 | result = js |
204 | 204 | ||
205 | return result | 205 | return result |
206 | 206 | ||
207 | 207 | ||
208 | def compressJS (self, js): | 208 | def compressJS (self, js): |
209 | return self.compressJS_jsmin(js) | 209 | return self.compressJS_jsmin(js) |
210 | #return self.compressJS_closureCompiler(js) | 210 | #return self.compressJS_closureCompiler(js) |
211 | 211 | ||
212 | 212 | ||
213 | #========================================================================== | 213 | #========================================================================== |
214 | 214 | ||
215 | def packBookmarklet (self, bookmakeletCode): | 215 | def packBookmarklet (self, bookmakeletCode): |
216 | replacers = [ | 216 | replacers = [ |
217 | ('isLoginForm', 'ilf'), | 217 | ('isLoginForm', 'ilf'), |
218 | ('findLoginForm', 'flf'), | 218 | ('findLoginForm', 'flf'), |
219 | ('findLoginForm', 'flf'), | 219 | ('findLoginForm', 'flf'), |
220 | ('formParameters', 'fp' ), | 220 | ('formParameters', 'fp' ), |
221 | ('pageParameters', 'pp' ), | 221 | ('pageParameters', 'pp' ), |
222 | ('serializeJSON', 'sj' ), | 222 | ('serializeJSON', 'sj' ), |
223 | ('reprString', 'rs' ), | 223 | ('reprString', 'rs' ), |
224 | ('logFormParameters', 'lfp'), | 224 | ('logFormParameters', 'lfp'), |
225 | ('loadClipperzBookmarklet','lcb'), | 225 | ('loadClipperzBookmarklet','lcb'), |
226 | ('loginForm', 'lf' ), | 226 | ('loginForm', 'lf' ), |
227 | ('parameters', 'p' ), | 227 | ('parameters', 'p' ), |
228 | ('inputElementValues', 'iev'), | 228 | ('inputElementValues', 'iev'), |
229 | ] | 229 | ] |
230 | result = self.compressJS(bookmakeletCode) | 230 | result = self.compressJS(bookmakeletCode) |
231 | 231 | ||
232 | result = re.sub('\n', ' ', result) #Fit all in a single line | 232 | result = re.sub('\n', ' ', result) #Fit all in a single line |
233 | # result = re.sub('\s+', ' ', result) #Collapse "redundant" spaces. WARNING: this could have some evil side effects on constant strings used inside to code!! | 233 | # result = re.sub('\s+', ' ', result) #Collapse "redundant" spaces. WARNING: this could have some evil side effects on constant strings used inside to code!! |
234 | # result = re.sub('\s?([,\+=\(\)\{\};])\s?', '\\1', result) | 234 | # result = re.sub('\s?([,\+=\(\)\{\};])\s?', '\\1', result) |
235 | 235 | ||
236 | for replacer in replacers: | 236 | for replacer in replacers: |
237 | result = re.sub(replacer[0], replacer[1], result) | 237 | result = re.sub(replacer[0], replacer[1], result) |
238 | 238 | ||
239 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> | 239 | # <!-- escaping required to handle the bookmarklet code within the javascript code --> |
240 | result = re.sub('\://', '%3a%2f%2f',result) | 240 | result = re.sub('\://', '%3a%2f%2f',result) |
241 | result = re.sub('/', '%2f', result) | 241 | result = re.sub('/', '%2f', result) |
242 | # result = re.sub('"', '%22', result) | 242 | # result = re.sub('"', '%22', result) |
243 | result = re.sub('"', '\\"', result) | 243 | result = re.sub('"', '\\"', result) |
244 | result = re.sub('\"', '%22', result) | 244 | result = re.sub('\"', '%22', result) |
245 | result = re.sub('\'', '%22', result) | 245 | result = re.sub('\'', '%22', result) |
246 | result = re.sub('\\\\', '%5c', result) | 246 | result = re.sub('\\\\', '%5c', result) |
247 | result = result.strip() | 247 | result = result.strip() |
248 | result = 'javascript:' + result | 248 | result = 'javascript:' + result |
249 | 249 | ||
250 | # replacers = [ | 250 | # replacers = [ |
251 | # ('aForm', '_1' ), | 251 | # ('aForm', '_1' ), |
252 | # ('inputFields', '_2' ), | 252 | # ('inputFields', '_2' ), |
253 | # ('passwordFieldsFound','_3' ), | 253 | # ('passwordFieldsFound','_3' ), |
254 | # ('aDocument', '_6' ), | 254 | # ('aDocument', '_6' ), |
255 | # ('aLevel', '_7' ), | 255 | # ('aLevel', '_7' ), |
256 | # # ('result', '_8' ), | 256 | # # ('result', '_8' ), |
257 | # ('documentForms', '_9' ), | 257 | # ('documentForms', '_9' ), |
258 | # ('iFrames', '_c' ), | 258 | # ('iFrames', '_c' ), |
259 | # ('anInputElement', '_d' ), | 259 | # ('anInputElement', '_d' ), |
260 | # ('options', '_f' ), | 260 | # ('options', '_f' ), |
261 | # ('option', '_12'), | 261 | # ('option', '_12'), |
262 | # ('aLoginForm', '_13'), | 262 | # ('aLoginForm', '_13'), |
263 | # # ('action', '_17'), | 263 | # # ('action', '_17'), |
264 | # ('radioValues', '_18'), | 264 | # ('radioValues', '_18'), |
265 | # ('radioValueName', '_19'), | 265 | # ('radioValueName', '_19'), |
266 | # ('inputElement', '_1a'), | 266 | # ('inputElement', '_1a'), |
267 | # ('elementValues', '_1b'), | 267 | # ('elementValues', '_1b'), |
268 | # ('radioValue', '_1c'), | 268 | # ('radioValue', '_1c'), |
269 | # ('values', '_1d'), | 269 | # ('values', '_1d'), |
270 | # ('objtype', '_21'), | 270 | # ('objtype', '_21'), |
271 | # ('useKey', '_27'), | 271 | # ('useKey', '_27'), |
272 | # ('bookmarkletDiv', '_28'), | 272 | # ('bookmarkletDiv', '_28'), |
273 | # ('someParameters', '_29'), | 273 | # ('someParameters', '_29'), |
274 | # ('anException', '_2a'), | 274 | # ('anException', '_2a'), |
275 | # ('newDiv', '_2b'), | 275 | # ('newDiv', '_2b'), |
276 | # ('base_url', '_2c'), | 276 | # ('base_url', '_2c'), |
277 | # ('help_url', '_2d'), | 277 | # ('help_url', '_2d'), |
278 | # ('logo_image_url', '_2e'), | 278 | # ('logo_image_url', '_2e'), |
279 | # ('background_image_url','_2f'), | 279 | # ('background_image_url','_2f'), |
280 | # ('close_image_url', '_30'), | 280 | # ('close_image_url', '_30'), |
281 | # #('bookmarklet_textarea','_31'), | 281 | # #('bookmarklet_textarea','_31'), |
282 | # ('innerHTML', '_32'), | 282 | # ('innerHTML', '_32'), |
283 | # ] | 283 | # ] |
284 | # for replacer in replacers: | 284 | # for replacer in replacers: |
285 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) | 285 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) |
286 | 286 | ||
287 | # replacers = [ | 287 | # replacers = [ |
288 | # ('headNode', '_1' ), | 288 | # ('headNode', '_1' ), |
289 | # ('clipperzScriptNode','_2' ), | 289 | # ('clipperzScriptNode','_2' ), |
290 | # ] | 290 | # ] |
291 | # for replacer in replacers: | 291 | # for replacer in replacers: |
292 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) | 292 | # result = re.sub('([^\.])' + replacer[0], '\\1' + replacer[1], result) |
293 | 293 | ||
294 | # result = re.sub(';', ';\n', result) | 294 | # result = re.sub(';', ';\n', result) |
295 | 295 | ||
296 | return result | 296 | return result |
297 | 297 | ||
298 | 298 | ||
299 | 299 | ||
300 | def bookmarklet (self): | 300 | def bookmarklet (self): |
301 | cacheKey = 'bookmarklet' | 301 | cacheKey = 'bookmarklet' |
302 | if not self.processedFiles.has_key(cacheKey): | 302 | if not self.processedFiles.has_key(cacheKey): |
303 | result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js'])) + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js'])) + '";' | 303 | result = 'bookmarklet="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet.js'])) + '";bookmarklet_ie="' + self.packBookmarklet(self.loadFilesContent('js', ['Bookmarklet_IE.js'])) + '";' |
304 | self.processedFiles[cacheKey] = result | 304 | self.processedFiles[cacheKey] = result |
305 | else: | 305 | else: |
306 | result = self.processedFiles[cacheKey] | 306 | result = self.processedFiles[cacheKey] |
307 | 307 | ||
308 | return result | 308 | return result |
309 | 309 | ||
310 | 310 | ||
311 | def replaceTemplatePlaceholders (self, assemblyMode, pageTitle, copyright, css, code, version, versionType): | 311 | def replaceTemplatePlaceholders (self, assemblyMode, pageTitle, copyright, css, code, version, versionType): |
312 | result = self.template() | 312 | result = self.template() |
313 | 313 | ||
314 | result = result.replace('@page.title@', pageTitle, 1) | 314 | result = result.replace('@page.title@', pageTitle, 1) |
315 | result = result.replace('@copyright@', copyright, 1) | 315 | result = result.replace('@copyright@', copyright, 1) |
316 | result = result.replace('@css@', css, 1) | 316 | result = result.replace('@css@', css, 1) |
317 | #result = result.replace('@bookmarklet@', bookmarklet,1) | 317 | #result = result.replace('@bookmarklet@', bookmarklet,1) |
318 | result = result.replace('@application.version@', version, 1) | 318 | result = result.replace('@application.version@', version, 1) |
319 | result = result.replace('@application.version.type@', versionType,1) | 319 | result = result.replace('@application.version.type@', versionType,1) |
320 | result = result.replace('@js_' + assemblyMode + '@', code, 1) | 320 | result = result.replace('@js_' + assemblyMode + '@', code, 1) |
321 | 321 | ||
322 | result = re.sub('@js_[^@]+@', '', result) | 322 | result = re.sub('@js_[^@]+@', '', result) |
323 | 323 | ||
324 | return result | 324 | return result |
325 | 325 | ||
326 | 326 | ||
327 | def assembleCopyrightHeader (self): | 327 | def assembleCopyrightHeader (self): |
328 | processedFile = 'copyright' | 328 | processedFile = 'copyright' |
329 | if not self.processedFiles.has_key(processedFile): | 329 | if not self.processedFiles.has_key(processedFile): |
330 | #self.log("assembling copyright header") | 330 | #self.log("assembling copyright header") |
331 | copyrightValues = self.settings['copyright.values'] | 331 | copyrightValues = self.settings['copyright.values'] |
332 | license = self.loadFilesContent('../../properties', ['license.txt']) | 332 | license = self.loadFilesContent('../../properties', ['license.txt']) |
333 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) | 333 | result = self.loadFilesContent('properties', ['creditsAndCopyrights.txt']) |
334 | 334 | ||
335 | result = re.sub('@clipperz.license@', license, result) | 335 | result = re.sub('@clipperz.license@', license, result) |
336 | for key in copyrightValues: | 336 | for key in copyrightValues: |
337 | result = re.sub('@'+key+'@', copyrightValues[key], result) | 337 | result = re.sub('@'+key+'@', copyrightValues[key], result) |
338 | 338 | ||
339 | self.processedFiles[processedFile] = result | 339 | self.processedFiles[processedFile] = result |
340 | 340 | ||
341 | return self.processedFiles[processedFile] | 341 | return self.processedFiles[processedFile] |
342 | 342 | ||
343 | 343 | ||
344 | def cssTagsForFiles (self, basePath, files): | 344 | def cssTagsForFiles (self, basePath, files): |
345 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> | 345 | #<link rel="stylesheet" type="text/css" href="./css/reset-min.css" /> |
346 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="./' + basePath + '/' + file + '" />', files)) | 346 | return '\n'.join(map(lambda file: '<link rel="stylesheet" type="text/css" href="./' + basePath + '/' + file + '" />', files)) |
347 | 347 | ||
348 | 348 | ||
349 | def cssTagForContent (self, content): | 349 | def cssTagForContent (self, content): |
350 | return '<style type="text/css">' + content + '</style>' | 350 | return '<style type="text/css">' + content + '</style>' |
351 | 351 | ||
352 | 352 | ||
353 | def scriptTagsForFiles (self, basePath, files): | 353 | def scriptTagsForFiles (self, basePath, files): |
354 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> | 354 | #<script type='text/javascript' src='./js/src/bookmarklet.js'></script> |
355 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="./' + basePath + '/' + file + '"></script>', files)) | 355 | return '\n'.join(map(lambda file: '<script type="text/javascript" src="./' + basePath + '/' + file + '"></script>', files)) |
356 | 356 | ||
357 | 357 | ||
358 | def scriptTagForContent (self, content): | 358 | def scriptTagForContent (self, content): |
359 | return '<script>' + content + '</script>' | 359 | return '<script>' + content + '</script>' |
360 | 360 | ||
361 | 361 | ||
362 | def assembleVersion (self, assemblyMode, pageTitle, copyright, css, js, version, versionType): | 362 | def assembleVersion (self, assemblyMode, pageTitle, copyright, css, js, version, versionType): |
363 | cacheKey = version + "-" + versionType | 363 | cacheKey = version + "-" + versionType |
364 | if not self.processedFiles.has_key(cacheKey): | 364 | if not self.processedFiles.has_key(cacheKey): |
365 | result = self.replaceTemplatePlaceholders(assemblyMode, pageTitle, copyright, css, js, version, versionType) | 365 | result = self.replaceTemplatePlaceholders(assemblyMode, pageTitle, copyright, css, js, version, versionType) |
366 | self.processedFiles[cacheKey] = result | 366 | self.processedFiles[cacheKey] = result |
367 | else: | 367 | else: |
368 | result = self.processedFiles[cacheKey] | 368 | result = self.processedFiles[cacheKey] |
369 | 369 | ||
370 | #self.log("# cacheKey:\n" + result) | 370 | #self.log("# cacheKey:\n" + result) |
371 | return result | 371 | return result |
372 | 372 | ||
373 | 373 | ||
374 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): | 374 | def assemble (self, assemblyMode='INSTALL', versionType='LIVE'): |
375 | pageTitle = "Clipperz - " + self.module | 375 | pageTitle = "Clipperz - " + self.module |
376 | if versionType != 'LIVE': | 376 | if versionType != 'LIVE': |
377 | pageTitle += " [" + versionType + " - " + assemblyMode +"]" | 377 | pageTitle += " [" + versionType + " - " + assemblyMode +"]" |
378 | 378 | ||
379 | if assemblyMode == 'INSTALL': | 379 | if assemblyMode == 'INSTALL': |
380 | css= self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) | 380 | css= self.cssTagForContent(self.compressCSS(self.loadFilesContent('css', self.settings['css']))) |
381 | js= self.scriptTagForContent(self.bookmarklet() + '\n' + self.compressJS(self.loadFilesContent('js', self.settings['js']))) | 381 | js= self.scriptTagForContent(self.bookmarklet() + '\n' + self.compressJS(self.loadFilesContent('js', self.settings['js']))) |
382 | else: | 382 | else: |
383 | css= self.cssTagsForFiles('css', self.filterFiles(self.settings['css'])) | 383 | css= self.cssTagsForFiles('css', self.filterFiles(self.settings['css'])) |
384 | js= self.scriptTagForContent(self.bookmarklet()) + '\n' + self.scriptTagsForFiles('js', self.filterFiles(self.settings['js'])) | 384 | js= self.scriptTagForContent(self.bookmarklet()) + '\n' + self.scriptTagsForFiles('js', self.filterFiles(self.settings['js'])) |
385 | 385 | ||
386 | return self.assembleVersion( | 386 | return self.assembleVersion( |
387 | assemblyMode= assemblyMode, | 387 | assemblyMode= assemblyMode, |
388 | pageTitle = pageTitle, | 388 | pageTitle = pageTitle, |
389 | copyright = self.assembleCopyrightHeader(), | 389 | copyright = self.assembleCopyrightHeader(), |
390 | css = css, | 390 | css = css, |
391 | js = js, | 391 | js = js, |
392 | version = self.repositoryVersion(), | 392 | version = self.repositoryVersion(), |
393 | versionType = versionType | 393 | versionType = versionType |
394 | ) | 394 | ) |
395 | 395 | ||
396 | 396 | ||
397 | 397 | ||
398 | 398 | ||
diff --git a/scripts/builder/main.py b/scripts/builder/main.py index ba0c72a..94f738f 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py | |||
@@ -1,166 +1,166 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | import sys, os, json | 4 | import sys, os, json |
5 | import shutil | 5 | import shutil |
6 | import pprint | 6 | import pprint |
7 | import frontendBuilder | 7 | import frontendBuilder |
8 | import codecs | 8 | import codecs |
9 | import itertools | 9 | import itertools |
10 | 10 | ||
11 | from collections import deque | 11 | from collections import deque |
12 | from phpBuilder import PhpBuilder | 12 | from phpBuilder import PhpBuilder |
13 | from pythonBuilder import PythonBuilder | 13 | from pythonBuilder import PythonBuilder |
14 | 14 | ||
15 | pp = pprint.PrettyPrinter(indent=4, depth=4) | 15 | pp = pprint.PrettyPrinter(indent=4, depth=4) |
16 | 16 | ||
17 | #-------------------------------------------------------------------- | 17 | #-------------------------------------------------------------------- |
18 | 18 | ||
19 | def scriptDir (): | 19 | def scriptDir (): |
20 | return os.path.dirname(sys.argv[0]) | 20 | return os.path.dirname(sys.argv[0]) |
21 | 21 | ||
22 | def projectBaseDir (): | 22 | def projectBaseDir (): |
23 | return os.path.abspath(scriptDir() + '/../..') | 23 | return os.path.abspath(scriptDir() + '/../..') |
24 | 24 | ||
25 | def projectTargetDir(): | 25 | def projectTargetDir(): |
26 | return projectBaseDir() + '/target/' | 26 | return projectBaseDir() + '/target/' |
27 | 27 | ||
28 | #-------------------------------------------------------------------- | 28 | #-------------------------------------------------------------------- |
29 | 29 | ||
30 | def createFolder (path): | 30 | def createFolder (path): |
31 | if not os.path.exists(path): | 31 | if not os.path.exists(path): |
32 | os.makedirs(path) | 32 | os.makedirs(path) |
33 | 33 | ||
34 | #-------------------------------------------------------------------- | 34 | #-------------------------------------------------------------------- |
35 | 35 | ||
36 | def loadSettings (component, module): | 36 | def loadSettings (component, module): |
37 | print "MODULE: " + module | 37 | print "MODULE: " + module |
38 | 38 | ||
39 | if '.' in module: | 39 | if '.' in module: |
40 | moduleComponents = module.split('.') | 40 | moduleComponents = module.split('.') |
41 | module = moduleComponents[0] | 41 | module = moduleComponents[0] |
42 | submodule = moduleComponents[1] | 42 | submodule = moduleComponents[1] |
43 | else: | 43 | else: |
44 | submodule = module | 44 | submodule = module |
45 | 45 | ||
46 | settings = codecs.open(projectBaseDir() + '/' + component + '/' + module + '/properties/' + submodule + '.properties.json', 'r', 'utf-8') | 46 | settings = codecs.open(projectBaseDir() + '/' + component + '/' + module + '/properties/' + submodule + '.properties.json', 'r', 'utf-8') |
47 | result = json.load(settings) | 47 | result = json.load(settings) |
48 | settings.close | 48 | settings.close |
49 | 49 | ||
50 | return result | 50 | return result |
51 | 51 | ||
52 | #==================================================================== | 52 | #==================================================================== |
53 | # | 53 | # |
54 | # def assembleFrontend (frontend, versions): | 54 | # def assembleFrontend (frontend, versions): |
55 | # result = {} | 55 | # result = {} |
56 | # settings = loadSettings('frontend', frontend) | 56 | # settings = loadSettings('frontend', frontend) |
57 | # builder = frontendBuilder.FrontendBuilder(frontend, settings, projectBaseDir()) | 57 | # builder = frontendBuilder.FrontendBuilder(frontend, settings, projectBaseDir()) |
58 | # | 58 | # |
59 | # for version in versions: | 59 | # for version in versions: |
60 | # if version == 'install': | 60 | # if version == 'install': |
61 | # result[version] = builder.assembleInstallVersion() | 61 | # result[version] = builder.assembleInstallVersion() |
62 | # elif version == 'debug': | 62 | # elif version == 'debug': |
63 | # result[version] = builder.assembleDebugVersion() | 63 | # result[version] = builder.assembleDebugVersion() |
64 | # else: | 64 | # else: |
65 | # raise Exception('unrecognized version: ' + version) | 65 | # raise Exception('unrecognized version: ' + version) |
66 | # | 66 | # |
67 | # return result | 67 | # return result |
68 | # | 68 | # |
69 | #==================================================================== | 69 | #==================================================================== |
70 | 70 | ||
71 | def assembleBackend (backend, frontends, versions): | 71 | def assembleBackend (backend, frontends, versions): |
72 | settings = loadSettings('backend', backend) | 72 | settings = loadSettings('backend', backend) |
73 | 73 | ||
74 | if backend == 'php': | 74 | if backend == 'php': |
75 | backendBuilder = PhpBuilder(projectTargetDir(), frontends, versions, settings) | 75 | backendBuilder = PhpBuilder(projectTargetDir(), frontends, versions, settings) |
76 | elif backend == 'python': | 76 | elif backend == 'python': |
77 | backendBuilder = PythonBuilder(projectTargetDir(), frontends, versions, settings) | 77 | backendBuilder = PythonBuilder(projectTargetDir(), frontends, versions, settings) |
78 | #elif backend == 'java': | 78 | #elif backend == 'java': |
79 | #buildJavaBackend (frontends, versions, settings) | 79 | #buildJavaBackend (frontends, versions, settings) |
80 | else: | 80 | else: |
81 | raise Exception('unrecognized backend: ' + backend) | 81 | raise Exception('unrecognized backend: ' + backend) |
82 | 82 | ||
83 | backendBuilder.run() | 83 | backendBuilder.run() |
84 | 84 | ||
85 | #==================================================================== | 85 | #==================================================================== |
86 | 86 | ||
87 | def build (settings): | 87 | def build (settings): |
88 | frontends = [] | 88 | frontends = [] |
89 | 89 | ||
90 | for frontend in settings['frontends']: | 90 | for frontend in settings['frontends']: |
91 | frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend))) | 91 | frontends.append(frontendBuilder.FrontendBuilder(frontend, loadSettings('frontend', frontend))) |
92 | 92 | ||
93 | for backend in settings['backends']: | 93 | for backend in settings['backends']: |
94 | assembleBackend(backend, frontends, settings['versions']) | 94 | assembleBackend(backend, frontends, settings['versions']) |
95 | 95 | ||
96 | #-------------------------------------------------------------------- | 96 | #-------------------------------------------------------------------- |
97 | 97 | ||
98 | def clean (): | 98 | def clean (): |
99 | print "cleaning up …" | 99 | print "cleaning up …" |
100 | if os.path.exists(projectTargetDir()): | 100 | if os.path.exists(projectTargetDir()): |
101 | shutil.rmtree(projectTargetDir()) | 101 | shutil.rmtree(projectTargetDir()) |
102 | 102 | ||
103 | #-------------------------------------------------------------------- | 103 | #-------------------------------------------------------------------- |
104 | 104 | ||
105 | def usage (message): | 105 | def usage (message): |
106 | if message != None: | 106 | if message != None: |
107 | print "ERROR: " + message | 107 | print "ERROR: " + message |
108 | 108 | ||
109 | 109 | ||
110 | print "build.py clean" | 110 | print "build.py clean" |
111 | print "build.py clean install" | 111 | print "build.py clean install" |
112 | print "build.py install --ALL" | 112 | print "build.py install --ALL" |
113 | print "build.py install debug --ALL" | 113 | print "build.py install debug --ALL" |
114 | print "build.py clean install debug --ALL" | 114 | print "build.py clean install debug --ALL" |
115 | print "build.ph install, debug --backends php java --frontends beta gamma" | 115 | print "build.ph install, debug --backends php java --frontends beta gamma" |
116 | print "build.ph install, debug --backends php java --frontends beta gamma gamma.mobile" | 116 | print "build.ph install, debug --backends php java --frontends beta gamma gamma.mobile" |
117 | exit(1) | 117 | exit(1) |
118 | 118 | ||
119 | #-------------------------------------------------------------------- | 119 | #-------------------------------------------------------------------- |
120 | 120 | ||
121 | def main (): | 121 | def main (): |
122 | settings = {} | 122 | settings = {} |
123 | parameters = list(itertools.islice(sys.argv, 1, None)) | 123 | parameters = list(itertools.islice(sys.argv, 1, None)) |
124 | 124 | ||
125 | shouldClean = len(filter(lambda x: x == 'clean', parameters)) > 0 | 125 | shouldClean = len(filter(lambda x: x == 'clean', parameters)) > 0 |
126 | if (shouldClean): | 126 | if (shouldClean): |
127 | clean () | 127 | clean () |
128 | 128 | ||
129 | parameters = filter(lambda x: x != 'clean', parameters) | 129 | parameters = filter(lambda x: x != 'clean', parameters) |
130 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) | 130 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) |
131 | settings['versions'] = versions; #['debug', 'install'] | 131 | settings['versions'] = versions; #['debug', 'install'] |
132 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) | 132 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) |
133 | 133 | ||
134 | if len(parameters) > 0: | 134 | if len(parameters) > 0: |
135 | parameter = parameters.popleft() | 135 | parameter = parameters.popleft() |
136 | if parameter == "--ALL": | 136 | if parameter == "--ALL": |
137 | settings['frontends'] = ['beta', 'gamma', 'mobile'] | 137 | settings['frontends'] = ['beta', 'gamma', 'mobile'] |
138 | settings['backends'] = ['php', 'python', 'java'] | 138 | settings['backends'] = ['php', 'python', 'java'] |
139 | else: | 139 | else: |
140 | while parameter != None: | 140 | while parameter != None: |
141 | values = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) | 141 | values = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) |
142 | 142 | ||
143 | if parameter == "--backends": | 143 | if parameter == "--backends": |
144 | settings['backends'] = values | 144 | settings['backends'] = values |
145 | elif parameter == "--frontends": | 145 | elif parameter == "--frontends": |
146 | settings['frontends'] = values | 146 | settings['frontends'] = values |
147 | 147 | ||
148 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) | 148 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) |
149 | if parameters: | 149 | if parameters: |
150 | parameter = parameters.popleft() | 150 | parameter = parameters.popleft() |
151 | else: | 151 | else: |
152 | parameter = None | 152 | parameter = None |
153 | 153 | ||
154 | if (not settings.has_key('versions')): | 154 | if (not settings.has_key('versions')): |
155 | usage("missing 'versions'") | 155 | usage("missing 'versions'") |
156 | if (not settings.has_key('frontends')): | 156 | if (not settings.has_key('frontends')): |
157 | usage("missing 'frontends'") | 157 | usage("missing 'frontends'") |
158 | if (not settings.has_key('backends')): | 158 | if (not settings.has_key('backends')): |
159 | usage("missing 'backends'") | 159 | usage("missing 'backends'") |
160 | 160 | ||
161 | build (settings) | 161 | build (settings) |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | if __name__ == "__main__": | 165 | if __name__ == "__main__": |
166 | main() \ No newline at end of file | 166 | main() |
diff --git a/scripts/builder/phpBuilder.py b/scripts/builder/phpBuilder.py index 9512192..cb4661d 100644 --- a/scripts/builder/phpBuilder.py +++ b/scripts/builder/phpBuilder.py | |||
@@ -1,14 +1,14 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | from backendBuilder import BackendBuilder | 4 | from backendBuilder import BackendBuilder |
5 | 5 | ||
6 | class PhpBuilder(BackendBuilder): | 6 | class PhpBuilder(BackendBuilder): |
7 | 7 | ||
8 | def name(self): | 8 | def name(self): |
9 | return "PHP builder" | 9 | return "PHP builder" |
10 | 10 | ||
11 | def relativePath(self): | 11 | def relativePath(self): |
12 | return 'php' | 12 | return 'php' |
13 | 13 | ||
14 | 14 | ||
diff --git a/scripts/builder/pythonBuilder.py b/scripts/builder/pythonBuilder.py index 44c62a8..a84598d 100644 --- a/scripts/builder/pythonBuilder.py +++ b/scripts/builder/pythonBuilder.py | |||
@@ -1,14 +1,14 @@ | |||
1 | #!/usr/bin/python | 1 | #!/usr/bin/env python |
2 | # -*- coding: UTF-8 -*- | 2 | # -*- coding: UTF-8 -*- |
3 | 3 | ||
4 | from backendBuilder import BackendBuilder | 4 | from backendBuilder import BackendBuilder |
5 | 5 | ||
6 | class PythonBuilder(BackendBuilder): | 6 | class PythonBuilder(BackendBuilder): |
7 | 7 | ||
8 | def name(self): | 8 | def name(self): |
9 | return "Python builder" | 9 | return "Python builder" |
10 | 10 | ||
11 | def relativePath(self): | 11 | def relativePath(self): |
12 | return 'python' | 12 | return 'python' |
13 | 13 | ||
14 | 14 | ||