build2-packaging / imgui

Build2 package for imgui
Other
2 stars 5 forks source link

Improve glue buildfile #13

Closed boris-kolpackov closed 1 year ago

boris-kolpackov commented 1 year ago

Currently the glue buildfile in the root of the imgui repository loads the cxx module and then decides which packages to load based on its cxx.target.class value. Here is what it looks like:

import pkgs = {libimgui/ libimgui-platform-glfw/ libimgui-render-opengl2/ libimgui-render-opengl3/ libimgui-render-vulkan/ libimgui-examples/}

using cxx

switch $cxx.target.class
{
    case 'windows'
    {
        import pkgs += {libimgui-platform-win32/ libimgui-render-dx9/ libimgui-render-dx10/ libimgui-render-dx11/ libimgui-render-dx12/}
    }
    case 'macos'
    {
        import pkgs += {libimgui-platform-osx/ libimgui-render-metal/}
    }
}

./: $pkgs

The problem with this approach is that, when used together with bdep, the packages could be configured for a different compiler (and thus target). But this can be fixed relatively easily by instead querying cxx.target.class from the libimgui package:

import pkgs = libhello/

libimgui = [dir_path] $pkgs

import pkgs += libimgui-platform-glfw/ libimgui-render-opengl2/ libimgui-render-opengl3/ libimgui-render-vulkan/ libimgui-examples/

switch $($libimgui/ cxx.target.class)

...
Rookfighter commented 1 year ago

Done.