main.py 1016 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # -*- coding:utf-8 -*-
  2. import sys
  3. import os
  4. import traceback
  5. import json
  6. from V1 import merge_apk
  7. from V2 import merge_apk_v2
  8. def package():
  9. if len(sys.argv) < 2:
  10. print("参数数量不正确")
  11. exit(1)
  12. config = sys.argv[1]
  13. if not os.path.exists(config):
  14. print("配置文件不存在")
  15. exit(1)
  16. try:
  17. ret = read_config_use_new_script(config)
  18. if ret:
  19. ret = merge_apk_v2.startMerge(config)
  20. else:
  21. ret = merge_apk.startMerge(config)
  22. except:
  23. ret = False
  24. print(traceback.format_exc())
  25. if not ret:
  26. print("切包失败,请联系开发人员")
  27. exit(1)
  28. print("成功")
  29. exit(0)
  30. pass
  31. def read_config_use_new_script(json_file_path):
  32. with open(json_file_path, 'r') as f:
  33. params = json.load(f)
  34. if not 'useAapt2' in params['meta_config']:
  35. return None
  36. return params['meta_config']['useAapt2']
  37. if __name__ == "__main__":
  38. package()