Skip to content

Commit 765d564

Browse files
committed
Improve number and content of comments
1 parent 5d860db commit 765d564

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

sdl2-sys/build.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,32 @@ fn download_sdl2() -> PathBuf {
117117
// apply patches to sdl2 source
118118
#[cfg(feature = "bundled")]
119119
fn patch_sdl2(sdl2_source_path: &Path) {
120+
// vector of <(patch_file_name, patch_file_contents)>
120121
let patches: Vec<(&str, &'static str)> = vec![
121-
("SDL2-2.0.8-4234-mac-os-dylib-fix.patch",
122-
include_str!("patches/SDL2-2.0.8-4234-mac-os-dylib-fix.patch")),
122+
// This patch fixes a CMake installation bug introduced in SDL2 2.0.4 on
123+
// the Mac OS platform. Without this patch, the libSDL2.dylib generated
124+
// during the SDL2 build phase will be overwritten by a symlink pointing
125+
// to nothing. A variation of this patch was accepted upstream and
126+
// should be included in SDL2 2.0.9.
127+
// https://bugzilla.libsdl.org/show_bug.cgi?id=4234
128+
("SDL2-2.0.8-4234-mac-os-dylib-fix.patch", include_str!("patches/SDL2-2.0.8-4234-mac-os-dylib-fix.patch")),
123129
];
124130
let sdl_version = format!("SDL2-{}", LASTEST_SDL2_VERSION);
125131

126132
for patch in &patches {
127-
// Only apply patches that apply to the current version of SDL2
133+
// Only apply patches whose file name is prefixed with the currently
134+
// targeted version of SDL2.
128135
if !patch.0.starts_with(&sdl_version) {
129136
continue;
130137
}
131138
let mut patch_set = unidiff::PatchSet::new();
132139
patch_set.parse(patch.1).expect("Error parsing diff");
133140

141+
// For every modified file, copy the existing file to <file_name>_old,
142+
// open a new copy of <file_name>. and fill the new file with a
143+
// combination of the unmodified contents, and the patched sections.
144+
// TOOD: This code is untested (save for the immediate application), and
145+
// probably belongs in the unidiff (or similar) package.
134146
for modified_file in patch_set.modified_files() {
135147
use std::io::{Write, BufRead};
136148

@@ -183,6 +195,7 @@ fn patch_sdl2(sdl2_source_path: &Path) {
183195
dst_buf.write_all(b"\n").unwrap();
184196
}
185197
}
198+
// For every removed file, simply delete the original.
186199
// TODO: This is entirely untested code. There are likely bugs here, and
187200
// this really should be part of the unidiff library, not a function
188201
// defined here. Hopefully this gets moved somewhere else before it
@@ -194,6 +207,8 @@ fn patch_sdl2(sdl2_source_path: &Path) {
194207
removed_file.path(),
195208
sdl2_source_path.to_string_lossy()));
196209
}
210+
// For every new file, copy the entire contents of the patched file into
211+
// a newly created <file_name>.
197212
// TODO: This is entirely untested code. There are likely bugs here, and
198213
// this really should be part of the unidiff library, not a function
199214
// defined here. Hopefully this gets moved somewhere else before it

0 commit comments

Comments
 (0)