aboutsummaryrefslogtreecommitdiff
path: root/aosp/preprocess.py
blob: 7a31ffcbc6eb0581bc40fac65135f1ebeebdb653 (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
#!/usr/bin/env python3

# ChromeOs version of zucchini expects to find its headers
# in a specifc path. In android the include paths are slightly
# different. Since we can't change upstream source code, we
# use this script to preprocess all files(.cc and ,h) and
# re-write all include paths


def main(argv):
  if len(argv) != 3:
    print("Usage:", argv[0], "<input path> <output path>")
    return 1
  input_path = argv[1]
  output_path = argv[2]
  with open(input_path, "r") as infp, open(output_path, "w") as outfp:
    for line in infp.readlines():
      line = line.replace('#include "components/zucchini/',
                          '#include "')
      line = line.replace('#include <components/zucchini/',
                          '#include <')
      line = line.replace('#include "third_party/abseil-cpp/',
                          '#include "')
      line = line.replace('#include <third_party/abseil-cpp/',
                          '#include <')
      outfp.write(line)


if __name__ == '__main__':
  import sys
  sys.exit(main(sys.argv))