LaCrOS: Replace defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH)
The change is mostly mechanical replacing defined(OS_CHROMEOS) with BUILDFLAG(IS_ASH) and GN variable is_chromeos with is_ash. Only the insertion of "//build:chromeos_buildflags" into appropriate deps in BUILD.gn is done semi-manualy. The change should not change the behaviour of any build.
This is in preparation to switching lacros build from target_os=linux to target_os=chromeos so that lacros does not include any additional code due the switch.
Please note that any new defined(OS_CHROMEOS) and is_chromeos introduced to should be consistent with the new meaning.
Please refer to this short document http://go/lacros-replace-chromeos-macro-with-ash for full context.
Bug: 1052397
Change-Id: I12e6a89c1e06b7223f37e9d916e1c101d1f8b8e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494405
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Commit-Queue: Yuta Hijikata <ythjkt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820518}
diff --git a/media/gpu/BUILD.gn b/media/gpu/BUILD.gn
index 59c5e41..5fcda1c 100644
--- a/media/gpu/BUILD.gn
+++ b/media/gpu/BUILD.gn
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import("//build/buildflag_header.gni")
+import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
@@ -290,6 +291,7 @@
deps = [
":buildflags",
"//base",
+ "//build:chromeos_buildflags",
"//media",
"//media/parsers",
"//ui/gfx:buffer_types",
@@ -438,6 +440,7 @@
"test:helpers",
"//base",
"//base/test:test_support",
+ "//build:chromeos_buildflags",
"//media:test_support",
"//media/gpu",
"//media/gpu/test:test_helpers",
@@ -496,7 +499,7 @@
]
sources = [ "h264_decoder_unittest.cc" ]
- if (is_chromeos && (use_v4l2_codec || use_vaapi)) {
+ if (is_ash && (use_v4l2_codec || use_vaapi)) {
deps += [ "//media/gpu/chromeos:unit_tests" ]
}
if (use_vaapi) {
diff --git a/media/gpu/args.gni b/media/gpu/args.gni
index 9672fba1..237858f 100644
--- a/media/gpu/args.gni
+++ b/media/gpu/args.gni
@@ -2,6 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/chromeos/ui_mode.gni")
+
declare_args() {
# Indicates if V4L plugin is used.
use_v4lplugin = false
@@ -31,5 +33,5 @@
declare_args() {
# VA-API also allows decoding of images, but we don't want to use this
# outside of chromeos, even if video decoding is enabled.
- use_vaapi_image_codecs = use_vaapi && is_chromeos
+ use_vaapi_image_codecs = use_vaapi && is_ash
}
diff --git a/media/gpu/chromeos/BUILD.gn b/media/gpu/chromeos/BUILD.gn
index d9c66039..80fcfb3 100644
--- a/media/gpu/chromeos/BUILD.gn
+++ b/media/gpu/chromeos/BUILD.gn
@@ -158,6 +158,7 @@
deps = [
":chromeos",
"//base/test:test_support",
+ "//build:chromeos_buildflags",
"//media:test_support",
"//media/gpu:buildflags",
"//media/gpu/test:frame_file_writer",
diff --git a/media/gpu/chromeos/image_processor_test.cc b/media/gpu/chromeos/image_processor_test.cc
index 84c35352..c13ee59 100644
--- a/media/gpu/chromeos/image_processor_test.cc
+++ b/media/gpu/chromeos/image_processor_test.cc
@@ -12,6 +12,7 @@
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "media/base/video_frame.h"
#include "media/base/video_frame_layout.h"
#include "media/base/video_types.h"
@@ -222,7 +223,7 @@
EXPECT_TRUE(ip_client->WaitForFrameProcessors());
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// We don't yet have the function to create Dmabuf-backed VideoFrame on
// platforms except ChromeOS. So MemToDmabuf test is limited on ChromeOS.
TEST_P(ImageProcessorParamTest, ConvertOneTime_DmabufToMem) {
@@ -286,7 +287,7 @@
EXPECT_EQ(ip_client->GetNumOfProcessedImages(), 1u);
EXPECT_TRUE(ip_client->WaitForFrameProcessors());
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_ASH)
// BGRA -> NV12
// I420 -> NV12
@@ -334,7 +335,7 @@
std::make_tuple(kNV12Image180, kNV12Image90),
std::make_tuple(kNV12Image180, kNV12Image)));
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// TODO(hiroh): Add more tests.
// MEM->DMABUF (V4L2VideoEncodeAccelerator),
#endif
diff --git a/media/gpu/ipc/service/BUILD.gn b/media/gpu/ipc/service/BUILD.gn
index fe51b14..e644ece 100644
--- a/media/gpu/ipc/service/BUILD.gn
+++ b/media/gpu/ipc/service/BUILD.gn
@@ -38,6 +38,7 @@
"//media/gpu",
]
deps = [
+ "//build:chromeos_buildflags",
"//gpu/command_buffer/service:gles2",
"//gpu/ipc/service",
"//media:media_buildflags",
diff --git a/media/gpu/ipc/service/vda_video_decoder.cc b/media/gpu/ipc/service/vda_video_decoder.cc
index 576d1b9..aceed50f 100644
--- a/media/gpu/ipc/service/vda_video_decoder.cc
+++ b/media/gpu/ipc/service/vda_video_decoder.cc
@@ -13,6 +13,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_info.h"
#include "gpu/config/gpu_preferences.h"
@@ -277,7 +278,7 @@
// (https://crbug.com/929565). We should support reinitialization for profile
// changes. We limit this support as small as possible for safety.
const bool is_profile_change =
-#if defined(OS_CHROMEOS) && BUILDFLAG(USE_VAAPI)
+#if BUILDFLAG(IS_ASH) && BUILDFLAG(USE_VAAPI)
config_.profile() != config.profile();
#else
false;
diff --git a/media/gpu/test/BUILD.gn b/media/gpu/test/BUILD.gn
index 675e565..12a8e2a 100644
--- a/media/gpu/test/BUILD.gn
+++ b/media/gpu/test/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/chromeos/ui_mode.gni")
import("//build/config/ui.gni")
import("//media/gpu/args.gni")
@@ -39,6 +40,7 @@
deps = [
":helpers",
":test_helpers",
+ "//build:chromeos_buildflags",
"//media/gpu",
]
}
@@ -51,6 +53,7 @@
]
deps = [
":helpers",
+ "//build:chromeos_buildflags",
"//media/gpu",
"//ui/gfx/codec:codec",
]
@@ -153,6 +156,7 @@
":helpers",
":video_player",
":video_test_environment",
+ "//build:chromeos_buildflags",
"//media/gpu",
]
}
@@ -204,6 +208,7 @@
]
deps = [
":helpers",
+ "//build:chromeos_buildflags",
"//media:test_support",
"//media/gpu",
"//media/gpu/chromeos",
@@ -214,7 +219,7 @@
}
}
-if (is_chromeos) {
+if (is_ash) {
static_library("local_gpu_memory_buffer_manager") {
testonly = true
sources = [
diff --git a/media/gpu/test/image_processor/image_processor_client.cc b/media/gpu/test/image_processor/image_processor_client.cc
index 4375c45..8111230 100644
--- a/media/gpu/test/image_processor/image_processor_client.cc
+++ b/media/gpu/test/image_processor/image_processor_client.cc
@@ -14,6 +14,7 @@
#include "base/memory/ptr_util.h"
#include "base/synchronization/waitable_event.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/video_frame.h"
#include "media/base/video_frame_layout.h"
@@ -156,7 +157,7 @@
CreateVideoFrameFromImage(input_image).get(),
*input_layout, VideoFrame::STORAGE_OWNED_MEMORY);
} else {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
ASSERT_TRUE_OR_RETURN_NULLPTR(
input_storage_type == VideoFrame::STORAGE_DMABUFS ||
input_storage_type == VideoFrame::STORAGE_GPU_MEMORY_BUFFER);
diff --git a/media/gpu/test/video_frame_file_writer.cc b/media/gpu/test/video_frame_file_writer.cc
index 3778613..3945b214 100644
--- a/media/gpu/test/video_frame_file_writer.cc
+++ b/media/gpu/test/video_frame_file_writer.cc
@@ -13,6 +13,7 @@
#include "base/memory/ptr_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "media/gpu/video_frame_mapper.h"
#include "media/gpu/video_frame_mapper_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -127,7 +128,7 @@
base::SStringPrintf(&filename, FILE_PATH_LITERAL("frame_%04zu_%dx%d"),
frame_index, visible_size.width(), visible_size.height());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// Create VideoFrameMapper if not yet created. The decoder's output pixel
// format is not known yet when creating the VideoFrameWriter. We can only
// create the VideoFrameMapper upon receiving the first video frame.
@@ -160,7 +161,7 @@
DCHECK_CALLED_ON_VALID_SEQUENCE(writer_thread_sequence_checker_);
auto mapped_frame = video_frame;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
if (video_frame->storage_type() == VideoFrame::STORAGE_DMABUFS ||
video_frame->storage_type() == VideoFrame::STORAGE_GPU_MEMORY_BUFFER) {
CHECK(video_frame_mapper_);
@@ -205,7 +206,7 @@
DCHECK_CALLED_ON_VALID_SEQUENCE(writer_thread_sequence_checker_);
auto mapped_frame = video_frame;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
if (video_frame->storage_type() == VideoFrame::STORAGE_DMABUFS ||
video_frame->storage_type() == VideoFrame::STORAGE_GPU_MEMORY_BUFFER) {
CHECK(video_frame_mapper_);
diff --git a/media/gpu/test/video_frame_validator.cc b/media/gpu/test/video_frame_validator.cc
index 09e0f29..b862296 100644
--- a/media/gpu/test/video_frame_validator.cc
+++ b/media/gpu/test/video_frame_validator.cc
@@ -15,6 +15,7 @@
#include "base/strings/stringprintf.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "media/base/video_frame.h"
#include "media/gpu/buildflags.h"
#include "media/gpu/macros.h"
@@ -236,7 +237,7 @@
MD5VideoFrameValidator::Validate(scoped_refptr<const VideoFrame> frame,
size_t frame_index) {
DCHECK_CALLED_ON_VALID_SEQUENCE(validator_thread_sequence_checker_);
-#if defined(OS_CHROMEOS) || BUILDFLAG(IS_LACROS)
+#if BUILDFLAG(IS_ASH) || BUILDFLAG(IS_LACROS)
// b/149808895: There is a bug in the synchronization on mapped buffers, which
// causes the frame validation failure. The bug is due to some missing i915
// patches in kernel v3.18. The bug will be fixed if the kernel is upreved to
@@ -256,7 +257,7 @@
if (is_skylake)
usleep(10);
}
-#endif // defined(OS_CHROMEOS) || BUILDFLAG(IS_LACROS)
+#endif // BUILDFLAG(IS_ASH) || BUILDFLAG(IS_LACROS)
if (frame->format() != validation_format_) {
frame = ConvertVideoFrame(frame.get(), validation_format_);
}
diff --git a/media/gpu/test/video_player/video_player_test_environment.cc b/media/gpu/test/video_player/video_player_test_environment.cc
index d85c7d5..86be228 100644
--- a/media/gpu/test/video_player/video_player_test_environment.cc
+++ b/media/gpu/test/video_player/video_player_test_environment.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/system/sys_info.h"
+#include "build/chromeos_buildflags.h"
#include "media/base/video_types.h"
#include "media/gpu/test/video.h"
#include "media/gpu/test/video_player/video_decoder_client.h"
@@ -64,7 +65,7 @@
// Note: buddy, guado and rikku support import mode for H.264 and VP9, but for
// VP8 they use a different video decoder (V4L2 instead of VAAPI) and don't
// support import mode.
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
constexpr const char* kImportModeBlocklist[] = {
"buddy", "guado", "guado-cfm", "guado-kernelnext", "nyan_big",
"nyan_blaze", "nyan_kitty", "rikku", "rikku-cfm"};
@@ -72,7 +73,7 @@
import_supported_ = (std::find(std::begin(kImportModeBlocklist),
std::end(kImportModeBlocklist),
board) == std::end(kImportModeBlocklist));
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_ASH)
// VideoDecoders always require import mode to be supported.
DCHECK(import_supported_ || implementation_ == DecoderImplementation::kVDA);
diff --git a/media/gpu/v4l2/BUILD.gn b/media/gpu/v4l2/BUILD.gn
index 9a999e4..7b5b8bf 100644
--- a/media/gpu/v4l2/BUILD.gn
+++ b/media/gpu/v4l2/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//media/gpu/args.gni")
@@ -108,7 +109,7 @@
deps += [ ":libv4l2_stubs" ]
}
- if (is_chromeos) {
+ if (is_ash) {
sources += [
"v4l2_jpeg_encode_accelerator.cc",
"v4l2_jpeg_encode_accelerator.h",
diff --git a/media/gpu/vaapi/BUILD.gn b/media/gpu/vaapi/BUILD.gn
index d811256..df51107 100644
--- a/media/gpu/vaapi/BUILD.gn
+++ b/media/gpu/vaapi/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/chromeos/ui_mode.gni")
import("//build/config/features.gni")
import("//build/config/ui.gni")
import("//media/gpu/args.gni")
@@ -99,7 +100,7 @@
"//ui/gl",
]
- if (is_chromeos) {
+ if (is_ash) {
sources += [
"vaapi_jpeg_encode_accelerator.cc",
"vaapi_jpeg_encode_accelerator.h",
@@ -167,6 +168,7 @@
]
deps = [
":libva_stubs",
+ "//build:chromeos_buildflags",
"//third_party/libyuv",
"//ui/base:features",
"//ui/gfx:memory_buffer",
@@ -242,7 +244,7 @@
}
# TODO(https://crbug.com/1043007): remove is_chromeos.
-if (is_chromeos) {
+if (is_ash) {
source_set("jpeg_decoder_unit_test") {
testonly = true
sources = [ "vaapi_jpeg_decoder_unittest.cc" ]
@@ -300,13 +302,14 @@
":vaapi_utils_unittest",
"//base",
"//base/test:test_support",
+ "//build:chromeos_buildflags",
"//gpu",
"//media/gpu/test:helpers",
"//testing/gtest",
]
# TODO(https://crbug.com/1043007): remove is_chromeos.
- if (is_chromeos) {
+ if (is_ash) {
deps += [
":jpeg_decoder_unit_test",
":webp_decoder_unit_test",
diff --git a/media/gpu/vaapi/vaapi_unittest.cc b/media/gpu/vaapi/vaapi_unittest.cc
index f9484430..653f593 100644
--- a/media/gpu/vaapi/vaapi_unittest.cc
+++ b/media/gpu/vaapi/vaapi_unittest.cc
@@ -22,6 +22,7 @@
#include "base/strings/string_split.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "base/test/test_suite.h"
+#include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "media/gpu/vaapi/vaapi_wrapper.h"
@@ -38,7 +39,7 @@
{VP8PROFILE_ANY, VAProfileVP8Version0_3},
{VP9PROFILE_PROFILE0, VAProfileVP9Profile0},
{VP9PROFILE_PROFILE2, VAProfileVP9Profile2},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// TODO(hiroh): Remove if-macro once libva for linux-chrome is upreved to
// 2.9.0 or newer.
// https://source.chromium.org/chromium/chromium/src/+/master:build/linux/sysroot_scripts/generated_package_lists/sid.amd64
@@ -64,7 +65,7 @@
{"VAProfileVP8Version0_3", VAProfileVP8Version0_3},
{"VAProfileVP9Profile0", VAProfileVP9Profile0},
{"VAProfileVP9Profile2", VAProfileVP9Profile2},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// TODO(hiroh): Remove if-macro once libva for linux-chrome is upreved to
// 2.9.0 or newer.
// https://source.chromium.org/chromium/chromium/src/+/master:build/linux/sysroot_scripts/generated_package_lists/sid.amd64
diff --git a/media/gpu/vaapi/vaapi_wrapper.cc b/media/gpu/vaapi/vaapi_wrapper.cc
index b7bb0cb..373016d 100644
--- a/media/gpu/vaapi/vaapi_wrapper.cc
+++ b/media/gpu/vaapi/vaapi_wrapper.cc
@@ -37,6 +37,7 @@
#include "base/system/sys_info.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "ui/base/ui_base_features.h"
#include "media/base/media_switches.h"
@@ -353,7 +354,7 @@
{VP9PROFILE_PROFILE2, VAProfileVP9Profile2},
// VaapiWrapper does not support Profile 3.
//{VP9PROFILE_PROFILE3, VAProfileVP9Profile3},
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// TODO(hiroh): Remove if-macro once libva for linux-chrome is upreved
// to 2.9.0 or newer.
// https://source.chromium.org/chromium/chromium/src/+/master:build/linux/sysroot_scripts/generated_package_lists/sid.amd64
@@ -2260,7 +2261,7 @@
static bool result = InitializeStubs(paths);
if (!result) {
static const char kErrorMsg[] = "Failed to initialize VAAPI libs";
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// When Chrome runs on Linux with target_os="chromeos", do not log error
// message without VAAPI libraries.
LOG_IF(ERROR, base::SysInfo::IsRunningOnChromeOS()) << kErrorMsg;
diff --git a/media/gpu/video_encode_accelerator_unittest.cc b/media/gpu/video_encode_accelerator_unittest.cc
index 8b9f416..f868e54 100644
--- a/media/gpu/video_encode_accelerator_unittest.cc
+++ b/media/gpu/video_encode_accelerator_unittest.cc
@@ -44,6 +44,7 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "gpu/config/gpu_driver_bug_workarounds.h"
#include "gpu/config/gpu_preferences.h"
#include "gpu/ipc/service/gpu_memory_buffer_factory.h"
@@ -313,7 +314,7 @@
return profile >= VP9PROFILE_MIN && profile <= VP9PROFILE_MAX;
}
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
// Determine the test is known-to-fail and should be skipped.
bool ShouldSkipTest(VideoPixelFormat format) {
struct Pattern {
@@ -361,7 +362,7 @@
return false;
}
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_ASH)
// Helper functions to do string conversions.
static base::FilePath::StringType StringToFilePathStringType(
@@ -2792,10 +2793,10 @@
const bool force_level = std::get<8>(GetParam());
const bool scale = std::get<9>(GetParam());
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
if (ShouldSkipTest(g_env->test_streams_[0]->pixel_format))
GTEST_SKIP();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_ASH)
if (force_level) {
// Skip ForceLevel test if "--force_level=false".
@@ -2927,10 +2928,10 @@
const int test_type = GetParam();
ASSERT_LT(test_type, 2) << "Invalid test type=" << test_type;
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
if (ShouldSkipTest(g_env->test_streams_[0]->pixel_format))
GTEST_SKIP();
-#endif // defined(OS_CHROMEOS)
+#endif // BUILDFLAG(IS_ASH)
if (test_type == 0)
SimpleTestFunc<VEANoInputClient>();
@@ -3184,7 +3185,7 @@
void Initialize() override {
base::TestSuite::Initialize();
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
task_environment_ = std::make_unique<base::test::TaskEnvironment>(
base::test::TaskEnvironment::MainThreadType::UI);
#else
@@ -3276,7 +3277,7 @@
}
if (it->first == "native_input") {
-#if defined(OS_CHROMEOS)
+#if BUILDFLAG(IS_ASH)
media::g_native_input = true;
#else
LOG(FATAL) << "Unsupported option";
diff --git a/media/gpu/vp9_decoder.cc b/media/gpu/vp9_decoder.cc
index a36e204..29cd176 100644
--- a/media/gpu/vp9_decoder.cc
+++ b/media/gpu/vp9_decoder.cc
@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "build/build_config.h"
+#include "build/chromeos_buildflags.h"
#include "media/base/limits.h"
#include "media/base/media_switches.h"
#include "media/gpu/vp9_decoder.h"
@@ -19,7 +20,7 @@
namespace {
std::vector<uint32_t> GetSpatialLayerFrameSize(
const DecoderBuffer& decoder_buffer) {
-#if defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS)
+#if defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_ASH)
const uint32_t* cue_data =
reinterpret_cast<const uint32_t*>(decoder_buffer.side_data());
if (!cue_data) {
@@ -36,7 +37,7 @@
return {};
}
return std::vector<uint32_t>(cue_data, cue_data + num_of_layers);
-#endif // defined(ARCH_CPU_X86_FAMILY) && defined(OS_CHROMEOS)
+#endif // defined(ARCH_CPU_X86_FAMILY) && BUILDFLAG(IS_ASH)
return {};
}