Make gtk2/gtk3 compile time switchable.

This adds a "use_gtk3" gyp/gn flag, along with a separate gtk2/gtk3
targets in system.gyp and //build/config/linux/gtk[23] in gn.

BUG=132847

Review URL: https://codereview.chromium.org/1293073006

Cr-Original-Commit-Position: refs/heads/master@{#346742}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: b8f8f682a82bce992edb35c3030214ede236d3ba
This commit is contained in:
erg 2015-09-01 14:39:03 -07:00 коммит произвёл Commit bot
Родитель 5a9a454592
Коммит 2c09162dbc
5 изменённых файлов: 129 добавлений и 9 удалений

Просмотреть файл

@ -702,6 +702,9 @@
# Libxkbcommon usage.
'use_xkbcommon%': 0,
# Whether we use GTKv3 on linux.
'use_gtk3%': 0,
# Control Flow Integrity for virtual calls and casts.
# See http://clang.llvm.org/docs/ControlFlowIntegrity.html
'cfi_vptr%': 0,
@ -1138,6 +1141,7 @@
'use_ozone%': '<(use_ozone)',
'use_ozone_evdev%': '<(use_ozone_evdev)',
'use_xkbcommon%': '<(use_xkbcommon)',
'use_gtk3%': '<(use_gtk3)',
'use_clipboard_aurax11%': '<(use_clipboard_aurax11)',
'desktop_linux%': '<(desktop_linux)',
'use_x11%': '<(use_x11)',

Просмотреть файл

@ -6,12 +6,12 @@ import("//build/config/linux/pkg_config.gni")
assert(is_linux, "This file should only be referenced on Linux")
# Depend on //build/config/linux/gtk to use GTK.
# Depend on //build/config/linux/gtk2 to use GTKv2.
#
# GN doesn't check visibility for configs so we give this an obviously internal
# name to discourage random targets from accidentally depending on this and
# bypassing the GTK target's visibility.
pkg_config("gtk_internal_config") {
pkg_config("gtk2_internal_config") {
# Gtk requires gmodule, but it does not list it as a dependency in some
# misconfigured systems.
packages = [
@ -23,7 +23,7 @@ pkg_config("gtk_internal_config") {
# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
# parts that explicitly need GTK are whitelisted on this target.
group("gtk") {
group("gtk2") {
visibility = [
"//chrome/browser/ui/libgtk2ui",
"//gpu/gles2_conform_support:gles2_conform_test_windowless",
@ -31,15 +31,15 @@ group("gtk") {
"//remoting/host/it2me:remote_assistance_host",
"//remoting/host:remoting_me2me_host_static",
]
public_configs = [ ":gtk_internal_config" ]
public_configs = [ ":gtk2_internal_config" ]
}
# Depend on "gtkprint" to get this.
pkg_config("gtkprint_internal_config") {
pkg_config("gtkprint2_internal_config") {
packages = [ "gtk+-unix-print-2.0" ]
}
group("gtkprint") {
group("gtkprint2") {
visibility = [ "//chrome/browser/ui/libgtk2ui" ]
public_configs = [ ":gtkprint_internal_config" ]
public_configs = [ ":gtkprint2_internal_config" ]
}

Просмотреть файл

@ -0,0 +1,45 @@
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/linux/pkg_config.gni")
assert(is_linux, "This file should only be referenced on Linux")
# Depend on //build/config/linux/gtk3 to use GTKv3.
#
# GN doesn't check visibility for configs so we give this an obviously internal
# name to discourage random targets from accidentally depending on this and
# bypassing the GTK target's visibility.
pkg_config("gtk3_internal_config") {
# Gtk requires gmodule, but it does not list it as a dependency in some
# misconfigured systems.
packages = [
"gmodule-2.0",
"gtk+-3.0",
"gthread-2.0",
]
}
# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
# parts that explicitly need GTK are whitelisted on this target.
group("gtk3") {
visibility = [
"//chrome/browser/ui/libgtk2ui",
"//gpu/gles2_conform_support:gles2_conform_test_windowless",
"//remoting/host",
"//remoting/host/it2me:remote_assistance_host",
"//remoting/host:remoting_me2me_host_static",
]
public_configs = [ ":gtk3_internal_config" ]
}
# Depend on "gtkprint" to get this.
pkg_config("gtkprint3_internal_config") {
packages = [ "gtk+-unix-print-3.0" ]
}
group("gtkprint3") {
visibility = [ "//chrome/browser/ui/libgtk2ui" ]
public_configs = [ ":gtkprint3_internal_config" ]
}

Просмотреть файл

@ -35,6 +35,9 @@ declare_args() {
# Whether the entire browser uses toolkit-views on Mac instead of Cocoa.
mac_views_browser = false
# Whether we should use GTKv3 instead of GTKv2.
use_gtk3 = false
}
# Additional dependent variables -----------------------------------------------

Просмотреть файл

@ -128,7 +128,7 @@
],
},
{
'target_name': 'gtk',
'target_name': 'gtk2',
'type': 'none',
'toolsets': ['host', 'target'],
'variables': {
@ -169,7 +169,7 @@
],
},
{
'target_name': 'gtkprint',
'target_name': 'gtkprint2',
'type': 'none',
'conditions': [
['_toolset=="target"', {
@ -423,6 +423,74 @@
}
], # targets
}],
['use_gtk3==1', {
# Hide GTK3 and related dependencies when use_gtk3==0 because the user
# might not have the GTK3 headers yet.
'targets': [
{
'target_name': 'gtk3',
'type': 'none',
'toolsets': ['host', 'target'],
'variables': {
# gtk requires gmodule, but it does not list it as a dependency
# in some misconfigured systems.
'gtk_packages': 'gmodule-2.0 gtk+-3.0 gthread-2.0',
},
'conditions': [
['_toolset=="target"', {
'all_dependent_settings': {
'cflags': [
'<!@(<(pkg-config) --cflags <(gtk_packages))',
],
},
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other <(gtk_packages))',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l <(gtk_packages))',
],
},
}, {
'all_dependent_settings': {
'cflags': [
'<!@(pkg-config --cflags <(gtk_packages))',
],
},
'link_settings': {
'ldflags': [
'<!@(pkg-config --libs-only-L --libs-only-other <(gtk_packages))',
],
'libraries': [
'<!@(pkg-config --libs-only-l <(gtk_packages))',
],
},
}],
],
},
{
'target_name': 'gtkprint3',
'type': 'none',
'conditions': [
['_toolset=="target"', {
'direct_dependent_settings': {
'cflags': [
'<!@(<(pkg-config) --cflags gtk+-unix-print-3.0)',
],
},
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other gtk+-unix-print-3.0)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l gtk+-unix-print-3.0)',
],
},
}],
],
},
],
}],
['use_x11==1 and chromeos==0', {
'targets': [
{