Subject: [PATCH] testing/rust-analyzer: new aport

From: "S.M Mukarram Nainar" <[email-masked]>
Date: Fri, 18 Feb 2022 07:25:07 -0500

https://github.com/rust-analyzer/rust-analyzer
A Rust compiler front-end for IDEs
---
 testing/rust-analyzer/APKBUILD | 44 ++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 testing/rust-analyzer/APKBUILD

diff --git a/testing/rust-analyzer/APKBUILD b/testing/rust-analyzer/APKBUILD
new file mode 100644
index 0000000000..3be97ba907
--- /dev/null
+++ b/testing/rust-analyzer/APKBUILD
@@ -0,0 +1,44 @@
+# Contributor: S.M Mukarram Nainar <[email-masked]>
+# Maintainer: S.M Mukarram Nainar <[email-masked]>
+pkgname=rust-analyzer
+_pkgver="2022-02-14"
+pkgver=${_pkgver//-}
+pkgrel=0
+pkgdesc="A Rust compiler front-end for IDEs"
+url="https://github.com/rust-analyzer/rust-analyzer"
+# limited by rust, x86/armhf/armv7 fail tests
+arch="x86_64 aarch64 ppc64le"
+license="MIT Apache-2.0"
+depends="rust-src"
+makedepends="cargo"
+checkdepends="rustfmt"
+subpackages="$pkgname-doc"
+source="$pkgname-$pkgver.tar.gz::https://github.com/rust-analyzer/rust-analyzer/archive/refs/tags/$_pkgver.tar.gz"
+builddir="$srcdir/$pkgname-$_pkgver"
+
+prepare() {
+	default_prepare
+
+	cargo fetch --locked
+}
+
+build() {
+	cargo build --frozen --release
+}
+
+check() {
+	cargo test --frozen
+}
+
+package() {
+	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer
+
+	install -Dm644 LICENSE-MIT "$pkgdir"/usr/share/licenses/$pkgname/LICENSE-MIT
+	install -Dm644 LICENSE-APACHE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE-APACHE
+
+	install -Dm644 docs/user/manual.adoc "$pkgdir"/usr/share/doc/$pkgname/manual.adoc
+}
+
+sha512sums="
+cad62bc2837daadf17fadd3e4ccb2cc9ea4203f14cdac6931548a025b2cd5daef5f4b645d36381fea5a5baf44b301d8b83f0136c095dcc3b500df476baab6f1b  rust-analyzer-20220214.tar.gz
+"
-- 
2.35.1

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:27:14 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

you removed the -t by accident so this is invalid

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216542

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:28:07 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

wouldn't it be better to just use `cargo install` since that is the recommended way of installing Rust bin crates?

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216544

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:28:39 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

i don't see a point when it's a single file and gives you nothing else anyway

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216545

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:29:18 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

this is also another fancy workspaces project that probably rebuilds on install, and what is the point of figuring that out when you can just copy one file, hehe

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216547

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:30:07 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

because it increases build time building whole workspace instead of single binary

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216548

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:31:34 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

and it's very easy to find where is the required manifest  
https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/Cargo.toml

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216550

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:32:22 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

then the solution is to build that single binary instead of the whole workspace- and you can still cp the file after. this is completely unrelated to the cargo install invocation, but only the cargo build one

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216551

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:35:26 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

if the cargo install ever actually did something useful like move some various extra files for you then i would get it, but 99% of the time it is identical to the cp and you have to rm -r some random folder it makes, so what exactly is the point? even in multi-bin projects you invoke `cargo install` once per individual binary, like in wezterm, so it saves absolutely nothing in 'complexity' of installing some build object

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216553

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:36:52 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

 but yes, of course a +1 that the build should take the correct binary object to not build the entire workspace- this makes perfect sense :)

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216554

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:39:27 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

Cargo manifests can have multiple binaries and `cargo install` should install all of them with a single command

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216559

---

From: mailinglist-bot <[email-masked]>
Date: Fri, 18 Feb 2022 12:44:33 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

"S.M Mukarram Nainar" <[email-masked]> replied via email:

```
> Cargo manifests can have multiple binaries and `cargo install` should install all of them with a single command

I actually had it using `cargo install` originally, but I switched it
because I thought this was clearer. I'll have to test the `--bin` flag
for building only the binary instead of the whole workspace — I didn't
know it existed.

```

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216560

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:44:55 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

they can, yes. i know how the cargo manifest works. this doesn't, though, and almost nothing i have ever touched does either, and even in projects with multiple bins they usually don't put them in one manifest (like whatever wezterm is doing). is there some issue with `install` on one file that will nuke everyones systems here, or?

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216562

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:46:39 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

You can use `cargo build --frozen --release --manifest-path crates/rust-analyzer/Cargo.toml` in `build()` and `cargo install --frozen --offline --root="$pkgdir"/usr --path "$builddir"/crates/rust-analyzer` in `package()`

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216563

---

From: Jakub Panek <[email-masked]>
Date: Fri, 18 Feb 2022 12:47:27 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

@psykose as long as you want to ignore recommended way of installing stuff, then nothing is wrong

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216564

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:48:41 -0000

> +	install -Dm755 "$pkgdir"/usr/bin target/release/rust-analyzer

i will definitely ignore the recommended way of calling cp on a single file, thanks

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216565

---

From: S.M Mukarram Nainar <[email-masked]>
Date: Fri, 18 Feb 2022 07:44:25 -0500

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:27:53 -0000

> +license="MIT Apache-2.0"

use an AND or OR depending on how they apply - looks like AND based on the readme
```suggestion:-0+0
license="MIT AND Apache-2.0"
```

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216543

---

From: alice <[email-masked]>
Date: Fri, 18 Feb 2022 12:33:31 -0000

> +license="MIT Apache-2.0"

actually  
`license = "MIT OR Apache-2.0"`
from https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/rust-analyzer/Cargo.toml

-- 
via https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/31077#note_216552