Commit d0fd6f0b authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Modify build_version to run sencha via a docker container.

parent 916453e7
......@@ -65,8 +65,12 @@ PDFDOC = opj(APP_STATIC, "docs", PDF)
W2P_DIR_CNT = "/opt/web2py"
APP_DIR_CNT = opj(W2P_DIR_CNT, "applications", APP)
APP_STATIC_CNT = opj(APP_DIR_CNT, "static")
DBUISRC_CNT = opj(APP_STATIC_CNT, "plugin_dbui", "src")
EXTJSSRC_CNT = opj(APP_STATIC_CNT, "plugin_extjs", "src")
JSDOC_CNT = opj(APP_STATIC_CNT, "docs", "jsduck")
JSLIBDEBUG_CNT = opj(APP_STATIC_CNT, "%s-debug.js" % APP)
JSLIBSRC_CNT = opj(APP_STATIC_CNT, APP, "src")
JSLIBMIN_CNT = opj(APP_STATIC_CNT, "%s-min.js" % APP)
JSLIBSRC_CNT = opj(APP_STATIC_CNT, APP, "src")
......@@ -178,12 +182,12 @@ def change_log():
def compile_js():
"""compile_js the javascript code and generate the debug version
as well as the minified version.
as well as the minimised version.
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 minimised 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
......@@ -200,41 +204,92 @@ def compile_js():
"""
print "Compile the javascript code ..."
if not which("sencha"):
print '\n\tThe application sencha is missing !'
print '\tSee: http://www.sencha.com/products/sencha-cmd/download'
print '\tSkip this step.\n'
sencha = which("sencha")
if len(sencha) == 0:
print "\n\tThe application sencha is missing !"
print "\tSee: http://www.sencha.com/products/sencha-cmd/download"
print "\tSkip this step.\n"
return
if not os.path.exists(JSLIBSRC):
print 'No javascript library. Exit.'
print "\n\tNo javascript library. Exit.\n"
return
# clean previous version
for item in (JSLIBDEBUG, JSLIBMIN):
if os.path.exists(item):
os.remove(item)
print 'Remove old javascript library', item
print "\n\tRemove old javascript library..\n"
call(["rm", "-f", JSLIBDEBUG, JSLIBMIN])
# debug version of the javascript library
cmd = ["sencha", "-sdk", EXTJSSRC,
"compile", "-classpath", "%s,%s" % (JSLIBSRC, DBUISRC),
"exclude", "--namespace", "Ext,App",
"and", "concat", JSLIBDEBUG]
# NOTE
# the processing depend on the localisation of sencha
# either on the localhost or behind a docker container
# the length of the cmd list allows to separate the two cases
call(cmd)
# NOTE
# container is running as root
# permissions have to be changed for the current user
print 'Debug version of the javascript library', JSLIBDEBUG, 'is ready'
# localhost
if len(sencha) == 1:
# Minified version of the javascript library
cmd = ["sencha", "-sdk", EXTJSSRC,
"compile", "-classpath", "%s,%s" % (JSLIBSRC, DBUISRC),
"exclude", "--namespace", "Ext,App",
"and", "concat", "--yui", JSLIBMIN]
cmd = list(sencha)
cmd.extend([
"-sdk", EXTJSSRC,
"compile", "-classpath", "%s,%s" % (JSLIBSRC, DBUISRC),
"exclude", "--namespace", "Ext,App",
"and", "concat", JSLIBDEBUG])
call(cmd)
call(cmd)
print 'Minified version of the javascript library', JSLIBMIN, 'is ready'
cmd = list(sencha)
cmd.extend([
"-sdk", EXTJSSRC,
"compile", "-classpath", "%s,%s" % (JSLIBSRC, DBUISRC),
"exclude", "--namespace", "Ext,App",
"and", "concat", "--yui", JSLIBMIN])
call(cmd)
else:
cmd = list(sencha)
cmd.extend([
"-sdk", EXTJSSRC_CNT,
"compile", "-classpath", "%s,%s" % (JSLIBSRC_CNT, DBUISRC_CNT),
"exclude", "--namespace", "Ext,App",
"and", "concat", JSLIBDEBUG_CNT])
call(cmd)
cmd = list(sencha)
cmd.extend([
"-sdk", EXTJSSRC_CNT,
"compile", "-classpath", "%s,%s" % (JSLIBSRC_CNT, DBUISRC_CNT),
"exclude", "--namespace", "Ext,App",
"and", "concat", "--yui", JSLIBMIN_CNT])
call(cmd)
cmd = ["docker", "exec", ARGS.docker_container,
"chown", get_perm(), JSLIBDEBUG_CNT, JSLIBMIN_CNT]
call(cmd)
print '\n\tDebug version of the js library', JSLIBDEBUG, 'is ready'
print '\tMinimised version of the js library', JSLIBMIN, 'is ready\n'
def get_perm():
""""Return the permission of the current user.
Returns:
str: permission encoded as uid:gid
"""
uid = check_output(["id", "-u"]).strip("\n")
gid = check_output(["id", "-g"]).strip("\n")
return "%s:%s" % (uid, gid)
def get_version():
......@@ -414,14 +469,18 @@ def jsduck():
return
# clean
print "\n\tRemove old javascript documentation..."
call(["rm", "-rf", JSDOC])
# NOTE
# the processing depend on the localisation of jsduck
# either on the localhost or behind a dcoker container
# either on the localhost or behind a docker container
# the length of the cmd list allows to separate the two cases
# localhost
# NOTE
# container is running as root
# permissions have to be changed for the current user
if len(cmd) == 1:
cmd.extend([EXTJSSRC, JSLIBSRC,
......@@ -441,14 +500,8 @@ def jsduck():
call(cmd)
# container is running as root
# change permission for the current user
uid = check_output(["id", "-u"]).strip("\n")
gid = check_output(["id", "-g"]).strip("\n")
perm = "%s:%s" % (uid, gid)
cnt = ARGS.docker_container
call(["docker", "exec", cnt, "chown", "-R", perm, JSDOC_CNT])
call(["docker", "exec", cnt, "chown", "-R", get_perm(), JSDOC_CNT])
print "\n\tJavaScript documentation in", JSDOC
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment