Re-land: "Isolate commit_id.h from other code."

Re-land limits the angle_version deps to Windows to fix an iOS
visibility rule violation in GN.

Instead of recompiling multiple source files, we can seal off the
files that include commit_id to prevent recompilations when the
commit changes and source files don't change.

Bug: angleproject:2551
Change-Id: I033f00ec7afe4bfd01e29e0eea8848eea27747a0
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3233899
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill 2021-10-08 13:00:19 -04:00 коммит произвёл Angle LUCI CQ
Родитель 4b75345a7d
Коммит d8c18ac6d8
15 изменённых файлов: 140 добавлений и 54 удалений

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

@ -376,7 +376,6 @@ angle_static_library("angle_common") {
public_deps = [
":angle_abseil",
":angle_version",
":includes",
]
public_configs += [ ":angle_common_config" ]
@ -663,10 +662,12 @@ config("angle_commit_id_config") {
visibility = [ ":angle_commit_id" ]
}
_commit_id_output_file = "$root_gen_dir/angle/angle_commit.h"
action("angle_commit_id") {
_commit_id_header = "$root_gen_dir/angle/angle_commit.h"
script = "src/commit_id.py"
outputs = [ _commit_id_output_file ]
outputs = [ _commit_id_header ]
visibility = [ ":angle_version" ]
# Add git as a dependency if it is available.
if (angle_enable_commit_id &&
@ -692,7 +693,7 @@ action("angle_commit_id") {
args = [
"gen",
rebase_path(_commit_id_output_file, root_build_dir),
rebase_path(_commit_id_header, root_build_dir),
]
public_configs = [ ":angle_commit_id_config" ]
@ -701,6 +702,34 @@ action("angle_commit_id") {
angle_source_set("angle_version") {
sources = [ "src/common/angle_version.h" ]
public_deps = [ ":angle_commit_id" ]
visibility = [ ":angle_version_info" ]
# The version headers are used directly in Windows .RC files.
if (is_win) {
visibility += [
":libEGL",
":libGL",
":libGLESv1_CM",
":libGLESv2",
":libGLESv2_capture_complement",
]
}
# TODO(jmadill): Remove once headers isolated. http://anglebug.com/2551
if (build_with_chromium) {
visibility += [
"//content/browser:browser",
"//gpu/command_buffer/service:gles2_sources",
]
}
}
angle_source_set("angle_version_info") {
sources = [
"src/common/angle_version_info.cpp",
"src/common/angle_version_info.h",
]
deps = [ ":angle_version" ]
}
config("angle_backend_config") {
@ -854,7 +883,7 @@ angle_source_set("libANGLE_base") {
public_deps = [
":angle_common",
":angle_gpu_info_util",
":angle_version",
":angle_version_info",
":libANGLE_headers",
":translator",
]
@ -1118,10 +1147,6 @@ template("angle_libGLESv2") {
sources += libglesv2_cl_sources
}
if (is_win) {
sources += [ "src/libGLESv2/${invoker.output_name}_autogen.def" ]
}
output_name = "${invoker.output_name}${angle_libs_suffix}"
configs += [
@ -1134,7 +1159,13 @@ template("angle_libGLESv2") {
deps = invoker.deps + [ ":includes" ]
public_deps = [ ":angle_version" ]
if (is_win) {
sources += [
"src/libGLESv2/${invoker.output_name}_autogen.def",
"src/libGLESv2/libGLESv2.rc",
]
deps += [ ":angle_version" ]
}
}
}
@ -1182,7 +1213,9 @@ if (is_win && !angle_is_winuwp) {
":libANGLE",
]
public_deps = [ ":angle_version" ]
if (is_win) {
deps += [ ":angle_version" ]
}
}
}
@ -1217,6 +1250,7 @@ angle_shared_library("libGLESv1_CM") {
if (is_win) {
sources += [ "src/libGLESv1_CM/libGLESv1_CM.def" ]
deps += [ ":angle_version" ]
}
}
@ -1240,6 +1274,10 @@ angle_source_set("libEGL_egl_loader") {
angle_shared_library("libEGL") {
sources = libegl_sources
if (is_win) {
sources += [ "src/libEGL/libEGL.rc" ]
}
output_name = "libEGL${angle_libs_suffix}"
configs += [
@ -1254,16 +1292,16 @@ angle_shared_library("libEGL") {
defines += [ "EGLAPI=__attribute__((visibility(\"default\")))" ]
}
if (is_win) {
sources += [ "src/libEGL/libEGL_autogen.def" ]
}
deps = [
":angle_common",
":angle_version",
":libEGL_egl_loader",
]
if (is_win) {
sources += [ "src/libEGL/libEGL_autogen.def" ]
deps += [ ":angle_version" ]
}
public_deps = [ ":includes" ]
data_deps = [ ":libGLESv2" ]

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

@ -0,0 +1,31 @@
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angle_version_info.cpp: ANGLE version queries.
#include "common/angle_version.h"
namespace angle
{
int GetANGLERevision()
{
return ANGLE_REVISION;
}
const char *GetANGLEVersionString()
{
return ANGLE_VERSION_STRING;
}
const char *GetANGLECommitHash()
{
return ANGLE_COMMIT_HASH;
}
int GetANGLECommitHashSize()
{
return ANGLE_COMMIT_HASH_SIZE;
}
} // namespace angle

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

@ -0,0 +1,19 @@
//
// Copyright 2021 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angle_version_info.h: ANGLE version queries.
#ifndef COMMON_VERSION_H_
#define COMMON_VERSION_H_
namespace angle
{
int GetANGLERevision();
const char *GetANGLEVersionString();
const char *GetANGLECommitHash();
int GetANGLECommitHashSize();
} // namespace angle
#endif // COMMON_VERSION_H_

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

@ -15,7 +15,7 @@
#include <vector>
#include "common/PackedEnums.h"
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "common/matrix_utils.h"
#include "common/platform.h"
#include "common/system_utils.h"
@ -3210,7 +3210,7 @@ void Context::initVersionStrings()
versionString << "OpenGL ES ";
}
versionString << clientVersion.major << "." << clientVersion.minor << ".0 (ANGLE "
<< ANGLE_VERSION_STRING << ")";
<< angle::GetANGLEVersionString() << ")";
mVersionString = MakeStaticString(versionString.str());
std::ostringstream shadingLanguageVersionString;
@ -3224,8 +3224,8 @@ void Context::initVersionStrings()
shadingLanguageVersionString << "OpenGL GLSL ";
}
shadingLanguageVersionString << (clientVersion.major == 2 ? 1 : clientVersion.major) << "."
<< clientVersion.minor << "0 (ANGLE " << ANGLE_VERSION_STRING
<< ")";
<< clientVersion.minor << "0 (ANGLE "
<< angle::GetANGLEVersionString() << ")";
mShadingLanguageString = MakeStaticString(shadingLanguageVersionString.str());
}

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

@ -16,7 +16,7 @@
#include <GLSLANG/ShaderVars.h>
#include <anglebase/sha1.h>
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "common/utilities.h"
#include "libANGLE/BinaryStream.h"
#include "libANGLE/Context.h"
@ -116,7 +116,7 @@ void MemoryProgramCache::ComputeHash(const Context *context,
}
// Add some ANGLE metadata and Context properties, such as version and back-end.
hashStream << ANGLE_COMMIT_HASH << context->getClientMajorVersion()
hashStream << angle::GetANGLECommitHash() << context->getClientMajorVersion()
<< context->getClientMinorVersion() << context->getString(GL_RENDERER);
// Hash pre-link program properties.

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

@ -12,7 +12,7 @@
#include <algorithm>
#include <utility>
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "common/bitset_utils.h"
#include "common/debug.h"
#include "common/platform.h"
@ -4635,8 +4635,8 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
{
BinaryOutputStream stream;
stream.writeBytes(reinterpret_cast<const unsigned char *>(ANGLE_COMMIT_HASH),
ANGLE_COMMIT_HASH_SIZE);
stream.writeBytes(reinterpret_cast<const unsigned char *>(angle::GetANGLECommitHash()),
angle::GetANGLECommitHashSize());
// nullptr context is supported when computing binary length.
if (context)
@ -4716,7 +4716,7 @@ angle::Result Program::serialize(const Context *context, angle::MemoryBuffer *bi
}
else
{
// If we dont have an attached shader, which would occur if this program was
// If we don't have an attached shader, which would occur if this program was
// created via glProgramBinary, pull from our cached copy
const angle::ProgramSources &cachedLinkedSources =
context->getShareGroup()->getFrameCaptureShared()->getProgramSources(id());
@ -4744,10 +4744,9 @@ angle::Result Program::deserialize(const Context *context,
BinaryInputStream &stream,
InfoLog &infoLog)
{
unsigned char commitString[ANGLE_COMMIT_HASH_SIZE];
stream.readBytes(commitString, ANGLE_COMMIT_HASH_SIZE);
if (memcmp(commitString, ANGLE_COMMIT_HASH, sizeof(unsigned char) * ANGLE_COMMIT_HASH_SIZE) !=
0)
std::vector<uint8_t> commitString(angle::GetANGLECommitHashSize(), 0);
stream.readBytes(commitString.data(), commitString.size());
if (memcmp(commitString.data(), angle::GetANGLECommitHash(), commitString.size()) != 0)
{
infoLog << "Invalid program binary version.";
return angle::Result::Stop;

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

@ -16,7 +16,7 @@
#include "sys/stat.h"
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "common/mathutil.h"
#include "common/serializer/JsonSerializer.h"
#include "common/string_utils.h"
@ -6034,7 +6034,7 @@ void FrameCaptureShared::writeCppReplayIndexFiles(const gl::Context *context,
JsonSerializer json;
json.startGroup("TraceMetadata");
json.addScalar("CaptureRevision", ANGLE_REVISION);
json.addScalar("CaptureRevision", GetANGLERevision());
json.addScalar("ContextClientMajorVersion", context->getClientMajorVersion());
json.addScalar("ContextClientMinorVersion", context->getClientMinorVersion());
json.addHexValue("DisplayPlatformType", displayAttribs.getAsInt(EGL_PLATFORM_ANGLE_TYPE_ANGLE));

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

@ -40,6 +40,7 @@ angle_source_set("angle_cl_backend") {
sources = _cl_backend_sources
public_deps = [
"$angle_root:angle_version_info",
"$angle_root:libANGLE_headers",
"$angle_root/third_party/OpenCL-ICD-Loader:opencl_icd_loader",
]

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

@ -7,15 +7,13 @@
#include "libANGLE/renderer/cl/CLPlatformCL.h"
#include "libANGLE/renderer/cl/CLContextCL.h"
#include "libANGLE/renderer/cl/CLDeviceCL.h"
#include "libANGLE/renderer/cl/cl_util.h"
#include "common/angle_version_info.h"
#include "libANGLE/CLContext.h"
#include "libANGLE/CLDevice.h"
#include "libANGLE/CLPlatform.h"
#include "common/angle_version.h"
#include "libANGLE/renderer/cl/CLContextCL.h"
#include "libANGLE/renderer/cl/CLDeviceCL.h"
#include "libANGLE/renderer/cl/cl_util.h"
extern "C" {
#include "icd.h"
@ -173,7 +171,7 @@ CLPlatformImpl::Info CLPlatformCL::createInfo() const
}
// Customize version string and name
info.versionStr += " (ANGLE " ANGLE_VERSION_STRING ")";
info.versionStr += std::string(" (ANGLE ") + angle::GetANGLEVersionString() + ")";
info.name.insert(0u, "ANGLE pass-through -> ");
if (version >= CL_MAKE_VERSION(2, 1, 0) &&

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

@ -264,6 +264,10 @@ angle_source_set("angle_vulkan_backend") {
"$angle_spirv_headers_dir:spv_headers",
]
if (angle_enable_cl || is_android) {
deps += [ "$angle_root:angle_version_info" ]
}
public_deps = [
"$angle_root:angle_glslang_wrapper",
"$angle_root:libANGLE_headers",

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

@ -12,7 +12,7 @@
#include "libANGLE/CLPlatform.h"
#include "anglebase/no_destructor.h"
#include "common/angle_version.h"
#include "common/angle_version_info.h"
namespace rx
{
@ -98,7 +98,8 @@ const std::string &CLPlatformVk::GetVersionString()
{
static const angle::base::NoDestructor<const std::string> sVersion(
"OpenCL " + std::to_string(CL_VERSION_MAJOR(GetVersion())) + "." +
std::to_string(CL_VERSION_MINOR(GetVersion())) + " ANGLE " ANGLE_VERSION_STRING);
std::to_string(CL_VERSION_MINOR(GetVersion())) + " ANGLE " +
angle::GetANGLEVersionString());
return *sVersion;
}

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

@ -13,7 +13,7 @@
#include <android/native_window.h>
#include <vulkan/vulkan.h>
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "libANGLE/renderer/driver_utils.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "libANGLE/renderer/vulkan/android/HardwareBufferImageSiblingVkAndroid.h"
@ -30,7 +30,7 @@ egl::Error DisplayVkAndroid::initialize(egl::Display *display)
ANGLE_TRY(DisplayVk::initialize(display));
std::stringstream strstr;
strstr << "Version (" << ANGLE_VERSION_STRING << "), ";
strstr << "Version (" << angle::GetANGLEVersionString() << "), ";
strstr << "Renderer (" << mRenderer->getRendererDescription() << ")";
__android_log_print(ANDROID_LOG_INFO, "ANGLE", "%s", strstr.str().c_str());

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

@ -7,7 +7,6 @@
#include "entry_points_wgl.h"
#include "common/angle_version.h"
#include "common/debug.h"
#include "common/event_tracer.h"
#include "common/utilities.h"

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

@ -625,10 +625,6 @@ libglesv2_cl_sources = [
"src/libGLESv2/proc_table_cl_autogen.cpp",
]
if (is_win) {
libglesv2_sources += [ "src/libGLESv2/libGLESv2.rc" ]
}
libglesv1_cm_sources = [
"src/libGLESv1_CM/libGLESv1_CM.cpp",
"src/libGLESv1_CM/resource.h",
@ -645,7 +641,3 @@ libegl_sources = [
"src/libGLESv2/entry_points_egl_autogen.h",
"src/libGLESv2/entry_points_egl_ext_autogen.h",
]
if (is_win) {
libegl_sources += [ "src/libEGL/libEGL.rc" ]
}

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

@ -8,7 +8,7 @@
#include "libGLESv2/egl_stubs_autogen.h"
#include "common/angle_version.h"
#include "common/angle_version_info.h"
#include "libANGLE/Context.h"
#include "libANGLE/Display.h"
#include "libANGLE/EGLSync.h"
@ -534,8 +534,12 @@ const char *QueryString(Thread *thread, Display *display, EGLint name)
result = display->getVendorString().c_str();
break;
case EGL_VERSION:
result = "1.5 (ANGLE " ANGLE_VERSION_STRING ")";
{
static const char *sVersionString =
MakeStaticString(std::string("1.5 (ANGLE ") + angle::GetANGLEVersionString() + ")");
result = sVersionString;
break;
}
default:
UNREACHABLE();
break;