Skip to content

Commit f392ff8

Browse files
author
zhangbin
committed
Add argument '--advanced' to set the compilationLevel for web platform.
1 parent fb44ec8 commit f392ff8

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

bin/cocos.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import cocos_project
2323
import shutil
2424

25-
COCOS2D_CONSOLE_VERSION = '0.9'
25+
COCOS2D_CONSOLE_VERSION = '1.0'
2626

2727

2828
class Logging:

plugins/project_compile/build_web/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def gen_buildxml(project_dir, project_json, output_dir, build_opts):
9595
buildContent = buildContent.replace("%sourceMapCfg%", sourceMapContent)
9696
buildContent = buildContent.replace("%ccJsList%", _getFileArrStr(ccJsList))
9797
buildContent = buildContent.replace("%userJsList%", _getFileArrStr(userJsList))
98+
buildContent = buildContent.replace("%debug%", build_opts["debug"])
9899

99100
buildXmlOutputFile = open(os.path.join(publish_dir, "build.xml"), "w")
100101
buildXmlOutputFile.write(buildContent)

plugins/project_compile/build_web/template/build.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<target name="compile">
88
<jscomp compilationLevel="%compilationLevel%"
99
warning="quiet"
10-
debug="false"
10+
debug="%debug%"
1111
output="%publishDir%/%outputFileName%"
1212
languagein="ECMASCRIPT5"
1313
%sourceMapCfg%

plugins/project_compile/project_compile.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _add_custom_options(self, parser):
7171

7272
group = parser.add_argument_group("Web Options")
7373
group.add_argument("--source-map", dest="source_map", action="store_true", help='Enable source-map')
74+
group.add_argument("--advanced", dest="advanced", action="store_true", help="Compile all source js files using Closure Compiler's advanced mode, bigger compression ratio bug more risk")
7475

7576
group = parser.add_argument_group("iOS/Mac Options")
7677
group.add_argument("-t", "--target", dest="target_name", help="Specify the target name to compile.")
@@ -138,6 +139,7 @@ def _check_custom_options(self, args):
138139
self._jobs = self.get_num_of_cpu()
139140

140141
self._has_sourcemap = args.source_map
142+
self._web_advanced = args.advanced
141143
self._no_res = args.no_res
142144
self._output_dir = self._get_output_dir()
143145
self._sign_id = args.sign_id
@@ -968,23 +970,26 @@ def build_web(self):
968970
else:
969971
self.sub_url = '/'
970972

973+
output_dir = "publish"
971974
if self._is_debug_mode():
972-
return
973-
else:
974-
self.sub_url = '%spublish/html5/' % self.sub_url
975+
output_dir = "runtime"
976+
if not self._web_advanced:
977+
return
978+
979+
self.sub_url = '%s%s/html5/' % (self.sub_url, output_dir)
975980

976981
f = open(os.path.join(project_dir, "project.json"))
977982
project_json = json.load(f)
978983
f.close()
979984
engine_dir = os.path.join(project_json["engineDir"])
980985
realEngineDir = os.path.normpath(os.path.join(project_dir, engine_dir))
981-
publish_dir = os.path.normpath(os.path.join(project_dir, "publish", "html5"))
986+
publish_dir = os.path.normpath(os.path.join(project_dir, output_dir, "html5"))
982987

983988
# need to config in options of command
984989
buildOpt = {
985990
"outputFileName" : "game.min.js",
986-
#"compilationLevel" : "simple",
987-
"compilationLevel" : "advanced",
991+
"debug": "true" if self._is_debug_mode() else "false",
992+
"compilationLevel" : "advanced" if self._web_advanced else "simple",
988993
"sourceMapOpened" : True if self._has_sourcemap else False
989994
}
990995

0 commit comments

Comments
 (0)