Browse Source

优化打包流程

yhz 5 years ago
parent
commit
aecaa679e8
7 changed files with 44 additions and 16 deletions
  1. 1 1
      config_utils.py
  2. 1 1
      config_utils_record.py
  3. 1 1
      config_utils_shanshen.py
  4. 12 4
      package_utils.py
  5. 16 4
      package_utils_record.py
  6. 12 4
      package_utils_shanshen.py
  7. 1 1
      打包参数.txt

+ 1 - 1
config_utils.py

@@ -39,7 +39,7 @@ def checkChannelConfig(config):
     if 'clearCache' not in config:
         config['clearCache'] = True
     if 'aapt2disable' not in config:
-        config['aapt2disable'] = True
+        config['aapt2disable'] = False
     if 'v2disable' not in config:
         config['v2disable'] = False
     if 'screenOrientation' not in config:

+ 1 - 1
config_utils_record.py

@@ -36,7 +36,7 @@ def checkChannelConfig(config):
     if 'clearCache' not in config:
         config['clearCache'] = True
     if 'aapt2disable' not in config:
-        config['aapt2disable'] = True
+        config['aapt2disable'] = False
     if 'v2disable' not in config:
         config['v2disable'] = False
     if 'screenOrientation' not in config:

+ 1 - 1
config_utils_shanshen.py

@@ -30,7 +30,7 @@ def checkChannelConfig(config):
     if 'clearCache' not in config:
         config['clearCache'] = True
     if 'aapt2disable' not in config:
-        config['aapt2disable'] = True
+        config['aapt2disable'] = False
     if 'v2disable' not in config:
         config['v2disable'] = False
     if 'outName' not in config:

+ 12 - 4
package_utils.py

@@ -123,9 +123,9 @@ def pack(game, sdk, config):
             if ret:
                 return ret
     # 生成R文件
-    ret = generateNewRFile(game, sdk, subChannel, config)
+    '''ret = generateNewRFile(game, sdk, subChannel, config)
     if ret:
-        return ret
+        return ret'''
     # 添加MultiDex支持
     if config['splitDex']:
         ret = splitDex(game, sdk, subChannel, config)
@@ -179,7 +179,15 @@ def removeOldCode(game, sdk, subChannel, config):
     '''
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
     codePath = os.path.join(decompliePath, 'smali', 'com', 'jmhy', 'sdk')
-    file_utils.deleteFolder(codePath)
+    #file_utils.deleteFolder(codePath)
+    allFiles = []
+    allFiles = file_utils.list_files(codePath, allFiles)
+    for f in allFiles:
+        fpath, fname = os.path.split(f)  #分离文件名和路径
+        if fname == 'R.smali' or fname.startswith('R$'):
+            continue
+        os.remove(f)
+        print('remove %s' % f)
     return 0
 
 def copyRes(game, sdk, subChannel, config):
@@ -1004,7 +1012,7 @@ def recomplie(game, sdk, subChannel, config):
     if config['aapt2disable']:
         useAppt2 = ''
 
-    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s" %s' % (decompliePath, outApk, useAppt2))
+    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s"%s' % (decompliePath, outApk, useAppt2))
 
 def alignApk(game, sdk, subChannel, config):
     '''

+ 16 - 4
package_utils_record.py

@@ -31,6 +31,10 @@ def pack(game, sdk, config):
     subChannel = config['subChannel']
     # 解包
     ret = decomplie(game, sdk, subChannel, config)
+    if ret:
+        return ret
+    # 删除旧代码
+    ret = removeOldCode(game, sdk, subChannel, config)
     if ret:
         return ret
     if 'deleteList' in config:
@@ -127,9 +131,9 @@ def pack(game, sdk, config):
     if ret:
         return ret
     # 生成R文件
-    ret = generateNewRFile(game, sdk, subChannel, config)
+    '''ret = generateNewRFile(game, sdk, subChannel, config)
     if ret:
-        return ret
+        return ret'''
     # 添加MultiDex支持
     if config['splitDex']:
         ret = splitDex(game, sdk, subChannel, config)
@@ -192,7 +196,15 @@ def removeOldCode(game, sdk, subChannel, config):
     '''
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
     codePath = os.path.join(decompliePath, 'smali', 'com', 'jmhy', 'lib', 'record')
-    file_utils.deleteFolder(codePath)
+    #file_utils.deleteFolder(codePath)
+    allFiles = []
+    allFiles = file_utils.list_files(codePath, allFiles)
+    for f in allFiles:
+        fpath, fname = os.path.split(f)  #分离文件名和路径
+        if fname == 'R.smali' or fname.startswith('R$'):
+            continue
+        os.remove(f)
+        print('remove %s' % f)
     return 0
 
 def copyRes(game, sdk, subChannel, config):
@@ -996,7 +1008,7 @@ def recomplie(game, sdk, subChannel, config):
     if config['aapt2disable']:
         useAppt2 = ''
 
-    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s" %s' % (decompliePath, outApk, useAppt2))
+    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s"%s' % (decompliePath, outApk, useAppt2))
 
 def alignApk(game, sdk, subChannel, config):
     '''

+ 12 - 4
package_utils_shanshen.py

@@ -109,9 +109,9 @@ def pack(game, sdk, config):
     if ret:
         return ret
     # 生成R文件
-    ret = generateNewRFile(game, sdk, subChannel, config)
+    '''ret = generateNewRFile(game, sdk, subChannel, config)
     if ret:
-        return ret
+        return ret'''
     # 添加MultiDex支持
     if config['splitDex']:
         ret = splitDex(game, sdk, subChannel, config)
@@ -165,7 +165,15 @@ def removeOldCode(game, sdk, subChannel, config):
     '''
     decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
     codePath = os.path.join(decompliePath, 'smali', 'com', 'shanshen', 'sdk')
-    file_utils.deleteFolder(codePath)
+    #file_utils.deleteFolder(codePath)
+    allFiles = []
+    allFiles = file_utils.list_files(codePath, allFiles)
+    for f in allFiles:
+        fpath, fname = os.path.split(f)  #分离文件名和路径
+        if fname == 'R.smali' or fname.startswith('R$'):
+            continue
+        os.remove(f)
+        print('remove %s' % f)
     return 0
 
 def copyRes(game, sdk, subChannel, config):
@@ -884,7 +892,7 @@ def recomplie(game, sdk, subChannel, config):
     if config['aapt2disable']:
         useAppt2 = ''
 
-    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s" %s' % (decompliePath, outApk, useAppt2))
+    return file_utils.execJarCmd(apktoolPath, 'b -f "%s" -o "%s"%s' % (decompliePath, outApk, useAppt2))
 
 def alignApk(game, sdk, subChannel, config):
     '''

+ 1 - 1
打包参数.txt

@@ -13,7 +13,7 @@
 	"versionName":"1.2.0",//版本号,可选
 	"targetSdkVersion":22,//安卓适配的目标版本,可选
 	"v2disable":"true",//是否禁用v2签名,可选,默认false
-	"aapt2disable":"false",//是否禁用aapt2,可选,默认true
+	"aapt2disable":"false",//是否禁用aapt2,可选,默认false
 	"icon":"/data/20180807/2a926665b167029844170812307a94fa.png",//icon路径
 	"splash":"/data/20180807/cf9251ac587c85eeb35137f6df8617c1.jpg",//启动图路径
 	"copyList":[//资源路径