mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Generate cef_config.h as a build-time step (fixes issue #2926)
This commit is contained in:
10
BUILD.gn
10
BUILD.gn
@ -1483,12 +1483,22 @@ action("make_api_hash_header") {
|
|||||||
args = rebase_path(outputs + include_dir, root_build_dir)
|
args = rebase_path(outputs + include_dir, root_build_dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Generate cef_config.h.
|
||||||
|
action("make_config_header") {
|
||||||
|
script = "tools/make_config_header.py"
|
||||||
|
|
||||||
|
outputs = [ "$root_out_dir/includes/include/cef_config.h" ]
|
||||||
|
|
||||||
|
args = rebase_path(outputs + [ "$root_out_dir/args.gn" ], root_build_dir)
|
||||||
|
}
|
||||||
|
|
||||||
# Generate pack files and associated CEF header files.
|
# Generate pack files and associated CEF header files.
|
||||||
group("cef_make_headers") {
|
group("cef_make_headers") {
|
||||||
deps = [
|
deps = [
|
||||||
":make_pack_header_resources",
|
":make_pack_header_resources",
|
||||||
":make_pack_header_strings",
|
":make_pack_header_strings",
|
||||||
":make_api_hash_header",
|
":make_api_hash_header",
|
||||||
|
":make_config_header",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,14 +146,3 @@ for dir, config in configs.items():
|
|||||||
RunAction(src_dir, cmd)
|
RunAction(src_dir, cmd)
|
||||||
if platform == 'windows':
|
if platform == 'windows':
|
||||||
issue_1999.apply(out_path)
|
issue_1999.apply(out_path)
|
||||||
|
|
||||||
gn_dir = list(configs.keys())[0]
|
|
||||||
out_gn_path = os.path.join(src_dir, 'out', gn_dir)
|
|
||||||
gn_path = os.path.join(out_gn_path, 'args.gn')
|
|
||||||
print("\nGenerating CEF buildinfo header file...")
|
|
||||||
cmd = [
|
|
||||||
sys.executable, 'tools/make_config_header.py', '--header',
|
|
||||||
'include/cef_config.h', '--cef_gn_config', gn_path
|
|
||||||
]
|
|
||||||
|
|
||||||
RunAction(cef_dir, cmd)
|
|
||||||
|
@ -3,122 +3,58 @@
|
|||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from date_util import *
|
from cef_parser import get_copyright
|
||||||
from file_util import *
|
from file_util import *
|
||||||
from optparse import OptionParser
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# cannot be loaded as a module
|
|
||||||
if __name__ != "__main__":
|
|
||||||
sys.stderr.write('This file cannot be loaded as a module!')
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
# parse command-line options
|
def make_config_header(gn_config):
|
||||||
disc = """
|
""" Creates the header file contents for the cef build configuration. """
|
||||||
This utility creates the config header file.
|
|
||||||
|
if not path_exists(gn_config):
|
||||||
|
raise Exception('File ' + gn_config + ' does not exist.')
|
||||||
|
|
||||||
|
defines = []
|
||||||
|
|
||||||
|
if sys.platform.startswith('linux'):
|
||||||
|
lines = read_file(gn_config).split("\n")
|
||||||
|
|
||||||
|
# All Linux builds use Ozone, and the X11 platform is enabled by default.
|
||||||
|
# Check if the config is explicitly disabling it.
|
||||||
|
if not 'ozone_platform_x11=false' in lines:
|
||||||
|
defines.append('#define CEF_X11 1')
|
||||||
|
|
||||||
|
result = get_copyright(full=True, translator=False) + \
|
||||||
|
"""//
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// This file is generated by the make_config_header.py tool.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef CEF_INCLUDE_CEF_CONFIG_H_
|
||||||
|
#define CEF_INCLUDE_CEF_CONFIG_H_
|
||||||
|
|
||||||
|
$DEFINES$
|
||||||
|
|
||||||
|
#endif // CEF_INCLUDE_CEF_CONFIG_H_
|
||||||
"""
|
"""
|
||||||
parser = OptionParser(description=disc)
|
|
||||||
parser.add_option(
|
|
||||||
'--header',
|
|
||||||
dest='header',
|
|
||||||
metavar='FILE',
|
|
||||||
help='output config header file [required]')
|
|
||||||
parser.add_option(
|
|
||||||
'--cef_gn_config',
|
|
||||||
dest='cef_gn_config',
|
|
||||||
metavar='FILE',
|
|
||||||
help='input CEF gn config file [required]')
|
|
||||||
parser.add_option(
|
|
||||||
'-q',
|
|
||||||
'--quiet',
|
|
||||||
action='store_true',
|
|
||||||
dest='quiet',
|
|
||||||
default=False,
|
|
||||||
help='do not output detailed status information')
|
|
||||||
(options, args) = parser.parse_args()
|
|
||||||
|
|
||||||
# the header option is required
|
result = result.replace('$DEFINES$', "\n".join(defines))
|
||||||
if options.header is None or options.cef_gn_config is None:
|
return result
|
||||||
parser.print_help(sys.stdout)
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
def check_x11_build(gn_config):
|
def write_config_header(output, gn_config):
|
||||||
""" Scan gn configuration file and decide whether it's x11 build or not """
|
output = os.path.abspath(output)
|
||||||
lines = read_file(gn_config).split("\n")
|
result = make_config_header(gn_config)
|
||||||
for line in lines:
|
return write_file_if_changed(output, result)
|
||||||
parts = line.split('=', 1)
|
|
||||||
if (parts[0] == "use_x11" and
|
|
||||||
parts[1] == "false") or (parts[0] == "use_ozone" and
|
|
||||||
parts[1] == "true"):
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
def write_config_header(header, cef_gn_config):
|
def main(argv):
|
||||||
""" Creates the header file for the cef build configuration
|
if len(argv) < 3:
|
||||||
if the information has changed or if the file doesn't already exist. """
|
print(("Usage:\n %s <output_header_file> <input_args_gn_file>" % argv[0]))
|
||||||
|
sys.exit(-1)
|
||||||
if not path_exists(cef_gn_config):
|
write_config_header(argv[1], argv[2])
|
||||||
raise Exception('file ' + cef_gn_config + ' does not exist.')
|
|
||||||
|
|
||||||
if path_exists(header):
|
|
||||||
oldcontents = read_file(header)
|
|
||||||
else:
|
|
||||||
oldcontents = ''
|
|
||||||
|
|
||||||
year = get_year()
|
|
||||||
|
|
||||||
cef_x11_defines = "#define CEF_X11 1" if check_x11_build(
|
|
||||||
cef_gn_config) else ""
|
|
||||||
|
|
||||||
newcontents = '// Copyright (c) '+year+' Marshall A. Greenblatt. All rights reserved.\n'+\
|
|
||||||
'//\n'+\
|
|
||||||
'// Redistribution and use in source and binary forms, with or without\n'+\
|
|
||||||
'// modification, are permitted provided that the following conditions are\n'+\
|
|
||||||
'// met:\n'+\
|
|
||||||
'//\n'+\
|
|
||||||
'// * Redistributions of source code must retain the above copyright\n'+\
|
|
||||||
'// notice, this list of conditions and the following disclaimer.\n'+\
|
|
||||||
'// * Redistributions in binary form must reproduce the above\n'+\
|
|
||||||
'// copyright notice, this list of conditions and the following disclaimer\n'+\
|
|
||||||
'// in the documentation and/or other materials provided with the\n'+\
|
|
||||||
'// distribution.\n'+\
|
|
||||||
'// * Neither the name of Google Inc. nor the name Chromium Embedded\n'+\
|
|
||||||
'// Framework nor the names of its contributors may be used to endorse\n'+\
|
|
||||||
'// or promote products derived from this software without specific prior\n'+\
|
|
||||||
'// written permission.\n'+\
|
|
||||||
'//\n'+\
|
|
||||||
'// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n'+\
|
|
||||||
'// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n'+\
|
|
||||||
'// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n'+\
|
|
||||||
'// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n'+\
|
|
||||||
'// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n'+\
|
|
||||||
'// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n'+\
|
|
||||||
'// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n'+\
|
|
||||||
'// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n'+\
|
|
||||||
'// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n'+\
|
|
||||||
'// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n'+\
|
|
||||||
'// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n'+\
|
|
||||||
'//\n'+\
|
|
||||||
'// ---------------------------------------------------------------------------\n'+\
|
|
||||||
'//\n'+\
|
|
||||||
'// This file is generated by the make_config_header.py tool.\n'+\
|
|
||||||
'//\n\n'+\
|
|
||||||
'#ifndef CEF_INCLUDE_CEF_CONFIG_H_\n'+\
|
|
||||||
'#define CEF_INCLUDE_CEF_CONFIG_H_\n\n'+\
|
|
||||||
'' + cef_x11_defines + '\n'+\
|
|
||||||
'#endif // CEF_INCLUDE_CEF_CONFIG_H_\n'
|
|
||||||
if newcontents != oldcontents:
|
|
||||||
write_file(header, newcontents)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
written = write_config_header(options.header, options.cef_gn_config)
|
if '__main__' == __name__:
|
||||||
if not options.quiet:
|
main(sys.argv)
|
||||||
if written:
|
|
||||||
sys.stdout.write('File ' + options.header + ' updated.\n')
|
|
||||||
else:
|
|
||||||
sys.stdout.write('File ' + options.header + ' is already up to date.\n')
|
|
||||||
|
@ -719,6 +719,7 @@ if mode == 'standard' or mode == 'minimal':
|
|||||||
|
|
||||||
# Transfer generated include files.
|
# Transfer generated include files.
|
||||||
generated_includes = [
|
generated_includes = [
|
||||||
|
'cef_config.h',
|
||||||
'cef_pack_resources.h',
|
'cef_pack_resources.h',
|
||||||
'cef_pack_strings.h',
|
'cef_pack_strings.h',
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user