Skip to content

Commit

Permalink
Provide a way to disable libpci dependency.
Browse files Browse the repository at this point in the history
Add a new gyp variable: use_libpci (default value is 1).
Add a new define when use_libpci==1: USE_LIBPCI.
Don't call specific PCI code in gpu_info_collector_linux.cc if USE_LIBPCI isn't defined.

BUG=427401
R=piman@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#302613}
  • Loading branch information
bedupont authored and Commit bot committed Nov 4, 2014
1 parent ad86665 commit 65ce5ac
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 67 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Behara Mani Shyam Patro <behara.ms@samsung.com>
Bem Jones-Bey <bemajaniman@gmail.com>
Bem Jones-Bey <bjonesbe@adobe.com>
Ben Karel <eschew@gmail.com>
Benjamin Dupont <bedupont@cisco.com>
Benjamin Jemlich <pcgod99@gmail.com>
Bernard Cafarelli <voyageur@gentoo.org>
Bhanukrushana Rout <b.rout@samsung.com>
Expand Down
9 changes: 9 additions & 0 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
# Whether we are using Views Toolkit
'toolkit_views%': 0,

# Use the PCI lib to collect GPU information.
'use_libpci%': 1,

# Use OpenSSL instead of NSS as the underlying SSL and crypto
# implementation. Certificate verification will in most cases be
# handled by the OS. If OpenSSL's struct X509 is used to represent
Expand Down Expand Up @@ -136,6 +139,7 @@
'use_cras%': '<(use_cras)',
'use_ozone%': '<(use_ozone)',
'embedded%': '<(embedded)',
'use_libpci%': '<(use_libpci)',
'use_openssl%': '<(use_openssl)',
'use_openssl_certs%': '<(use_openssl_certs)',
'enable_viewport%': '<(enable_viewport)',
Expand Down Expand Up @@ -281,6 +285,7 @@
'use_aura%': '<(use_aura)',
'use_ash%': '<(use_ash)',
'use_cras%': '<(use_cras)',
'use_libpci%': '<(use_libpci)',
'use_ozone%': '<(use_ozone)',
'use_ozone_evdev%': '<(use_ozone_evdev)',
'use_clipboard_aurax11%': '<(use_clipboard_aurax11)',
Expand Down Expand Up @@ -1081,6 +1086,7 @@
'use_aura%': '<(use_aura)',
'use_ash%': '<(use_ash)',
'use_cras%': '<(use_cras)',
'use_libpci%': '<(use_libpci)',
'use_openssl%': '<(use_openssl)',
'use_openssl_certs%': '<(use_openssl_certs)',
'use_nss%': '<(use_nss)',
Expand Down Expand Up @@ -2979,6 +2985,9 @@
}],
], # conditions for 'target_defaults'
'target_conditions': [
['<(use_libpci)==1', {
'defines': ['USE_LIBPCI=1'],
}],
['<(use_openssl)==1', {
'defines': ['USE_OPENSSL=1'],
}],
Expand Down
132 changes: 68 additions & 64 deletions build/linux/system.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,74 @@
},
],
}],
['use_libpci==1', {
'targets': [
{
'target_name': 'libpci',
'type': 'static_library',
'cflags': [
'<!@(<(pkg-config) --cflags libpci)',
],
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
'conditions': [
['linux_link_libpci==1', {
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other libpci)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l libpci)',
],
}
}],
],
},
'include_dirs': [
'../..',
],
'hard_dependency': 1,
'actions': [
{
'variables': {
'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libpci.h',
'output_cc': '<(INTERMEDIATE_DIR)/libpci_loader.cc',
'generator': '../../tools/generate_library_loader/generate_library_loader.py',
},
'action_name': 'generate_libpci_loader',
'inputs': [
'<(generator)',
],
'outputs': [
'<(output_h)',
'<(output_cc)',
],
'action': ['python',
'<(generator)',
'--name', 'LibPciLoader',
'--output-h', '<(output_h)',
'--output-cc', '<(output_cc)',
'--header', '<pci/pci.h>',
# TODO(phajdan.jr): Report problem to pciutils project
# and get it fixed so that we don't need --use-extern-c.
'--use-extern-c',
'--link-directly=<(linux_link_libpci)',
'pci_alloc',
'pci_init',
'pci_cleanup',
'pci_scan_bus',
'pci_fill_info',
'pci_lookup_name',
],
'message': 'Generating libpci library loader',
'process_outputs_as_sources': 1,
},
],
},
],
}],
], # conditions
'targets': [
{
Expand Down Expand Up @@ -840,70 +908,6 @@
],
},
},
{
'target_name': 'libpci',
'type': 'static_library',
'cflags': [
'<!@(<(pkg-config) --cflags libpci)',
],
'direct_dependent_settings': {
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)',
],
'conditions': [
['linux_link_libpci==1', {
'link_settings': {
'ldflags': [
'<!@(<(pkg-config) --libs-only-L --libs-only-other libpci)',
],
'libraries': [
'<!@(<(pkg-config) --libs-only-l libpci)',
],
}
}],
],
},
'include_dirs': [
'../..',
],
'hard_dependency': 1,
'actions': [
{
'variables': {
'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libpci.h',
'output_cc': '<(INTERMEDIATE_DIR)/libpci_loader.cc',
'generator': '../../tools/generate_library_loader/generate_library_loader.py',
},
'action_name': 'generate_libpci_loader',
'inputs': [
'<(generator)',
],
'outputs': [
'<(output_h)',
'<(output_cc)',
],
'action': ['python',
'<(generator)',
'--name', 'LibPciLoader',
'--output-h', '<(output_h)',
'--output-cc', '<(output_cc)',
'--header', '<pci/pci.h>',
# TODO(phajdan.jr): Report problem to pciutils project
# and get it fixed so that we don't need --use-extern-c.
'--use-extern-c',
'--link-directly=<(linux_link_libpci)',
'pci_alloc',
'pci_init',
'pci_cleanup',
'pci_scan_bus',
'pci_fill_info',
'pci_lookup_name',
],
'message': 'Generating libpci library loader',
'process_outputs_as_sources': 1,
},
],
},
{
'target_name': 'libresolv',
'type': 'none',
Expand Down
10 changes: 9 additions & 1 deletion gpu/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

import("//build/config/ui.gni")

declare_args() {
# Use the PCI lib to collect GPU information on Linux.
use_libpci = true
}

source_set("config") {
sources = [
"dx_diag_node.cc",
Expand Down Expand Up @@ -62,7 +67,10 @@ source_set("config") {
]
}
}
if (is_linux && (use_x11 || use_ozone)) {
if (use_libpci) {
defines += [ "USE_LIBPCI=1" ]
}
if (is_linux && use_libpci && (use_x11 || use_ozone)) {
deps += [
"//build/config/linux:libpci",
]
Expand Down
10 changes: 9 additions & 1 deletion gpu/config/gpu_info_collector_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
#include "base/strings/string_tokenizer.h"
#include "base/strings/string_util.h"
#include "gpu/config/gpu_info_collector.h"
#include "library_loaders/libpci.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"

#if defined(USE_LIBPCI)
#include "library_loaders/libpci.h"
#endif

namespace gpu {

namespace {
Expand Down Expand Up @@ -72,6 +75,10 @@ const uint32 kVendorIDAMD = 0x1002;
CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
DCHECK(gpu_info);

#if !defined(USE_LIBPCI)
return kCollectInfoNonFatalFailure;
#else

if (IsPciSupported() == false) {
VLOG(1) << "PCI bus scanning is not supported";
return kCollectInfoNonFatalFailure;
Expand Down Expand Up @@ -144,6 +151,7 @@ CollectInfoResult CollectPCIVideoCardInfo(GPUInfo* gpu_info) {
if (!primary_gpu_identified)
return kCollectInfoNonFatalFailure;
return kCollectInfoSuccess;
#endif
}

} // namespace anonymous
Expand Down
2 changes: 1 addition & 1 deletion gpu/gpu_config.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
'../third_party/amd/amd_videocard_info_win.cc',
],
}],
['OS=="linux" and (use_x11==1 or use_ozone==1)', {
['OS=="linux" and use_libpci==1 and (use_x11==1 or use_ozone==1)', {
'dependencies': [
'../build/linux/system.gyp:libpci',
],
Expand Down

0 comments on commit 65ce5ac

Please sign in to comment.