sdk_script.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import file_utils
  2. import xml_utils
  3. import os.path
  4. def execute(game, sdk, config):
  5. if not checkConfig(config):
  6. return 1
  7. subChannel = config['subChannel']
  8. createJmhyProperties(game, sdk, subChannel, config)
  9. createQytxProperties(game, sdk, subChannel, config)
  10. return 0
  11. def checkConfig(config):
  12. '''
  13. 检查配置
  14. '''
  15. if 'properties' not in config:
  16. print('properties not exists in config')
  17. return False
  18. if 'qytx' not in config:
  19. print('qytx not exists in config')
  20. return False
  21. properties = config['properties']
  22. if 'agent' not in properties or 'version' not in properties:
  23. print('agent or version not exists in properties')
  24. return False
  25. '''if 'appid' not in config or 'appkey' not in config:
  26. print('appid or appkey not exists in config')
  27. return False'''
  28. return True
  29. def createJmhyProperties(game, sdk, subChannel, config):
  30. '''
  31. 创建jmhy.properties
  32. '''
  33. print('create jmhy.properties')
  34. propValue = config['properties']
  35. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  36. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  37. content = ''
  38. for key in propValue:
  39. content = '%s%s=%s\n' % (content, key, propValue[key])
  40. file_utils.createFile(properties, content)
  41. return 0
  42. def copyWechatCode(game, sdk, subChannel, config):
  43. '''
  44. 拷贝微信sdk的代码
  45. '''
  46. print('copy WXPayEntryActivity.smali')
  47. sdkPath = file_utils.getFullSDKPath(sdk)
  48. WXPayEntryActivity = 'WXPayEntryActivity.smali'
  49. wxFile = os.path.join(sdkPath, 'smali', WXPayEntryActivity)
  50. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  51. smaliPath = os.path.join(decompliePath, 'smali')
  52. targetPath = file_utils.getPackagePath(smaliPath, config['packageName'])
  53. targetFile = os.path.join(targetPath, 'wxapi', WXPayEntryActivity)
  54. ret = file_utils.copyFile(wxFile, targetFile)
  55. if ret:
  56. return ret
  57. file_utils.replaceContent(targetFile, '${packageName}', config['packageName'].replace('.', '/'))
  58. return 0
  59. def createQytxProperties(game, sdk, subChannel, config):
  60. '''
  61. 创建qytx.properties
  62. '''
  63. print('create qytx.properties')
  64. propValue = config['qytx']
  65. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  66. properties = os.path.join(decompliePath, 'assets', 'qytx.properties')
  67. content = ''
  68. for key in propValue:
  69. content = '%s%s=%s\n' % (content, key, propValue[key])
  70. file_utils.createFile(properties, content)
  71. return 0