Skip to content

Instantly share code, notes, and snippets.

@chirayudesai
Last active August 9, 2016 09:01
Show Gist options
  • Save chirayudesai/8f313028414f7ddd1880481f9c074783 to your computer and use it in GitHub Desktop.
Save chirayudesai/8f313028414f7ddd1880481f9c074783 to your computer and use it in GitHub Desktop.
AUR chromium-dev 54.0.2816.0
Description: Enables using VA-API hardware acceleration in Linux. The patch for bpf_gpu_policy_linux.cc initially came from https://codereview.chromium.org/15955009/diff/92001/content/common/sandbox_linux/bpf_gpu_policy_linux.cc.
Index: dev/chrome/browser/about_flags.cc
===================================================================
--- dev.orig/chrome/browser/about_flags.cc
+++ dev/chrome/browser/about_flags.cc
@@ -910,7 +910,7 @@ const FeatureEntry kFeatureEntries[] = {
"disable-accelerated-video-decode",
IDS_FLAGS_ACCELERATED_VIDEO_DECODE_NAME,
IDS_FLAGS_ACCELERATED_VIDEO_DECODE_DESCRIPTION,
- kOsMac | kOsWin | kOsCrOS,
+ kOsAll,
SINGLE_DISABLE_VALUE_TYPE(switches::kDisableAcceleratedVideoDecode),
},
#if defined(USE_ASH)
Index: dev/content/common/BUILD.gn
===================================================================
--- dev.orig/content/common/BUILD.gn
+++ dev/content/common/BUILD.gn
@@ -12,6 +12,49 @@ if (is_mac) {
import("//build/config/mac/mac_sdk.gni")
}
+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
+ action("libva_generate_stubs") {
+ extra_header = "../../media/gpu/va_stub_header.fragment"
+
+ script = "../../tools/generate_stubs/generate_stubs.py"
+ sources = [
+ "../../media/gpu/va.sigs",
+ ]
+ inputs = [
+ extra_header,
+ ]
+ sources += [ "../../media/gpu/va_x11.sigs" ]
+ if (use_ozone) {
+ sources += [
+ "../../media/gpu/va_drm.sigs",
+ "va_wayland.sigs",
+ ]
+ }
+ stubs_filename_root = "va_stubs"
+
+ outputs = [
+ "$target_gen_dir/$stubs_filename_root.cc",
+ "$target_gen_dir/$stubs_filename_root.h",
+ ]
+ args = [
+ "-i",
+ rebase_path("$target_gen_dir", root_build_dir),
+ "-o",
+ rebase_path("$target_gen_dir", root_build_dir),
+ "-t",
+ "posix_stubs",
+ "-e",
+ rebase_path(extra_header, root_build_dir),
+ "-s",
+ stubs_filename_root,
+ "-p",
+ "content/common",
+ ]
+
+ args += rebase_path(sources, root_build_dir)
+ }
+}
+
source_set("common") {
# Targets external to content should always link to the public API.
# In addition, targets outside of the content component (shell and tests)
@@ -183,6 +226,15 @@ source_set("common") {
if (use_seccomp_bpf) {
defines += [ "USE_SECCOMP_BPF" ]
+ if (current_cpu != "arm" && is_desktop_linux) {
+ sources += get_target_outputs(":libva_generate_stubs")
+ deps += [ ":libva_generate_stubs" ]
+ configs += [ "//third_party/libva:libva_config" ]
+ if (use_ozone) {
+ configs += [ "//build/config/linux:x11" ]
+ deps += [ "//third_party/wayland:wayland_client" ]
+ }
+ }
} else {
if (is_linux) {
sources -= [
Index: dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- dev.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
+++ dev/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
@@ -23,6 +23,12 @@
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "build/build_config.h"
+
+#if !defined(__arm__)
+// Auto-generated for dlopen libva libraries
+#include "content/common/va_stubs.h"
+#endif
+
#include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
#include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
#include "content/common/set_process_title.h"
@@ -34,6 +40,14 @@
#include "sandbox/linux/syscall_broker/broker_process.h"
#include "sandbox/linux/system_headers/linux_syscalls.h"
+#if !defined(__arm__)
+#include "third_party/libva/va/va.h"
+#include "third_party/libva/va/va_x11.h"
+#if defined(USE_OZONE)
+#include "third_party/libva/va/wayland/va_wayland.h"
+#endif
+#endif
+
using sandbox::arch_seccomp_data;
using sandbox::bpf_dsl::Allow;
using sandbox::bpf_dsl::ResultExpr;
@@ -42,6 +56,16 @@ using sandbox::syscall_broker::BrokerFil
using sandbox::syscall_broker::BrokerProcess;
using sandbox::SyscallSets;
+#if !defined(__arm__)
+using content_common::kModuleVa;
+using content_common::kModuleVa_x11;
+#if defined(USE_OZONE)
+using content_common::kModuleVa_drm;
+#endif
+using content_common::InitializeStubs;
+using content_common::StubPathMap;
+#endif
+
namespace content {
namespace {
@@ -96,7 +120,7 @@ inline bool UseLibV4L2() {
bool IsAcceleratedVaapiVideoEncodeEnabled() {
bool accelerated_encode_enabled = false;
-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
accelerated_encode_enabled =
@@ -297,32 +321,72 @@ bool GpuProcessPolicy::PreSandboxHook()
GpuBrokerProcessPolicy::Create,
std::vector<BrokerFilePermission>()); // No extra files in whitelist.
+#if !defined(__arm__)
if (IsArchitectureX86_64() || IsArchitectureI386()) {
// Accelerated video dlopen()'s some shared objects
// inside the sandbox, so preload them now.
if (IsAcceleratedVaapiVideoEncodeEnabled() ||
IsAcceleratedVideoDecodeEnabled()) {
- const char* I965DrvVideoPath = NULL;
- const char* I965HybridDrvVideoPath = NULL;
-
- if (IsArchitectureX86_64()) {
- I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
- I965HybridDrvVideoPath = "/usr/lib64/va/drivers/hybrid_drv_video.so";
- } else if (IsArchitectureI386()) {
- I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
+ VLOG(1) << "Attempting to enable hardware video acceleration.";
+ StubPathMap paths;
+ paths[kModuleVa].push_back("libva.so.1");
+ paths[kModuleVa_x11].push_back("libva-x11.so.1");
+#if defined(USE_OZONE)
+ paths[kModuleVa_drm].push_back("libva-drm.so.1");
+#endif
+ if (!InitializeStubs(paths)) {
+ LOG(WARNING) << "Failed to initialize stubs";
+ return true;
}
- dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
- if (I965HybridDrvVideoPath)
- dlopen(I965HybridDrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
- dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
+ // libva drivers won't get loaded even above two libraries get dlopened.
+ // Thus, libva calls will fail after post sandbox stage.
+ //
+ // To get the va driver loaded before sandboxing, upstream simply dlopen
+ // the hard-coded va driver path because ChromeOS is the only platform
+ // that Google want to support libva.
+ //
+ // While generic linux distros ship va driver as anywhere they want.
+ // Fortunately, the va driver will be loadded when vaInitialize() get
+ // called.
+ // So the following code is to call vaInitialize() before sandboxing.
+
+ VADisplay va_display = NULL;
#if defined(USE_OZONE)
- dlopen("libva-drm.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-#elif defined(USE_X11)
- dlopen("libva-x11.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
+ struct wl_display* wayland_display = wl_display_connect(NULL);
+ if (wayland_display) {
+ va_display = vaGetDisplayWl(wayland_display);
+ if (!vaDisplayIsValid(va_display)) {
+ LOG(WARNING) << "Failed to call vaGetDisplayWl()";
+ va_display = NULL;
+ }
+ } else {
+ LOG(WARNING) << "Failed to find Wayland display";
+ }
+#endif
+
+ if (!va_display) {
+ Display* x_display = XOpenDisplay(NULL);
+ if (!x_display) {
+ LOG(WARNING) << "Failed to find X-Display";
+ return true;
+ }
+ va_display = vaGetDisplay(x_display);
+ if (!vaDisplayIsValid(va_display)) {
+ LOG(WARNING) << "Failed to call vaGetDisplay()";
+ return true;
+ }
+ }
+
+ int major_version, minor_version;
+ if (vaInitialize(va_display, &major_version, &minor_version)
+ != VA_STATUS_SUCCESS) {
+ LOG(WARNING) << "Failed to call vaInitialize()";
+ return true;
+ }
+ } // end of IsAcceleratedVaapiVideoEncodeEnabled() || IsAcceleratedVideoDecodeEnabled()
+ } // end of IsArchitectureX86_64() || IsArchitectureI386()
#endif
- }
- }
return true;
}
Index: dev/content/common/va_wayland.sigs
===================================================================
--- /dev/null
+++ dev/content/common/va_wayland.sigs
@@ -0,0 +1,8 @@
+// Copyright 2014 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.
+
+//------------------------------------------------
+// Functions from libva-wayland used in chromium code.
+//------------------------------------------------
+VADisplay vaGetDisplayWl(struct wl_display *display);
Index: dev/content/content_gpu.gypi
===================================================================
--- dev.orig/content/content_gpu.gypi
+++ dev/content/content_gpu.gypi
@@ -49,7 +49,7 @@
],
},
}],
- ['target_arch!="arm" and chromeos == 1', {
+ ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', {
'include_dirs': [
'<(DEPTH)/third_party/libva',
],
Index: dev/content/gpu/BUILD.gn
===================================================================
--- dev.orig/content/gpu/BUILD.gn
+++ dev/content/gpu/BUILD.gn
@@ -86,7 +86,7 @@ source_set("gpu_sources") {
]
}
- if (is_chromeos && current_cpu != "arm") {
+ if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
configs += [ "//third_party/libva:libva_config" ]
}
Index: dev/content/gpu/gpu_main.cc
===================================================================
--- dev.orig/content/gpu/gpu_main.cc
+++ dev/content/gpu/gpu_main.cc
@@ -75,7 +75,7 @@
#include "content/common/sandbox_mac.h"
#endif
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
#include "media/gpu/vaapi_wrapper.h"
#endif
@@ -253,7 +253,7 @@ int GpuMain(const MainFunctionParams& pa
GetGpuInfoFromCommandLine(gpu_info, command_line);
gpu_info.in_process_gpu = false;
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
media::VaapiWrapper::PreSandboxInitialization();
#endif
Index: dev/content/public/common/content_switches.cc
===================================================================
--- dev.orig/content/public/common/content_switches.cc
+++ dev/content/public/common/content_switches.cc
@@ -973,7 +973,9 @@ const char kDisableAudioSupportForDeskto
#if defined(OS_CHROMEOS)
// Disables panel fitting (used for mirror mode).
const char kDisablePanelFitting[] = "disable-panel-fitting";
+#endif
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
// Disables VA-API accelerated video encode.
const char kDisableVaapiAcceleratedVideoEncode[] =
"disable-vaapi-accelerated-video-encode";
Index: dev/content/public/common/content_switches.h
===================================================================
--- dev.orig/content/public/common/content_switches.h
+++ dev/content/public/common/content_switches.h
@@ -284,6 +284,8 @@ CONTENT_EXPORT extern const char kEnable
#if defined(OS_CHROMEOS)
CONTENT_EXPORT extern const char kDisablePanelFitting[];
+#endif
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
#endif
Index: dev/gpu/config/software_rendering_list_json.cc
===================================================================
--- dev.orig/gpu/config/software_rendering_list_json.cc
+++ dev/gpu/config/software_rendering_list_json.cc
@@ -431,17 +431,6 @@ const char kSoftwareRenderingListJson[]
]
},
{
- "id": 48,
- "description": "Accelerated video decode is unavailable on Linux",
- "cr_bugs": [137247],
- "os": {
- "type": "linux"
- },
- "features": [
- "accelerated_video_decode"
- ]
- },
- {
"id": 50,
"description": "Disable VMware software renderer on older Mesa",
"cr_bugs": [145531, 332596, 571899],
Index: dev/media/BUILD.gn
===================================================================
--- dev.orig/media/BUILD.gn
+++ dev/media/BUILD.gn
@@ -353,7 +353,7 @@ component("media") {
allow_circular_includes_from = [ "//media/base/android" ]
}
- if (current_cpu != "arm" && is_chromeos) {
+ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
sources += [
"filters/h264_bitstream_buffer.cc",
"filters/h264_bitstream_buffer.h",
@@ -650,7 +650,7 @@ test("media_unittests") {
}
}
- if (current_cpu != "arm" && is_chromeos) {
+ if (current_cpu != "arm" && (is_chromeos || is_desktop_linux)) {
sources += [ "filters/h264_bitstream_buffer_unittest.cc" ]
}
Index: dev/media/gpu/BUILD.gn
===================================================================
--- dev.orig/media/gpu/BUILD.gn
+++ dev/media/gpu/BUILD.gn
@@ -12,7 +12,7 @@ if (is_mac) {
import("//build/config/mac/mac_sdk.gni")
}
-if (is_chromeos && current_cpu != "arm") {
+if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
action("libva_generate_stubs") {
extra_header = "va_stub_header.fragment"
@@ -236,7 +236,7 @@ component("gpu") {
}
}
- if (is_chromeos) {
+ if (is_linux) {
sources += [
"accelerated_video_decoder.h",
"h264_decoder.cc",
@@ -280,7 +280,7 @@ component("gpu") {
"GLESv2",
]
}
- if (current_cpu == "arm") {
+ if (current_cpu == "arm" && is_chromeos) {
sources += [
"tegra_v4l2_device.cc",
"tegra_v4l2_device.h",
Index: dev/media/gpu/gpu_video_decode_accelerator_factory_impl.cc
===================================================================
--- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.cc
+++ dev/media/gpu/gpu_video_decode_accelerator_factory.cc
@@ -14,7 +14,7 @@
#include "media/gpu/dxva_video_decode_accelerator_win.h"
#elif defined(OS_MACOSX)
#include "media/gpu/vt_video_decode_accelerator_mac.h"
-#elif defined(OS_CHROMEOS)
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
#if defined(USE_V4L2_CODEC)
#include "media/gpu/v4l2_device.h"
#include "media/gpu/v4l2_slice_video_decode_accelerator.h"
@@ -79,7 +79,7 @@
#if defined(OS_WIN)
capabilities.supported_profiles =
DXVAVideoDecodeAccelerator::GetSupportedProfiles(gpu_preferences);
-#elif defined(OS_CHROMEOS)
+#elif defined(OS_CHROMEOS) || defined(OS_LINUX)
VideoDecodeAccelerator::SupportedProfiles vda_profiles;
#if defined(USE_V4L2_CODEC)
vda_profiles = V4L2VideoDecodeAccelerator::GetSupportedProfiles();
@@ -131,7 +131,7 @@
&GpuVideoDecodeAcceleratorFactory::CreateV4L2VDA,
&GpuVideoDecodeAcceleratorFactory::CreateV4L2SVDA,
#endif
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
&GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA,
#endif
#if defined(OS_MACOSX)
@@ -199,11 +199,12 @@
}
#endif
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
std::unique_ptr<VideoDecodeAccelerator>
GpuVideoDecodeAcceleratorFactory::CreateVaapiVDA(
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences) const {
+ VLOG(1) << "Creating new VAAPI video decode accelerator.";
std::unique_ptr<VideoDecodeAccelerator> decoder;
decoder.reset(new VaapiVideoDecodeAccelerator(make_context_current_cb_,
bind_image_cb_));
Index: dev/media/gpu/gpu_video_decode_accelerator_factory.h
===================================================================
--- dev.orig/media/gpu/gpu_video_decode_accelerator_factory.h
+++ dev/media/gpu/gpu_video_decode_accelerator_factory.h
@@ -101,7 +101,7 @@ class MEDIA_GPU_EXPORT GpuVideoDecodeAcc
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences) const;
#endif
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)
+#if (defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)
std::unique_ptr<VideoDecodeAccelerator> CreateVaapiVDA(
const gpu::GpuDriverBugWorkarounds& workarounds,
const gpu::GpuPreferences& gpu_preferences) const;
Index: dev/media/gpu/ipc/service/BUILD.gn
===================================================================
--- dev.orig/media/gpu/ipc/service/BUILD.gn
+++ dev/media/gpu/ipc/service/BUILD.gn
@@ -38,7 +38,7 @@ source_set("service") {
"//third_party/mesa:mesa_headers",
]
- if (is_chromeos && current_cpu != "arm") {
+ if ((is_desktop_linux || is_chromeos) && current_cpu != "arm") {
configs += [ "//third_party/libva:libva_config" ]
}
Index: dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
===================================================================
--- dev.orig/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
+++ dev/media/gpu/ipc/service/gpu_video_decode_accelerator.cc
@@ -58,7 +58,7 @@ static bool MakeDecoderContextCurrent(
return true;
}
-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
static bool BindImage(const base::WeakPtr<gpu::GpuCommandBufferStub>& stub,
uint32_t client_texture_id,
uint32_t texture_target,
@@ -171,7 +171,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecod
get_gl_context_cb_ = base::Bind(&GetGLContext, stub_->AsWeakPtr());
make_context_current_cb_ =
base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr());
-#if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
+#if ((defined(OS_LINUX) || defined(OS_CHROMEOS)) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX)
bind_image_cb_ = base::Bind(&BindImage, stub_->AsWeakPtr());
#endif
get_gles2_decoder_cb_ = base::Bind(&GetGLES2Decoder, stub_->AsWeakPtr());
Index: dev/media/gpu/va_stub_header.fragment
===================================================================
--- dev.orig/media/gpu/va_stub_header.fragment
+++ dev/media/gpu/va_stub_header.fragment
@@ -5,8 +5,9 @@ extern "C" {
#include "third_party/libva/va/drm/va_drm.h"
#include "third_party/libva/va/va.h"
-#if defined(USE_X11)
#include "third_party/libva/va/va_x11.h"
+#if defined(USE_OZONE)
+#include "third_party/libva/va/wayland/va_wayland.h"
#endif
}
Index: dev/media/gpu/vaapi_video_decode_accelerator.cc
===================================================================
--- dev.orig/media/gpu/vaapi_video_decode_accelerator.cc
+++ dev/media/gpu/vaapi_video_decode_accelerator.cc
@@ -343,17 +343,17 @@ bool VaapiVideoDecodeAccelerator::Initia
base::AutoLock auto_lock(lock_);
DCHECK_EQ(state_, kUninitialized);
- DVLOG(2) << "Initializing VAVDA, profile: " << profile;
+ VLOG(1) << "Initializing VAVDA, profile: " << profile;
#if defined(USE_X11)
if (gl::GetGLImplementation() != gl::kGLImplementationDesktopGL) {
- DVLOG(1) << "HW video decode acceleration not available without "
+ VLOG(1) << "HW video decode acceleration not available without "
"DesktopGL (GLX).";
return false;
}
#elif defined(USE_OZONE)
if (gl::GetGLImplementation() != gl::kGLImplementationEGLGLES2) {
- DVLOG(1) << "HW video decode acceleration not available without "
+ VLOG(1) << "HW video decode acceleration not available without "
<< "EGLGLES2.";
return false;
}
@@ -363,7 +363,7 @@ bool VaapiVideoDecodeAccelerator::Initia
VaapiWrapper::kDecode, profile, base::Bind(&ReportToUMA, VAAPI_ERROR));
if (!vaapi_wrapper_.get()) {
- DVLOG(1) << "Failed initializing VAAPI for profile " << profile;
+ VLOG(1) << "Failed initializing VAAPI for profile " << profile;
return false;
}
@@ -378,7 +378,7 @@ bool VaapiVideoDecodeAccelerator::Initia
vp9_accelerator_.reset(new VaapiVP9Accelerator(this, vaapi_wrapper_.get()));
decoder_.reset(new VP9Decoder(vp9_accelerator_.get()));
} else {
- DLOG(ERROR) << "Unsupported profile " << profile;
+ VLOG(1) << "Unsupported profile " << profile;
return false;
}
Index: dev/media/gpu/vaapi_wrapper.cc
===================================================================
--- dev.orig/media/gpu/vaapi_wrapper.cc
+++ dev/media/gpu/vaapi_wrapper.cc
@@ -189,7 +189,7 @@ scoped_refptr<VaapiWrapper> VaapiWrapper
VAProfile va_profile,
const base::Closure& report_error_to_uma_cb) {
if (!profile_infos_.Get().IsProfileSupported(mode, va_profile)) {
- DVLOG(1) << "Unsupported va_profile: " << va_profile;
+ VLOG(1) << "Unsupported va_profile: " << va_profile;
return nullptr;
}
@@ -342,15 +342,17 @@ VaapiWrapper::GetSupportedProfileInfosFo
bool VaapiWrapper::VaInitialize(const base::Closure& report_error_to_uma_cb) {
static bool vaapi_functions_initialized = PostSandboxInitialization();
if (!vaapi_functions_initialized) {
- bool running_on_chromeos = false;
-#if defined(OS_CHROMEOS)
+ bool error_level_logging = false;
+#if defined(OS_LINUX)
+ error_level_logging = true;
+#elif defined(OS_CHROMEOS)
// When chrome runs on linux with chromeos=1, do not log error message
// without VAAPI libraries.
- running_on_chromeos = base::SysInfo::IsRunningOnChromeOS();
+ error_level_logging = base::SysInfo::IsRunningOnChromeOS();
#endif
static const char kErrorMsg[] = "Failed to initialize VAAPI libs";
- if (running_on_chromeos)
- LOG(ERROR) << kErrorMsg;
+ if (error_level_logging)
+ VLOG(1) << kErrorMsg;
else
DVLOG(1) << kErrorMsg;
return false;
@@ -416,7 +418,7 @@ bool VaapiWrapper::IsEntrypointSupported
if (std::find(supported_entrypoints.begin(), supported_entrypoints.end(),
entrypoint) == supported_entrypoints.end()) {
- DVLOG(1) << "Unsupported entrypoint";
+ VLOG(1) << "Unsupported entrypoint";
return false;
}
return true;
@@ -440,8 +442,8 @@ bool VaapiWrapper::AreAttribsSupported_L
if (attribs[i].type != required_attribs[i].type ||
(attribs[i].value & required_attribs[i].value) !=
required_attribs[i].value) {
- DVLOG(1) << "Unsupported value " << required_attribs[i].value
- << " for attribute type " << required_attribs[i].type;
+ VLOG(1) << "Unsupported value " << required_attribs[i].value
+ << " for attribute type " << required_attribs[i].type;
return false;
}
}
Index: dev/media/media.gyp
===================================================================
--- dev.orig/media/media.gyp
+++ dev/media/media.gyp
@@ -749,7 +749,7 @@
],
}],
# For VaapiVideoEncodeAccelerator.
- ['target_arch != "arm" and chromeos == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
'sources': [
'filters/h264_bitstream_buffer.cc',
'filters/h264_bitstream_buffer.h',
@@ -1310,7 +1310,7 @@
}]
],
}],
- ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
'sources': [
'filters/h264_bitstream_buffer_unittest.cc',
],
@@ -2255,7 +2255,7 @@
],
}],
- ['chromeos==1 and target_arch != "arm"', {
+ ['(desktop_linux==1 or chromeos==1) and target_arch != "arm"', {
'targets': [
{
'target_name': 'vaapi_jpeg_decoder_unittest',
Index: dev/media/media_gpu.gypi
===================================================================
--- dev.orig/media/media_gpu.gypi
+++ dev/media/media_gpu.gypi
@@ -174,7 +174,7 @@
},
],
}],
- ['chromeos==1', {
+ ['chromeos==1 or desktop_linux==1', {
'sources': [
'gpu/accelerated_video_decoder.h',
'gpu/h264_decoder.cc',
@@ -230,7 +230,7 @@
'gpu/tegra_v4l2_device.h',
],
}],
- ['target_arch != "arm" and chromeos == 1', {
+ ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1)', {
'dependencies': [
'../media/media.gyp:media',
'../third_party/libyuv/libyuv.gyp:libyuv',
Index: dev/content/content_common.gypi
===================================================================
--- dev.orig/content/content_common.gypi
+++ dev/content/content_common.gypi
@@ -644,6 +644,52 @@
],
}, {
'defines': ['USE_SECCOMP_BPF'],
+ 'dependencies': [
+ '../build/linux/system.gyp:x11',
+ ],
+ 'variables': {
+ 'sig_files': [
+ '../media/gpu/va.sigs',
+ '../media/gpu/va_x11.sigs',
+ ],
+ 'generate_stubs_script': '../tools/generate_stubs/generate_stubs.py',
+ 'extra_header': '../media/gpu/va_stub_header.fragment',
+ 'outfile_type': 'posix_stubs',
+ 'stubs_filename_root': 'va_stubs',
+ 'project_path': 'content/common',
+ 'intermediate_dir': '<(INTERMEDIATE_DIR)',
+ 'output_root': '<(SHARED_INTERMEDIATE_DIR)/va',
+ },
+ 'actions': [
+ {
+ 'action_name': 'libva_generate_stubs',
+ 'inputs': [
+ '<(generate_stubs_script)',
+ '<(extra_header)',
+ '<@(sig_files)',
+ ],
+ 'outputs': [
+ '<(intermediate_dir)/<(stubs_filename_root).cc',
+ '<(output_root)/<(project_path)/<(stubs_filename_root).h',
+ ],
+ 'action': ['python',
+ '<(generate_stubs_script)',
+ '-i', '<(intermediate_dir)',
+ '-o', '<(output_root)/<(project_path)',
+ '-t', '<(outfile_type)',
+ '-e', '<(extra_header)',
+ '-s', '<(stubs_filename_root)',
+ '-p', '<(project_path)',
+ '<@(_inputs)',
+ ],
+ 'process_outputs_as_sources': 1,
+ 'message': 'Generating libva stubs for dynamic loading',
+ },
+ ],
+ 'include_dirs': [
+ '<(DEPTH)/third_party/libva',
+ '<(output_root)',
+ ],
}],
['use_ozone==1', {
'dependencies': [
# Maintainer: Gustavo Alvarez <sl1pkn07@gmail.com>
# Contributor: Mikhail Vorozhtsov <mikhail.vorozhtsov@gmail.com>
# Contributor: Nagisa <simonas@kazlauskas.me>
# Contributor: Misc <andreas.reis@gmail.com>
# Contributor: Jeagoss <jgoliver@jeago.com>
# Contributor: Saikrishna Arcot <saiarcot895@gmail.com> (Author of https://github.com/saiarcot895/chromium-ubuntu-build/blob/master/debian/patches/enable_vaapi_on_linux.diff)
# Contirbutor: Chirayu Desai <chirayudesai1@gmail.com>
#########################
## -- Build options -- ##
#########################
_use_clang=1 # Use clang compiler (system). Results in faster build and smaller chromium.
_use_bundled_clang=1 # Use bundled clang compiler (needs build). NOTE: if use this option, '_use_clang' is need set to 1
_use_ccache=0 # Use ccache when build
_use_pax=0 # Set 1 to change PaX permisions in executables NOTE: only use if use PaX environment
_use_gtk3=1 # If set 1, then build with GTK3 support, if set 0, then build with GTK2
_debug_mode=0 # Build in debug mode
##############################################
## -- Package and components information -- ##
##############################################
pkgname=chromium-dev
pkgver=54.0.2816.0
_launcher_ver=3
pkgrel=1
pkgdesc="The open-source project behind Google Chrome (Dev Channel)"
arch=('i686' 'x86_64')
url='http://www.chromium.org'
license=('BSD')
depends=('desktop-file-utils'
#'icu'
'jsoncpp'
#'libsrtp'
'libwebp'
'libxslt'
'libxss'
'minizip'
'perl-file-basedir'
'nss'
'pciutils'
#'re2'
'snappy'
'speech-dispatcher'
'speex'
'xdg-utils'
#'opus'
#'protobuf'
#'libevent'
'libvpx.so'
'ffmpeg'
)
makedepends=('libexif'
'elfutils'
'gperf'
'ninja'
'perl-json'
'python2-beautifulsoup4'
'python2-html5lib'
'python2-simplejson'
'python2-jinja'
'python2-ply'
'subversion'
'yasm'
'git'
'imagemagick'
)
optdepends=('chromium-pepper-flash-dev: PPAPI Flash Player (Dev Channel) (64bits only)'
'chromium-widevine-dev: Widevine plugin (eg: Netflix) (Dev Channel) (64bits only)'
#
'kdebase-kdialog: Needed for file dialogs in KDE4/KF5'
'kdialog-frameworks-git: Needed for file dialogs in KF5'
#
'kwalletmanager: Needed for storing passwords in KWallet in KF5'
#
'libexif: Need for read EXIF metadata'
'ttf-font: For some typography'
)
source=("https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${pkgver}.tar.xz"
"chromium-launcher-${_launcher_ver}.tar.gz::https://github.com/foutrelis/chromium-launcher/archive/v${_launcher_ver}.tar.gz"
'chromium-dev.svg'
# Patch form Gentoo
'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-ffmpeg-r3.patch'
'https://raw.githubusercontent.com/gentoo/gentoo/master/www-client/chromium/files/chromium-system-jinja-r12.patch'
# Misc Patches
'https://gist.github.com/chirayudesai/8f313028414f7ddd1880481f9c074783/raw/9871ff6d6346d351f1cbc7fa84421307e34ee51c/enable_vaapi_on_linux.diff'
'minizip.patch::http://pastebin.com/raw/QCqSDam5'
# Patch from crbug (chromium bugtracker)
'chromium-widevine-r1.patch' # https://crbug.com/473866
)
sha1sums=( #"$(curl -sL https://gsdview.appspot.com/chromium-browser-official/?marker=chromium-${pkgver}.tar.xz.hashes | awk -v FS='<td>"' -v RS='"</td>' '$0=$2' | head -n1)"
"$(curl -sL https://commondatastorage.googleapis.com/chromium-browser-official/chromium-${pkgver}.tar.xz.hashes | grep sha1 | cut -d " " -f3)"
'd18f8d96e80be9c31d994cc6362d7d8041c53319'
'336976cb66bf8df71fc7f2e92aa723891b6efb53'
# Patch form Gentoo
'07331ea52fdbf30b1bddc66d439921016d2bf720'
'e5e573cb88122546f2a430f15ed5ded608b50371'
# Misc Patches
'320a7322768fb6e4b0f0e1ffd91f8b53ad092155'
'bc90b327b05dbecaa88da43211ae0a4ed0c6c57f'
# Patch from crbug (chromium bugtracker)
'3032c9aeb68d80d8ef3cb8029be0d06ee402fa7f'
)
options=('!strip')
install=chromium-dev.install
################################################
## -- Don't touch anything below this line -- ##
################################################
# Build Debug mode?
if [ "${_debug_mode}" = "1" ]; then
_debug_flag="-g"
_strip=0
# options+=('debug')
elif [ "${_debug_mode}" = "0" ]; then
_strip=1
fi
# Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
# NOTE: These are for Arch Linux use ONLY. For your own distribution, please
# get your own set of keys. Feel free to contact foutrelis@archlinux.org for
# more information.
_google_api_key="AIzaSyDwr302FpOSkGRpLlUpPThNTDPbXcIn_FM"
_google_default_client_id="413772536636.apps.googleusercontent.com"
_google_default_client_secret="0ZChLK6AxeA3Isu96MkwqDR4"
# 32 or 64 bits?
if [ "${CARCH}" = "i686" ]; then
_target_arch=ia32
_build_pnacl=0
_pnacl_arch=32
elif [ "${CARCH}" = "x86_64" ]; then
_target_arch=x64
_build_pnacl=1
_pnacl_arch=64
fi
# If use PaX environment, need 'paxctl'
if [ "${_use_pax}" = "1" ]; then
makedepends+=('paxctl')
fi
# Need you use clang?
if [ "${_use_clang}" = "1" ]; then
makedepends+=('clang')
fi
if [ "${_use_bundled_clang}" = "1" ]; then
makedepends+=('cmake'
'ocaml'
'libffi'
'chrpath'
)
fi
# Build with GTK3?
if [ "${_use_gtk3}" = "1" ]; then
depends+=('gtk3')
makedepends+=('gtk2')
_launcher_gtk='GTK=3'
optdepends+=('libappindicator-gtk3: Needed for show systray icon in the panel in plasma-next (KF5)')
elif [ "${_use_gtk3}" = "0" ]; then
depends+=('gtk2')
optdepends+=('libappindicator-gtk2: Needed for show systray icon in the panel in plasma-next (KF5)')
fi
# Need you use ccache?
if [ "${_use_ccache}" = "1" ]; then
makedepends+=('ccache')
fi
# Are we in Gnome?
_use_gnome=0
if [ -f /usr/lib/libgconf-2.so ]; then
depends+=('gconf')
_use_gnome=1
fi
# Are you use gnome-keyring?
_use_gnome_keyring=0
if [ -f /usr/lib/libgnome-keyring.so ]; then
depends+=('libgnome-keyring'
'gnome-keyring')
_use_gnome_keyring=1
fi
# Are you use Pulseaudio?
_use_pulseaudio=0
if [ -x /usr/lib/libpulse.so ]; then
depends+=('libpulse')
_use_pulseaudio=1
fi
# List of third-party components needed for build chromium. The rest is remove by remove_bundled_libraries srcipt in prepare()
_necesary=('base/third_party/dmg_fp'
'base/third_party/dynamic_annotations'
'base/third_party/icu'
'base/third_party/libevent'
'base/third_party/nspr'
'base/third_party/superfasthash'
'base/third_party/symbolize'
'base/third_party/valgrind'
'base/third_party/xdg_mime'
'base/third_party/xdg_user_dirs'
'breakpad/src/third_party/curl'
'chrome/third_party/mozilla_security_manager'
'courgette/third_party'
'native_client/src/third_party/dlmalloc'
'native_client_sdk/src/libraries/third_party/newlib-extras'
'net/third_party/mozilla_security_manager'
'net/third_party/nss'
'third_party/WebKit'
'third_party/analytics'
'third_party/angle'
'third_party/angle/src/common/third_party/numerics'
'third_party/angle/src/third_party/compiler'
'third_party/angle/src/third_party/murmurhash'
'third_party/angle/src/third_party/trace_event'
'third_party/angle/src/third_party/libXNVCtrl'
'third_party/brotli'
'third_party/boringssl'
'third_party/cacheinvalidation'
'third_party/catapult'
'third_party/catapult/third_party/polymer'
'third_party/catapult/third_party/py_vulcanize'
'third_party/catapult/third_party/py_vulcanize/third_party/rcssmin'
'third_party/catapult/third_party/py_vulcanize/third_party/rjsmin'
'third_party/catapult/tracing/third_party/d3'
'third_party/catapult/tracing/third_party/gl-matrix'
'third_party/catapult/tracing/third_party/jszip'
'third_party/catapult/tracing/third_party/mannwhitneyu'
'third_party/ced'
'third_party/cld_2'
'third_party/cros_system_api'
'third_party/cython/python_flags.py'
'third_party/devscripts'
'third_party/dom_distiller_js'
'third_party/dom_distiller_js/dist/proto_gen/third_party/dom_distiller_js'
'third_party/fips181'
'third_party/flatbuffers'
'third_party/flot'
'third_party/google_input_tools'
'third_party/google_input_tools/third_party/closure_library'
'third_party/google_input_tools/third_party/closure_library/third_party/closure'
'third_party/hunspell'
'third_party/iccjpeg'
'third_party/icu' # https://crbug.com/584920 and https://crbug.com/592268
'third_party/jstemplate'
'third_party/khronos'
'third_party/leveldatabase'
'third_party/libaddressinput'
'third_party/libjingle'
'third_party/libjpeg_turbo'
'third_party/libphonenumber'
'third_party/libsecret'
'third_party/libsrtp'
'third_party/libudev'
'third_party/libusb'
'third_party/libva'
'third_party/libxml/chromium'
'third_party/libwebm'
'third_party/libXNVCtrl'
'third_party/libyuv'
'third_party/lss'
'third_party/lzma_sdk'
'third_party/mesa'
'third_party/modp_b64'
'third_party/mt19937ar'
'third_party/openh264'
'third_party/openmax_dl'
'third_party/opus'
'third_party/ots'
'third_party/pdfium'
'third_party/pdfium/third_party/agg23'
'third_party/pdfium/third_party/base'
'third_party/pdfium/third_party/bigint'
'third_party/pdfium/third_party/freetype'
'third_party/pdfium/third_party/lcms2-2.6'
'third_party/pdfium/third_party/libjpeg'
'third_party/pdfium/third_party/libopenjpeg20'
'third_party/pdfium/third_party/libpng16'
'third_party/pdfium/third_party/libtiff'
'third_party/pdfium/third_party/zlib_v128'
'third_party/polymer'
'third_party/protobuf'
'third_party/protobuf/third_party/six'
'third_party/qcms'
'third_party/re2'
'third_party/sfntly'
'third_party/skia'
'third_party/smhasher'
'third_party/sqlite'
'third_party/tcmalloc'
'third_party/usrsctp'
'third_party/web-animations-js'
'third_party/webdriver'
'third_party/webrtc'
'third_party/widevine'
'third_party/woff2'
'third_party/x86inc'
'third_party/zlib/google'
'url/third_party/mozilla'
'v8/src/third_party/valgrind'
)
if [ "${_debug_mode}" = "1" ]; then
_necesary+=('native_client/src/third_party/valgrind')
fi
# Set build flags
# NOTE
# -Denable_sql_database=0 | http://crbug.com/22208
# -Dlogging_like_official_build=1 | Save space by removing DLOG and DCHECK messages (about 6% reduction).
# -Dlinux_use_gold_flags=0 | Never use bundled gold binary. Disable gold linker flags for now.
# -Dusb_ids_path=/usr/share/hwdata/usb.ids | Use the file at run time instead of effectively compiling it in.
# -Dicu_use_data_file_flag=1 | set to 0 when fix https://crbug.com/592268
_flags=("-Dclang=${_use_clang}"
'-Ddisable_glibc=1'
'-Ddisable_fatal_linker_warnings=1'
'-Denable_sql_database=0'
'-Denable_touch_ui=1'
'-Denable_webrtc=1'
'-Denable_widevine=1'
'-Denable_pepper_cdms=1'
'-Denable_hangout_services_extension=1'
'-Dffmpeg_branding=ChromeOS'
"-Dgoogle_api_key=${_google_api_key}"
"-Dgoogle_default_client_id=${_google_default_client_id}"
"-Dgoogle_default_client_secret=${_google_default_client_secret}"
'-Dicu_use_data_file_flag=1'
'-Dlibspeechd_h_prefix=speech-dispatcher/'
"-Dlinux_link_gnome_keyring=${_use_gnome_keyring}"
"-Dlinux_link_gsettings=${_use_gnome}"
'-Dlinux_link_kerberos=1'
'-Dlinux_link_libbrlapi=1'
'-Dlinux_link_libpci=1'
'-Dlinux_link_libspeechd=1'
"-Dlinux_link_pulseaudio=${_use_pulseaudio}"
"-Dlinux_strip_binary=${_strip}"
'-Dlinux_use_bundled_binutils=0'
'-Dlinux_use_bundled_gold=0'
'-Dlinux_use_gold_flags=0'
'-Dlogging_like_official_build=1'
'-Dno_strict_aliasing=1'
'-Dproprietary_codecs=1'
'-Dpython_ver=2.7'
"-Dremove_webcore_debug_symbols=${_strip}"
"-Dtarget_arch=${_target_arch}"
'-Dusb_ids_path=/usr/share/hwdata/usb.ids'
"-Duse_gconf=${_use_gnome}"
"-Duse_gio=${_use_gnome}"
"-Duse_gnome_keyring=${_use_gnome_keyring}"
"-Duse_gtk3=${_use_gtk3}"
"-Duse_pulseaudio=${_use_pulseaudio}"
'-Duse_sysroot=0'
'-Duse_gold=0'
'-Duse_xkbcommon=1'
'-Dwerror='
)
# Set pnacl flags (depending of the $CARCH)
if [ "${_build_pnacl}" = "0" ]; then
_flags+=('-Ddisable_nacl=1'
'-Ddisable_pnacl=1'
)
fi
# Set clang flags
if [ "${_use_clang}" = "1" ]; then
if [ "${_use_bundled_clang}" = "0" ]; then
_flags+=('-Dclang_use_chrome_plugins=0'
'-Dhost_clang=0'
)
elif [ "${_use_bundled_clang}" = "1" ]; then
_flags+=('-Dclang_use_chrome_plugins=1'
'-Dhost_clang=1'
)
fi
fi
# Set the bundled/external components
# TODO
# -Duse_system_hunspell=1 | Upstream changes needed
# -Duse_system_libusb=1 | https://crbug.com/266149
# -Duse_system_opus=1 | https://code.google.com/p/webrtc/issues/detail?id=3077
# -Duse_system_sqlite=1 | https://crbug.com/22208
# -Duse_system_ssl=1 | https://crbug.com/58087
# -Duse_system_libsrtp=1 | https://crbug.com/501318
# -Duse_system_re2=1 | https://bugs.gentoo.org/show_bug.cgi?id=571156
# -Duse_system_protobuf=1 | https://bugs.gentoo.org/show_bug.cgi?id=525560
# -Duse_system_icu=1 | https://crbug.com/584920 and https://crbug.com/592268
# -Duse_system_libjpeg=1 | https://bugs.gentoo.org/show_bug.cgi?id=584518
# NOTE
# -Duse_system_openssl=0 | Set to 1 if use BoringSSL instead of SSL
# -Duse_system_libevent=0 | Need older version (<2.x.x)
# -Duse_system_v8=0 | Possible broken in API/ABI if use a differen version
# -Duse_system_libxnvctrl=0 | Because not exist in Arch (and not all users use nvidia blob drivers)
_use_system=('-Duse_system_expat=1'
'-Duse_system_ffmpeg=1'
'-Duse_system_flac=1'
'-Duse_system_fontconfig=1'
'-Duse_system_harfbuzz=1'
'-Duse_system_icu=0'
'-Duse_system_jsoncpp=1'
'-Duse_system_libevent=0'
'-Duse_system_libexif=1'
'-Duse_system_libjpeg=0'
'-Duse_system_libpng=1'
'-Duse_system_libsrtp=0'
'-Duse_system_libusb=0'
'-Duse_system_libvpx=1'
'-Duse_system_libwebp=1'
'-Duse_system_libxml=1'
'-Duse_system_libxnvctrl=0'
'-Duse_system_libxslt=1'
'-Duse_system_minizip=1'
'-Duse_system_nspr=1'
'-Duse_system_openssl=0'
'-Duse_system_opus=0'
'-Duse_system_protobuf=0'
'-Duse_system_re2=0'
'-Duse_system_snappy=1'
'-Duse_system_speex=1'
'-Duse_system_sqlite=0'
'-Duse_system_ssl=0'
'-Duse_system_v8=0'
'-Duse_system_yasm=1'
'-Duse_system_xdg_utils=1'
'-Duse_system_zlib=1'
)
################################################
prepare() {
# Set Python2 path
mkdir -p python-path
ln -s /usr/bin/python2 "${srcdir}/python-path/python"
export PATH="${srcdir}/python-path:$PATH"
cd "chromium-${pkgver}"
# Fix to save configuration in ~/.config/chromium-dev
sed -e "s|'filename': 'chromium-browser'|'filename': 'chromium-dev'|" \
-e "s|'confdir': 'chromium'|'confdir': 'chromium-dev'|" \
-i chrome/chrome_exe.gypi
sed -e 's|config_dir.Append("chromium")|config_dir.Append("chromium-dev")|' \
-e 's|config_dir.Append("chrome-frame")|config_dir.Append("chrome-frame-dev")|' \
-i chrome/common/chrome_paths_linux.cc
msg2 "Patching the sources"
# Patch sources from Gentoo
patch -p1 -i "${srcdir}/chromium-system-ffmpeg-r3.patch"
patch -p1 -i "${srcdir}/chromium-system-jinja-r12.patch"
# Misc Patches:
patch -p1 -i "${srcdir}/enable_vaapi_on_linux.diff"
patch -p1 -i "${srcdir}/minizip.patch"
# Patch from crbug (chromium bugtracker)
# https://crbug.com/473866
patch -p0 -i "${srcdir}/chromium-widevine-r1.patch"
sed 's|@WIDEVINE_VERSION@|The Cake Is a Lie|g' -i "third_party/widevine/cdm/stub/widevine_cdm_version.h"
##
# Fix libpng errors
pushd chrome/app/theme &> /dev/null
export IFS=$'\n'
for i in $(find . -name '*.png' -type f); do
mogrify "${i}" &> /dev/null
done
export IFS=' '
popd &> /dev/null
# Make it possible to remove third_party/adobe
echo > "${srcdir}/flapper_version.h"
_flags+=("-Dflapper_version_h_file=${srcdir}/flapper_version.h")
# Remove most bundled libraries. Some are still needed.
msg2 "Removing unnecessary components to save space"
python2 build/linux/unbundle/remove_bundled_libraries.py ${_necesary[@]} --do-remove
rm -fr native_client/toolchain
rm -fr build/linux/debian*
if [ "${_build_pnacl}" = "1" ]; then
msg2 "Setup NaCl/PNaCl SDK: Download and install NaCl/PNaCl toolchains"
python2 build/download_nacl_toolchains.py --packages nacl_x86_newlib,pnacl_newlib,pnacl_translator sync --extract
fi
msg2 "Make sure use Python2"
find . -name '*.py' -exec sed -r 's|/usr/bin/python$|&2|g' -i {} +
find . -name '*.py' -exec sed -r 's|/usr/bin/env python$|&2|g' -i {} +
touch chrome/test/data/webui/i18n_process_css_test.html
# Changing bundle libraries to system ones
python2 build/linux/unbundle/replace_gyp_files.py ${_use_system[@]}
# update libaddressinput strings
python2 third_party/libaddressinput/chromium/tools/update-strings.py
}
build() {
msg2 "Build the Launcher"
make -C "chromium-launcher-${_launcher_ver}" CHROMIUM_SUFFIX="-dev" PREFIX=/usr ${_launcher_gtk}
cd "chromium-${pkgver}"
# Set ccache environment
if [ "${_use_ccache}" = "1" ]; then
msg2 "Setup ccache"
export CCACHE_CPP2=yes
export CCACHE_SLOPPINESS=time_macros
fi
# Use system/bundled Clang? or GCC?
_bundled_clang_path="${srcdir}/chromium-${pkgver}/third_party/llvm-build/Release+Asserts/bin"
if [ "${_use_clang}" = "0" ]; then
msg2 "Setup for use system GCC"
if [ "${_use_ccache}" = "0" ]; then
export CC="gcc -Wall"
export CXX="g++ -Wall"
elif [ "${_use_ccache}" = "1" ]; then
export CC="ccache gcc -Wall"
export CXX="ccache g++ -Wall"
fi
elif [ "${_use_clang}" = "1" ]; then
if [ "${_use_bundled_clang}" = "0" ]; then
msg2 "Setup for use system Clang"
if [ "${_use_ccache}" = "0" ]; then
export CC="clang -Qunused-arguments"
export CXX="clang++ -Qunused-arguments"
elif [ "${_use_ccache}" = "1" ]; then
export CC="ccache clang -Qunused-arguments"
export CXX="ccache clang++ -Qunused-arguments"
fi
export CXXFLAGS="${CXXFLAGS} -Wno-unknown-warning-option"
elif [ "${_use_bundled_clang}" = "1" ]; then
msg2 "Setup and build bundled Clang"
python2 tools/clang/scripts/update.py --force-local-build --without-android --gcc-toolchain=/usr
if [ "${_use_ccache}" = "0" ]; then
export CC="${_bundled_clang_path}/clang -Qunused-arguments"
export CXX="${_bundled_clang_path}/clang++ -Qunused-arguments"
elif [ "${_use_ccache}" = "1" ]; then
export CC="ccache ${_bundled_clang_path}/clang -Qunused-arguments"
export CXX="ccache ${_bundled_clang_path}/clang++ -Qunused-arguments"
fi
fi
fi
# CFLAGS are passed through -Drelease_extra_cflags=
export -n CFLAGS CXXFLAGS
msg2 "Starting building Chromium..."
# Configure the builder
python2 build/gyp_chromium --depth=. -Drelease_extra_cflags="$CFLAGS $_debug_flag" ${_flags[@]} ${_use_system[@]}
# Build mksnapshot and pax-mark it.
if [ "${_use_pax}" = "1" ]; then
ninja -C out/Release -v mksnapshot
paxctl -cm out/Release/mksnapshot
fi
# Build all with ninja
LC_ALL=C ninja -C out/Release -v pdf chrome chrome_sandbox chromedriver widevinecdmadapter clearkeycdm
# Pax-mark again
if [ "${_use_pax}" = "1" ]; then
paxctl -cm out/Release/chrome
fi
}
package() {
# Install launcher
make -C "chromium-launcher-${_launcher_ver}" CHROMIUM_SUFFIX="-dev" PREFIX=/usr DESTDIR="${pkgdir}" install-strip
install -Dm644 "chromium-launcher-${_launcher_ver}/LICENSE" "${pkgdir}/usr/share/licenses/chromium-dev/LICENSE.launcher"
pushd "chromium-${pkgver}/out/Release" &> /dev/null
if [ "${_debug_mode}" = "1" ]; then
# Build with debug needs a tons of space. remove this save that space
rm -fr "chromium-launcher-${_launcher_ver}/third_party"
fi
# Install binaries
install -Dm755 chrome "${pkgdir}/usr/lib/chromium-dev/chromium-dev"
install -Dm644 chrome.1 "${pkgdir}/usr/share/man/man1/chromium-dev.1"
install -Dm4755 chrome_sandbox "${pkgdir}/usr/lib/chromium-dev/chrome-sandbox"
install -Dm755 chromedriver "${pkgdir}/usr/lib/chromium-dev/chromedriver"
ln -s /usr/lib/chromium-dev/chromedriver "${pkgdir}/usr/bin/chromedriver-dev"
# Install libs
for i in libwidevinecdmadapter libclearkeycdm; do
install -Dm755 "${i}.so" "${pkgdir}/usr/lib/chromium-dev/${i}.so"
done
install -Dm644 icudtl.dat "${pkgdir}/usr/lib/chromium-dev/icudtl.dat" # https://crbug.com/584920 and https://crbug.com/592268
install -Dm644 natives_blob.bin "${pkgdir}/usr/lib/chromium-dev/natives_blob.bin"
install -Dm644 snapshot_blob.bin "${pkgdir}/usr/lib/chromium-dev/snapshot_blob.bin"
# Install Resources
for i in content_resources keyboard_resources resources chrome_100_percent chrome_200_percent; do
install -Dm644 "${i}.pak" "${pkgdir}/usr/lib/chromium-dev/${i}.pak"
done
# Install locales
find pseudo_locales -type f -name "*.pak" -exec install -Dm644 '{}' "${pkgdir}/usr/lib/chromium-dev/{}" \;
find locales -type f -name "*.pak" -exec install -Dm644 '{}' "${pkgdir}/usr/lib/chromium-dev/{}" \;
find resources -type f -name "*" -exec install -Dm644 '{}' "${pkgdir}/usr/lib/chromium-dev/{}" \;
(cd "${pkgdir}/usr/lib/chromium-dev"; ln -s locales remote_locales)
# Install icons
for _size in 16 22 24 32 48 128 256; do
case "${_size}" in
16|32) _branding="${srcdir}/chromium-${pkgver}/chrome/app/theme/default_100_percent/chromium" ;;
*) _branding="${srcdir}/chromium-${pkgver}/chrome/app/theme/chromium" ;;
esac
install -Dm644 "${_branding}/product_logo_${_size}.png" "${pkgdir}/usr/share/icons/hicolor/${_size}x${_size}/apps/chromium-dev.png"
done
# Install pNaCL/NaCL stuff if is detected
if [ "${_build_pnacl}" = "1" ]; then
install -Dm755 nacl_helper "${pkgdir}/usr/lib/chromium-dev/nacl_helper"
install -Dm755 nacl_helper_bootstrap "${pkgdir}/usr/lib/chromium-dev/nacl_helper_bootstrap"
install -Dm755 nacl_helper_nonsfi "${pkgdir}/usr/lib/chromium-dev/nacl_helper_nonsfi"
install -Dm755 "nacl_irt_x86_${_pnacl_arch}.nexe" "${pkgdir}/usr/lib/chromium-dev/nacl_irt_x86_${_pnacl_arch}.nexe"
(cd pnacl; for i in $(find -type f); do install -Dm755 "${i}" "${pkgdir}/usr/lib/chromium-dev/pnacl/${i}"; done)
fi
popd &> /dev/null
# Install some external files
install -Dm644 "chromium-${pkgver}/chrome/installer/linux/common/desktop.template" "${pkgdir}/usr/share/applications/chromium-dev.desktop"
sed -e 's|@@MENUNAME@@|Chromium-dev|g' \
-e 's|@@USR_BIN_SYMLINK_NAME@@|chromium-dev|g' \
-e 's|@@PACKAGE@@|chromium-dev|g' \
-i "${pkgdir}/usr/share/applications/chromium-dev.desktop"
install -Dm644 chromium-dev.svg "${pkgdir}/usr/share/icons/hicolor/scalable/apps/chromium-dev.svg"
install -Dm644 "chromium-${pkgver}/LICENSE" "${pkgdir}/usr/share/licenses/chromium-dev/LICENSE"
# install gnome stuff if detect it
if [ "${_use_gnome}" = "1" ]; then
install -Dm644 "chromium-${pkgver}/chrome/installer/linux/common/default-app.template" "${pkgdir}/usr/share/gnome-control-center/default-apps/chromium-dev.xml"
sed -e 's|@@MENUNAME@@|Chromium-dev|g' \
-e 's|@@INSTALLDIR@@|/usr/bin|g' \
-e 's|@@PACKAGE@@|chromium-dev|g' \
-i "${pkgdir}/usr/share/gnome-control-center/default-apps/chromium-dev.xml"
fi
if [ "${_debug_mode}" = "0" ]; then
# Manually strip binaries so that 'nacl_irt_*.nexe' is left intact
if [ "${_build_pnacl}" = "1" ]; then
strip $STRIP_BINARIES "${pkgdir}/usr/lib/chromium-dev/"nacl_helper{,_bootstrap,_nonsfi}
fi
strip $STRIP_BINARIES "${pkgdir}/usr/lib/chromium-dev/"{chromium-dev,chrome-sandbox,chromedriver}
strip $STRIP_SHARED "${pkgdir}/usr/lib/chromium-dev/"lib{widevinecdmadapter,clearkeycdm}.so
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment