summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-10-17 15:20:31 +0200
committerLuboš Luňák <l.lunak@collabora.com>2019-10-18 11:00:04 +0200
commit7d7fea7f75524611238ce1b3546b95646cdcf359 (patch)
tree0b8f8b14ab4c35653923be643701599135b18612 /bin
parenttdf#127773 AutoCorrect Dialog Word Completion Tab update (diff)
downloadcore-7d7fea7f75524611238ce1b3546b95646cdcf359.tar.gz
core-7d7fea7f75524611238ce1b3546b95646cdcf359.zip
make bin/update_pch.s always include code in trivial #if's
E.g. #ifdef LIBO_INTERNAL_ONLY is always true for code that builds with our PCHs. Change-Id: I3cf311ea3621b909105754cfea2cb0116b8b67f5 Reviewed-on: https://gerrit.libreoffice.org/80961 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/update_pch36
1 files changed, 33 insertions, 3 deletions
diff --git a/bin/update_pch b/bin/update_pch
index 62ed9e773779..10f5e2e9df65 100755
--- a/bin/update_pch
+++ b/bin/update_pch
@@ -633,6 +633,25 @@ def process_makefile(root, module, libname):
return groups
+def is_allowed_if(line, module):
+ """ Check whether the given #if condition
+ is allowed for the given module or whether
+ its block should be ignored.
+ """
+
+ # remove trailing comments
+ line = re.sub(r'(.*) *//.*', r'\1', line)
+ line = line.strip()
+
+ # Our sources always build with LIBO_INTERNAL_ONLY.
+ if line == "#if defined LIBO_INTERNAL_ONLY" or line == "#ifdef LIBO_INTERNAL_ONLY":
+ return True
+ if module == "external/skia":
+ # We always set these.
+ if line == "#ifdef SK_VULKAN" or line == "#if SK_SUPPORT_GPU":
+ return True
+ return False
+
def process_source(root, module, filename, maxdepth=0):
""" Process a source file to extract
included headers.
@@ -644,17 +663,28 @@ def process_source(root, module, filename, maxdepth=0):
ifdepth = 0
lastif = ''
raw_includes = []
+ allowed_ifs = []
+ ifsallowed = 0
with open(filename, 'r') as f:
for line in f:
line = line.strip()
if line.startswith('#if'):
+ if is_allowed_if(line, module):
+ allowed_ifs.append(True)
+ ifsallowed += 1
+ else:
+ allowed_ifs.append(False)
+ lastif = line
ifdepth += 1
- lastif = line
elif line.startswith('#endif'):
ifdepth -= 1
- lastif = '#if'
+ if allowed_ifs[ ifdepth ]:
+ ifsallowed -= 1
+ else:
+ lastif = '#if'
+ del allowed_ifs[ ifdepth ]
elif line.startswith('#include'):
- if ifdepth <= maxdepth:
+ if ifdepth - ifsallowed <= maxdepth:
line = sanitize(line)
if line:
line = get_filename(line)