Github messages for voidlinux
 help / color / mirror / Atom feed
From: kwshi <kwshi@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] New package: dune-2.8.5 (OCaml builder), `dune` build-style
Date: Thu, 30 Dec 2021 02:46:36 +0100	[thread overview]
Message-ID: <20211230014636.WrCD_wEUncMx5ldx8UnndOvVhqxr7DlTpAEVlwKeLEk@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-31601@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 2041 bytes --]

There is an updated pull request by kwshi against master on the void-packages repository

https://github.com/kwshi/void-packages dune
https://github.com/void-linux/void-packages/pull/31601

New package: dune-2.8.5 (OCaml builder), `dune` build-style
<!-- Mark items with [x] where applicable -->

This PR adds the [Dune](https://dune.build/) build system for OCaml projects, somewhat analogous to Cargo for Rust, Stack for Haskell, etc.; it is considered "the" modern OCaml build system & most widely used for OCaml projects. I've also defined a `dune.sh` build style for simplifying OCaml source builds. To make sure it works/demo its use, I've also added `ocaml-sexplib0`, which builds using `build_style=dune`.

#### General

- [x] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?

- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!--
#### Does it build and run successfully?
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] I built this PR locally for my native architecture, (ARCH-LIBC)
- [ ] I built this PR locally for these architectures (if supported. mark crossbuilds):
  - [ ] aarch64-musl
  - [ ] armv7l
  - [ ] armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/31601.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-dune-31601.patch --]
[-- Type: text/x-diff, Size: 6062 bytes --]

From aec910eaa10edb0197de129e414e817b6c0a5238 Mon Sep 17 00:00:00 2001
From: Kye Shi <shi.kye@gmail.com>
Date: Mon, 21 Jun 2021 18:27:45 -0700
Subject: [PATCH 1/3] common: add `dune` build style

---
 common/build-style/dune.sh             | 34 ++++++++++++++++++++++++++
 common/environment/build-style/dune.sh |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 common/build-style/dune.sh
 create mode 100644 common/environment/build-style/dune.sh

diff --git a/common/build-style/dune.sh b/common/build-style/dune.sh
new file mode 100644
index 000000000000..e0f4c8d61b14
--- /dev/null
+++ b/common/build-style/dune.sh
@@ -0,0 +1,34 @@
+#
+# This helper is for templates using OCaml's dune build system.
+#
+do_build() {
+	: ${make_cmd:=dune}
+	: ${make_build_target:=@install}
+
+	"${make_cmd}" build --release $makejobs $make_build_args $make_build_target
+}
+
+do_check() {
+	: ${make_cmd:=dune}
+	: ${make_check_target:=@runtest}
+
+	"${make_cmd}" build $makejobs $make_check_args $make_check_target
+}
+
+do_install() {
+	: ${make_cmd:=dune}
+
+	"${make_cmd}" install \
+		--prefix="/usr" \
+		--libdir="/usr/lib/ocaml" \
+		--mandir="/usr/share/man" \
+		--destdir="$DESTDIR" \
+		$make_install_args $make_install_target
+
+	# patch: mv /usr/doc to /usr/share/doc because dune does not provide way to
+	# customize doc install path
+	if [ -e "$DESTDIR/usr/doc" ]; then
+		mkdir -p "$DESTDIR/usr/share"
+		mv "$DESTDIR/usr/doc" "$DESTDIR/usr/share"
+	fi
+}
diff --git a/common/environment/build-style/dune.sh b/common/environment/build-style/dune.sh
new file mode 100644
index 000000000000..36cf08537c55
--- /dev/null
+++ b/common/environment/build-style/dune.sh
@@ -0,0 +1 @@
+hostmakedepends+=" ocaml dune"

From e2e333b378373a9d5485e8342b79161dfa06653d Mon Sep 17 00:00:00 2001
From: Kye Shi <shi.kye@gmail.com>
Date: Mon, 21 Jun 2021 18:27:54 -0700
Subject: [PATCH 2/3] Manual.md: document `dune` build style

---
 Manual.md | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/Manual.md b/Manual.md
index 042f0e18ae5d..2a7ba1ac8c48 100644
--- a/Manual.md
+++ b/Manual.md
@@ -585,18 +585,22 @@ or `gnu-makefile`, this is the target passed to `${make_cmd}` in the build phase
 when unset the default target is used.
 If `${build_style}` is `python3-pep517`, this is the path of the package
 directory that should be built as a Python wheel; when unset, defaults to `.` (the current
-directory with respect to the build).
+directory with respect to the build). If `${build_style}` is `dune`, this is the target passed to 
+`dune build` in the build phase; when unset, defaults to `@install`.
 
 - `make_check_target` The target to be passed in to `${make_cmd}` at the check phase if
 `${build_style}` is set to `configure`, `gnu-configure` or `gnu-makefile`
