]> git.pld-linux.org Git - packages/ocaml-csexp.git/commitdiff
- new auto/th/ocaml-csexp-1.4.0-1
authorJan Rękorajski <baggins@pld-linux.org>
Fri, 19 Mar 2021 22:02:32 +0000 (23:02 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Fri, 19 Mar 2021 22:02:32 +0000 (23:02 +0100)
ocaml-csexp-result.patch [new file with mode: 0644]
ocaml-csexp.spec [new file with mode: 0644]

diff --git a/ocaml-csexp-result.patch b/ocaml-csexp-result.patch
new file mode 100644 (file)
index 0000000..c1aab55
--- /dev/null
@@ -0,0 +1,92 @@
+--- a/csexp.opam
++++ b/csexp.opam
+@@ -32,7 +32,6 @@ bug-reports: "https://github.com/ocaml-d
+ depends: [
+   "dune" {>= "1.11"}
+   "ocaml" {>= "4.02.3"}
+-  "result" {>= "1.5"}
+ ]
+ dev-repo: "git+https://github.com/ocaml-dune/csexp.git"
+ build: [
+--- a/src/csexp.ml
++++ b/src/csexp.ml
+@@ -102,12 +102,6 @@ end
+ module Make (Sexp : Sexp) = struct
+   open Sexp
+-  (* This is to keep compatibility with 4.02 without writing [Result.]
+-     everywhere *)
+-  type ('a, 'b) result = ('a, 'b) Result.result =
+-    | Ok of 'a
+-    | Error of 'b
+-
+   module Parser = struct
+     exception Parse_error of string
+@@ -370,9 +364,9 @@ module Make (Sexp : Sexp) = struct
+     module Monad : Monad
+-    val read_string : t -> int -> (string, string) Result.t Monad.t
++    val read_string : t -> int -> (string, string) result Monad.t
+-    val read_char : t -> (char, string) Result.t Monad.t
++    val read_char : t -> (char, string) result Monad.t
+   end
+   module Make_parser (Input : Input) = struct
+--- a/src/csexp.mli
++++ b/src/csexp.mli
+@@ -34,24 +34,24 @@ module type S = sig
+       [s]. It is an error for [s] to contain a S-expression followed by more
+       data. In case of error, the offset of the error as well as an error
+       message is returned. *)
+-  val parse_string : string -> (sexp, int * string) Result.t
++  val parse_string : string -> (sexp, int * string) result
+   (** [parse_string s] parses a sequence of S-expressions encoded in canonical
+       form in [s] *)
+-  val parse_string_many : string -> (sexp list, int * string) Result.t
++  val parse_string_many : string -> (sexp list, int * string) result
+   (** Read exactly one canonical S-expressions from the given channel. Note that
+       this function never raises [End_of_file]. Instead, it returns [Error]. *)
+-  val input : in_channel -> (sexp, string) Result.t
++  val input : in_channel -> (sexp, string) result
+   (** Same as [input] but returns [Ok None] if the end of file has already been
+       reached. If some more characters are available but the end of file is
+       reached before reading a complete S-expression, this function returns
+       [Error]. *)
+-  val input_opt : in_channel -> (sexp option, string) Result.t
++  val input_opt : in_channel -> (sexp option, string) result
+   (** Read many S-expressions until the end of input is reached. *)
+-  val input_many : in_channel -> (sexp list, string) Result.t
++  val input_many : in_channel -> (sexp list, string) result
+   (** {2 Serialising} *)
+@@ -353,18 +353,18 @@ module type S = sig
+       val bind : 'a t -> ('a -> 'b t) -> 'b t
+     end
+-    val read_string : t -> int -> (string, string) Result.t Monad.t
++    val read_string : t -> int -> (string, string) result Monad.t
+-    val read_char : t -> (char, string) Result.t Monad.t
++    val read_char : t -> (char, string) result Monad.t
+   end
+   [@@deprecated "Use Parser module instead"]
+   [@@@warning "-3"]
+   module Make_parser (Input : Input) : sig
+-    val parse : Input.t -> (sexp, string) Result.t Input.Monad.t
++    val parse : Input.t -> (sexp, string) result Input.Monad.t
+-    val parse_many : Input.t -> (sexp list, string) Result.t Input.Monad.t
++    val parse_many : Input.t -> (sexp list, string) result Input.Monad.t
+   end
+   [@@deprecated "Use Parser module instead"]
+ end
diff --git a/ocaml-csexp.spec b/ocaml-csexp.spec
new file mode 100644 (file)
index 0000000..04c9109
--- /dev/null
@@ -0,0 +1,162 @@
+#
+# Conditional build:
+%bcond_without ocaml_opt       # skip building native optimized binaries (bytecode is always built)
+%bcond_with    dune            # build with dune, this is off due to circular deps
+
+# not yet available on x32 (ocaml 4.02.1), update when upstream will support it
+%ifnarch %{ix86} %{x8664} %{arm} aarch64 ppc sparc sparcv9
+%undefine      with_ocaml_opt
+%endif
+
+%if %{without ocaml_opt}
+%define                _enable_debug_packages  0
+%endif
+
+%define                module  csexp
+Summary:       Parsing and printing of S-expressions in canonical form
+Name:          ocaml-%{module}
+Version:       1.4.0
+Release:       1
+License:       MIT
+Source0:       https://github.com/ocaml-dune/csexp/releases/download/%{version}/%{module}-%{version}.tbz
+# Source0-md5: d6b5866be24bf8730c127eedca4dc447
+URL:           https://github.com/ocaml-dune/csexp
+# Depend on Stdlib.Result instead of ocaml-result.
+Patch0:                %{name}-result.patch
+BuildRequires: ocaml >= 4.02.3
+%if %{with dune}
+BuildRequires: ocaml-dune >= 1.11
+BuildRequires: ocaml-odoc
+BuildRequires: ocaml-result-devel >= 1.5
+%endif
+BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+This project provides minimal support for parsing and printing
+S-expressions in canonical form, which is a very simple and canonical
+binary encoding of S-expressions.
+
+%package devel
+Summary:       Development files for %{name}
+Requires:      %{name} = %{version}-%{release}
+%if %{with dune}
+Requires:      ocaml-result-devel
+%endif
+
+%description devel
+The %{name}-devel package contains libraries and signature files for
+developing applications that use %{name}.
+
+%prep
+%setup -q -n %{module}-%{version}
+%if %{without dune}
+%patch0 -p1
+%endif
+
+%build
+%if %{with dune}
+dune build %{?_smp_mflags} --display=verbose @install
+dune build %{?_smp_mflags} @doc
+%else
+OFLAGS="-strict-sequence -strict-formats -short-paths -keep-locs -g -opaque"
+OCFLAGS="$OFLAGS -bin-annot"
+cd src
+ocamlc $OCFLAGS -output-obj csexp.mli
+ocamlc $OCFLAGS -a -o csexp.cma csexp.ml
+%if %{with ocaml_opt}
+ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -a \
+       -o csexp.cmxa csexp.ml
+ocamlopt $OFLAGS -ccopt "%{rpmcflags}" -cclib "%{rpmldflags}" -shared \
+       -o csexp.cmxs csexp.ml
+%endif
+%endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%if %{with dune}
+dune install --destdir=$RPM_BUILD_ROOT
+
+# We do not want the dune markers
+find _build/default/_doc/_html -name .dune-keep -delete
+
+# We do not want the ml files
+find $RPM_BUILD_ROOT%{_libdir}/ocaml -name \*.ml -delete
+
+# We install the documentation with the doc macro
+rm -fr $RPM_BUILD_ROOT%{_prefix}/doc
+%else
+# Install without dune.  See comment at the top.
+install -d $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
+cp -p src/csexp.{cma,cmi,cmt,cmti,mli} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
+%if %{with ocaml_opt}
+cp -p src/csexp.{a,cmx,cmxa,cmxs} $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}
+%endif
+
+cp -p csexp.opam $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/opam
+
+cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/META << EOF
+version = "%{version}"
+description = "Parsing and printing of S-expressions in canonical form"
+archive(byte) = "csexp.cma"
+%ifarch %{ocaml_native_compiler}
+archive(native) = "csexp.cmxa"
+%endif
+plugin(byte) = "csexp.cma"
+%ifarch %{ocaml_native_compiler}
+plugin(native) = "csexp.cmxs"
+%endif
+EOF
+
+cat >> $RPM_BUILD_ROOT%{_libdir}/ocaml/%{module}/dune-package << EOF
+(lang dune 2.8)
+(name csexp)
+(version %{version})
+(library
+ (name csexp)
+ (kind normal)
+%if %{with ocaml_opt}
+ (archives (byte csexp.cma) (native csexp.cmxa))
+ (plugins (byte csexp.cma) (native csexp.cmxs))
+ (native_archives csexp.a)
+%else
+ (archives (byte csexp.cma))
+ (plugins (byte csexp.cma))
+%endif
+ (main_module_name Csexp)
+%if %{with ocaml_opt}
+ (modes byte native)
+%else
+ (modes byte)
+%endif
+ (modules
+  (singleton (name Csexp) (obj_name csexp) (visibility public) (impl) (intf))))
+EOF
+%endif
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(644,root,root,755)
+%doc README.md
+%doc LICENSE.md
+%dir %{_libdir}/ocaml/%{module}/
+%{_libdir}/ocaml/%{module}/META
+%{_libdir}/ocaml/%{module}/*.cma
+%{_libdir}/ocaml/%{module}/*.cmi
+%if %{with ocaml_opt}
+%{_libdir}/ocaml/%{module}/*.cmxs
+%endif
+
+%files devel
+%defattr(644,root,root,755)
+%{_libdir}/ocaml/%{module}/dune-package
+%{_libdir}/ocaml/%{module}/opam
+%if %{with ocaml_opt}
+%{_libdir}/ocaml/%{module}/*.a
+%{_libdir}/ocaml/%{module}/*.cmx
+%{_libdir}/ocaml/%{module}/*.cmxa
+%endif
+%{_libdir}/ocaml/%{module}/*.cmt
+%{_libdir}/ocaml/%{module}/*.cmti
+%{_libdir}/ocaml/%{module}/*.mli
This page took 0.099596 seconds and 4 git commands to generate.