sdk_script.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. changePlaceholders(game, sdk, subChannel, config)
  9. ret = file_utils.copySdkSmaliCode(game, sdk, subChannel, config)
  10. if ret:
  11. return ret
  12. def checkConfig(config):
  13. '''
  14. 检查配置
  15. '''
  16. if 'properties' not in config:
  17. print('properties not exists in config')
  18. return False
  19. properties = config['properties']
  20. if 'agent' not in properties or 'version' not in properties:
  21. print('agent or version not exists in properties')
  22. return False
  23. '''if 'appid' not in config or 'appkey' not in config:
  24. print('appid or appkey not exists in config')
  25. return False'''
  26. return True
  27. def createJmhyProperties(game, sdk, subChannel, config):
  28. '''
  29. 创建jmhy.properties
  30. '''
  31. print('create jmhy.properties')
  32. propValue = config['properties']
  33. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  34. properties = os.path.join(decompliePath, 'assets', 'jmhy.properties')
  35. content = ''
  36. for key in propValue:
  37. content = '%s%s=%s\n' % (content, key, propValue[key])
  38. print('write properties : %s = %s' % (key, propValue[key]))
  39. file_utils.createFile(properties, content)
  40. return 0
  41. def changePlaceholders(game, sdk, subChannel, config):
  42. decompliePath = file_utils.getDecompliePath(game, sdk, subChannel, config['cache'])
  43. manifest = os.path.join(decompliePath, "assets", "BSSDKConfig.xml")
  44. ret = file_utils.replaceContent(manifest, '${AppId}', config['placeholders']["AppId"])
  45. if ret:
  46. return ret