public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [cygport - the Cygwin packaging tool] branch master, updated. 0.33.1-33-gd6e4074
@ 2020-04-30  3:26 Yaakov Selkowitz
  0 siblings, 0 replies; only message in thread
From: Yaakov Selkowitz @ 2020-04-30  3:26 UTC (permalink / raw)
  To: cygwin-apps-cvs




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=d6e4074c793a3b5ffdbe80df2196fc9847308e34

commit d6e4074c793a3b5ffdbe80df2196fc9847308e34
Author: Yaakov Selkowitz <yselkowi@redhat.com>
Date:   Wed Apr 29 23:05:29 2020 -0400

    ocaml-dune: new cygclass

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=7d24eb71bdd91e2a368739728dbd522ddd4faaac

commit 7d24eb71bdd91e2a368739728dbd522ddd4faaac
Author: Yaakov Selkowitz <yselkowi@redhat.com>
Date:   Wed Apr 29 23:04:15 2020 -0400

    list_deps: use ocamlobjinfo for better OCaml dependency detection

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=a11e26a4e6c67a123a8320ea8789843e2191ffb6

commit a11e26a4e6c67a123a8320ea8789843e2191ffb6
Author: Yaakov Selkowitz <yselkowi@redhat.com>
Date:   Wed Apr 29 22:45:52 2020 -0400

    pkg_pkg: add cygport to all source package build-depends


Diff:
---
 cygclass/meson.build                               |   3 +
 cygclass/ocaml-dune.cygclass                       |  99 +++++++++++++++++++++
 lib/pkg_info.cygpart                               |  27 +++++-
 lib/pkg_pkg.cygpart                                |   7 +-
 testsuite/distdir/result-1.5.tbz                   | Bin 0 -> 2174 bytes
 .../dist/multiple/multiple-3.14-1-src.hint         |   2 +-
 .../dist/single/single-2.3.4-1-src.hint            |   2 +-
 testsuite/ocaml/dune/ocaml-result.cygport          |  15 ++++
 testsuite/ocaml/dune/ocaml-result.list             |  14 +++
 testsuite/ocaml/meson.build                        |   5 ++
 10 files changed, 169 insertions(+), 5 deletions(-)

diff --git a/cygclass/meson.build b/cygclass/meson.build
index 69f2fd1..94568af 100644
--- a/cygclass/meson.build
+++ b/cygclass/meson.build
@@ -111,6 +111,8 @@
 #    For packages which depend on Lua or provide Lua modules.
 #  * ocaml.cygclass -
 #    For packages which depend on OCaml or provide OCaml libraries.
+#  * ocaml-dune.cygclass -
+#    For OCaml packages which use the Dune buildsystem.
 #  * octave.cygclass -
 #    For packages which depend on Octave or provide Octave modules.
 #  * perl.cygclass -
