diff options
| -rw-r--r-- | docs/markdown/Pkgconfig-module.md | 4 | ||||
| -rw-r--r-- | docs/markdown/snippets/pkgconfig-gen-license.md | 3 | ||||
| -rw-r--r-- | mesonbuild/modules/pkgconfig.py | 10 | ||||
| -rw-r--r-- | test cases/common/280 pkgconfig-gen/meson.build | 5 |
4 files changed, 18 insertions, 4 deletions
diff --git a/docs/markdown/Pkgconfig-module.md b/docs/markdown/Pkgconfig-module.md index 80882cb7d..7ddd31026 100644 --- a/docs/markdown/Pkgconfig-module.md +++ b/docs/markdown/Pkgconfig-module.md @@ -47,6 +47,7 @@ keyword arguments. `pkgconfig.generate()` was used on to put in the `Requires` field - `requires_private` the same as `requires` but for the `Requires.private` field - `url` a string with a url for the library +- `license` (*Since 1.9.0*) a string with a SPDX license to add to the generated file. - `variables` a list of strings with custom variables to add to the generated file. The strings must be in the form `name=value` and may reference other pkgconfig variables, @@ -90,6 +91,9 @@ application. That will cause pkg-config to prefer those builddir. This is an experimental feature provided on a best-effort basis, it might not work in all use-cases. +*Since 1.9.0* you can specify a license identifier. To use the current project +licence, simply use `license: meson.project_license()` as argument to `generate()`. + ### Implicit dependencies The exact rules followed to find dependencies that are implicitly diff --git a/docs/markdown/snippets/pkgconfig-gen-license.md b/docs/markdown/snippets/pkgconfig-gen-license.md new file mode 100644 index 000000000..c2e681818 --- /dev/null +++ b/docs/markdown/snippets/pkgconfig-gen-license.md @@ -0,0 +1,3 @@ +## Added license keyword to pkgconfig.generate + +When specified, it will add a `License:` attribute to the generated .pc file. diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index c3fae1e94..e3f7a972d 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -38,6 +38,7 @@ if T.TYPE_CHECKING: filebase: T.Optional[str] description: T.Optional[str] url: str + license: str subdirs: T.List[str] conflicts: T.List[str] dataonly: bool @@ -441,6 +442,7 @@ class PkgConfigModule(NewExtensionModule): def _generate_pkgconfig_file(self, state: ModuleState, deps: DependenciesHelper, subdirs: T.List[str], name: str, description: str, url: str, version: str, + license: str, pcfile: str, conflicts: T.List[str], variables: T.List[T.Tuple[str, str]], unescaped_variables: T.List[T.Tuple[str, str]], @@ -523,6 +525,8 @@ class PkgConfigModule(NewExtensionModule): ofile.write(f'Description: {description}\n') if url: ofile.write(f'URL: {url}\n') + if license: + ofile.write(f'License: {license}\n') ofile.write(f'Version: {version}\n') reqs_str = deps.format_reqs(deps.pub_reqs) if reqs_str: @@ -605,6 +609,7 @@ class PkgConfigModule(NewExtensionModule): KwargInfo('name', (str, NoneType), validator=lambda x: 'must not be an empty string' if x == '' else None), KwargInfo('subdirs', ContainerTypeInfo(list, str), default=[], listify=True), KwargInfo('url', str, default=''), + KwargInfo('license', str, default='', since='1.9.0'), KwargInfo('version', (str, NoneType)), VARIABLES_KW.evolve(name="unescaped_uninstalled_variables", since='0.59.0'), VARIABLES_KW.evolve(name="unescaped_variables", since='0.59.0'), @@ -659,6 +664,7 @@ class PkgConfigModule(NewExtensionModule): filebase = kwargs['filebase'] if kwargs['filebase'] is not None else name description = kwargs['description'] if kwargs['description'] is not None else default_description url = kwargs['url'] + license = kwargs['license'] conflicts = kwargs['conflicts'] # Prepend the main library to public libraries list. This is required @@ -713,7 +719,7 @@ class PkgConfigModule(NewExtensionModule): pkgroot_name = os.path.join('{libdir}', 'pkgconfig') relocatable = state.get_option('pkgconfig.relocatable') self._generate_pkgconfig_file(state, deps, subdirs, name, description, url, - version, pcfile, conflicts, variables, + version, license, pcfile, conflicts, variables, unescaped_variables, False, dataonly, pkgroot=pkgroot if relocatable else None) res = build.Data([mesonlib.File(True, state.environment.get_scratch_dir(), pcfile)], pkgroot, pkgroot_name, None, state.subproject, install_tag='devel') @@ -722,7 +728,7 @@ class PkgConfigModule(NewExtensionModule): pcfile = filebase + '-uninstalled.pc' self._generate_pkgconfig_file(state, deps, subdirs, name, description, url, - version, pcfile, conflicts, variables, + version, license, pcfile, conflicts, variables, unescaped_variables, uninstalled=True, dataonly=dataonly) # Associate the main library with this generated pc file. If the library # is used in any subsequent call to the generated, it will generate a diff --git a/test cases/common/280 pkgconfig-gen/meson.build b/test cases/common/280 pkgconfig-gen/meson.build index 3f158882f..42ce1280d 100644 --- a/test cases/common/280 pkgconfig-gen/meson.build +++ b/test cases/common/280 pkgconfig-gen/meson.build @@ -1,4 +1,4 @@ -project('pkgconfig-get', 'c') +project('pkgconfig-get', 'c', meson_version: '>=1.9.0') pkgg = import('pkgconfig') @@ -16,4 +16,5 @@ pkgg.generate( filebase : 'simple', description : 'A simple demo library.', libraries: [lib_dep], -)
\ No newline at end of file + license: 'Apache-2.0', +) |
