Bug 1885602 - Part 4: Implement navigating to the settings from the menu header for...
[gecko.git] / toolkit / library / gen_buildid.py
blob9943ad25391097606623b9415cd8e0d601dccc7d
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 file,
3 # You can obtain one at http://mozilla.org/MPL/2.0/.
5 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
6 # vim: set filetype=python:
7 # This Source Code Form is subject to the terms of the Mozilla Public
8 # License, v. 2.0. If a copy of the MPL was not distibuted with this
9 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
12 import os
13 from io import StringIO
15 import buildconfig
16 from mozbuild.preprocessor import Preprocessor
19 def main(output, input_file):
20 with open(input_file) as fh:
21 if buildconfig.substs["EXPAND_LIBS_LIST_STYLE"] == "linkerscript":
23 def cleanup(line):
24 assert line.startswith('INPUT("')
25 assert line.endswith('")')
26 return line[len('INPUT("') : -len('")')]
28 objs = [cleanup(l.strip()) for l in fh.readlines()]
29 else:
30 objs = [l.strip() for l in fh.readlines()]
32 pp = Preprocessor()
33 pp.out = StringIO()
34 pp.do_include(os.path.join(buildconfig.topobjdir, "buildid.h"))
35 buildid = pp.context["MOZ_BUILDID"]
36 output.write('extern const char gToolkitBuildID[] = "%s";' % buildid)
37 return set(
38 os.path.join("build", o)
39 for o in objs
40 if os.path.splitext(os.path.basename(o))[0] != "buildid"