@@ -115,6 +115,14 @@ def _add_custom_options(self, parser):
115
115
group .add_argument ("--lua-encrypt-sign" , dest = "lua_encrypt_sign" ,
116
116
help = MultiLanguage .get_string ('COMPILE_ARG_LUA_ENCRYPT_SIGN' ))
117
117
118
+ group = parser .add_argument_group (MultiLanguage .get_string ('COMPILE_ARG_GROUP_TIZEN' ))
119
+ group .add_argument ("--tizen-arch" , dest = "tizen_arch" , default = "x86" , choices = [ "x86" , "arm" ], help = MultiLanguage .get_string ('COMPILE_ARG_TIZEN_ARCH' ))
120
+ # group.add_argument("--tizen-compiler", dest="tizen_compiler", choices=[ "llvm", "gcc" ], help=MultiLanguage.get_string('COMPILE_ARG_TIZEN_COMPILER'))
121
+ # group.add_argument("--tizen-pkgtype", dest="tizen_pkgtype", default="tpk", choices=[ "tpk", "wgt" ], help=MultiLanguage.get_string('COMPILE_ARG_TIZEN_PKGTYPE'))
122
+ group .add_argument ("--tizen-profile" , dest = "tizen_profile" , help = MultiLanguage .get_string ('COMPILE_ARG_TIZEN_PROFILE' ))
123
+ group .add_argument ("--tizen-sign" , dest = "tizen_sign" , help = MultiLanguage .get_string ('COMPILE_ARG_TIZEN_SIGN' ))
124
+ group .add_argument ("--tizen-strip" , dest = "tizen_strip" , action = "store_true" , help = MultiLanguage .get_string ('COMPILE_ARG_TIZEN_STRIP' ))
125
+
118
126
category = self .plugin_category ()
119
127
name = self .plugin_name ()
120
128
usage = "\n \t %%prog %s %s -p <platform> [-s src_dir][-m <debug|release>]" \
@@ -157,6 +165,15 @@ def _check_custom_options(self, args):
157
165
if args .target_name is not None :
158
166
self .xcode_target_name = args .target_name
159
167
168
+ # Tizen arguments
169
+ self .tizen_arch = args .tizen_arch
170
+ # self.tizen_compiler = args.tizen_compiler
171
+ # self.tizen_pkgtype = args.tizen_pkgtype
172
+ self .tizen_pkgtype = 'tpk'
173
+ self .tizen_sign = args .tizen_sign
174
+ self .tizen_strip = args .tizen_strip
175
+ self .tizen_profile = args .tizen_profile
176
+
160
177
if args .compile_script is not None :
161
178
self ._compile_script = bool (args .compile_script )
162
179
else :
@@ -1160,24 +1177,7 @@ def build_win32(self):
1160
1177
shutil .copy (file_path , output_dir )
1161
1178
1162
1179
# copy lua files & res
1163
- build_cfg_path = self ._build_cfg_path ()
1164
- build_cfg = os .path .join (build_cfg_path , CCPluginCompile .BUILD_CONFIG_FILE )
1165
- if not os .path .exists (build_cfg ):
1166
- message = MultiLanguage .get_string ('COMPILE_ERROR_FILE_NOT_FOUND_FMT' , build_cfg )
1167
- raise cocos .CCPluginError (message , cocos .CCPluginError .ERROR_PATH_NOT_FOUND )
1168
- f = open (build_cfg )
1169
- data = json .load (f )
1170
-
1171
- if data .has_key (CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ):
1172
- if self ._no_res :
1173
- fileList = data [CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ]
1174
- else :
1175
- fileList = data [CCPluginCompile .CFG_KEY_COPY_RESOURCES ] + data [CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ]
1176
- else :
1177
- fileList = data [CCPluginCompile .CFG_KEY_COPY_RESOURCES ]
1178
-
1179
- for cfg in fileList :
1180
- cocos .copy_files_with_config (cfg , build_cfg_path , output_dir )
1180
+ self ._copy_resources (output_dir )
1181
1181
1182
1182
# check the project config & compile the script files
1183
1183
if self ._project ._is_js_project ():
@@ -1524,6 +1524,113 @@ def build_metro(self):
1524
1524
build_mode = 'Debug' if self ._is_debug_mode () else 'Release'
1525
1525
self .build_vs_project (projectPath , self .project_name , build_mode , self .vs_version )
1526
1526
1527
+ def _build_tizen_proj (self , tizen_cmd_path , build_mode , proj_path ):
1528
+ build_native_cmd = "%s build-native -- \" %s\" " % (tizen_cmd_path , proj_path )
1529
+ build_native_cmd += " -C %s" % build_mode
1530
+ build_native_cmd += " -a %s" % self .tizen_arch
1531
+
1532
+ # if self.tizen_compiler is not None:
1533
+ # build_native_cmd += " -c %s" % self.tizen_compiler
1534
+ # TODO now only support gcc
1535
+ build_native_cmd += " -c gcc"
1536
+
1537
+ self ._run_cmd (build_native_cmd )
1538
+
1539
+ def build_tizen (self ):
1540
+ if not self ._platforms .is_tizen_active ():
1541
+ return
1542
+
1543
+ tizen_studio_path = cocos .check_environment_variable ("TIZEN_STUDIO_HOME" )
1544
+ tizen_proj_path = self ._platforms .project_path ()
1545
+ tizen_cmd_path = cocos .CMDRunner .convert_path_to_cmd (os .path .join (tizen_studio_path , "tools" , "ide" , "bin" , "tizen" ))
1546
+ build_mode = 'Debug' if self ._is_debug_mode () else 'Release'
1547
+
1548
+ # build library projects
1549
+ build_cfg_data = self ._get_build_cfg ()
1550
+ if build_cfg_data .has_key ('depend_projs' ):
1551
+ lib_projs = build_cfg_data ['depend_projs' ]
1552
+ for proj in lib_projs :
1553
+ proj_path = os .path .normpath (os .path .join (self ._build_cfg_path (), proj ))
1554
+ self ._build_tizen_proj (tizen_cmd_path , build_mode , proj_path )
1555
+
1556
+ # build the game project
1557
+ self ._build_tizen_proj (tizen_cmd_path , build_mode , tizen_proj_path )
1558
+
1559
+ # copy resources files
1560
+ res_path = os .path .join (tizen_proj_path , 'res' )
1561
+ self ._copy_resources (res_path )
1562
+
1563
+ # check the project config & compile the script files
1564
+ if self ._project ._is_js_project ():
1565
+ self .compile_js_scripts (res_path , res_path )
1566
+
1567
+ if self ._project ._is_lua_project ():
1568
+ self .compile_lua_scripts (res_path , res_path , False )
1569
+
1570
+ # config the profile path
1571
+ if self .tizen_profile is not None :
1572
+ config_cmd = "%s cli-config -g \" default.profiles.path=%s\" " % (tizen_cmd_path , self .tizen_profile )
1573
+ self ._run_cmd (config_cmd )
1574
+
1575
+ # invoke tizen package
1576
+ build_cfg_path = os .path .join (tizen_proj_path , build_mode )
1577
+ if not os .path .isdir (build_cfg_path ):
1578
+ raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_TIZEN_NO_FILE_FMT' , build_cfg_path ))
1579
+
1580
+ package_cmd = "%s package -- \" %s\" -t %s" % (tizen_cmd_path , build_cfg_path , self .tizen_pkgtype )
1581
+ if self .tizen_sign is not None :
1582
+ package_cmd += " -s \" %s\" " % self .tizen_sign
1583
+
1584
+ if self .tizen_strip :
1585
+ package_cmd += " -S"
1586
+
1587
+ self ._run_cmd (package_cmd )
1588
+
1589
+ # get the package path
1590
+ from xml .dom import minidom
1591
+ doc = minidom .parse (os .path .join (tizen_proj_path , "tizen-manifest.xml" ))
1592
+ pkgid = doc .getElementsByTagName ("manifest" )[0 ].getAttribute ("package" )
1593
+ version = doc .getElementsByTagName ("manifest" )[0 ].getAttribute ("version" )
1594
+
1595
+ if self .tizen_arch == "arm" :
1596
+ arch_str = "arm"
1597
+ else :
1598
+ arch_str = "i386"
1599
+
1600
+ pkg_file_name = "%s-%s-%s.%s" % (pkgid , version , arch_str , self .tizen_pkgtype )
1601
+ tizen_pkg_path = os .path .join (tizen_proj_path , build_mode , pkg_file_name )
1602
+ if not os .path .isfile (tizen_pkg_path ):
1603
+ raise cocos .CCPluginError (MultiLanguage .get_string ('COMPILE_ERROR_TIZEN_BUILD_FAILED' ))
1604
+
1605
+ # copy the package into output dir
1606
+ if not os .path .exists (self ._output_dir ):
1607
+ os .makedirs (self ._output_dir )
1608
+ shutil .copy (tizen_pkg_path , self ._output_dir )
1609
+ self .tizen_pkg_path = os .path .join (self ._output_dir , pkg_file_name )
1610
+
1611
+ def _get_build_cfg (self ):
1612
+ build_cfg_dir = self ._build_cfg_path ()
1613
+ build_cfg = os .path .join (build_cfg_dir , CCPluginCompile .BUILD_CONFIG_FILE )
1614
+ if not os .path .exists (build_cfg ):
1615
+ message = MultiLanguage .get_string ('COMPILE_ERROR_FILE_NOT_FOUND_FMT' , build_cfg )
1616
+ raise cocos .CCPluginError (message , cocos .CCPluginError .ERROR_PATH_NOT_FOUND )
1617
+ f = open (build_cfg )
1618
+ return json .load (f )
1619
+
1620
+ def _copy_resources (self , dst_path ):
1621
+ data = self ._get_build_cfg ()
1622
+
1623
+ if data .has_key (CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ):
1624
+ if self ._no_res :
1625
+ fileList = data [CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ]
1626
+ else :
1627
+ fileList = data [CCPluginCompile .CFG_KEY_COPY_RESOURCES ] + data [CCPluginCompile .CFG_KEY_MUST_COPY_RESOURCES ]
1628
+ else :
1629
+ fileList = data [CCPluginCompile .CFG_KEY_COPY_RESOURCES ]
1630
+
1631
+ for cfg in fileList :
1632
+ cocos .copy_files_with_config (cfg , self ._build_cfg_path (), dst_path )
1633
+
1527
1634
def checkFileByExtention (self , ext , path ):
1528
1635
filelist = os .listdir (path )
1529
1636
for fullname in filelist :
@@ -1557,6 +1664,7 @@ def run(self, argv, dependencies):
1557
1664
self .build_wp8 ()
1558
1665
self .build_wp8_1 ()
1559
1666
self .build_metro ()
1667
+ self .build_tizen ()
1560
1668
1561
1669
# invoke the custom step: post-build
1562
1670
self ._project .invoke_custom_step_script (cocos_project .Project .CUSTOM_STEP_POST_BUILD , target_platform , args_build_copy )
0 commit comments