sdk_script.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import os.path
  2. import file_utils
  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. def checkConfig(config):
  10. '''
  11. 检查配置
  12. '''
  13. if 'properties' not in config:
  14. print('properties not exists in config')
  15. return False
  16. properties = config['properties']
  17. if 'agent' not in properties or 'version' not in properties:
  18. print('agent or version not exists in properties')
  19. return False
  20. '''if 'appid' not in config or 'appkey' not in config:
  21. print('appid or appkey not exists in config')
  22. return False'''
  23. return True
  24. def createJmhyProperties(game, sdk, subChannel, config):
  25. '''
  26. 创建jmhy.properties
  27. '''
  28. print('create jmhy.properties')
  29. propValue = config['properties']
  30. decompliePath = file_utils.get_decompile_path(game, sdk, subChannel, config['cache'])
  31. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  32. content = ''
  33. for key in propValue:
  34. content = '%s%s=%s\n' % (content, key, propValue[key])
  35. print('write properties : %s = %s' % (key, propValue[key]))
  36. file_utils.create_file(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.get_full_sdk_path(sdk)
  44. WXPayEntryActivity = 'WXPayEntryActivity.smali'
  45. wxFile = os.path.join(sdkPath, 'smali', WXPayEntryActivity)
  46. decompliePath = file_utils.get_decompile_path(game, sdk, subChannel, config['cache'])
  47. smaliPath = os.path.join(decompliePath, 'smali')
  48. targetPath = file_utils.get_package_path(smaliPath, config['packageName'])
  49. targetFile = os.path.join(targetPath, 'wxapi', WXPayEntryActivity)
  50. ret = file_utils.copy_file(wxFile, targetFile)
  51. if ret:
  52. return ret
  53. file_utils.replace_content(targetFile, '${packageName}', config['packageName'].replace('.', '/'))
  54. return 0