Skip to content

Commit 0c82e2b

Browse files
authored
Update leveldb 1.22 patch to fix a compiler issue, and avoid trying to patch twice. (#11292)
Add a build stamp file to ensure that leveldb is only patched once.
1 parent 52ebbbf commit 0c82e2b

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

cmake/external/leveldb-1.22_windows_paths.patch

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/util/env_windows.cc b/util/env_windows.cc
2-
index 09e3df6..23d60f1 100644
2+
index 09e3df6..5d9b2f2 100644
33
--- a/util/env_windows.cc
44
+++ b/util/env_windows.cc
55
@@ -362,9 +362,11 @@ class WindowsEnv : public Env {
@@ -118,7 +118,7 @@ index 09e3df6..23d60f1 100644
118118
DWORD last_error = ::GetLastError();
119119
::FindClose(dir_handle);
120120
if (last_error != ERROR_NO_MORE_FILES) {
121-
@@ -482,13 +496,16 @@ class WindowsEnv : public Env {
121+
@@ -482,21 +496,24 @@ class WindowsEnv : public Env {
122122
}
123123

124124
Status DeleteFile(const std::string& fname) override {
@@ -131,12 +131,12 @@ index 09e3df6..23d60f1 100644
131131
}
132132

133133
Status CreateDir(const std::string& name) override {
134+
- if (!::CreateDirectoryA(name.c_str(), nullptr)) {
134135
+ auto wDirname = toUtf16(name);
135136
+ if (!::CreateDirectoryW(wDirname.c_str(), nullptr)) {
136-
if (!::CreateDirectoryA(name.c_str(), nullptr)) {
137137
return WindowsError(name, ::GetLastError());
138138
}
139-
@@ -496,7 +513,8 @@ class WindowsEnv : public Env {
139+
return Status::OK();
140140
}
141141

142142
Status DeleteDir(const std::string& name) override {
@@ -146,7 +146,7 @@ index 09e3df6..23d60f1 100644
146146
return WindowsError(name, ::GetLastError());
147147
}
148148
return Status::OK();
149-
@@ -504,7 +522,9 @@ class WindowsEnv : public Env {
149+
@@ -504,7 +521,9 @@ class WindowsEnv : public Env {
150150

151151
Status GetFileSize(const std::string& fname, uint64_t* size) override {
152152
WIN32_FILE_ATTRIBUTE_DATA attrs;
@@ -157,7 +157,7 @@ index 09e3df6..23d60f1 100644
157157
return WindowsError(fname, ::GetLastError());
158158
}
159159
ULARGE_INTEGER file_size;
160-
@@ -518,7 +538,9 @@ class WindowsEnv : public Env {
160+
@@ -518,7 +537,9 @@ class WindowsEnv : public Env {
161161
const std::string& target) override {
162162
// Try a simple move first. It will only succeed when |to_path| doesn't
163163
// already exist.
@@ -168,7 +168,7 @@ index 09e3df6..23d60f1 100644
168168
return Status::OK();
169169
}
170170
DWORD move_error = ::GetLastError();
171-
@@ -527,7 +549,7 @@ class WindowsEnv : public Env {
171+
@@ -527,7 +548,7 @@ class WindowsEnv : public Env {
172172
// succeed when |to_path| does exist. When writing to a network share, we
173173
// may not be able to change the ACLs. Ignore ACL errors then
174174
// (REPLACEFILE_IGNORE_MERGE_ERRORS).
@@ -177,7 +177,7 @@ index 09e3df6..23d60f1 100644
177177
REPLACEFILE_IGNORE_MERGE_ERRORS, nullptr, nullptr)) {
178178
return Status::OK();
179179
}
180-
@@ -546,8 +568,9 @@ class WindowsEnv : public Env {
180+
@@ -546,8 +567,9 @@ class WindowsEnv : public Env {
181181
Status LockFile(const std::string& fname, FileLock** lock) override {
182182
*lock = nullptr;
183183
Status result;
@@ -189,7 +189,7 @@ index 09e3df6..23d60f1 100644
189189
/*lpSecurityAttributes=*/nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
190190
nullptr);
191191
if (!handle.is_valid()) {
192-
@@ -584,10 +607,11 @@ class WindowsEnv : public Env {
192+
@@ -584,10 +606,11 @@ class WindowsEnv : public Env {
193193
return Status::OK();
194194
}
195195

@@ -203,7 +203,7 @@ index 09e3df6..23d60f1 100644
203203
std::stringstream ss;
204204
ss << tmp_path << "leveldbtest-" << std::this_thread::get_id();
205205
*result = ss.str();
206-
@@ -598,7 +622,8 @@ class WindowsEnv : public Env {
206+
@@ -598,7 +621,8 @@ class WindowsEnv : public Env {
207207
}
208208

209209
Status NewLogger(const std::string& filename, Logger** result) override {
@@ -213,7 +213,7 @@ index 09e3df6..23d60f1 100644
213213
if (fp == nullptr) {
214214
*result = nullptr;
215215
return WindowsError("NewLogger", ::GetLastError());
216-
@@ -640,6 +665,31 @@ class WindowsEnv : public Env {
216+
@@ -640,6 +664,31 @@ class WindowsEnv : public Env {
217217
bool started_bgthread_;
218218
std::deque<BGItem> queue_;
219219
Limiter mmap_limiter_;

cmake/external/leveldb_patch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ def main() -> None:
5353
with cmakelists_txt_file.open("wt", encoding="utf8") as f:
5454
f.writelines(patched_lines)
5555

56-
if additional_patch_file:
56+
additional_patch_stamp = 'leveldb_additional_patch_stamp'
57+
if additional_patch_file and not os.path.exists(additional_patch_stamp):
58+
print("Applying patch %s" % additional_patch_file)
5759
subprocess.run(['git', 'apply', '-v', additional_patch_file],
5860
check=True)
61+
# Create a stamp file so the patch isn't applied twice.
62+
open(additional_patch_stamp, 'a').close()
5963

6064

6165
@dataclasses.dataclass(frozen=True)

0 commit comments

Comments
 (0)