Add alternative method to use a version/git hash from a file.

- This is necessary for Chromium builds from tarballs where git is no longer available. This gives Chromium another option to create the version file when creating the tarball to accomplish the same thing.

Bug: dawn:549
Change-Id: Iffb4bf694b0df1306dd92939353422e5115346a7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94043
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Loko Kung <lokokung@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Loko Kung
2022-06-22 04:19:43 +00:00
committed by Dawn LUCI CQ
parent ef62b58cf9
commit 7d2b9d9e83
8 changed files with 65 additions and 55 deletions

View File

@@ -185,6 +185,16 @@ dawn_generator("dawn_version_gen") {
"--dawn-dir",
rebase_path("${dawn_root}", root_build_dir),
]
# We can use the explicit version file if it is generated instead of relying
# on the existence of git.
if (dawn_version_file != "") {
args += [
"--version-file",
rebase_path(dawn_version_file, root_build_dir),
]
}
outputs = [ "src/dawn/common/Version_autogen.h" ]
}

View File

@@ -95,8 +95,8 @@ BackendsBitset GetEnabledBackends() {
}
dawn::platform::CachingInterface* GetCachingInterface(dawn::platform::Platform* platform) {
if (platform != nullptr && dawn::kGitHash.size() > 0) {
return platform->GetCachingInterface(dawn::kGitHash.data(), dawn::kGitHash.size());
if (platform != nullptr && dawn::kDawnVersion.size() > 0) {
return platform->GetCachingInterface(dawn::kDawnVersion.data(), dawn::kDawnVersion.size());
}
return nullptr;
}

View File

@@ -252,7 +252,6 @@ dawn_test("dawn_unittests") {
"unittests/SystemUtilsTests.cpp",
"unittests/ToBackendTests.cpp",
"unittests/TypedIntegerTests.cpp",
"unittests/VersionTests.cpp",
"unittests/native/BlobTests.cpp",
"unittests/native/CacheKeyTests.cpp",
"unittests/native/CacheRequestTests.cpp",

View File

@@ -1,32 +0,0 @@
// Copyright 2022 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string>
#include "dawn/common/Version_autogen.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace dawn {
namespace {
using ::testing::SizeIs;
TEST(VersionTests, GitCommitHashLength) {
// Git hashes should be 40 characters long.
EXPECT_THAT(std::string(kGitHash), SizeIs(40));
}
} // namespace
} // namespace dawn