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

Add DIA SDK dependency #13638

Merged
merged 6 commits into from
Sep 21, 2024
Merged

Add DIA SDK dependency #13638

merged 6 commits into from
Sep 21, 2024

Conversation

vid512
Copy link
Contributor

@vid512 vid512 commented Sep 5, 2024

Solves: #13627

Tested on Windows with [msvc, clang_cl], building [x86, x86_64, arm, aarch64] targets (latter two via cross-compiling). AFAIK this is all that DIA SDK supports.

Possible issues:

  1. Version of dependency is not provided. The only way I could find would require us to drag in some library for parsing the version out of msdiaXXX.dll resources.

  2. Should the dependency be named 'dia' or 'diasdk'? I am afraid the name 'dia' may be too generic and may conflict with something else in future. This library in particular is very commonly called 'DIA SDK', including the 'SDK' part, maybe for the very same reason.

  3. Trickiest part is how to allow users to copy the runtime DLL to build directory, if they want to. This is not strictly required, but a very nice practical feature, without which an application must ask its users to manually register some DLL somewhere inside Program Files from admin console. To provide a better option, the dependency needs to return DLL path to meson.build script. I may have abused dependency variables here a bit. Currently this dependency returns a "internal" variable 'dll' (despite "internal" variables being only used with internal dependencies?). I am not aware of any other way to return such value from dependency. It works like this:

dia = dependency('diasdk', required: true)
dia_dll_name = dia.get_variable(internal: 'dll')
fs = import('fs')
fs.copyfile( dia_dll_name )

conf = configuration_data()
conf.set('msdia_dll_name', fs.name(dia_dll_name))
configure_file(input: 'config.h.in', output: 'config.h', configuration: conf)

executable('dia_from_dll', ['dia_from_dll.cpp'], dependencies: [dia])

Not sure if this is tolerable, or if there is some better way.

mesonbuild/dependencies/dev.py Fixed Show fixed Hide fixed
mesonbuild/dependencies/dev.py Fixed Show fixed Hide fixed
mesonbuild/dependencies/dev.py Fixed Show fixed Hide fixed
@@ -0,0 +1,8 @@
project('diatest', 'cpp')
Copy link
Member

Choose a reason for hiding this comment

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

I think you should rather add the tests to test cases/windows instead of creating a new test category

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think Windows would be appropriate. The other option would be frameworks

@bruchar1 bruchar1 added the OS:windows Winodows OS specific issues label Sep 6, 2024
Copy link
Member

@dcbaker dcbaker 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 pretty good, I've got a few things we could fix up though

mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
@@ -0,0 +1,8 @@
project('diatest', 'cpp')
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think Windows would be appropriate. The other option would be frameworks

test cases/diasdk/1 simple/meson.build Outdated Show resolved Hide resolved
docs/markdown/Dependencies.md Show resolved Hide resolved
@vid512
Copy link
Contributor Author

vid512 commented Sep 7, 2024

All requested changes should now be incorporated. Sorry for chaos with commits & reverts - still learning.

I had to do detection of MSVC 'clang' (not 'clang-cl') compiler in a bit more complicated manner, in order to differentiate MSVC clang vs. MinGW clang.

In my tests, building with this dependency is still failing on x86 clang-cl, due to #13643 . Apparently Meson doesn't have a CI/CD testing for that scenario(?). As soon as that issue gets resolved, this problem should disappear as well.

@vid512 vid512 requested a review from dcbaker September 7, 2024 09:55
Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

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

I have a couple more things, mostly around the version I think we need to work out, but I think we're getting close.

mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
docs/markdown/Dependencies.md Outdated Show resolved Hide resolved
docs/markdown/snippets/dia_sdk.md Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Show resolved Hide resolved
mesonbuild/dependencies/dev.py Outdated Show resolved Hide resolved
mesonbuild/dependencies/dev.py Show resolved Hide resolved
Copy link
Member

@bruchar1 bruchar1 left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 768 to 769
mlog.error('DIA SDK is only supported in C and C++ projects')
return
Copy link
Member

Choose a reason for hiding this comment

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

You can raise DependencyException('DIA SDK is ....') here instead, and meson will make it look like this:

Dependency lookup for diasdk with method 'system' failed: DIA SDK is only supported in C and C++ projects

Comment on lines 797 to 805
def get_variable(self, *, cmake: T.Optional[str] = None, pkgconfig: T.Optional[str] = None,
configtool: T.Optional[str] = None, internal: T.Optional[str] = None,
default_value: T.Optional[str] = None,
pkgconfig_define: PkgConfigDefineType = None) -> str:
if internal == 'dll':
return self.dll
if default_value is not None:
return default_value
raise DependencyException(f'Cannot get variable {internal}')
Copy link
Member

Choose a reason for hiding this comment

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

I... get what this is trying to do, but it still seems weird. :D

@dcbaker this is a system dependency piggybacking onto the mechanism for declare_dependency(variables: [...]) support?

Do we want to extend the get_variable interface to cope with system dependencies? consider them equivalent to configtool or internal? Simply expect them to use get_variable('dll') without a type-specific request?

Copy link
Member

@dcbaker dcbaker Sep 17, 2024

Choose a reason for hiding this comment

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

I would prefer to extend with system type. I still think the no type selection thing is an anti-feature, it lulls people into a false sense of "everything will work right all the time!" and it only happens to work in the case of pkg-config and wraps, but keeps them from even thinking about the less common cases like cmake.

endif

dia = dependency('diasdk', required: true)
dia_dll_name = dia.get_variable(internal: 'dll')
Copy link
Member

Choose a reason for hiding this comment

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

You don't need "internal" here. The get_variable() method accepts a generic variable name, and a type-specific one. The latter is intended to be useful for cases where e.g. the same information is available via both pkg-config and cmake but the name of the pkg-config variable is different from the name of the cmake variable.

(e.g. because cmake loves capitalized variable names.)

It is therefore necessary to pass a different name into get_variable() depending on which type of dependency was found -- or use dep.get_variable(pkgconfig: 'foo', cmake: 'FOO')

@dcbaker dcbaker merged commit dbad301 into mesonbuild:master Sep 21, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:windows Winodows OS specific issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants