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

Can't change name_suffix/prefix for only static library in both_libraries() #4133

Open
nacho opened this issue Sep 6, 2018 · 9 comments
Open
Labels
bug OS:windows Winodows OS specific issues

Comments

@nacho
Copy link
Contributor

nacho commented Sep 6, 2018

This is what I get from the library I just ported:

Installing lmdb.dll to C:\gtk-build\gtk\x64\release\bin
Installing lmdb.pdb to C:\gtk-build\gtk\x64\release\bin
Installing lmdb.lib to C:\gtk-build\gtk\x64\release\lib
Installing lmdb.pdb to C:\gtk-build\gtk\x64\release\lib
Installing liblmdb.a to C:\gtk-build\gtk\x64\release\lib

I would expect the following:
lmdb.dll, lmdb.pdb in bin and lmdb.lib in lib for the shared library and this seems fine.

Instead for the static library I would expect:
liblmdb.lib and liblmdb.pdb both in lib

@nirbheek
Copy link
Member

nirbheek commented Sep 6, 2018

libfoo.lib is not understood by GCC or Clang as a valid syntax for static libraries, so -lfoo won't resolve to that. OTOH, MSVC has no short-cut syntax for libraries, and it accepts libfoo.a as a static library, so we always use libfoo.a.

You can override this with name_suffix: 'lib' on each target.

@nacho
Copy link
Contributor Author

nacho commented Sep 6, 2018

how about the pdb file? should we make it match the same file name?

@nacho
Copy link
Contributor Author

nacho commented Sep 6, 2018

BTW, is there any way to override only the static library one?

@nirbheek
Copy link
Member

nirbheek commented Sep 6, 2018

Hum, you're right the interaction b/w name_suffix: and both libraries is broken. I would recommend that for now you don't use that, and use two separate static_library() and shared_library() invocations. You can use foo_static.extract_all_objects() in the shared_library() instead of the sources to ensure that the objects aren't built twice.

@nirbheek nirbheek changed the title msvc both_libraries not installing the correct stuff Can't change name_suffix/prefix for only static library in both_libraries() Sep 6, 2018
@nirbheek nirbheek added bug OS:windows Winodows OS specific issues and removed support/RFC labels Sep 6, 2018
@xclaesse
Copy link
Member

xclaesse commented Sep 6, 2018

Does this means we need all those kwargs for library(): static_name_prefix, static_name_suffix, shared_name_prefix, and shared_name_suffix ?

Note that even when not build both libraries, current API is weird, because when you're using library() you don't know if you're going to build the static or shared library. Wondering if this is another case of passing different args for static and shared, just like for `c_args'. I once proposed to add an extra_args kwarg that would take a dict like:

library('foo', extra_args : {
  'static_library' : {'name_suffix' : 'lib',
                            'c_args' : '-DSTATIC_COMPILATION'},
  'shared_library' : {'name_suffix' : 'dll'},
})

@nirbheek
Copy link
Member

nirbheek commented Sep 6, 2018

dictionaries, yes, but I prefer this syntax: name_suffix : {'static': 'lib', 'shared': 'notdll'}

@xclaesse
Copy link
Member

xclaesse commented Sep 6, 2018

My idea about extra_args dictionary is to have a generic solution, and allow having a single dictionary you could pass to all/most your build targets. It would be accepted by executable(), library(), build_target(), etc.

{
  '<tagettype>' : {
    '<kwarg>' : <value>,
  },
}

@xclaesse
Copy link
Member

xclaesse commented Sep 6, 2018

I guess solution here is really similar to what @nirbheek suggested in issue #4019.

@nirbheek
Copy link
Member

nirbheek commented Sep 7, 2018

The target_spec solution would be ideal, yes, and if we can agree on the need for it and the syntax we should do it.

xclaesse added a commit to xclaesse/meson that referenced this issue Sep 11, 2018
The dict must map a target type to a string. This makes possible to pass
different name_prefix and name_suffix to static and shared libraries
when using both_libraries().

Closes mesonbuild#4133.
xclaesse added a commit to xclaesse/meson that referenced this issue Sep 11, 2018
The dict must map a target type to a string. This makes possible to pass
different name_prefix and name_suffix to static and shared libraries
when using both_libraries().

Closes mesonbuild#4133.
xclaesse added a commit to xclaesse/meson that referenced this issue Nov 2, 2018
The dict must map a target type to a string. This makes possible to pass
different name_prefix and name_suffix to static and shared libraries
when using both_libraries().

Closes mesonbuild#4133.
xclaesse added a commit to xclaesse/meson that referenced this issue Nov 9, 2018
The dict must map a target type to a string. This makes possible to pass
different name_prefix and name_suffix to static and shared libraries
when using both_libraries().

Closes mesonbuild#4133.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug OS:windows Winodows OS specific issues
Projects
None yet
Development

No branches or pull requests

3 participants