Skip to content

Commit

Permalink
[openimageio] fix build on vs2019 and earlier (#28885)
Browse files Browse the repository at this point in the history
* [openimageio] fix build on vs2019 and earlier

update port-version

* ./vcpkg x-add-version --all

* ./vcpkg x-add-version --all --overwrite-version
  • Loading branch information
russelltg committed Jan 13, 2023
1 parent 34ddfbb commit 92225e6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
20 changes: 20 additions & 0 deletions ports/openimageio/fix-vs2019-encoding-conversion.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/src/libutil/strutil.cpp b/src/libutil/strutil.cpp
index 129a9b5..09baea8 100644
--- a/src/libutil/strutil.cpp
+++ b/src/libutil/strutil.cpp
@@ -914,8 +914,15 @@ std::string
Strutil::utf16_to_utf8(const std::u16string& str) noexcept
{
try {
+ // https://stackoverflow.com/a/35103224
+#if defined _MSC_VER && _MSC_VER >= 1900 && _MSC_VER < 1930
+ std::wstring_convert<std::codecvt_utf8_utf16<int16_t>, int16_t> convert;
+ auto p = reinterpret_cast<const int16_t *>(str.data());
+ return convert.to_bytes(p, p + str.size());
+#else
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> conv;
return conv.to_bytes(str);
+#endif
} catch (const std::exception&) {
return std::string();
}
1 change: 1 addition & 0 deletions ports/openimageio/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ vcpkg_from_github(
fix-openexr-dll.patch
imath-version-guard.patch
fix-openimageio_include_dir.patch
fix-vs2019-encoding-conversion.patch
)

file(REMOVE_RECURSE "${SOURCE_PATH}/ext")
Expand Down
1 change: 1 addition & 0 deletions ports/openimageio/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "openimageio",
"version": "2.4.5.0",
"port-version": 1,
"description": "A library for reading and writing images, and a bunch of related classes, utilities, and application.",
"homepage": "https://github.com/OpenImageIO/oiio",
"license": "BSD-3-Clause",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5606,7 +5606,7 @@
},
"openimageio": {
"baseline": "2.4.5.0",
"port-version": 0
"port-version": 1
},
"openjpeg": {
"baseline": "2.5.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/o-/openimageio.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "ecd81b1df58bf0fb628ad86bfde7522e36a602e4",
"version": "2.4.5.0",
"port-version": 1
},
{
"git-tree": "74ab484049a78fea2929dc9afc4ae5a6b9b2dd45",
"version": "2.4.5.0",
Expand Down

0 comments on commit 92225e6

Please sign in to comment.