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/.
5 # Write out a C++ enum definition whose members are the names of
8 # The scalars are defined in files provided as command-line arguments.
13 from mozparsers
import parse_scalars
14 from mozparsers
.shared_telemetry_utils
import ParserError
16 banner
= """/* This file is auto-generated, see gen_scalar_enum.py. */
20 #ifndef mozilla_TelemetryScalarEnums_h
21 #define mozilla_TelemetryScalarEnums_h
24 enum class ScalarID : uint32_t {\
29 } // namespace mozilla
30 } // namespace Telemetry
31 #endif // mozilla_TelemetryScalarEnums_h
35 def main(output
, *filenames
):
36 # Load the scalars first.
38 for filename
in filenames
:
40 batch
= parse_scalars
.load_scalars(filename
)
42 except ParserError
as ex
:
43 print("\nError processing %s:\n%s\n" % (filename
, str(ex
)), file=sys
.stderr
)
46 # Write the enum file.
47 print(banner
, file=output
)
48 print(file_header
, file=output
)
51 if s
.record_on_os(buildconfig
.substs
["OS_TARGET"]):
52 print(" %s," % s
.enum_label
, file=output
)
54 print(" ScalarCount,", file=output
)
56 print(file_footer
, file=output
)
59 if __name__
== "__main__":
60 main(sys
.stdout
, *sys
.argv
[1:])