From 88df21fcb3e8004456a280a547b2f1e2a96f0f4d Mon Sep 17 00:00:00 2001 From: Jerry James Date: Fri, 26 Mar 2021 16:21:22 -0600 Subject: [PATCH] Fix tests on 64-bit systems with the -test-lib64 patch. - Add -emacs-iedit patch to adapt to recent iedit changes. - Build with auto-complete, company-mode, and caml-mode support. - Add subpackages: dot-merlin-reader, emacs-merlin, and vim-merlin. - Generate autoloads for the Emacs interface. --- ocaml-merlin-iedit.patch | 38 +++++++ ocaml-merlin-test-lib64.patch | 10 ++ ocaml-merlin.spec | 195 +++++++++++++++++++++++----------- 3 files changed, 183 insertions(+), 60 deletions(-) create mode 100644 ocaml-merlin-iedit.patch create mode 100644 ocaml-merlin-test-lib64.patch diff --git a/ocaml-merlin-iedit.patch b/ocaml-merlin-iedit.patch new file mode 100644 index 0000000..1ddf2c6 --- /dev/null +++ b/ocaml-merlin-iedit.patch @@ -0,0 +1,38 @@ +--- a/emacs/merlin-company.el 2021-02-16 03:29:29.000000000 -0700 ++++ b/emacs/merlin-company.el 2021-03-09 16:53:30.948523612 -0700 +@@ -29,6 +29,7 @@ + + (defcustom merlin-company-everywhere t + "Non-nil to offer completions in comments and strings." ++ :group 'merlin + :type 'boolean) + + ;; Internal functions +--- a/emacs/merlin-iedit.el 2021-02-16 03:29:29.000000000 -0700 ++++ b/emacs/merlin-iedit.el 2021-03-10 09:03:03.533151403 -0700 +@@ -32,8 +32,8 @@ + iedit-read-only-occurrences-overlays) + (push (iedit-make-occurrence-overlay beginning ending) + iedit-occurrences-overlays)))) +- (when (and occurrences iedit-unmatched-lines-invisible) +- (iedit-hide-unmatched-lines iedit-occurrence-context-lines)))) ++ (when (and occurrences iedit-hiding) ++ (iedit-hide-context-lines iedit-occurrence-context-lines)))) + (length occurrences)) + + (defun merlin-iedit-occurrences () +@@ -44,10 +44,10 @@ + "-identifier-at" (merlin/unmake-point (point))))) + (when r + (if (listp r) +- (flet ((iedit-printable (a) +- (merlin-iedit--printable)) +- (iedit-make-occurrences-overlays (a b c) +- (merlin-iedit--make-occurrences-overlays a))) ++ (cl-flet ((iedit-printable (a) ++ (merlin-iedit--printable)) ++ (iedit-make-occurrences-overlays (a b c) ++ (merlin-iedit--make-occurrences-overlays a))) + (iedit-start r (point-min) (point-max))) + (message r)))))) + diff --git a/ocaml-merlin-test-lib64.patch b/ocaml-merlin-test-lib64.patch new file mode 100644 index 0000000..0d6a2d3 --- /dev/null +++ b/ocaml-merlin-test-lib64.patch @@ -0,0 +1,10 @@ +--- a/tests/merlin-wrapper 2021-02-16 02:59:33.000000000 -0700 ++++ b/tests/merlin-wrapper 2021-02-23 15:54:14.988017568 -0700 +@@ -4,6 +4,6 @@ export PATH=$(dirname dot-merlin-reader) + + touch .merlin && ocamlmerlin "$@" \ + | jq 'del(.timing)' \ +- | sed -e 's:"[^"]*lib/ocaml:"lib/ocaml:g' \ ++ | sed -re 's:"[^"]*lib(64)?/ocaml:"lib/ocaml:g' \ + | sed -e 's:\\n:\ + :g' diff --git a/ocaml-merlin.spec b/ocaml-merlin.spec index 54a4ccc..ec2b173 100644 --- a/ocaml-merlin.spec +++ b/ocaml-merlin.spec @@ -1,89 +1,164 @@ -Name: ocaml-merlin +%ifnarch %{ocaml_native_compiler} +%global debug_package %{nil} +%endif + +%global srcname merlin + +Name: ocaml-%{srcname} Version: 4.1 -Release: 1%{?dist} -Summary: Context sensitive completion for OCaml in Vim and Emacs +Release: 2%{?dist} +Summary: Context sensitive completion for OCaml -%global libname %(echo %{name} | sed -e 's/^ocaml-//') - -# The entire source is MIT except src/ocaml are QPL +# The entire source is MIT except: +# - QPL: src/ocaml/driver/pparse.ml{,i} +# - QPL: src/ocaml/preprocess/lexer_ident.mll +# - QPL: src/ocaml/preprocess/lexer_raw.ml{i,l} +# - LGPLv2 with exceptions: src/ocaml/preprocess/parser_raw.mly +# - LGPLv2 with exceptions: upstream/ocaml_411/parsing/parser.mly +# - LGPLv2 with exceptions: upstream/ocaml_412/parsing/parser.mly +# +# The final license is due to the linking exception on the LGPLv2 files. License: MIT and QPL -URL: https://github.com/ocaml/%{libname} -Source0: https://github.com/ocaml/%{libname}/archive/v%{version}.tar.gz#/%{libname}-%{version}.tar.gz +URL: https://ocaml.github.io/%{srcname}/ +Source0: https://github.com/ocaml/%{srcname}/archive/v%{version}/%{srcname}-%{version}.tar.gz +# Fix the tests to work with /usr/lib64 as well as /usr/lib +Patch0: %{name}-test-lib64.patch +# Update the Emacs interface for recent changes to emacs-iedit +Patch1: %{name}-iedit.patch -BuildRequires: ocaml -BuildRequires: ocaml-dune >= 1.8 -BuildRequires: ocaml-findlib-devel -BuildRequires: ocaml-yojson-devel -BuildRequires: ocaml-biniou-devel -BuildRequires: ocaml-easy-format-devel -BuildRequires: ocaml-csexp-devel -BuildRequires: ocaml-result-devel - -# For merlin-lsp -#BuildRequires: ocaml-yojson-devel >= 1.6.0 -#BuildRequires: ocaml-menhir-devel -#BuildRequires: ocaml-ppx-deriving-devel -#BuildRequires: ocaml-ppx-deriving-yojson-devel -#BuildRequires: ocaml-ppx-tools-devel -#BuildRequires: ocaml-ppx-derivers-devel -#BuildRequires: ocaml-migrate-parsetree-devel -#BuildRequires: ocaml-result-devel - -# Required for tests, not available in Fedora -#BuildRequires: craml BuildRequires: emacs -# For byte-compile elisp -#BuildRequires: emacs-auto-complete -#BuildRequires: emacs-tuareg -# The following two are not yet available in Fedora. -# So byte compilation is disabled -#BuildRequires: emacs-company -#BuildRequires: emacs-iedit +BuildRequires: emacs-auto-complete +BuildRequires: emacs-company-mode +BuildRequires: emacs-iedit +BuildRequires: emacs-tuareg +BuildRequires: jq +BuildRequires: ocaml >= 4.11.1 +BuildRequires: ocaml-biniou-devel +BuildRequires: ocaml-caml-mode +BuildRequires: ocaml-csexp-devel >= 1.2.3 +BuildRequires: ocaml-dune >= 2.7.0 +BuildRequires: ocaml-easy-format-devel +BuildRequires: ocaml-findlib-devel >= 1.6.0 +BuildRequires: ocaml-menhir-devel +BuildRequires: ocaml-odoc +BuildRequires: ocaml-result-devel >= 1.5 +BuildRequires: ocaml-source +BuildRequires: ocaml-yojson-devel >= 1.6.0 BuildRequires: vim-enhanced -Requires: emacs-filesystem >= %{_emacs_version} + +Requires: dot-merlin-reader%{?_isa} = %{version}-%{release} + +%global _desc %{expand: +Merlin is an assistant for editing OCaml code. It aims to provide the +features available in modern IDEs: error reporting, auto completion, +source browsing and much more.} + +%description %_desc + +You should also install a package that integrates with your editor of +choice, such as emacs-merlin or vim-merlin. + +%package -n dot-merlin-reader +Summary: Merlin configuration file reader + +%description -n dot-merlin-reader +This package contains a helper process that reads .merlin files and gives +the normalized content to merlin. + +%package -n emacs-merlin +Summary: Context sensitive completion for OCaml in Emacs +BuildArch: noarch +Requires: ocaml-merlin = %{version}-%{release} +Requires: emacs(bin) >= %{?_emacs_version}%{!?_emacs_version:0} +Requires: emacs-caml-mode + +Recommends: emacs-auto-complete +Recommends: emacs-company-mode +Recommends: emacs-iedit +Recommends: emacs-tuareg + +%description -n emacs-merlin %_desc + +This package contains the Emacs interface to merlin. + +%package -n vim-merlin +Summary: Context sensitive completion for OCaml in Vim +BuildArch: noarch +Requires: ocaml-merlin = %{version}-%{release} Requires: vim-filesystem -%description -Merlin is an assistant for editing OCaml code. It aims to provide the features -available in modern IDEs: error reporting, auto completion, source browsing and -much more. +%description -n vim-merlin %_desc +This package contains the Vim interface to merlin. %prep -%setup -q -n %{libname}-%{version} - +%autosetup -n %{srcname}-%{version} -p1 %build -dune build %{_smp_mflags} --build-dir _build_%{libname} -p %{libname} -#dune build --build-dir _build_%{libname}_lsp -p %{libname}-lsp - +dune build %{_smp_mflags} +dune build %{_smp_mflags} @doc %install -dune install --build-dir _build_%{libname} --prefix=%{buildroot}%{_prefix} --libdir=%{buildroot}%{_libdir}/ocaml %{libname} -#dune install --build-dir _build_%{libname}_lsp --prefix=%{buildroot}%{_prefix} --libdir=%{buildroot}%{_libdir}/ocaml %{libname}-lsp +dune install --destdir=%{buildroot} + +# We do not want the dune markers +find _build/default/_doc/_html -name .dune-keep -delete + +# We do not want the ml files +find %{buildroot}%{_libdir}/ocaml -name \*.ml -delete + +# We install the documentation with the doc macro +rm -fr %{buildroot}%{_prefix}/doc + +%ifarch %{ocaml_native_compiler} +# Add missing executable bits +find %{buildroot}%{_libdir}/ocaml -name \*.cmxs -exec chmod a+x {} \+ +%endif # Reinstall vim files to Fedora default location mkdir -p %{buildroot}%{vimfiles_root} -mv %{buildroot}%{_datadir}/%{libname}/vim/* %{buildroot}%{vimfiles_root} -rmdir %{buildroot}%{_datadir}/%{libname}/vim -rmdir %{buildroot}%{_datadir}/%{libname} -# Reinstall documents using %%doc later -rm -fr %{buildroot}%{_prefix}/doc +mv %{buildroot}%{_datadir}/%{srcname}/vim/* %{buildroot}%{vimfiles_root} +rm -fr %{buildroot}%{_datadir}/%{srcname} + +# Generate the autoload file for the Emacs interface and byte compile +cd %{buildroot}%{_emacs_sitelispdir} +emacs -batch --no-init-file --no-site-file \ + --eval "(progn (setq generated-autoload-file \"$PWD/merlin-autoloads.el\" backup-inhibited t) (update-directory-autoloads \".\"))" +mkdir -p %{buildroot}%{_emacs_sitestartdir} +mv merlin-autoloads.el %{buildroot}%{_emacs_sitestartdir} +%_emacs_bytecompile *.el +cd - %check -# Test requirement is not satisfied in Fedora - +dune runtest %files -%doc doc/* featuremap.* README.md CHANGES.md +%doc featuremap.* CHANGES.md README.md %license LICENSE -%{_bindir}/* -%{_libdir}/ocaml/%{libname} -#%{_libdir}/ocaml/%{libname}-lsp -%{_emacs_sitelispdir}/* +%{_bindir}/ocamlmerlin +%{_bindir}/ocamlmerlin-server +%{_libdir}/ocaml/%{srcname}/ + +%files -n dot-merlin-reader +%license LICENSE +%{_bindir}/dot-merlin-reader +%{_libdir}/ocaml/dot-merlin-reader/ + +%files -n emacs-merlin +%{_emacs_sitelispdir}/merlin* +%{_emacs_sitestartdir}/merlin-autoloads.el + +%files -n vim-merlin %{vimfiles_root}/*/* %changelog +* Fri Mar 26 2021 Jerry James - 4.1-2 +- Fix tests on 64-bit systems with the -test-lib64 patch +- Add -emacs-iedit patch to adapt to recent iedit changes +- Build with auto-complete, company-mode, and caml-mode support +- Add subpackages: dot-merlin-reader, emacs-merlin, and vim-merlin +- Generate autoloads for the Emacs interface + * Mon Mar 1 2021 Richard W.M. Jones - 4.1-1 - New upstream version 4.1. - OCaml 4.12.0 build