@@ -199,6 +201,7 @@ cygclasses = files(
     'multilib.cygclass',
     'ninja.cygclass',
     'ocaml.cygclass',
+    'ocaml-dune.cygclass',
     'octave.cygclass',
     'perl.cygclass',
     'php.cygclass',
diff --git a/cygclass/ocaml-dune.cygclass b/cygclass/ocaml-dune.cygclass
new file mode 100644
index 0000000..113fccb
--- /dev/null
+++ b/cygclass/ocaml-dune.cygclass
@@ -0,0 +1,99 @@
+################################################################################
+#
+# ocaml-dune.cygclass - functions for installing OCaml packages with Dune
+#
+# Part of cygport - Cygwin packaging application
+# Copyright (C) 2006-2019 Yaakov Selkowitz
+# Provided by the Cygwin project <https://cygwin.com/>
+#
+# cygport is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cygport is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cygport.  If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+
+#****h* Cygclasses/ocaml-dune.cygclass
+#  SYNOPSIS
+#  inherit ocaml-dune
+#  DESCRIPTION
+#  Dune is a relatively new, and increasingly popular, build system designed
+#  for OCaml projects.
+#
+#  This cygclass provides functions for building Dune-based OCaml packages.
+#  INHERITS
+#  ocaml.cygclass
+#  REQUIRES
+#  ocaml-dune
+#****
+
+inherit ocaml
+
+check_prog_req dune ocaml-dune
+
+#****v* ocaml-dune.cygclass/OCAML_DUNE_BUILD_ARGS
+#  DESCRIPTION
+#  Arguments, usually build targets, to be passed to "dune build"
+#  by ocaml_dune_compile.
+#****
+
+#****C* ocaml-dune.cygclass/ocaml_dune_compile
+#  DESCRIPTION
+#  Runs "dune build", passing OCAML_DUNE_BUILD_ARGS and any given arguments.
+#****
+ocaml_dune_compile() {
+	DUNE_BUILD_DIR=${B} \
+	dune build --display=verbose --profile=release ${OCAML_DUNE_BUILD_ARGS} ${@} || error "dune build failed"
+}
+
+#****I* ocaml-dune.cygclass/ocaml_dune_install
+#  DESCRIPTION
+#  Runs "dune install" with a destdir of $D.
+#****
+ocaml_dune_install() {
+	DUNE_BUILD_DIR=${B} \
+	dune install --display=verbose --destdir ${D} || error "dune install failed"
+}
+
+#****T* ocaml-dune.cygclass/ocaml_dune_test
+#  DESCRIPTION
+#  Runs "dune runtest" with any given test directories.
+#****
+ocaml_dune_test() {
+	DUNE_BUILD_DIR=${B} \
+	dune runtest --display=verbose ${OCAML_DUNE_TEST_TARGETS} ${@} || error "dune runtest failed"
+}
+
+#****o* ocaml-dune.cygclass/src_compile (ocaml-dune)
+#  DEFINITION
+src_compile() {
+	cd ${S}
+	ocaml_dune_compile
+}
+#****
+
+#****o* ocaml-dune.cygclass/src_install (ocaml-dune)
+#  DEFINITION
+src_install() {
+	cd ${S}
+	ocaml_dune_install
+}
+#****
+
+#****o* ocaml-dune.cygclass/src_test (ocaml-dune)
+#  DEFINITION
+src_test() {
+	cd ${S}
+	ocaml_dune_test
+}
+#****
+
+readonly -f ocaml_dune_compile ocaml_dune_install ocaml_dune_test
diff --git a/lib/pkg_info.cygpart b/lib/pkg_info.cygpart
index 4d6f598..aa4f666 100644
--- a/lib/pkg_info.cygpart
+++ b/lib/pkg_info.cygpart
@@ -357,9 +357,32 @@ __list_deps() {
 	if check_prog ocamlc.opt
 	then
 		mldir=$(ocamlc.opt -where)
+		if [ -d ${D}${mldir} ]
+		then
+			for cma in $(find ${D}${mldir} ${mldir} -name '*.cma')
+			do
+				ocamlobjinfo $cma | sed -nr "s#(Unit|Module) name: #$cma:#p"
+			done > ${T}/.cmaobjinfo.out
+			for cmxa in $(find ${D}${mldir} ${mldir} -name '*.cmxa')
+			do
+				ocamlobjinfo $cmxa | sed -nr "s#(Unit|Module) name: #$cmxa:#p"
+			done > ${T}/.cmxaobjinfo.out
+			alldeps+=" "$(find "${@//^_^/ }" -type f -name '*.cma' | xargs -r ocamlobjinfo \
+					| grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' \
+					| sort -u \
+					| while read md5sum module
+					  do grep -m 1 ":$module$" ${T}/.cmaobjinfo.out | sed -e 's/:.*//'
+					  done | sort -u)
+			alldeps+=" "$(find "${@//^_^/ }" -type f -name '*.cmxa' | xargs -r ocamlobjinfo \
+					| grep -Eo '[0-9a-f]{32}[[:space:]]+[A-Za-z0-9_]+' \
+					| sort -u \
+					| while read md5sum module
+					  do grep -m 1 ":$module$" ${T}/.cmxaobjinfo.out | sed -e 's/:.*//'
+					  done | sort -u)
+		fi
 		for mllib in $(find "${@//^_^/ }" -type f -name '*.cmxa')
 		do
-			for mldep in $(strings ${mllib} | sed -ne 's/^.-l\([^@]*\).*/lib\1/gp')
+			for mldep in $(ocamlobjinfo ${mllib} | sed -nr '/^Extra C object files:/s/(.*: )?-l([^ ]*)/lib\2/gp')
 			do
 				if [ -f ${mllib%/*}/${mldep}.a ]
 				then
@@ -372,7 +395,7 @@ __list_deps() {
 				fi
 			done
 		done
-		if check_prog ocamlfind
+		if check_prog ocamlfind && [ ${PN} != "ocaml-findlib" ]
 		then
 			alldeps+=" "$(find "${@//^_^/ }" -path "${mldir#/}/*/META" \
 					| xargs -r grep -h 'requires *=' \
diff --git a/lib/pkg_pkg.cygpart b/lib/pkg_pkg.cygpart
index 119d6a6..23bb229 100644
--- a/lib/pkg_pkg.cygpart
+++ b/lib/pkg_pkg.cygpart
@@ -386,6 +386,11 @@ __pkg_diff() {
 		default_excludes+=" *.linfo";
 	fi
 
+	if inherited ocaml
+	then
+		default_excludes+=" .merlin";
+	fi
+
 	# cd now so that wildcards aren't mistakenly expanded to match files in
 	# user's directory
 	cd ${workdir};
@@ -910,7 +915,7 @@ _EOF
 		then
 			cat > ${distdir}/${PN}/${PN}-${PVR}-src.hint <<-_EOF
 category: ${!pkg_category_var:-${CATEGORY}}
-build-depends: ${BUILD_REQUIRES}
+build-depends: cygport ${BUILD_REQUIRES}
 sdesc: "${!pkg_summary_var:-${SUMMARY}}"
 ldesc: "${!pkg_description_var:-${DESCRIPTION:-${!pkg_summary_var:-${SUMMARY}}}}"
 skip:
diff --git a/testsuite/distdir/result-1.5.tbz b/testsuite/distdir/result-1.5.tbz
new file mode 100644
index 0000000..939a9e9
Binary files /dev/null and b/testsuite/distdir/result-1.5.tbz differ
diff --git a/testsuite/hints/multiple/hints/multiple-3.14-1.x86_64/dist/multiple/multiple-3.14-1-src.hint b/testsuite/hints/multiple/hints/multiple-3.14-1.x86_64/dist/multiple/multiple-3.14-1-src.hint
index 46ca274..c07abf4 100644
--- a/testsuite/hints/multiple/hints/multiple-3.14-1.x86_64/dist/multiple/multiple-3.14-1-src.hint
+++ b/testsuite/hints/multiple/hints/multiple-3.14-1.x86_64/dist/multiple/multiple-3.14-1-src.hint
@@ -1,5 +1,5 @@
 category: Base
-build-depends: 
+build-depends: cygport 
 sdesc: "Summary of hints for multiple package test (source)"
 ldesc: "Description of hints for multiple package test (source)"
 skip:
diff --git a/testsuite/hints/single/hints/single-2.3.4-1.x86_64/dist/single/single-2.3.4-1-src.hint b/testsuite/hints/single/hints/single-2.3.4-1.x86_64/dist/single/single-2.3.4-1-src.hint
index 7bd601a..afad2f6 100644
--- a/testsuite/hints/single/hints/single-2.3.4-1.x86_64/dist/single/single-2.3.4-1-src.hint
+++ b/testsuite/hints/single/hints/single-2.3.4-1.x86_64/dist/single/single-2.3.4-1-src.hint
@@ -1,5 +1,5 @@
 category: Base
-build-depends: 
+build-depends: cygport 
 sdesc: "Summary of hints for single package test"
 ldesc: "Description of hints for single package test"
 skip:
diff --git a/testsuite/ocaml/dune/ocaml-result.cygport b/testsuite/ocaml/dune/ocaml-result.cygport
new file mode 100644
index 0000000..f52ac17
--- /dev/null
+++ b/testsuite/ocaml/dune/ocaml-result.cygport
@@ -0,0 +1,15 @@
+inherit ocaml-dune
+
+NAME="ocaml-result"
+VERSION=1.5
+RELEASE=1
+CATEGORY="OCaml"
+SUMMARY="Compatibility library for OCaml result type"
+DESCRIPTION="Projects that want to use the new result type defined in OCaml
+4.03+ while staying compatible with older version of OCaml should use the
+Result module defined in this library."
+HOMEPAGE="https://github.com/janestreet/result"
+SRC_URI="${HOMEPAGE}/releases/download/${VERSION}/result-${VERSION}.tbz"
+SRC_DIR="result-${VERSION}"
+
+BUILD_REQUIRES="ocaml ocaml-dune"
diff --git a/testsuite/ocaml/dune/ocaml-result.list b/testsuite/ocaml/dune/ocaml-result.list
new file mode 100644
index 0000000..57e68a8
--- /dev/null
+++ b/testsuite/ocaml/dune/ocaml-result.list
@@ -0,0 +1,14 @@
+/usr/lib/ocaml/result/META
+/usr/lib/ocaml/result/dune-package
+/usr/lib/ocaml/result/opam
+/usr/lib/ocaml/result/result.a
+/usr/lib/ocaml/result/result.cma
+/usr/lib/ocaml/result/result.cmi
+/usr/lib/ocaml/result/result.cmt
+/usr/lib/ocaml/result/result.cmx
+/usr/lib/ocaml/result/result.cmxa
+/usr/lib/ocaml/result/result.cmxs
+/usr/lib/ocaml/result/result.ml
+/usr/share/doc/ocaml-result/CHANGES.md
+/usr/share/doc/ocaml-result/LICENSE.md
+/usr/share/doc/ocaml-result/README.md
diff --git a/testsuite/ocaml/meson.build b/testsuite/ocaml/meson.build
index f50622c..ded19fe 100644
--- a/testsuite/ocaml/meson.build
+++ b/testsuite/ocaml/meson.build
@@ -2,3 +2,8 @@ ocaml = find_program('ocamlc.opt', required: false)
 if ocaml.found()
 tests += [['ocaml/findlib']]
 endif
+
+ocaml_dune = find_program('dune', required: false)
+if ocaml_dune.found()
+tests += [['ocaml/dune']]
+endif



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-30  3:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30  3:26 [cygport - the Cygwin packaging tool] branch master, updated. 0.33.1-33-gd6e4074 Yaakov Selkowitz

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 read-only IMAP folder(s) and NNTP newsgroup(s).