Linux: Add support for ozone builds (fixes issue #2296).

Ozone builds can run with different platform backends (Wayland, X11, etc). Usage of the Views framework is required, and the cefclient sample application is not supported.

Example usage:

$ export GN_DEFINES="use_ozone=true"
$ cd /path/to/chromium/src/cef
$ ./cef_create_projects.sh
$ cd /path/to/chromium/src
$ ninja -C out/Release_GN_x64 cefsimple
$ ./out/Release_GN_x64/cefsimple --use-views --ozone-platform=wayland

Binary distributions can be created by passing the `--ozone` flag to make_distrib.py.
This commit is contained in:
santosh mahto 2019-04-23 17:00:14 +00:00 committed by Marshall Greenblatt
parent 07863c0d46
commit 491253fa03
20 changed files with 321 additions and 57 deletions

3
.gitignore vendored
View File

@ -46,5 +46,6 @@ Thumbs.db
/binary_distrib
/docs
# CEF generated files
/include/cef_config.h
/include/cef_version.h
.ccls-cache/
.ccls-cache/

View File

@ -196,10 +196,13 @@ gypi_paths2 = exec_script("//cef/tools/gypi_to_gn.py",
group("cef") {
testonly = true
deps = [
":cefclient",
":cefsimple",
":ceftests",
]
if (!is_linux || use_x11) {
deps += [ ":cefclient" ]
}
}
@ -769,14 +772,25 @@ static_library("libcef_static") {
"libcef/browser/osr/render_widget_host_view_osr_linux.cc",
"libcef/browser/printing/print_dialog_linux.cc",
"libcef/browser/printing/print_dialog_linux.h",
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
if (use_x11) {
sources += [
"libcef/browser/native/window_x11.cc",
"libcef/browser/native/window_x11.h",
]
}
deps += [
"//build/config/freetype",
"//third_party/fontconfig",
]
if (is_linux && !use_x11) {
deps += [
"//third_party/angle:libEGL",
]
}
}
if (is_mac) {
@ -894,6 +908,15 @@ static_library("libcef_static") {
"//ui/aura/test/ui_controls_factory_aura.h",
]
if (is_linux && !use_x11) {
sources += [
"//ui/aura/test/mus/window_tree_client_test_api.h",
"//ui/aura/test/mus/window_tree_client_test_api.cc",
"//ui/aura/test/ui_controls_factory_ozone.cc",
"//ui/events/test/events_test_utils.cc"
]
}
deps += [
"//ui/aura",
"//ui/events",
@ -931,16 +954,23 @@ static_library("libcef_static") {
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/aura_test_utils.cc",
"//ui/aura/test/aura_test_utils.h",
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/events:test_support which is testingonly.
"//ui/events/test/platform_event_waiter.cc",
"//ui/events/test/platform_event_waiter.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
if (use_x11) {
sources += [
# Support for UI input events.
# Part of //ui/aura:test_support which is testingonly.
"//ui/aura/test/ui_controls_factory_aurax11.cc",
"//ui/aura/test/x11_event_sender.cc",
"//ui/aura/test/x11_event_sender.h",
# Part of //ui/views:test_support which is testingonly.
"//ui/views/test/ui_controls_factory_desktop_aurax11.cc",
"//ui/views/test/ui_controls_factory_desktop_aurax11.h",
]
}
}
} else {
sources += [
@ -1952,6 +1982,12 @@ if (is_mac) {
# The cefclient target depends on packages that are not available in the
# default sysroot environment.
if (is_linux && !use_sysroot) {
pkg_config("glib") {
packages = [
"glib-2.0",
]
}
pkg_config("gtk") {
packages = [
"gmodule-2.0",
@ -2111,9 +2147,11 @@ if (is_mac) {
sources += gypi_paths2.includes_linux +
gypi_paths2.cefsimple_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
}
if (!is_component_build) {
# Set rpath to find our own libfreetype even in a non-component build.
@ -2170,9 +2208,15 @@ if (is_mac) {
sources += gypi_paths2.shared_sources_linux +
gypi_paths2.ceftests_sources_linux
libs = [
"X11",
]
if (use_x11) {
libs = [
"X11",
]
} else {
if (!use_sysroot) {
configs += [ ":glib" ]
}
}
deps += [
":copy_ceftests_files",

View File

@ -200,11 +200,14 @@ add_subdirectory(${CEF_LIBCEF_DLL_WRAPPER_PATH} libcef_dll_wrapper)
# Comes from the <target>/CMakeLists.txt file in the current directory.
# TODO: Change these lines to match your project target when you copy this file.
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests")
add_subdirectory(tests/cefclient)
add_subdirectory(tests/cefsimple)
add_subdirectory(tests/gtest)
add_subdirectory(tests/ceftests)
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/cefclient")
add_subdirectory(tests/cefclient)
endif()
# Display configuration settings.
PRINT_CEF_CONFIG()

View File

@ -36,6 +36,7 @@
'include/base/internal/cef_thread_checker_impl.h',
'include/cef_api_hash.h',
'include/cef_base.h',
'include/cef_config.h',
'include/cef_version.h',
'include/internal/cef_export.h',
'include/internal/cef_logging_internal.h',

View File

@ -32,18 +32,27 @@
#pragma once
#include "include/base/cef_build.h"
#include "include/cef_config.h"
#if defined(OS_LINUX)
#if defined(CEF_X11)
typedef union _XEvent XEvent;
typedef struct _XDisplay XDisplay;
#endif
#include "include/internal/cef_export.h"
#include "include/internal/cef_string.h"
// Handle types.
#if defined(CEF_X11)
#define cef_cursor_handle_t unsigned long
#define cef_event_handle_t XEvent*
#else
#define cef_cursor_handle_t void*
#define cef_event_handle_t void*
#endif
#define cef_window_handle_t unsigned long
#define kNullCursorHandle 0
@ -58,7 +67,9 @@ extern "C" {
// Return the singleton X11 display shared with Chromium. The display is not
// thread-safe and must only be accessed on the browser process UI thread.
///
#if defined(CEF_X11)
CEF_EXPORT XDisplay* cef_get_xdisplay();
#endif
///
// Structure representing CefExecuteProcess arguments.

View File

@ -10,7 +10,6 @@
#include "libcef/browser/context.h"
#include "libcef/browser/native/menu_runner_linux.h"
#include "libcef/browser/native/window_delegate_view.h"
#include "libcef/browser/native/window_x11.h"
#include "libcef/browser/thread_util.h"
#include "base/no_destructor.h"
@ -23,10 +22,14 @@
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
#include "ui/events/keycodes/keysym_to_unicode.h"
#include "ui/gfx/font_render_params.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/widget.h"
#include "third_party/blink/public/mojom/renderer_preferences.mojom.h"
#if defined(USE_X11)
#include "libcef/browser/native/window_x11.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#endif
namespace {
// Returns the number of seconds since system boot.
@ -48,8 +51,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
false,
use_external_begin_frame),
host_window_created_(false),
window_widget_(nullptr),
window_x11_(nullptr) {}
window_widget_(nullptr) {}
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
CefBrowserHostImpl* browser) {
@ -62,7 +64,6 @@ void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
}
bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
DCHECK(!window_x11_);
DCHECK(!window_widget_);
if (window_info_.width == 0)
@ -73,6 +74,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
gfx::Rect rect(window_info_.x, window_info_.y, window_info_.width,
window_info_.height);
#if defined(USE_X11)
DCHECK(!window_x11_);
// Create a new window object. It will delete itself when the associated X11
// window is destroyed.
window_x11_ = new CefWindowX11(browser_, window_info_.parent_window, rect,
@ -93,6 +96,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
window_widget_->Show();
window_x11_->Show();
#endif // defined(USE_X11)
// As an additional requirement on Linux, we must set the colors for the
// render widgets in webkit.
@ -121,8 +125,10 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
}
void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
#if defined(USE_X11)
if (window_x11_)
window_x11_->Close();
#endif
}
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
@ -146,18 +152,21 @@ void CefBrowserPlatformDelegateNativeLinux::SendFocusEvent(bool setFocus) {
browser_->web_contents()->Focus();
}
#if defined(USE_X11)
if (window_x11_) {
// Give native focus to the DesktopNativeWidgetAura for the root window.
// Needs to be done via the ::Window so that keyboard focus is assigned
// correctly.
window_x11_->Focus();
}
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
// Call the parent method to dismiss any existing popups.
CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted();
#if defined(USE_X11)
if (!window_x11_)
return;
@ -175,13 +184,16 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
content::RenderWidgetHostImpl::From(
browser_->web_contents()->GetRenderViewHost()->GetWidget())
->SendScreenRects();
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
#if defined(USE_X11)
if (window_x11_) {
window_x11_->SetBounds(
gfx::Rect(window_x11_->bounds().origin(), gfx::Size(width, height)));
}
#endif // defined(USE_X11)
}
gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
@ -189,6 +201,7 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
if (windowless_handler_)
return windowless_handler_->GetParentScreenPoint(view);
#if defined(USE_X11)
if (!window_x11_)
return view;
@ -198,6 +211,8 @@ gfx::Point CefBrowserPlatformDelegateNativeLinux::GetScreenPoint(
const gfx::Rect& bounds_in_screen = window_x11_->GetBoundsInScreen();
return gfx::Point(bounds_in_screen.x() + view.x(),
bounds_in_screen.y() + view.y());
#endif // defined(USE_X11)
return gfx::Point();
}
void CefBrowserPlatformDelegateNativeLinux::ViewText(const std::string& text) {
@ -260,6 +275,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
NOTREACHED();
}
#if defined(USE_X11)
// Populate DOM values that will be passed to JavaScript handlers via
// KeyboardEvent.
result.dom_code = static_cast<int>(
@ -275,6 +291,7 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
result.SetModifiers(result.GetModifiers() |
TranslateModifiers(key_event.modifiers));
#endif // defined(USE_X11)
}
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
@ -363,7 +380,8 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
const content::NativeWebKeyboardEvent& event) const {
if (!event.os_event)
return NULL;
return const_cast<CefEventHandle>(event.os_event->native_event());
return const_cast<CefEventHandle>(
static_cast<CefEventHandle>(event.os_event->native_event()));
}
std::unique_ptr<CefMenuRunner>

View File

@ -7,7 +7,9 @@
#include "libcef/browser/native/browser_platform_delegate_native.h"
#if defined(USE_X11)
class CefWindowX11;
#endif
// Windowed browser implementation for Linux.
class CefBrowserPlatformDelegateNativeLinux
@ -60,7 +62,9 @@ class CefBrowserPlatformDelegateNativeLinux
// associated root window is destroyed.
views::Widget* window_widget_;
CefWindowX11* window_x11_;
#if defined(USE_X11)
CefWindowX11* window_x11_ = nullptr;
#endif
};
#endif // CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_LINUX_H_

View File

@ -9,7 +9,6 @@
#include <utility>
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/osr_util.h"
#include "libcef/browser/osr/software_output_device_osr.h"
#include "libcef/browser/osr/synthetic_gesture_target_osr.h"

View File

@ -13,7 +13,7 @@
#include "include/cef_base.h"
#include "include/cef_browser.h"
#include "libcef/browser/browser_host_impl.h"
#include "libcef/browser/osr/motion_event_osr.h"
#include "base/memory/weak_ptr.h"
@ -60,7 +60,6 @@ class CursorManager;
} // namespace content
class CefBeginFrameTimer;
class CefBrowserHostImpl;
class CefCopyFrameGenerator;
class CefSoftwareOutputDeviceOSR;
class CefWebContentsViewOSR;

View File

@ -5,16 +5,20 @@
#include "libcef/browser/osr/render_widget_host_view_osr.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#if defined(USE_X11)
#include <X11/Xlib.h>
#include <X11/cursorfont.h>
#undef Status // Avoid conflicts with url_request_status.h
#include "libcef/browser/native/window_x11.h"
#include "third_party/blink/public/platform/web_cursor_info.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_types.h"
#endif // defined(USE_X11)
#if defined(USE_X11)
namespace {
// Based on ui/base/cursor/cursor_loader_x11.cc.
@ -163,25 +167,31 @@ XCursorCache* cursor_cache = nullptr;
}
} // namespace
#endif // defined(USE_X11)
void CefRenderWidgetHostViewOSR::PlatformCreateCompositorWidget(
bool is_guest_view_hack) {
#if defined(USE_X11)
// Create a hidden 1x1 window. It will delete itself on close.
window_ = new CefWindowX11(NULL, None, gfx::Rect(0, 0, 1, 1), "");
compositor_widget_ = window_->xwindow();
#endif
}
void CefRenderWidgetHostViewOSR::PlatformResizeCompositorWidget(
const gfx::Size&) {}
void CefRenderWidgetHostViewOSR::PlatformDestroyCompositorWidget() {
#if defined(USE_X11)
DCHECK(window_);
window_->Close();
#endif
compositor_widget_ = gfx::kNullAcceleratedWidget;
}
ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
blink::WebCursorInfo::Type type) {
#if defined(USE_X11)
if (type == WebCursorInfo::kTypeNone) {
if (!invisible_cursor_) {
invisible_cursor_.reset(new ui::XScopedCursor(ui::CreateInvisibleCursor(),
@ -191,4 +201,6 @@ ui::PlatformCursor CefRenderWidgetHostViewOSR::GetPlatformCursor(
} else {
return GetXCursor(ToCursorID(type));
}
#endif // defined(USE_X11)
return 0;
}

View File

@ -20,7 +20,7 @@
#include "ui/aura/test/ui_controls_factory_aura.h"
#include "ui/aura/window.h"
#include "ui/base/test/ui_controls_aura.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
#include "ui/views/test/ui_controls_factory_desktop_aurax11.h"
#endif
#endif
@ -37,8 +37,9 @@ void InitializeUITesting() {
if (!initialized) {
ui_controls::EnableUIControls();
#if defined(USE_AURA)
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
ui_controls::InstallUIControlsAura(
views::test::CreateUIControlsDesktopAura());
#else

View File

@ -13,7 +13,7 @@
#include "ui/views/widget/widget.h"
#include "ui/views/window/native_frame_view.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
#include <X11/Xlib.h>
#include "ui/gfx/x/x11_types.h"
#endif
@ -250,6 +250,7 @@ void CefWindowView::CreateWidget() {
views::Widget::InitParams params;
params.delegate = this;
params.type = views::Widget::InitParams::TYPE_WINDOW;
params.bounds = gfx::Rect(CalculatePreferredSize());
bool can_activate = true;
if (cef_delegate()) {
@ -294,7 +295,7 @@ void CefWindowView::CreateWidget() {
DCHECK(widget->widget_delegate()->CanActivate());
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(USE_X11)
if (is_frameless_) {
::Window window = view_util::GetWindowHandle(widget);
DCHECK(window);
@ -329,7 +330,7 @@ void CefWindowView::CreateWidget() {
XChangeProperty(display, window, mwmHintsProperty, mwmHintsProperty, 32,
PropModeReplace, (unsigned char*)&hints, 5);
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) && defined(USE_X11)
}
CefRefPtr<CefWindow> CefWindowView::GetCefWindow() const {

View File

@ -73,6 +73,9 @@ if(OS_LINUX)
# Copy binary and resource files to the target output directory.
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")
if (EXISTS "${CEF_BINARY_DIR}/libminigbm.so")
COPY_FILES("${CEF_TARGET}" "libminigbm.so" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
endif()
# Set SUID permissions on the chrome-sandbox target.
SET_LINUX_SUID_PERMISSIONS("${CEF_TARGET}" "${CEF_TARGET_OUT_DIR}/chrome-sandbox")

View File

@ -4,10 +4,13 @@
#include "tests/cefsimple/simple_app.h"
#if defined(CEF_X11)
#include <X11/Xlib.h>
#endif
#include "include/base/cef_logging.h"
#if defined(CEF_X11)
namespace {
int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
@ -26,6 +29,7 @@ int XIOErrorHandlerImpl(Display* display) {
}
} // namespace
#endif // defined(CEF_X11)
// Entry point function for all processes.
int main(int argc, char* argv[]) {
@ -41,10 +45,12 @@ int main(int argc, char* argv[]) {
return exit_code;
}
#if defined(CEF_X11)
// Install xlib error handlers so that the application won't be terminated
// on non-fatal errors.
XSetErrorHandler(XErrorHandlerImpl);
XSetIOErrorHandler(XIOErrorHandlerImpl);
#endif
// Specify CEF global settings here.
CefSettings settings;

View File

@ -43,6 +43,10 @@ class SimpleWindowDelegate : public CefWindowDelegate {
return true;
}
CefSize GetPreferredSize(CefRefPtr<CefView> view) OVERRIDE {
return CefSize(800, 600);
}
private:
CefRefPtr<CefBrowserView> browser_view_;

View File

@ -4,8 +4,11 @@
#include "tests/cefsimple/simple_handler.h"
#if defined(CEF_X11)
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#endif
#include <string>
#include "include/base/cef_logging.h"
@ -15,6 +18,7 @@ void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
const CefString& title) {
std::string titleStr(title);
#if defined(CEF_X11)
// Retrieve the X11 display shared with Chromium.
::Display* display = cef_get_xdisplay();
DCHECK(display);
@ -41,4 +45,5 @@ void SimpleHandler::PlatformTitleChange(CefRefPtr<CefBrowser> browser,
// is Compound Text. This shouldn't matter 90% of the time since this is the
// fallback to the UTF8 property above.
XStoreName(display, browser->GetHost()->GetWindowHandle(), titleStr.c_str());
#endif // defined(CEF_X11)
}

View File

@ -3,8 +3,9 @@
// can be found in the LICENSE file.
#include "include/base/cef_build.h"
#include "include/cef_config.h"
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
#include <X11/Xlib.h>
// Definitions conflict with gtest.
#undef None
@ -84,7 +85,7 @@ void ContinueOnUIThread(CefRefPtr<CefTaskRunner> test_task_runner) {
CefCreateClosureTask(base::Bind(&RunTestsOnTestThread)));
}
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
LOG(WARNING) << "X error received: "
<< "type " << event->type << ", "
@ -99,7 +100,7 @@ int XErrorHandlerImpl(Display* display, XErrorEvent* event) {
int XIOErrorHandlerImpl(Display* display) {
return 0;
}
#endif // defined(OS_LINUX)
#endif // defined(OS_LINUX) && defined(CEF_X11)
} // namespace
@ -173,7 +174,7 @@ int main(int argc, char* argv[]) {
PlatformInit();
#endif
#if defined(OS_LINUX)
#if defined(OS_LINUX) && defined(CEF_X11)
// Install xlib error handlers so that the application won't be terminated
// on non-fatal errors.
XSetErrorHandler(XErrorHandlerImpl);

View File

@ -132,3 +132,14 @@ for dir, config in configs.items():
RunAction(src_dir, cmd)
if platform == 'windows':
issue_1999.apply(out_path)
gn_dir = 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 = [
'python', 'tools/make_config_header.py', '--header', 'include/cef_config.h',
'--cef_gn_config', gn_path
]
RunAction(cef_dir, cmd)

121
tools/make_config_header.py Normal file
View File

@ -0,0 +1,121 @@
# Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
from date_util import *
from file_util import *
from optparse import OptionParser
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
disc = """
This utility creates the config header file.
"""
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
if options.header is None or options.cef_gn_config is None:
parser.print_help(sys.stdout)
sys.exit()
def check_x11_build(gn_config):
""" Scan gn configuration file and decide whether it's x11 build or not """
lines = read_file(gn_config).split("\n")
for line in lines:
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):
""" Creates the header file for the cef build configuration
if the information has changed or if the file doesn't already exist. """
if not path_exists(cef_gn_config):
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 not options.quiet:
if written:
sys.stdout.write('File ' + options.header + ' updated.\n')
else:
sys.stdout.write('File ' + options.header + ' is already up to date.\n')

View File

@ -496,6 +496,12 @@ parser.add_option(
dest='sandbox',
default=False,
help='include only the cef_sandbox static library (macOS and Windows only)')
parser.add_option(
'--ozone',
action='store_true',
dest='ozone',
default=False,
help='include ozone build related files (Linux only)')
parser.add_option(
'-q',
'--quiet',
@ -541,6 +547,10 @@ if not options.ninjabuild:
print 'Ninja build is required on all platforms'
sys.exit()
if options.ozone and platform != 'linux':
print '--ozone is only supported on Linux.'
sys.exit()
# script directory
script_dir = os.path.dirname(__file__)
@ -602,6 +612,9 @@ elif options.sandbox:
else:
mode = 'standard'
if options.ozone:
output_dir_name = output_dir_name + '_ozone'
output_dir = create_output_dir(output_dir_name, options.outputdir)
# create the README.TXT file
@ -711,9 +724,10 @@ if mode == 'standard':
shared_dir = os.path.join(tests_dir, 'shared')
make_dir(shared_dir, options.quiet)
# create the tests/cefclient directory
cefclient_dir = os.path.join(tests_dir, 'cefclient')
make_dir(cefclient_dir, options.quiet)
if not options.ozone:
# create the tests/cefclient directory
cefclient_dir = os.path.join(tests_dir, 'cefclient')
make_dir(cefclient_dir, options.quiet)
# create the tests/cefsimple directory
cefsimple_dir = os.path.join(tests_dir, 'cefsimple')
@ -733,17 +747,18 @@ if mode == 'standard':
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_resources'], \
'tests/shared/', shared_dir, options.quiet)
# transfer common cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_browser'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_renderer'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources_extensions_set_page_color'], \
'tests/cefclient/', cefclient_dir, options.quiet)
if not options.ozone:
# transfer common cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_browser'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_renderer'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources'], \
'tests/cefclient/', cefclient_dir, options.quiet)
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_resources_extensions_set_page_color'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer common cefsimple files
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_common'], \
@ -757,9 +772,10 @@ if mode == 'standard':
create_fuzed_gtest(tests_dir)
# process cmake templates
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefclient', 'CMakeLists.txt.in'), \
os.path.join(cefclient_dir, 'CMakeLists.txt'), \
variables, options.quiet)
if not options.ozone:
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefclient', 'CMakeLists.txt.in'), \
os.path.join(cefclient_dir, 'CMakeLists.txt'), \
variables, options.quiet)
process_cmake_template(os.path.join(cef_dir, 'tests', 'cefsimple', 'CMakeLists.txt.in'), \
os.path.join(cefsimple_dir, 'CMakeLists.txt'), \
variables, options.quiet)
@ -1101,6 +1117,8 @@ elif platform == 'linux':
{'path': 'swiftshader/libGLESv2.so'},
]
# yapf: enable
if options.ozone:
binaries.append({'path': 'libminigbm.so', 'conditional': True})
if mode == 'client':
binaries.append({'path': 'cefsimple'})
@ -1163,9 +1181,10 @@ elif platform == 'linux':
transfer_gypi_files(cef_dir, cef_paths2['shared_sources_linux'], \
'tests/shared/', shared_dir, options.quiet)
# transfer cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \
'tests/cefclient/', cefclient_dir, options.quiet)
if not options.ozone:
# transfer cefclient files
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \
'tests/cefclient/', cefclient_dir, options.quiet)
# transfer cefsimple files
transfer_gypi_files(cef_dir, cef_paths2['cefsimple_sources_linux'], \