summaryrefslogtreecommitdiff
path: root/scripts/builder
authorGiulio 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)
commit13ebf1b1987a1566d081ff1ba89b4dca197b7d2e (patch) (unidiff)
treedcd7121febab3bd2c1436d2f55a5a2ac07ad2e83 /scripts/builder
parentbbd415769410aac765f889e74a28992bc8483f94 (diff)
parent2a98e81b954ab84efc8d3f4e1d837bf190f77d7d (diff)
downloadclipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.zip
clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.gz
clipperz-13ebf1b1987a1566d081ff1ba89b4dca197b7d2e.tar.bz2
Merge pull request #7 from themiurgo/master
Fixes shebang for python builder scripts
Diffstat (limited to 'scripts/builder') (more/less context) (ignore whitespace changes)
-rw-r--r--scripts/builder/backendBuilder.py2
-rw-r--r--scripts/builder/frontendBuilder.py2
-rwxr-xr-xscripts/builder/main.py4
-rw-r--r--scripts/builder/phpBuilder.py2
-rw-r--r--scripts/builder/pythonBuilder.py2
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,49 +1,49 @@
1#!/usr/bin/python 1#!/usr/bin/env python
2# -*- coding: UTF-8 -*- 2# -*- coding: UTF-8 -*-
3 3
4import sys, os, json 4import sys, os, json
5import shutil 5import shutil
6import main 6import main
7import hashlib 7import hashlib
8 8
9class BackendBuilder: 9class 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')
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,49 +1,49 @@
1#!/usr/bin/python 1#!/usr/bin/env python
2# -*- coding: UTF-8 -*- 2# -*- coding: UTF-8 -*-
3 3
4import sys, os, re 4import sys, os, re
5import cssmin 5import cssmin
6import jsmin 6import jsmin
7import codecs 7import codecs
8import shutil 8import shutil
9import StringIO 9import StringIO
10import urllib 10import 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
14from dulwich.repo import Repo 14from dulwich.repo import Repo
15 15
16import main 16import main
17 17
18 18
19 19
20class FrontendBuilder: 20class 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
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,49 +1,49 @@
1#!/usr/bin/python 1#!/usr/bin/env python
2# -*- coding: UTF-8 -*- 2# -*- coding: UTF-8 -*-
3 3
4import sys, os, json 4import sys, os, json
5import shutil 5import shutil
6import pprint 6import pprint
7import frontendBuilder 7import frontendBuilder
8import codecs 8import codecs
9import itertools 9import itertools
10 10
11from collections import deque 11from collections import deque
12from phpBuilder import PhpBuilder 12from phpBuilder import PhpBuilder
13from pythonBuilder import PythonBuilder 13from pythonBuilder import PythonBuilder
14 14
15pp = pprint.PrettyPrinter(indent=4, depth=4) 15pp = pprint.PrettyPrinter(indent=4, depth=4)
16 16
17#-------------------------------------------------------------------- 17#--------------------------------------------------------------------
18 18
19def scriptDir (): 19def scriptDir ():
20 return os.path.dirname(sys.argv[0]) 20 return os.path.dirname(sys.argv[0])
21 21
22def projectBaseDir (): 22def projectBaseDir ():
23 return os.path.abspath(scriptDir() + '/../..') 23 return os.path.abspath(scriptDir() + '/../..')
24 24
25def projectTargetDir(): 25def projectTargetDir():
26 return projectBaseDir() + '/target/' 26 return projectBaseDir() + '/target/'
27 27
28#-------------------------------------------------------------------- 28#--------------------------------------------------------------------
29 29
30def createFolder (path): 30def 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
36def loadSettings (component, module): 36def 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
@@ -118,49 +118,49 @@ def usage (message):
118 118
119#-------------------------------------------------------------------- 119#--------------------------------------------------------------------
120 120
121def main (): 121def 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
165if __name__ == "__main__": 165if __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
4from backendBuilder import BackendBuilder 4from backendBuilder import BackendBuilder
5 5
6class PhpBuilder(BackendBuilder): 6class 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
4from backendBuilder import BackendBuilder 4from backendBuilder import BackendBuilder
5 5
6class PythonBuilder(BackendBuilder): 6class 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