You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.6 KiB

  1. #!/usr/bin/env python3
  2. import os
  3. import json
  4. import re
  5. import sys
  6. if len(sys.argv) == 1 or not sys.argv[1]:
  7. raise SystemExit('Build dir missing.')
  8. proj_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], '..')
  9. build_dir = os.path.abspath(sys.argv[1])
  10. version = ''
  11. with open(os.path.join(proj_dir, 'dist', 'version')) as f:
  12. version = f.read().strip()
  13. # Import data from chromium platform
  14. chromium_manifest = {}
  15. opera_manifest = {}
  16. chromium_manifest_file = os.path.join(proj_dir, 'platform', 'chromium', 'manifest.json')
  17. with open(chromium_manifest_file) as f1:
  18. chromium_manifest = json.load(f1)
  19. # WebExtension
  20. opera_manifest_add_file = os.path.join(proj_dir, 'platform', 'opera', 'manifest-add.json')
  21. with open(opera_manifest_add_file) as f2:
  22. opera_manifest = json.load(f2)
  23. for key in chromium_manifest:
  24. if key not in opera_manifest:
  25. opera_manifest[key] = chromium_manifest[key]
  26. # Development build? If so, modify name accordingly.
  27. match = re.search('^(\d+\.\d+\.\d+)(\.|b|rc)(\d+)$', version)
  28. if match:
  29. version = match.group(1)
  30. revision = int(match.group(3))
  31. if match.group(2) == 'rc':
  32. revision += 100
  33. version += '.' + str(revision)
  34. opera_manifest['name'] += ' development build'
  35. opera_manifest['short_name'] += ' dev build'
  36. opera_manifest['browser_action']['default_title'] += ' dev build'
  37. opera_manifest['version'] = version
  38. opera_manifest_file = os.path.join(build_dir, 'manifest.json')
  39. with open(opera_manifest_file, 'w') as f2:
  40. json.dump(opera_manifest, f2, indent=2, separators=(',', ': '), sort_keys=True)
  41. f2.write('\n')