Skip to content

Commit

Permalink
Add //build/config/linux/dri to extract path to dri drivers
Browse files Browse the repository at this point in the history
The dri drivers path is the variable 'dridriverdir' in 'dri.pc'

If found then translate it to the macro DRI_DRIVER_DIR.

It can be useful in various places instead of guessing the path.
For now only use it in gpu_sandbox_hook_linux except for ChromeOS.

Bug: 787787
Change-Id: I7fef8606a4f2cbc04233af820a91cf12a4c7a9a5
Reviewed-on: https://chromium-review.googlesource.com/785371
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: Antoine Labour <piman@chromium.org>
Commit-Queue: Julien Isorce <julien.isorce@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519658}
  • Loading branch information
Julien Isorce authored and Commit Bot committed Nov 28, 2017
1 parent 8580c22 commit b662350
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
18 changes: 18 additions & 0 deletions build/config/linux/dri/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2017 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")

pkg_config("dri") {
packages = [ "dri" ]
dri_driver_dir = exec_script(pkg_config_script,
pkg_config_args + [
"--dridriverdir",
"dri",
],
"string")
defines = [ "DRI_DRIVER_DIR=\"$dri_driver_dir\"" ]
}
13 changes: 13 additions & 0 deletions build/config/linux/pkg-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def main():
parser.add_option('--atleast-version', action='store',
dest='atleast_version', type='string')
parser.add_option('--libdir', action='store_true', dest='libdir')
parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir')
(options, args) = parser.parse_args()

# Make a list of regular expressions to strip out.
Expand Down Expand Up @@ -162,6 +163,18 @@ def main():
sys.stdout.write(libdir.strip())
return 0

if options.dridriverdir:
cmd = [options.pkg_config, "--variable=dridriverdir"] + args
if options.debug:
sys.stderr.write('Running: %s\n' % cmd)
try:
dridriverdir = subprocess.check_output(cmd)
except:
print "Error from pkg-config."
return 1
sys.stdout.write(dridriverdir.strip())
return

cmd = [options.pkg_config, "--cflags", "--libs"] + args
if options.debug:
sys.stderr.write('Running: %s\n' % ' '.join(cmd))
Expand Down
1 change: 1 addition & 0 deletions build/dotfile_settings.gni
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ build_dotfile_settings = {
"//build/config/linux/BUILD.gn",
"//build/config/linux/pkg_config.gni",
"//build/config/linux/atk/BUILD.gn",
"//build/config/linux/dri/BUILD.gn",
"//build/config/mac/mac_sdk.gni",
"//build/config/mac/rules.gni",
"//build/config/posix/BUILD.gn",
Expand Down
4 changes: 4 additions & 0 deletions content/gpu/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,8 @@ target(link_target_type, "gpu_sources") {
if (enable_vulkan) {
deps += [ "//gpu/vulkan" ]
}

if (is_desktop_linux) {
configs += [ "//build/config/linux/dri" ]
}
}
7 changes: 6 additions & 1 deletion content/gpu/gpu_sandbox_hook_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ bool LoadAmdGpuLibraries() {
LOG(ERROR) << "dlopen(libglapi.so) failed with error: " << dlerror();
return false;
}
if (nullptr == dlopen("/usr/lib64/dri/radeonsi_dri.so", dlopen_flag)) {

const char* radeonsi_lib = "/usr/lib64/dri/radeonsi_dri.so";
#if defined(DRI_DRIVER_DIR)
radeonsi_lib = DRI_DRIVER_DIR "/radeonsi_dri.so";
#endif
if (nullptr == dlopen(radeonsi_lib, dlopen_flag)) {
LOG(ERROR) << "dlopen(radeonsi_dri.so) failed with error: " << dlerror();
return false;
}
Expand Down

0 comments on commit b662350

Please sign in to comment.