Add support for installing dylib crate types (#340)

---------

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Roman Volosatovs <rvolosatovs@riseup.net>
This commit is contained in:
Ivan Petkov 2023-06-07 18:00:25 -07:00 committed by GitHub
parent f31931d6f8
commit 057d95721e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 4 deletions

View File

@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased
### Added
* `buildPackage` now supports installing `dylib` targets
### Changed
* **Breaking** (technically): if `buildPackage` is called _without_ setting
`cargoArtifacts`, the default `buildDepsOnly` invocation will now stop running
any installation hooks

View File

@ -249,6 +249,7 @@ in
liball_types.a
liball_types.so
libonly_cdylib.so
libonly_dylib.so
libonly_staticlib.a
EOF

View File

@ -16,6 +16,13 @@ dependencies = [
"some-dep",
]
[[package]]
name = "only-dylib"
version = "0.1.0"
dependencies = [
"some-dep",
]
[[package]]
name = "only-staticlib"
version = "0.1.0"

View File

@ -1,7 +1,8 @@
[workspace]
members = [
"only-cdylib",
"only-staticlib",
"all-types",
"only-cdylib",
"only-dylib",
"only-staticlib",
]
exclude = ["some-dep"]

View File

@ -0,0 +1,12 @@
[package]
name = "only-dylib"
version = "0.1.0"
edition = "2021"
[dependencies]
some-dep = { path = "../some-dep" }
[lib]
crate-type = [
"dylib",
]

View File

@ -0,0 +1,4 @@
#[no_mangle]
pub fn bar(a: i32) -> i32 {
some_dep::foo(a) * a
}

View File

@ -157,7 +157,7 @@ understood by `mkCargoDerivation` apply here as well, with the only difference
being some additional book keeping necessary to log cargo's results and
subsequently install from that log.
Note that only `bin`, `staticlib`, and `cdylib` targets will be installed by
Note that only `bin`, `cdylib`, `dylib`, and `staticlib`, targets will be installed by
default (namely `rlib` targets will be ignored), though it is possible to adjust
the behavior by changing the `installPhaseCommand` or registering additional
install hooks.

View File

@ -15,7 +15,11 @@ function installFromCargoBuildLog() (
local select_non_test='select(.reason == "compiler-artifact" and .profile.test == false)'
local select_bins="${select_non_test} | .executable | select(.!= null)"
local select_lib_files="${select_non_test}"'
| select(.target.kind | contains(["staticlib"]) or contains(["cdylib"]))
| select(.target.kind
| contains(["cdylib"])
or contains(["dylib"])
or contains(["staticlib"])
)
| .filenames[]
| select(endswith(".rlib") | not)
'