Ver código fonte

修复暗黑母包打包失败

zengqb 4 anos atrás
pai
commit
cd9aefdbbb
4 arquivos alterados com 50 adições e 4 exclusões
  1. 1 2
      file_utils.py
  2. 21 0
      game_script/ahlz/game_script.py
  3. 27 0
      package_utils.py
  4. 1 2
      xml_utils.py

+ 1 - 2
file_utils.py

@@ -18,8 +18,7 @@ def getFullGameApk(name):
     '''
     return getFullPath('game', name, name + '.apk')
 
-def \
-        getFullSDKPath(sdk):
+def getFullSDKPath(sdk):
     '''
     获取sdk的目录
     '''

+ 21 - 0
game_script/ahlz/game_script.py

@@ -0,0 +1,21 @@
+import file_utils
+import common_utils
+import xml_utils
+import os.path
+import xml.etree.ElementTree as ET
+
+namespaces = {'android' : 'http://schemas.android.com/apk/res/android'}
+encoding = 'UTF-8'
+
+def execute(game, sdk, config):
+    print('execute %s game script...' % game)
+
+    subChannel = config['subChannel']
+
+    decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
+    manifest = os.path.join(decompliePath, 'AndroidManifest.xml')
+    activityName = 'com.tencent.android.tpush.XGPushActivity'
+    #删除Activity
+    xml_utils.deleteActivityByName(manifest, activityName)
+
+    return 0

+ 27 - 0
package_utils.py

@@ -127,6 +127,11 @@ def pack(game, sdk, config):
     if ret:
         return ret
 
+    # 游戏独立处理
+    ret = doGameScript(game, sdk, config)
+    if ret:
+        return ret
+
     #格式化Xml
     # ret = formatXml(game, sdk, subChannel, config)
     # if ret:
@@ -725,6 +730,28 @@ def doGamePostScript(game, sdk, config):
 
     return ret
 
+
+def doGameScript(game, sdk, config):
+    '''
+    执行游戏相关特殊处理脚本
+    '''
+    channelPath = file_utils.getFullPath('game_script', game)
+    targetScript = os.path.join(channelPath, 'game_script.py')
+    print(targetScript + "--------")
+    if not os.path.exists(targetScript):
+        print('game_script no exists')
+        return 0
+
+    print('doGameScript...')
+    sys.path.append(channelPath)
+
+    module = importlib.import_module('game_script')
+    ret = module.execute(game, sdk, config)
+
+    sys.path.remove(channelPath)
+
+    return ret
+
 def addLogSdk(game, sdk, subChannel, config, logSdk):
     # 拷贝jniLibs
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])

+ 1 - 2
xml_utils.py

@@ -589,7 +589,7 @@ def removeRootAttr(manifest, attrType):
 
 def deleteActivityByName(manifest,activityName):
     '''
-    获取启动的activity
+    删除activity
     '''
     attrName = getNamespacesFormat('android:name', namespaces)
     for key in namespaces:
@@ -600,7 +600,6 @@ def deleteActivityByName(manifest,activityName):
     appNode = targetRoot.find('application')
     activitys = appNode.findall('activity')
     for activity in activitys:
-        print ('activity name ======= ' + activity.attrib[attrName])
         if activity.attrib[attrName] == activityName:
             print('delete ------------------> ' + activityName)
             appNode.remove(activity)