-build methods. By default set to `check`.
+build methods; by default set to `check`. If `${build_style}` is `dune`, this
+is the target passed to `dune build` for running tests; when unset, defaults to `@runtest`.
 
 - `make_install_target` The installation target. When `${build_style}` is set to `configure`,
 `gnu-configure` or `gnu-makefile`, this is the target passed to `${make_command}` in the install
 phase; when unset, it defaults to `install`. If `${build_style}` is `python-pep517`, this is the
 path of the Python wheel produced by the build phase that will be installed; when unset, the
 `python-pep517` build style will look for a wheel matching the package name and version in the
-current directory with respect to the install.
+current directory with respect to the install. If `${build_style}` is `dune`, this is the list
+of OCaml packages to install, specified as a comma-separated list; when unset, all packages
+defined in the source project will be installed.
 
 - `patch_args` The arguments to be passed in to the `patch(1)` command when applying
 patches to the package sources during `do_patch()`. Patches are stored in
@@ -920,6 +924,15 @@ the default `build`.
 - `configure` For packages that use non-GNU configure scripts, at least `--prefix=/usr`
 should be passed in via `configure_args`.
 
+- `dune` For packages written in OCaml that use Dune for building.
+Arguments to `dune build` can be passed via `make_build_args`, and the build target
+(default `@install`) can be overridden via `make_build_target`.  Arguments to 
+`dune install` can be passed via `make_install_args`, and the list of packages to
+install (defaults to all packages defined in the project) can be overridden via 
+`make_install_target` as a comma-separated list (e.g. `containers,containers-data`).  
+Tests are run using `dune build @runtest`; the target (default `@runtest`) can be 
+overridden via `make_check_target` and arguments passed via `make_check_args`.
+
 - `fetch` For packages that only fetch files and are installed as is via `do_install()`.
 
 - `gnu-configure` For packages that use GNU configure scripts, additional configuration

From 36477c4a54bbea1fe1080630646b1f8927675296 Mon Sep 17 00:00:00 2001
From: Kye Shi <shi.kye@gmail.com>
Date: Mon, 21 Jun 2021 19:18:08 -0700
Subject: [PATCH 3/3] new package: ocaml-sexplib0-0.14.0

---
 srcpkgs/ocaml-sexplib0/template | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 srcpkgs/ocaml-sexplib0/template

diff --git a/srcpkgs/ocaml-sexplib0/template b/srcpkgs/ocaml-sexplib0/template
new file mode 100644
index 000000000000..ac4f6a150ab3
--- /dev/null
+++ b/srcpkgs/ocaml-sexplib0/template
@@ -0,0 +1,17 @@
+# Template file for 'ocaml-sexplib0'
+pkgname=ocaml-sexplib0
+version=0.14.0
+revision=1
+wrksrc="sexplib0-$version"
+build_style="dune"
+short_desc="Minimal-dependency base S-expressions library for OCaml"
+maintainer="Kye Shi <shi.kye@gmail.com>"
+license="MIT"
+homepage="https://github.com/janestreet/sexplib0"
+distfiles="https://github.com/janestreet/sexplib0/archive/refs/tags/v$version.tar.gz"
+checksum="1e2d1c27015809d816d1c707abfbc61f6b55830dedec01de8152d10ab7d6a19e"
+nocross="yes"
+
+post_install() {
+	vlicense "LICENSE.md"
+}

  parent reply	other threads:[~2021-12-30  1:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22  0:34 [PR PATCH] New package: dune-2.8.5 (OCaml build system), " kwshi
2021-06-22  0:36 ` [PR PATCH] [Updated] " kwshi
2021-06-22  0:57 ` kwshi
2021-06-22  1:02 ` kwshi
2021-06-22  2:18 ` kwshi
2021-06-22  2:34 ` kwshi
2021-06-22  2:36 ` kwshi
2021-06-22  2:41 ` kwshi
2021-06-22  2:45 ` kwshi
2021-06-22  2:54 ` [PR PATCH] [Updated] New package: dune-2.8.5 (OCaml builder), " kwshi
2021-06-22 19:56 ` kwshi
2021-12-30  1:46 ` kwshi [this message]
2022-05-23  2:12 ` common/build-style: add `dune` (OCaml builder) github-actions
2022-06-06  2:14 ` [PR PATCH] [Closed]: " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211230014636.WrCD_wEUncMx5ldx8UnndOvVhqxr7DlTpAEVlwKeLEk@z \
    --to=kwshi@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).