aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Huang <huangs@chromium.org>2021-11-17 16:20:51 +0000
committerCopybara-Service <copybara-worker@google.com>2021-11-17 08:30:34 -0800
commit9a6bb5673d3441e0aee2c3e79e6dec027840d7e1 (patch)
tree9632b83864a5bfed66ed8d8254b906e4afea707d
parent261f4df0801de80106dd28a47914131c9b897058 (diff)
downloadzucchini-9a6bb5673d3441e0aee2c3e79e6dec027840d7e1.tar.gz
[Zucchini] Move version info to a separate file.
This CL moves zucchini::{kMajorVersion, kMinorVersion, kInvalidVersion} to a standalone file version_info.h. The location should remain stable. Stability is important so that: * External tools can determine Zucchini versoin from source, i.e., the file serves as an implicit API. * Running 'git log' on version_info.h will point to CLs that implement or enable patch break changes. Bug: 1231882 Change-Id: I13243a5627870a31d8789d3579f1a50cc0e52bd5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3287124 Commit-Queue: Samuel Huang <huangs@chromium.org> Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/main@{#942645} NOKEYCHECK=True GitOrigin-RevId: 0b4473c4e1683729ac9f81257ba48e1d3e34418f
-rw-r--r--BUILD.gn1
-rw-r--r--element_detection.cc2
-rw-r--r--main_utils.cc2
-rw-r--r--patch_read_write_unittest.cc1
-rw-r--r--patch_reader.cc1
-rw-r--r--patch_utils.h12
-rw-r--r--patch_writer.cc1
-rw-r--r--version_info.h30
8 files changed, 37 insertions, 13 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 54b06ab..9fa2ea9 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -97,6 +97,7 @@ static_library("zucchini_lib") {
"type_elf.h",
"type_win_pe.h",
"typed_value.h",
+ "version_info.h",
"zucchini.h",
"zucchini_apply.cc",
"zucchini_apply.h",
diff --git a/element_detection.cc b/element_detection.cc
index 5548610..2d260e4 100644
--- a/element_detection.cc
+++ b/element_detection.cc
@@ -9,7 +9,7 @@
#include "components/zucchini/buildflags.h"
#include "components/zucchini/disassembler.h"
#include "components/zucchini/disassembler_no_op.h"
-#include "components/zucchini/patch_utils.h"
+#include "components/zucchini/version_info.h"
#if BUILDFLAG(ENABLE_DEX)
#include "components/zucchini/disassembler_dex.h"
diff --git a/main_utils.cc b/main_utils.cc
index b499817..48b52e1 100644
--- a/main_utils.cc
+++ b/main_utils.cc
@@ -22,7 +22,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/zucchini/io_utils.h"
-#include "components/zucchini/patch_utils.h"
+#include "components/zucchini/version_info.h"
#include "components/zucchini/zucchini_commands.h"
#if defined(OS_WIN)
diff --git a/patch_read_write_unittest.cc b/patch_read_write_unittest.cc
index 25e1fb0..cce590d 100644
--- a/patch_read_write_unittest.cc
+++ b/patch_read_write_unittest.cc
@@ -11,6 +11,7 @@
#include <utility>
#include <vector>
+#include "components/zucchini/version_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace zucchini {
diff --git a/patch_reader.cc b/patch_reader.cc
index 8fd9b57..50ee199 100644
--- a/patch_reader.cc
+++ b/patch_reader.cc
@@ -11,6 +11,7 @@
#include "components/zucchini/algorithm.h"
#include "components/zucchini/crc32.h"
#include "components/zucchini/element_detection.h"
+#include "components/zucchini/version_info.h"
namespace zucchini {
diff --git a/patch_utils.h b/patch_utils.h
index 822fedc..82b2b48 100644
--- a/patch_utils.h
+++ b/patch_utils.h
@@ -11,20 +11,10 @@
#include <type_traits>
#include "components/zucchini/image_utils.h"
+#include "components/zucchini/version_info.h"
namespace zucchini {
-// A change in major version indicates breaking changes such that a patch
-// definitely cannot be applied by a zucchini binary whose major version doesn't
-// match.
-enum : uint16_t { kMajorVersion = 1 };
-// A change in minor version indicates possibly breaking changes at the element
-// level, such that it may not be possible to apply a patch whose minor version
-// doesn't match this version. To determine if a given patch may be applied with
-// this version, VerifyPatch() should be called.
-enum : uint16_t { kMinorVersion = 0 };
-enum : uint16_t { kInvalidVersion = 0xffff };
-
// A Zucchini 'ensemble' patch is the concatenation of a patch header with a
// list of patch 'elements', each containing data for patching individual
// elements.
diff --git a/patch_writer.cc b/patch_writer.cc
index 04f3244..186ece8 100644
--- a/patch_writer.cc
+++ b/patch_writer.cc
@@ -11,6 +11,7 @@
#include "base/numerics/safe_conversions.h"
#include "components/zucchini/crc32.h"
#include "components/zucchini/element_detection.h"
+#include "components/zucchini/version_info.h"
namespace zucchini {
diff --git a/version_info.h b/version_info.h
new file mode 100644
index 0000000..c6d2fac
--- /dev/null
+++ b/version_info.h
@@ -0,0 +1,30 @@
+// Copyright 2021 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.
+
+#ifndef COMPONENTS_ZUCCHINI_VERSION_INFO_H_
+#define COMPONENTS_ZUCCHINI_VERSION_INFO_H_
+
+// This file serves as a stable location for main Zucchini version constants,
+// whose names and types should also be stable. These allow external tools to
+// determine Zucchini version at compile time by inclusion or parsing.
+
+namespace zucchini {
+
+// A change in major version indicates breaking changes such that a patch
+// definitely cannot be applied by a zucchini binary whose major version doesn't
+// match.
+enum : uint16_t { kMajorVersion = 1 };
+
+// A change in minor version indicates possibly breaking changes at the element
+// level, such that it may not be possible to apply a patch whose minor version
+// doesn't match this version. To determine if a given patch may be applied with
+// this version, VerifyPatch() should be called.
+enum : uint16_t { kMinorVersion = 0 };
+
+// A empty or error value for major or minor version numbers.
+enum : uint16_t { kInvalidVersion = 0xffff };
+
+} // namespace zucchini
+
+#endif // COMPONENTS_ZUCCHINI_VERSION_INFO_H_