diff --git a/buildVersion.py b/buildVersion.py index 3e7e8e136d095fb1fa24140d63b0f5ddf4ead7c4..b15cdd402153c9162ab2b34674b38d5870c89cba 100755 --- a/buildVersion.py +++ b/buildVersion.py @@ -22,7 +22,6 @@ EXAMPLES > buildVersion -h - > buildVersion 0.4.3 AUTHOR R. Le Gac, renaud.legac@free.fr @@ -60,6 +59,7 @@ PACK_PLUGIN_URL = 'http://localhost:8000/%s/default/pack_plugin' % APP EPYDOC = '/usr/bin/epydoc' GIT = '/usr/bin/git' JSDUCK = os.path.expandvars("$HOME/bin/jsduck") +SENCHA = os.path.expandvars("$HOME/bin/sencha") YUICOMPRESSOR = os.path.expandvars("$HOME/lib/yuicompressor-2.4.8.jar") MSG_VERSION = 'Enter the new version: ' @@ -112,6 +112,64 @@ def epydoc(): print "HTML documentation in", PYDOC +def compile(): + """compile the javascript code and generate the debug version + as well as the minified version of the dbui library. + + The compiler verify that the code complied with the class model + and order the file in the proper way. + + The minified library can be build in several ways, including + the Ext JS class required by the applications. In the + current version, the library contains only the dbui classes and + the Ext JS ones have to be loaded separately. In that sense + this command is very similar to the yuicompressor one. + + Several compressor can be used yui, closure compiler, .... + In the current version, the default yui compressor is used? + + This operation relies on the Sencha Cmd: + http://www.sencha.com/products/sencha-cmd/download + + The details documantation can be found: + http://docs.sencha.com/extjs/4.2.2/#!/guide/command + + """ + if not os.path.exists(SENCHA): + print '\n\tThe application sencha is missing !' + print '\tSee: http://www.sencha.com/products/sencha-cmd/download' + print '\tSkip this step.\n' + return + + # clean previous version + for el in (JSLIBDEBUG, JSLIBMIN): + if os.path.exists(el): + os.remove(el) + print 'Remove javascript library', el + + # debug version of the javascript library + print 'Debug version of the javascript library', JSLIBDEBUG + + cwd = os.getcwd() + + cmd = ["sencha", "-sdk", os.path.join(cwd, EXTJSSRC), + "compile", "-class", os.path.join(cwd, JSLIBSRC), + "exclude", "--namespace", "Ext", + "and", "concat", os.path.join(cwd, JSLIBDEBUG)] + + subprocess.call(cmd) + + # Minified version of the javascript library + print 'Minified version of the javascript library', JSLIBMIN + + cmd = ["sencha", "-sdk", os.path.join(cwd, EXTJSSRC), + "compile", "-class", os.path.join(cwd, JSLIBSRC), + "exclude", "--namespace", "Ext", + "and", "concat", "--yui", os.path.join(cwd, JSLIBMIN)] + + subprocess.call(cmd) + + def get_version(): """Get the current version identifier. @@ -299,6 +357,11 @@ if __name__ == '__main__': dest= "all", help= "run all steps.") + ops.add_option("-c", "--compile", + action="store_true", + dest="compile", + help="compile the minimal library using sencha command.") + ops.add_option("-e", "--epydoc", action="store_true", dest= "epydoc", @@ -335,6 +398,7 @@ if __name__ == '__main__': help= "pack the web2py plugin.") ops.set_defaults(all=False, + compile=False, epydoc=False, get=False, git=False, @@ -365,13 +429,16 @@ if __name__ == '__main__': if opt.jsduck: jsduck() + if opt.compile: + compile() + if opt.yuicompressor: yuicompressor() if opt.web2py: epydoc() jsduck() - yuicompressor() + compile() web2py() # run all steps @@ -386,7 +453,7 @@ if __name__ == '__main__': git() epydoc() jsduck() - yuicompressor() + compile() web2py() print 'Exit buidVersion\n'