sdk_script.py 2.0 KB

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