generator: do not include %cargo_install for cdylib-only crates
This commit is contained in:
parent
334f043031
commit
de8205940a
5 changed files with 43 additions and 2 deletions
|
@ -13,7 +13,7 @@ import jinja2
|
|||
|
||||
from rust2rpm import __version__, log
|
||||
from rust2rpm.licensing import translate_license
|
||||
from rust2rpm.metadata import guess_main_package, package_uses_rust_1_60_feature_syntax
|
||||
from rust2rpm.metadata import guess_main_package, package_uses_rust_1_60_feature_syntax, metadata_is_cdylib
|
||||
|
||||
|
||||
def to_list(s):
|
||||
|
@ -126,6 +126,7 @@ def spec_render_crate(
|
|||
|
||||
is_bin = metadata.is_bin()
|
||||
is_lib = metadata.is_lib()
|
||||
is_cdylib = metadata_is_cdylib(metadata)
|
||||
|
||||
package = metadata.packages[0]
|
||||
description = package.get_description()
|
||||
|
@ -210,7 +211,7 @@ def spec_render_crate(
|
|||
"rpm_license_files": license_files,
|
||||
"rpm_doc_files": doc_files,
|
||||
# Parameters that control generation of subpackages
|
||||
"rpm_binary_package": is_bin,
|
||||
"rpm_binary_package": is_bin or is_cdylib,
|
||||
"rpm_binary_names": binaries if is_bin else [],
|
||||
"rpm_library_package": is_lib,
|
||||
"crate_features": features,
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
from cargo2rpm.metadata import Metadata, Package
|
||||
|
||||
|
||||
def metadata_is_cdylib(metadata: Metadata) -> bool:
|
||||
for package in metadata.packages:
|
||||
for target in package.targets:
|
||||
if "cdylib" in target.kind and "cdylib" in target.crate_types:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def guess_main_package(metadata: Metadata) -> Package:
|
||||
if not metadata.is_workspace():
|
||||
return metadata.packages[0]
|
||||
|
|
|
@ -191,7 +191,11 @@ echo {{ "%r" | format(req) }}
|
|||
%cargo_build{{ cargo_args }}
|
||||
|
||||
%install
|
||||
{% if not (not rpm_library_package and rpm_binary_package and binaries|length == 0) %}
|
||||
%cargo_install{{ cargo_args }}
|
||||
{% else %}
|
||||
# FIXME
|
||||
{% endif %}
|
||||
|
||||
%if %{with check}
|
||||
%check
|
||||
|
|
|
@ -86,7 +86,11 @@ echo {{ "%r" | format(req) }}
|
|||
%cargo_build{{ cargo_args }}
|
||||
|
||||
%install
|
||||
{% if binaries|length == 0 %}
|
||||
%cargo_install{{ cargo_args }}
|
||||
{% else %}
|
||||
# FIXME
|
||||
{% endif %}
|
||||
|
||||
%if %{with check}
|
||||
%check
|
||||
|
|
24
tox.ini
24
tox.ini
|
@ -12,3 +12,27 @@ commands =
|
|||
pytest -v
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}
|
||||
|
||||
[testenv:coverage]
|
||||
deps =
|
||||
pytest
|
||||
coverage
|
||||
-rrequirements.txt
|
||||
whitelist_externals =
|
||||
cargo
|
||||
commands =
|
||||
coverage run --branch -m pytest -v {posargs}
|
||||
coverage html
|
||||
coverage report
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}
|
||||
|
||||
[testenv:mypy]
|
||||
deps =
|
||||
mypy
|
||||
pytest
|
||||
-rrequirements.txt
|
||||
commands =
|
||||
mypy -p rust2rpm {posargs}
|
||||
setenv =
|
||||
PYTHONPATH = {toxinidir}
|
||||
|
|
Loading…
Reference in a new issue