Skip to content

Conversation

@jessey-git
Copy link
Contributor

Description

This change embeds version information into our Windows binaries. This is done by ways of a version_win32.rc resource file[1] populated at CMake configure time with our major.minor.patch version information.

This not only allows at a glance to discover what version a particular OIIO binary is (see screenshot), but it also impacts certain MSI installer behaviors. If this is a MSI install which updates a prior installation, and the shared libs/dlls don't have version information, then the installer assumes the binaries are equal and just skips them. This can be problematic for applications that package OIIO etc.

Old on left, New on right:
old-vs-new

[1] https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource

Checklist:

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • If I added or modified a C++ API call, I have also amended the
    corresponding Python bindings (and if altering ImageBufAlgo functions, also
    exposed the new functionality as oiiotool options).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

@jessey-git jessey-git requested review from ThiagoIze and lgritz April 10, 2025 17:11
@lgritz
Copy link
Collaborator

lgritz commented Apr 12, 2025

Thanks, I never would have known how to do this, or even that it was a thing.

It looks fine to me, inasmuch as it's all enclosed in if (WIN32) so can't break any other platforms, and CI passes including on Windows.

But I'm not qualified to know if you've done it right. Would anybody else like to get their eyes on this and weigh in? (I will merge it in a couple days unless somebody objects.)

Should we have something in the testsuite (obviously that only runs for Windows) that validates this in some way? You posted a screenshot from a GUI tool, but is there anything scriptable that can extract that information from the libraries and compare to a reference output, so we can be sure via CI that we don't break this in the future?

Copy link
Collaborator

@ThiagoIze ThiagoIze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks essentially good to me. There's a few parts where I don't know enough about this to say if it's totally right. For instance, VarFileInfo is listed as 1252. Why that instead of 1200, which is unicode? I don't know the answer. Maybe it doesn't really matter for our purposes?

I'm approving on the assumption that this is working properly for you in Windows. I do like what the new properties window is showing.

@jessey-git
Copy link
Contributor Author

Should we have something in the testsuite (obviously that only runs for Windows) that validates this in some way?

It's trivially accessible using Powershell. Let me see if I can make it work somehow.

@jessey-git
Copy link
Contributor Author

This looks essentially good to me. There's a few parts where I don't know enough about this to say if it's totally right. For instance, VarFileInfo is listed as 1252. Why that instead of 1200, which is unicode? I don't know the answer. Maybe it doesn't really matter for our purposes?

It's a good question that I can't find a definitive answer to. The VarFileInfo block relates to the StringFileInfo block above it; i.e. the 0x409, 1252 == 040904E4 once both fields are hex'd. I think this is basically used to provide language-specific strings in the File properties box if the user happens to be running Windows in a different locale. Like if the description of the application had translatable elements in it. I honestly don't know if its better or worse to use Unicode for this one :-/

@jessey-git
Copy link
Contributor Author

Alright, added a test to verify the embedded version information and that seems to pass. Here's 2 examples of what you might see from the output of the script during both a Pass and a Fail:

Pass

182: Test command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "C:/Users/jesse/source/OpenImageIO/testsuite/win32/version_check.ps1" "C:/Users/jesse/source/OpenImageIO/build/bin/RelWithDebInfo/" "3.1.1.0"
182: Working Directory: C:/Users/jesse/source/OpenImageIO/build/src/libOpenImageIO
182: Test timeout computed to be: 1500
182: Arguments : C:/Users/jesse/source/OpenImageIO/build/bin/RelWithDebInfo/ 3.1.1.0
182: Expected : OpenImageIO|3.1.1.0|3.1
182: Actual   : OpenImageIO|3.1.1.0|3.1
182:          : OpenImageIO|3.1.1.0|3.1
1/1 Test #182: win32_versioning .................   Passed    0.43 sec

Fail

182: Test command: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe "C:/Users/jesse/source/OpenImageIO/testsuite/win32/version_check.ps1" "C:/Users/jesse/source/OpenImageIO/build/bin/RelWithDebInfo/" "3.1.1.0"
182: Working Directory: C:/Users/jesse/source/OpenImageIO/build/src/libOpenImageIO
182: Test timeout computed to be: 1500
182: Arguments : C:/Users/jesse/source/OpenImageIO/build/bin/RelWithDebInfo/ 3.2.0.0
182: Expected : OpenImageIO|3.2.0.0|3.2
182: Actual   : OpenImageIO|3.1.1.0|3.1
182:          : OpenImageIO|3.1.1.0|3.1
1/1 Test #182: win32_versioning .................***Failed    0.43 sec

Copy link
Collaborator

@lgritz lgritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lgritz lgritz merged commit e43fada into AcademySoftwareFoundation:main Apr 14, 2025
28 checks passed
lgritz pushed a commit to lgritz/OpenImageIO that referenced this pull request Apr 16, 2025
…emySoftwareFoundation#4696)

This change embeds version information into our Windows binaries. This
is done by ways of a `version_win32.rc` resource file[1] populated at
CMake configure time with our major.minor.patch version information.

This not only allows at a glance to discover what version a particular
OIIO binary is (see screenshot), but it also impacts certain MSI
installer behaviors. If this is a MSI install which updates a prior
installation, and the shared libs/dlls don't have version information,
then the installer assumes the binaries are equal and just skips them.
This can be problematic for applications that package OIIO etc.

Old on left, New on right:

![old-vs-new](https://github.com/user-attachments/assets/2ff354ab-54a9-4dfb-8d97-90b138472bd7)

[1]
https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 17, 2025
…emySoftwareFoundation#4696)

This change embeds version information into our Windows binaries. This
is done by ways of a `version_win32.rc` resource file[1] populated at
CMake configure time with our major.minor.patch version information.

This not only allows at a glance to discover what version a particular
OIIO binary is (see screenshot), but it also impacts certain MSI
installer behaviors. If this is a MSI install which updates a prior
installation, and the shared libs/dlls don't have version information,
then the installer assumes the binaries are equal and just skips them.
This can be problematic for applications that package OIIO etc.

Old on left, New on right:

![old-vs-new](https://github.com/user-attachments/assets/2ff354ab-54a9-4dfb-8d97-90b138472bd7)

[1]
https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
Signed-off-by: Scott Wilson <[email protected]>
@jessey-git jessey-git deleted the dll-versioning branch May 17, 2025 22:23
scott-wilson pushed a commit to scott-wilson/OpenImageIO that referenced this pull request May 18, 2025
…emySoftwareFoundation#4696)

This change embeds version information into our Windows binaries. This
is done by ways of a `version_win32.rc` resource file[1] populated at
CMake configure time with our major.minor.patch version information.

This not only allows at a glance to discover what version a particular
OIIO binary is (see screenshot), but it also impacts certain MSI
installer behaviors. If this is a MSI install which updates a prior
installation, and the shared libs/dlls don't have version information,
then the installer assumes the binaries are equal and just skips them.
This can be problematic for applications that package OIIO etc.

Old on left, New on right:

![old-vs-new](https://github.com/user-attachments/assets/2ff354ab-54a9-4dfb-8d97-90b138472bd7)

[1]
https://learn.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource

---------

Signed-off-by: Jesse Yurkovich <[email protected]>
Signed-off-by: Scott Wilson <[email protected]>
@lgritz lgritz added the build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration. label Jul 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build / testing / port / CI Affecting the build system, tests, platform support, porting, or continuous integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants