author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-02-11 23:48:42 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-02-11 23:48:42 (UTC) |
commit | a0661c3b02aa26d6b08ff13dc321e09478868159 (patch) (side-by-side diff) | |
tree | 87bd0af25a0732adb9d14a34d25f9d5479fdf5ee /scripts/builder/backendBuilder.py | |
parent | 96d01919d3ff42c3fdd7f6186a0500caccd3c140 (diff) | |
parent | 7804333809bf725e32a08c531a06acd7d668e190 (diff) | |
download | clipperz-a0661c3b02aa26d6b08ff13dc321e09478868159.zip clipperz-a0661c3b02aa26d6b08ff13dc321e09478868159.tar.gz clipperz-a0661c3b02aa26d6b08ff13dc321e09478868159.tar.bz2 |
Merge pull request #25 from gcsolaroli/master
Initial integration of /beta and /gamma with a single backend
Diffstat (limited to 'scripts/builder/backendBuilder.py') (more/less context) (show whitespace changes)
-rw-r--r-- | scripts/builder/backendBuilder.py | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index 16dbe2f..5ecdda0 100644 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py @@ -3,10 +3,14 @@ import sys, os, json import shutil -import main import hashlib -class BackendBuilder: +import main + +#=================================================================== + + +class BackendBuilder(object): def __init__ (self, projectTargetDir, frontends, versions, settings): self.projectTargetDir = projectTargetDir @@ -14,46 +18,54 @@ class BackendBuilder: self.versions = versions self.settings = settings + # -------------------------------------------------------------------------- + def name (self): raise NotImplementedError() + def relativePath (self): raise NotImplementedError() + def compileCode (self): - pass + raise NotImplementedError() + - def copyCompiledCodeToTargetDir (self): - src = self.sourceFolder() - dst = self.targetFolder() - main.createFolder(os.path.dirname(dst)) - shutil.copytree(src, dst) + def createPackage (self): + raise NotImplementedError() + + # -------------------------------------------------------------------------- def sourceFolder (self): - return main.projectBaseDir() + '/backend/' + self.relativePath() + '/src' + return os.path.join(main.projectBaseDir() , 'backend', self.relativePath(), 'src') - def targetFolder (self): - return self.projectTargetDir + self.relativePath() + def tempFolder (self): + return os.path.join(self.projectTargetDir, '.tmp', self.relativePath()) - def createTargetFolder (self): - main.createFolder(self.targetFolder()) + def frontEndTempFolder (self): + return self.tempFolder() -# def copyFrontendResources (self, frontend): -# print "copying resources for frontend: " + frontend -# print "SETTINGS: " + str(self.settings) + def developmentTargetFolder (self): + return os.path.join(self.projectTargetDir, 'development', self.relativePath()) - def writeToTargetFolder (self, filename, content): - file = open(self.targetFolder() + '/' + filename, 'w') + def targetFolder (self): + return os.path.join(self.projectTargetDir, self.relativePath()) + + # -------------------------------------------------------------------------- + + def writeToFolder (self, folder, filename, content): + file = open(os.path.join(folder, filename), 'w') file.write(content.encode('utf-8')) file.close() - def configureIndexContent (self, indexContent): + def configureIndexContent (self, indexContent, requestPathPrefix = ".."): result = indexContent - result = result.replace( '@request.path@', self.settings['request.path'] ) + result = result.replace( '@request.path@', requestPathPrefix + '/' + self.settings['request.path'] ) result = result.replace( '@should.pay.toll@', self.settings['should.pay.toll'] ) return result @@ -68,22 +80,39 @@ class BackendBuilder: print message + ": " + sha256Digest + " (sha256)" + def shouldCompileCode (self): + return ('debug' in self.versions) or ('install' in self.versions) + def run (self): print self.name() + " - RUN" + if self.shouldCompileCode(): self.compileCode() - self.copyCompiledCodeToTargetDir() for frontend in self.frontends: - frontendPath = frontend.module + '/' + main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) + if 'debug' in self.versions: - frontend.copyResourcesToTargetFolder(self.targetFolder()) - #self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assembleDebugVersion())) - self.writeToTargetFolder(frontendPath + 'index_debug.html', self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG'))) + frontend.copyResourcesToFolder(self.frontEndTempFolder()) + + index = self.configureIndexContent(frontend.assemble(assemblyMode='DEBUG', versionType='DEBUG')) + self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index_debug.html'), index) if 'install' in self.versions: index = self.configureIndexContent(frontend.assemble()) - self.writeToTargetFolder(frontendPath + 'index.html', index) + self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index.html'), index) + self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index.html checksum") + self.createPackage() + + if 'development' in self.versions: + for frontend in self.frontends: + main.createFolder(os.path.join(self.developmentTargetFolder(), frontend.module)) + + index = self.configureIndexContent(frontend.assemble(assemblyMode='DEVELOPMENT', versionType='DEBUG'), self.settings['development.settings']['url']) + self.writeToFolder(self.developmentTargetFolder(), os.path.join(frontend.module, 'index_development.html'), index) + + +#=================================================================== |