Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[imgui] Add test-engine feature #38758

Merged
merged 22 commits into from
May 29, 2024
Merged

[imgui] Add test-engine feature #38758

merged 22 commits into from
May 29, 2024

Conversation

RT2Code
Copy link
Contributor

@RT2Code RT2Code commented May 16, 2024

Add test-engine feature to the imgui port: https://github.com/ocornut/imgui_test_engine

I made it a feature because they both depend on each other to build, that's why it is a feature instead of a new port.

  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version.
  • Any fixed CI baseline entries are removed from that file.
  • Any patches that are no longer applied are deleted from the port's directory.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is added to each modified port's versions file.

@RT2Code RT2Code marked this pull request as draft May 16, 2024 09:50
@RT2Code RT2Code marked this pull request as ready for review May 16, 2024 09:58
@MonicaLiu0311 MonicaLiu0311 added the category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist label May 16, 2024
ports/imgui/portfile.cmake Show resolved Hide resolved
ports/imgui/portfile.cmake Outdated Show resolved Hide resolved
ports/imgui/portfile.cmake Outdated Show resolved Hide resolved
vcpkg_from_github(
OUT_SOURCE_PATH TEST_ENGINE_SOURCE_PATH
REPO ocornut/imgui_test_engine
REF "v${VERSION}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a test port to activate this feature?
It is easy to forget the test, or just to forget to update the SHA512 for a optional download.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't know that test ports existed, but I suppose it would be better to have one here. I added it.

@dg0yt
Copy link
Contributor

dg0yt commented May 17, 2024

Now we see how useful test ports and executables are...
With test-engine in imgui, there are two problems downstream:

  • stb definitions in test engine duplicate the definitions in downstream apps.
  • stb definitions in test engine are not relocatable.

Excerpt from milerius-sfml-imgui:

/mnt/vcpkg-ci/installed/x64-linux/include/stb_image_write.h:1617: multiple definition of `stbi_write_jpg'; /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libimguid.a(imgui_capture_tool.cpp.o):/mnt/vcpkg-ci/b/imgui/src/.6-docking-82d03bc653.clean/test-engine/thirdparty/stb/imstb_image_write.h:1519: first defined here
/usr/bin/ld: /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libsfml-graphics-s-d.a(ImageLoader.cpp.o): warning: relocation against `stbi_write_force_png_filter' in read-only section `.text'
/usr/bin/ld: /mnt/vcpkg-ci/installed/x64-linux/debug/lib/libsfml-graphics-s-d.a(ImageLoader.cpp.o): relocation R_X86_64_PC32 against symbol `stbi_write_tga_with_rle' can not be used when making a shared object; recompile with -fPIC

IMO there should be no stb definition in any lib (unless there would be a single stb lib) - that's how stb is designed.

@RT2Code RT2Code marked this pull request as draft May 19, 2024 18:04
@RT2Code
Copy link
Contributor Author

RT2Code commented May 21, 2024

I managed to make it build on all platforms. I disabled uwp support because the test-engine library uses some CRT functions which aren't supported on this platform like _wpopen. I also replaced the embedded stb lib with the one from vcpkg to better conform to the vcpkg maintainer guidelines.

One thing that I'm really unhappy with is the way that the std implementation is managed. The only way I found to make it build everywhere was to disable it for static builds, but keep it enabled for dynamic builds, which is unconsistent.

Wouldn't it be better if the stb port compiled it to a static library instead of only providing the headers and leaving the responsability of handling the implementation to the user? The macro would need to be defined only once, in the port build, and then it would act like any other static library. No multiple definitions, no need to define any macro to get the implementation.

@RT2Code RT2Code marked this pull request as ready for review May 21, 2024 21:25
WangWeiLin-MV
WangWeiLin-MV previously approved these changes May 22, 2024
Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

Choose a reason for hiding this comment

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

The port usage and features test pass with the following triplets:

  • x64-linux
  • x64-windows

Test invalid since PR updated.

@WangWeiLin-MV WangWeiLin-MV added the info:reviewed Pull Request changes follow basic guidelines label May 22, 2024
@dg0yt
Copy link
Contributor

dg0yt commented May 22, 2024

Wouldn't it be better if the stb port compiled it to a static library instead of only providing the headers and leaving the responsability of handling the implementation to the user? The macro would need to be defined only once, in the port build, and then it would act like any other static library. No multiple definitions, no need to define any macro to get the implementation.

That is also what I think. There are several such packages which claim to be header only, but actually only avoid building a proper static lib.
However I don't want to open this can of worms for packages which document another form of use.

@RT2Code
Copy link
Contributor Author

RT2Code commented May 22, 2024

I spent more time studying the stb libs and it made me reconsider what I said. Those libs have many important compile time options, and some are designed to build with static symbols to allow for separate configurations in different compile units. If we build them into a static library, we remove those options for the user, so I now think the current way vcpkg handle stb is the best.

That being said, I have found a better way to fix the multiple definition issue. As I said, some stb libs provide the option to make the symbols static instead of public in the compilation unit, and it's perfect to prevent any clash with other libraries using the same stb headers. I just added the STB_IMAGE_WRITE_STATIC macro before std_image_write.h inclusion, and now everything builds fine on every platform with no ugly hacks.

@WangWeiLin-MV WangWeiLin-MV removed the info:reviewed Pull Request changes follow basic guidelines label May 23, 2024
WangWeiLin-MV
WangWeiLin-MV previously approved these changes May 24, 2024
Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

Choose a reason for hiding this comment

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

The port usage tests pass with the following triplets:

  • x64-linux
  • x64-windows

@WangWeiLin-MV WangWeiLin-MV added the info:reviewed Pull Request changes follow basic guidelines label May 24, 2024
@RT2Code RT2Code marked this pull request as draft May 24, 2024 23:03
@RT2Code
Copy link
Contributor Author

RT2Code commented May 24, 2024

Sorry, I changed it to draft because I want to try a different approach to add this feature which could be better. I'll make a second PR and I'll explain the difference between the two versions, so you can choose the one you think is the most pertinent.

@BillyONeal
Copy link
Member

In general, ports are not expected to build tests. Can you explain what a vcpkg customer does with this option? (This might be entirely fine, I just want to understand that it is :) )

@RT2Code
Copy link
Contributor Author

RT2Code commented May 25, 2024

The test-engine library is an official component of imgui composed of two parts :

  • The test-engine itself, a test/automation system for imgui.
  • The test-suite, a collection of tests for imgui written with the test-engine.

The latter is not relevant for vcpkg, because as you said, ports are not supposed to build tests, that's why I ignore it in this port. But the test-engine can be very useful for a variety of applications. It's akin to libraries like google-test or catch2, it can be used to write your own tests for imgui, or for automation purposes. As it can simulate user inputs, it can also be used to write some kind of live tutorials, and it is also able to export the result to videos/gifs to showcase it. There's also a performance tool, and that's the feature that is lacking in the current PR that I want to try to add, but it's not easy because of a circular dependency with implot.

In a nutshell, the test-engine is a very powerful framework, adding many new features to imgui and it really should be available in vcpkg.

@RT2Code RT2Code mentioned this pull request May 27, 2024
11 tasks
@RT2Code
Copy link
Contributor Author

RT2Code commented May 27, 2024

I made the alternative PR I talked about: #38961. It is better in every way and should be preferred in my opinion, but if it is refused for whatever reason, this one serves as an alternative.

@RT2Code RT2Code marked this pull request as ready for review May 27, 2024 15:38
@RT2Code
Copy link
Contributor Author

RT2Code commented May 27, 2024

Ultimately, I was unable to make the new PR work for reasons explained here, so, except if someone knows a way to fix it, I guess this one will have to do.

versions/i-/imgui.json Outdated Show resolved Hide resolved
@vicroms vicroms marked this pull request as draft May 27, 2024 22:54
@WangWeiLin-MV WangWeiLin-MV self-requested a review May 28, 2024 01:59
@vicroms vicroms marked this pull request as ready for review May 29, 2024 08:40
@vicroms vicroms merged commit 935b5c8 into microsoft:master May 29, 2024
17 checks passed
@RT2Code RT2Code deleted the imgui branch May 29, 2024 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants