directive4.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. # Imports
  5. from __future__ import print_function, unicode_literals
  6. import os
  7. import sys
  8. # Sanity check
  9. if not len(sys.argv) > 1:
  10. print("Incorrect number of arguments")
  11. sys.exit(1)
  12. # Vars
  13. listConfigure = sys.argv[1:]
  14. listConfig = []
  15. strBrandingDirectory = ""
  16. listViolations = []
  17. # Build a list of set configure variables
  18. for _value in listConfigure:
  19. _splitString = _value.split("=")
  20. if _splitString[1] == "1":
  21. listConfig += [ _splitString[0] ]
  22. elif _splitString[0] == "MOZ_BRANDING_DIRECTORY":
  23. strBrandingDirectory = _splitString[1]
  24. # Only applies if using Official Branding or specific branding directories
  25. if ('MOZ_OFFICIAL_BRANDING' in listConfig) or (strBrandingDirectory.endswith("branding/official")) or (strBrandingDirectory.endswith("branding/unstable")):
  26. # Applies to Pale Moon and Basilisk
  27. if ('MC_BASILISK' in listConfig) or ('MC_PALEMOON' in listConfig):
  28. listViolations += [
  29. 'MOZ_SYSTEM_JPEG',
  30. 'MOZ_SYSTEM_ZLIB',
  31. 'MOZ_SYSTEM_BZ2',
  32. 'MOZ_SYSTEM_JEMALLOC'
  33. ]
  34. # Applies to Pale Moon Only
  35. if 'MC_PALEMOON' in listConfig:
  36. listViolations += [
  37. 'MOZ_EME',
  38. 'MOZ_WEBRTC'
  39. ]
  40. # Iterate through enabled violations and output 1 to DIRECTIVE4 if any are found
  41. for _value in listViolations:
  42. if _value in listConfig:
  43. sys.stdout.write("1")
  44. sys.exit(1)
  45. # Exit outputting nothing to DIRECTIVE4 being empty because there are no violations
  46. sys.exit(0)