package_test.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import package_utils
  2. import file_utils
  3. import xml_utils
  4. import config_utils
  5. import os
  6. import os.path
  7. import json
  8. def packTest():
  9. '''
  10. 测试代码
  11. '''
  12. game = 'sample'
  13. sdk = 'float'
  14. subChannel = 'test'
  15. channelPath = file_utils.getChannelPath(game, sdk)
  16. configPath = os.path.join(channelPath, 'config.json')
  17. jsonText = file_utils.readFile(configPath)
  18. config = json.loads(jsonText)
  19. config_utils.replaceArgs(config)
  20. config = getItemConfig(config, subChannel)
  21. if config is None:
  22. return 1
  23. package_utils.decomplie(game, sdk, subChannel, config)
  24. package_utils.removeNoSupportAttr(game, sdk, subChannel, config)
  25. package_utils.mergeDrawableRes(game, sdk, subChannel, config)
  26. package_utils.removeSameRes(game, sdk, subChannel, config)
  27. package_utils.copyRes(game, sdk, subChannel, config)
  28. package_utils.mergeManifestRes(game, sdk, subChannel, config)
  29. package_utils.changePlaceholders(game, sdk, subChannel, config)
  30. package_utils.addMetaData(game, sdk, subChannel, config)
  31. package_utils.copyAppRes(game, sdk, subChannel, config)
  32. package_utils.changePackageName(game, sdk, subChannel, config)
  33. package_utils.changeAppName(game, sdk, subChannel, config)
  34. package_utils.changeAppIcon(game, sdk, subChannel, config)
  35. package_utils.addLauncher(game, sdk, subChannel, config)
  36. package_utils.packJar(game, sdk, subChannel, config)
  37. package_utils.doSDKPostScript(game, sdk, config)
  38. package_utils.doGamePostScript(game, sdk, config)
  39. package_utils.generateNewRFile(game, sdk, subChannel, config)
  40. package_utils.splitDex(game, sdk, subChannel, config)
  41. package_utils.recomplie(game, sdk, subChannel, config)
  42. package_utils.alignApk(game, sdk, subChannel, config)
  43. package_utils.apksignerApk(game, sdk, subChannel, config)
  44. package_utils.clearTemp(game, sdk, subChannel, config)
  45. def getCmd(cmd):
  46. p = os.popen(cmd)
  47. content = p.read()
  48. #print(content)
  49. return content
  50. def getItemConfig(config, subChannel):
  51. if type(config) == dict:
  52. if subChannel is None or config['subChannel'] == subChannel:
  53. return config
  54. elif type(config) == list:
  55. for itemConfig in config:
  56. if subChannel is None or itemConfig['subChannel'] == subChannel:
  57. return subChannel
  58. return None
  59. packTest()