summaryrefslogtreecommitdiff
path: root/build/directive4.py
blob: e32b5b3a9eecd62e33515b303e07f1e0a8bfa276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Imports
from __future__ import print_function, unicode_literals

import os
import sys

# Sanity check
if not len(sys.argv) > 1:
  print("Incorrect number of arguments")
  sys.exit(1)

# Vars
listConfigure = sys.argv[1:]
listConfig = []
strBrandingDirectory = ""
listViolations = []

# Build a list of set configure variables
for _value in listConfigure:
  _splitString = _value.split("=")

  if _splitString[1] == "1":
    listConfig += [ _splitString[0] ]
  elif _splitString[0] == "MOZ_BRANDING_DIRECTORY":
    strBrandingDirectory = _splitString[1]

# Only applies if using Official Branding or specific branding directories
if ('MOZ_OFFICIAL_BRANDING' in listConfig) or (strBrandingDirectory.endswith("branding/official")) or (strBrandingDirectory.endswith("branding/unstable")):  
  # Anything that applies to Pale Moon only goes here
  if 'MC_PALEMOON' in listConfig:
    listViolations += [
      'MOZ_SYSTEM_JPEG',
      'MOZ_SYSTEM_ZLIB',
      'MOZ_SYSTEM_BZ2',
      'MOZ_SYSTEM_JEMALLOC'
    ]
  
  # Iterate through enabled violations and output 1 to DIRECTIVE4 if any are found
  for _value in listViolations:
    if _value in listConfig:
      sys.stdout.write("1")
      sys.exit(1)

# Exit outputting nothing to DIRECTIVE4 being empty because there are no violations
sys.exit(0)