• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
2# reserved. Use of this source code is governed by a BSD-style license that
3# can be found in the LICENSE file.
4
5from __future__ import absolute_import
6from cef_parser import get_copyright
7from file_util import *
8import sys
9
10
11def make_config_header(gn_config):
12  """ Creates the header file contents for the cef build configuration. """
13
14  if not path_exists(gn_config):
15    raise Exception('File ' + gn_config + ' does not exist.')
16
17  defines = []
18
19  if sys.platform.startswith('linux'):
20    lines = read_file(gn_config).split("\n")
21
22    # All Linux builds use Ozone, and the X11 platform is enabled by default.
23    # Check if the config is explicitly disabling it.
24    if not 'ozone_platform_x11=false' in lines:
25      defines.append('#define CEF_X11 1')
26
27  result = get_copyright(full=True, translator=False) + \
28"""//
29// ---------------------------------------------------------------------------
30//
31// This file is generated by the make_config_header.py tool.
32//
33
34#ifndef CEF_INCLUDE_CEF_CONFIG_H_
35#define CEF_INCLUDE_CEF_CONFIG_H_
36
37$DEFINES$
38
39#endif  // CEF_INCLUDE_CEF_CONFIG_H_
40"""
41
42  result = result.replace('$DEFINES$', "\n".join(defines))
43  return result
44
45
46def write_config_header(output, gn_config):
47  output = os.path.abspath(output)
48  result = make_config_header(gn_config)
49  return write_file_if_changed(output, result)
50
51
52def main(argv):
53  if len(argv) < 3:
54    print(("Usage:\n  %s <output_header_file> <input_args_gn_file>" % argv[0]))
55    sys.exit(-1)
56  write_config_header(argv[1], argv[2])
57
58
59if '__main__' == __name__:
60  main(sys.argv)
61