Move to pre-release of 0.3.8.

Requires dune.
This commit is contained in:
Richard W.M. Jones 2019-10-01 10:27:06 +01:00
parent 4bcc0d82b6
commit 90d5b1884b
15 changed files with 37 additions and 1313 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ ocaml-gettext-0.3.3.tar.gz
/ocaml-gettext-0.3.4.tar.gz
/ocaml-gettext-0.3.5.tar.gz
/0.3.7.tar.gz
/ocaml-gettext-0.3.8-3aecf8e5350f.tar.gz

View File

@ -1,109 +0,0 @@
From 35d2d7381c7101bb73d0b7f00fea06442c7b2ab8 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 29 Aug 2017 18:29:34 +0200
Subject: [PATCH 01/11] pr_gettext: stop tracking (and printing) untranslated
strings
Do not collect anymore the information of untranslated strings, since it
is only used to print all of them at the end of the message extraction.
While I understand the reason why this was done (i.e. to discover
potentially untranslated user strings), this is something that just
causes lots of output in complex projects, since strings are basically
used for many non-UI tasks (say Str, Sys.command, etc), so the actual
result is that there are lots of false positive. Also, this is not
something xgettext (from GNU gettext) does.
---
libgettext-ocaml/pr_gettext.ml | 44 ----------------------------------
1 file changed, 44 deletions(-)
diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
index c44933f..d78cf21 100644
--- a/libgettext-ocaml/pr_gettext.ml
+++ b/libgettext-ocaml/pr_gettext.ml
@@ -71,17 +71,10 @@ struct
module Loc = Syntax.Loc
module Ast = Syntax.Ast
- type untranslated_t =
- {
- str: string; (* Real string, not OCaml one *)
- locations: (string * int) list; (* Location in the file *)
- }
-
type t =
{
po_content: po_content;
translated: SetString.t;
- untranslated: untranslated_t MapString.t;
}
let string_of_ocaml_string str =
@@ -91,29 +84,6 @@ struct
"%S"
(fun s -> s)
- let string_not_translated t ocaml_str =
- not (SetString.mem ocaml_str t.translated)
-
- let add_untranslated t loc ocaml_str =
- let cur =
- try
- MapString.find ocaml_str t.untranslated
- with Not_found ->
- {
- str = string_of_ocaml_string ocaml_str;
- locations = [];
- }
- in
- let untranslated =
- MapString.add
- ocaml_str
- {cur with
- locations =
- (Loc.file_name loc, Loc.start_line loc) :: cur.locations}
- t.untranslated
- in
- {t with untranslated = untranslated}
-
let add_translation t loc ocaml_singular plural_opt domain =
let filepos =
@@ -164,15 +134,6 @@ struct
| Some f -> open_out f
| None -> stdout
in
- MapString.iter
- (fun _ {str = str; locations = locs} ->
- List.iter
- (fun (fn, lineno) ->
- Printf.eprintf
- "%s:%d String %S not translated\n%!"
- fn lineno str)
- locs)
- t.untranslated;
Marshal.to_channel fd t.po_content []
(* Check if the given node belong to the given functions *)
@@ -197,7 +158,6 @@ struct
val t =
{
po_content = empty_po;
- untranslated = MapString.empty;
translated = SetString.empty;
}
@@ -234,10 +194,6 @@ struct
(* Add a plural / defined domain string *)
{< t = add_translation t loc singular (Some plural) (Some domain) >}
- | <:expr@loc<$str:str$>> when
- string_not_translated t str ->
- {< t = add_untranslated t loc str >}
-
| e -> super#expr e
end
--
2.22.0

View File

@ -1,26 +0,0 @@
From 3f4fc73c2a0315c2da16dee7db0fcb2766f55d3c Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 29 Aug 2017 18:36:10 +0200
Subject: [PATCH 02/11] pr_gettext: stop printing extracted strings
They are written in the pot file already, no need to print them to
stderr (even though they are not errors).
---
libgettext-ocaml/pr_gettext.ml | 1 -
1 file changed, 1 deletion(-)
diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
index d78cf21..47d93e5 100644
--- a/libgettext-ocaml/pr_gettext.ml
+++ b/libgettext-ocaml/pr_gettext.ml
@@ -78,7 +78,6 @@ struct
}
let string_of_ocaml_string str =
- prerr_endline str;
Scanf.sscanf
(Printf.sprintf "\"%s\"" str)
"%S"
--
2.22.0

View File

@ -1,44 +0,0 @@
From 202bf1e00eaa533e133c29b509d77cdfb7c13f5e Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 29 Aug 2017 18:55:37 +0200
Subject: [PATCH 03/11] add more generated files to .gitignore
Make sure all the files generated during a build are properly ignored
from the git status.
---
.gitignore | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/.gitignore b/.gitignore
index d853d40..87821c3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,12 @@
+*.a
+*.cma
+*.cmi
+*.cmo
+*.cmx
+*.cmxa
+*.o
+*.so
+*_parser.output
/_build/
/setup.data
/setup.log
@@ -7,6 +16,12 @@
/configure
/libgettext-ocaml/META
/libgettext-ocaml/gettextConfig.ml
+/libgettext-ocaml/gettextPo_parser.mli
/config.log
/config.status
+/po/*.mo
/po/fr.po.bak
+/doc/*.1
+/doc/*.5
+/ocaml-gettext/ocaml-gettext
+/ocaml-gettext/ocaml-xgettext
--
2.22.0

View File

@ -1,53 +0,0 @@
From b1d775dd3b59f844a89603cfcc154dd18aea6202 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 12 Jul 2019 16:12:14 +0100
Subject: [PATCH 04/11] .gitignore: Add a few more ignored files and
directories.
---
.gitignore | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/.gitignore b/.gitignore
index 87821c3..59dfc69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,21 +7,24 @@
*.o
*.so
*_parser.output
-/_build/
-/setup.data
-/setup.log
-/dist/
-/test.byte
+
/ConfMakefile
-/configure
-/libgettext-ocaml/META
-/libgettext-ocaml/gettextConfig.ml
-/libgettext-ocaml/gettextPo_parser.mli
+/_build/
+/autom4te.cache/
/config.log
/config.status
-/po/*.mo
-/po/fr.po.bak
+/configure
+/dist/
/doc/*.1
/doc/*.5
+/libgettext-ocaml/META
+/libgettext-ocaml/gettextConfig.ml
+/libgettext-ocaml/gettextMo_parser.ml
+/libgettext-ocaml/gettextPo_parser.mli
/ocaml-gettext/ocaml-gettext
/ocaml-gettext/ocaml-xgettext
+/po/*.mo
+/po/fr.po.bak
+/setup.data
+/setup.log
+/test.byte
--
2.22.0

View File

@ -1,64 +0,0 @@
From 685abfdad5f66b8df3ddf0713f7d3ba733b56b60 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 12 Jul 2019 13:50:31 +0100
Subject: [PATCH 05/11] Miscellaneous changes to remove deprecated features.
- Use Bytes instead of mutable strings.
- Use String.uppercase_ascii instead of String.uppercase.
---
libgettext-ocaml/gettextMo.ml | 4 ++--
libgettext-ocaml/gettextMo_int32.ml | 2 +-
libgettext-ocaml/gettextMo_parser.mly | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libgettext-ocaml/gettextMo.ml b/libgettext-ocaml/gettextMo.ml
index fb395e8..246a115 100644
--- a/libgettext-ocaml/gettextMo.ml
+++ b/libgettext-ocaml/gettextMo.ml
@@ -164,7 +164,7 @@ let input_mo_untranslated failsafe chn mo_header number =
with End_of_file ->
raise (MoInvalidStringOutOfBound(in_channel_length chn,offset_pair))
in
- split_plural str
+ split_plural (Bytes.to_string str)
else
raise (MoInvalidStringOutOfBound(Int32.to_int mo_header.number_of_strings, number))
;;
@@ -183,7 +183,7 @@ let input_mo_translated failsafe chn mo_header number =
raise (MoInvalidTranslationOutOfBound
(in_channel_length chn,offset_pair))
in
- split_plural str
+ split_plural (Bytes.to_string str)
)
else
(
diff --git a/libgettext-ocaml/gettextMo_int32.ml b/libgettext-ocaml/gettextMo_int32.ml
index 7490a3e..4816d83 100644
--- a/libgettext-ocaml/gettextMo_int32.ml
+++ b/libgettext-ocaml/gettextMo_int32.ml
@@ -104,7 +104,7 @@ let input_int32_pair_string chn endian =
(Int32.to_int length,Int32.to_int offset)
in
if 0 <= ioffset + ilength && ioffset + ilength < in_channel_length chn then
- let str = String.make ilength 'X'
+ let str = Bytes.make ilength 'X'
in
seek_in chn ioffset;
really_input chn str 0 ilength;
diff --git a/libgettext-ocaml/gettextMo_parser.mly b/libgettext-ocaml/gettextMo_parser.mly
index 95d50e3..b2e55ca 100644
--- a/libgettext-ocaml/gettextMo_parser.mly
+++ b/libgettext-ocaml/gettextMo_parser.mly
@@ -99,7 +99,7 @@ plural_forms:
;
content_type:
- STRING SEMICOLON CHARSET EQUAL STRING { ($1,String.uppercase $5) }
+ STRING SEMICOLON CHARSET EQUAL STRING { ($1,String.uppercase_ascii $5) }
;
expr:
--
2.22.0

View File

@ -1,106 +0,0 @@
From 2894761bcccf8d51c87f8f0470ed7514a94dca9e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 12 Jul 2019 16:03:04 +0100
Subject: [PATCH 06/11] ocaml-gettext: Use cpp instead of camlp4 for #ifdef
macros.
This requires some small changes to multiline strings to allow them to
pass through cpp without error or warning.
---
ocaml-gettext/Makefile | 4 ++--
ocaml-gettext/OCamlGettext.ml | 33 +++++++++++++++++----------------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/ocaml-gettext/Makefile b/ocaml-gettext/Makefile
index 3858ea8..d5f37fa 100644
--- a/ocaml-gettext/Makefile
+++ b/ocaml-gettext/Makefile
@@ -41,12 +41,12 @@ REQUIRES = gettext.extension fileutils
ifeq ($(GETTEXT_MODULES),CAMOMILE)
REQUIRES += gettext-camomile
-INCLUDES += -pp 'camlp4o -I +camlp4 pa_macro.cmo -DCAMOMILE'
+INCLUDES += -pp 'cpp -DCAMOMILE'
endif
ifeq ($(GETTEXT_MODULES),STUB)
REQUIRES += gettext-stub
-INCLUDES += -pp 'camlp4o -I +camlp4 pa_macro.cmo -DSTUB'
+INCLUDES += -pp 'cpp -DSTUB'
endif
include ../TopMakefile
diff --git a/ocaml-gettext/OCamlGettext.ml b/ocaml-gettext/OCamlGettext.ml
index 6e72971..837057e 100644
--- a/ocaml-gettext/OCamlGettext.ml
+++ b/ocaml-gettext/OCamlGettext.ml
@@ -36,14 +36,15 @@ open GettextCategory;;
open GettextUtils;;
open FilePath.DefaultPath;;
-IFDEF CAMOMILE THEN
+#ifdef CAMOMILE
module OcamlGettextRealize = GettextCamomile.Open
-ELSE IFDEF STUB THEN
+#else
+#ifdef STUB
module OcamlGettextRealize = GettextStub.Native
-ELSE
+#else
module OcamlGettextRealize = GettextDummy.Dummy
-ENDIF
-ENDIF
+#endif
+#endif
;;
module OcamlGettext = Gettext.Program
@@ -104,12 +105,12 @@ let string_of_exception exc =
(s_ "You must specify one action.")
| InstallUninstallTooManyFilename ->
(s_
-"You cannot specify at the same time a language, a textdomain
-and provide more than one file to install/uninstall : all files
+"You cannot specify at the same time a language, a textdomain\n\
+and provide more than one file to install/uninstall : all files\n\
will have the same destination filename.")
| CompileTooManyFilename ->
(s_
-"You cannot specify a output filename and more than one
+"You cannot specify a output filename and more than one\n\
filename : all the compiled file will have the same output filename")
| _ ->
Gettext.string_of_exception exc
@@ -197,8 +198,8 @@ let guess_language_textdomain (language_option,textdomain_option) lst =
in
* (((chop_extension str_reduce), (get_extension str_reduce)),fl_mo)*)
raise (Failure
-"FilePath suffers from a default with the handling of
-chop/get_extension. This bug should disappears with
+"FilePath suffers from a default with the handling of\n\
+chop/get_extension. This bug should disappears with\n\
newer version of ocaml-fileutils")
) lst
;;
@@ -526,12 +527,12 @@ let () =
t := { !t with input_files = str :: !t.input_files }
)
(
- spf (f_ "%s
-
-Command: ocaml-gettext -action (%s) [options]
-When trying to guess language and textdomain from a
-MO file, the rules applied are: language.textdomain.mo
-
+ spf (f_ "%s\n\
+\n\
+Command: ocaml-gettext -action (%s) [options]\n\
+When trying to guess language and textdomain from a\n\
+MO file, the rules applied are: language.textdomain.mo\n\
+\n\
Options:")
gettext_copyright
(String.concat "|" (List.map fst actions))
--
2.22.0

View File

@ -1,82 +0,0 @@
From 399cf541e2abde8053b7ce39650f745c8bab8c44 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Jul 2019 13:18:35 +0100
Subject: [PATCH 07/11] Fix warnings in newer OCaml.
File "../libgettext-ocaml/gettextMo.ml", line 259, characters 13-36:
259 | | Failure("lexing: empty token") ->
^^^^^^^^^^^^^^^^^^^^^^^
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 9.5)
File "../libgettext-ocaml/gettextMo.ml", line 275, characters 15-38:
275 | | Failure("lexing: empty token") ->
^^^^^^^^^^^^^^^^^^^^^^^
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 9.5)
File "../libgettext-ocaml/gettextMo.ml", line 296, characters 15-38:
296 | | Failure("lexing: empty token") ->
^^^^^^^^^^^^^^^^^^^^^^^
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 9.5)
File "gettextStub.ml", line 101, characters 28-63:
101 | with Failure("setlocale(invalid localization)") as exc ->
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 9.5)
---
libgettext-ocaml/gettextMo.ml | 6 +++---
libgettext-stub-ocaml/gettextStub.ml | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libgettext-ocaml/gettextMo.ml b/libgettext-ocaml/gettextMo.ml
index 246a115..22630d4 100644
--- a/libgettext-ocaml/gettextMo.ml
+++ b/libgettext-ocaml/gettextMo.ml
@@ -256,7 +256,7 @@ let input_mo_informations failsafe chn mo_header =
GettextMo_parser.main GettextMo_lexer.token_field_name lexbuf
with
Parsing.Parse_error
- | Failure("lexing: empty token") ->
+ | Failure _ ->
fail_or_continue failsafe
(MoInvalidOptions (lexbuf,empty_translation))
[]
@@ -272,7 +272,7 @@ let input_mo_informations failsafe chn mo_header =
GettextMo_lexer.token_field_plural_value lexbuf
with
Parsing.Parse_error
- | Failure("lexing: empty token") ->
+ | Failure _ ->
fail_or_continue
failsafe
(MoInvalidPlurals(lexbuf,field_plural_forms))
@@ -293,7 +293,7 @@ let input_mo_informations failsafe chn mo_header =
GettextMo_lexer.token_field_content_type lexbuf
with
Parsing.Parse_error
- | Failure("lexing: empty token") ->
+ | Failure _ ->
fail_or_continue failsafe
(MoInvalidContentType(lexbuf,field_content_type))
gettext_content
diff --git a/libgettext-stub-ocaml/gettextStub.ml b/libgettext-stub-ocaml/gettextStub.ml
index 03ac2a5..dc798a2 100644
--- a/libgettext-stub-ocaml/gettextStub.ml
+++ b/libgettext-stub-ocaml/gettextStub.ml
@@ -98,7 +98,7 @@ module Native : GettextTypes.REALIZE_TYPE =
(
try
GettextStubCompat.setlocale GettextStubCompat.LC_ALL language
- with Failure("setlocale(invalid localization)") as exc ->
+ with Failure _ as exc ->
let () =
fail_or_continue t.failsafe exc ()
in
--
2.22.0

View File

@ -1,31 +0,0 @@
From 1ac10b2d4ee97e490880dbf8e70842f771c4e02e Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 18 Jul 2019 13:20:50 +0100
Subject: [PATCH 08/11] Fix probable incorrect definition of unit type.
echo File "../libgettext-ocaml/gettextCharset.ml", line 48, characters 4-15:
48 | type u = ()
^^^^^^^^^^^
Warning 65: This type declaration is defining a new '()' constructor
which shadows the existing one.
Hint: Did you mean 'type u = unit'?
---
libgettext-ocaml/gettextCharset.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgettext-ocaml/gettextCharset.ml b/libgettext-ocaml/gettextCharset.ml
index 54cd75d..1963708 100644
--- a/libgettext-ocaml/gettextCharset.ml
+++ b/libgettext-ocaml/gettextCharset.ml
@@ -45,7 +45,7 @@ module type CHARSET_TYPE =
module Dummy : CHARSET_TYPE =
struct
type encoding = string
- type u = ()
+ type u = unit
let create t in_enc out_enc = ()
--
2.22.0

View File

@ -1,597 +0,0 @@
From 739e3a900993299e7e8b90af3da565417eb84412 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 12 Jul 2019 16:02:16 +0100
Subject: [PATCH 09/11] Convert from camlp4 to ppx for translatable string
extraction.
---
aclocal.m4 | 6 +-
configure.in | 3 -
libgettext-ocaml/Makefile | 17 ---
libgettext-ocaml/pr_gettext.ml | 218 -------------------------------
ocaml-gettext/Makefile | 11 +-
ocaml-gettext/OCamlGettext.ml | 2 +-
ocaml-gettext/xgettext.ml | 228 +++++++++++++++++++++++++++++++++
test/test.ml | 4 +-
8 files changed, 234 insertions(+), 255 deletions(-)
delete mode 100644 libgettext-ocaml/pr_gettext.ml
create mode 100644 ocaml-gettext/xgettext.ml
diff --git a/aclocal.m4 b/aclocal.m4
index 72a27da..2a1110f 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -204,7 +204,7 @@ else
fi
])
-# AC_CHECK_[CAMLP4,CAMLIDL,OCAMLMKLIB,MKCAMLP4] ([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+# AC_CHECK_[CAMLIDL,OCAMLMKLIB] ([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
#---------------------------------------------------------
# Subst the corresponding var
AC_DEFUN([AC_CHECK_STAR],
@@ -219,12 +219,8 @@ else
fi
AC_SUBST($1)
])
-AC_DEFUN([AC_CHECK_CAMLP4], [AC_CHECK_STAR(CAMLP4,camlp4,$1,$2)])
-AC_DEFUN([AC_CHECK_CAMLP4OF], [AC_CHECK_STAR(CAMLP4OF,camlp4of,$1,$2)])
-AC_DEFUN([AC_CHECK_CAMLP4O], [AC_CHECK_STAR(CAMLP4O,camlp4o,$1,$2)])
AC_DEFUN([AC_CHECK_CAMLIDL], [AC_CHECK_STAR(CAMLIDL,camlidl,$1,$2)])
AC_DEFUN([AC_CHECK_OCAMLMKLIB], [AC_CHECK_STAR(OCAMLMKLIB,ocamlmklib,$1,$2)])
-AC_DEFUN([AC_CHECK_MKCAMLP4], [AC_CHECK_STAR(MKCAMLP4,mkcamlp4,$1,$2)])
AC_DEFUN([AC_CHECK_OCAMLDOC], [AC_CHECK_STAR(OCAMLDOC,ocamldoc,$1,$2)])
AC_DEFUN([AC_CHECK_XSLTPROC], [AC_CHECK_STAR(XSLTPROC,xsltproc,$1,$2)])
AC_DEFUN([AC_CHECK_XMLLINT], [AC_CHECK_STAR(XMLLINT,xmllint,$1,$2)])
diff --git a/configure.in b/configure.in
index 9840d2b..3ef4c8d 100644
--- a/configure.in
+++ b/configure.in
@@ -85,9 +85,6 @@ AC_CHECK_OCAMLOPT([],[AC_MSG_WARN(Cannot find ocamlopt, byte compilation only)])
AC_CHECK_OCAMLLEX([],[AC_MSG_ERROR(Cannot find ocamllex.)])
AC_CHECK_OCAMLYACC([],[AC_MSG_ERROR(Cannot find ocamlyacc.)])
AC_CHECK_OCAMLFIND([],[AC_MSG_ERROR(Cannot find ocamlfind.)])
-AC_CHECK_CAMLP4([],[AC_MSG_ERROR(Cannot find camlp4.)])
-AC_CHECK_CAMLP4O([],[AC_MSG_ERROR(Cannot find camlp4o.)])
-AC_CHECK_CAMLP4OF([],[AC_MSG_ERROR(Cannot find camlp4of.)])
AC_CHECK_OCAMLMKLIB([],[AC_MSG_ERROR(Cannot find ocamlmklib.)])
if test "x$BUILD_DOC" = "xyes"; then
diff --git a/libgettext-ocaml/Makefile b/libgettext-ocaml/Makefile
index 1a155c1..e64e0a1 100644
--- a/libgettext-ocaml/Makefile
+++ b/libgettext-ocaml/Makefile
@@ -161,22 +161,5 @@ clean::
-$(RM) gettextCompile.mli
-$(RM) gettextMo.mli
-########################
-# Pa_gettext extension #
-########################
-
-INSTALLIB += \
- pr_gettext.cmo
-
-pr_gettext.cmo: pr_gettext.ml
- ocamlc \
- -I +camlp4 \
- -I $(shell ocamlc -where)/camlp4/Camlp4Parsers \
- -pp camlp4of \
- camlp4lib.cma \
- gettextBase.cma \
- gettextExtension.cma \
- -c $< -o $@
-
include ../ConfMakefile
include ../TopMakefile
diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
deleted file mode 100644
index 47d93e5..0000000
--- a/libgettext-ocaml/pr_gettext.ml
+++ /dev/null
@@ -1,218 +0,0 @@
-(**************************************************************************)
-(* ocaml-gettext: a library to translate messages *)
-(* *)
-(* Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> *)
-(* *)
-(* This library is free software; you can redistribute it and/or *)
-(* modify it under the terms of the GNU Lesser General Public *)
-(* License as published by the Free Software Foundation; either *)
-(* version 2.1 of the License, or (at your option) any later version; *)
-(* with the OCaml static compilation exception. *)
-(* *)
-(* This library 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 *)
-(* Lesser General Public License for more details. *)
-(* *)
-(* You should have received a copy of the GNU Lesser General Public *)
-(* License along with this library; if not, write to the Free Software *)
-(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)
-(* USA *)
-(**************************************************************************)
-
-(** Camlp4 dumper to extract strings.
- @author Sylvain Le Gall
- @author Richard W.M. Jones (translation to OCaml 3.10.X new camlp4)
- *)
-
-(* Extract the string which should be used for a gettext translation. Output a
- po_content list through the function Marshal.to_channel
- Functions that are looked for :
-Functions Arg 1 Arg 2 Arg 3 Arg 4 Arg 5 Arg 6 ...
-s_ singular
-f_ singular
-sn_ singular plural _
-fn_ singular plural _
-gettext _ singular
-fgettext _ singular
-dgettext _ domain singular
-fdgettext _ domain singular
-dcgettext _ domain singular _
-fdcgettext _ domain singular _
-ngettext _ singular plural _
-fngettext _ singular plural _
-dngettext _ domain singular plural _
-fdngettext _ domain singular plural _
-dcngettext _ domain singular plural _ _
-fdcngettext _ domain singular plural _ _
-
-
-All this function name should also be matched when they are called using a
-module.
-
-*)
-
-open Format
-open GettextTypes
-open GettextPo
-
-let default_textdomain = ref None
-
-module Id = struct
- (* name is printed with the -loaded-modules switch *)
- let name = "pr_gettext"
- (* cvs id's seem to be the preferred version string *)
- let version = "$Id$"
-end
-
-module Make (Syntax : Camlp4.Sig.Camlp4Syntax)
- : Camlp4.Sig.Printer(Syntax.Ast).S =
-struct
- module Loc = Syntax.Loc
- module Ast = Syntax.Ast
-
- type t =
- {
- po_content: po_content;
- translated: SetString.t;
- }
-
- let string_of_ocaml_string str =
- Scanf.sscanf
- (Printf.sprintf "\"%s\"" str)
- "%S"
- (fun s -> s)
-
-
- let add_translation t loc ocaml_singular plural_opt domain =
- let filepos =
- Loc.file_name loc, Loc.start_line loc
- in
- let singular =
- string_of_ocaml_string ocaml_singular
- in
- let translated =
- SetString.add ocaml_singular t.translated
- in
- let translated, translation =
- match plural_opt with
- | Some ocaml_plural ->
- let plural =
- string_of_ocaml_string ocaml_plural
- in
- SetString.add ocaml_plural translated,
- {
- po_comment_special = [];
- po_comment_filepos = [filepos];
- po_comment_translation = PoPlural([singular],[plural],[[""];[""]]);
- }
- | None ->
- translated,
- {
- po_comment_special = [];
- po_comment_filepos = [filepos];
- po_comment_translation = PoSingular([singular],[""]);
- }
- in
- let po_content =
- match domain, !default_textdomain with
- | Some domain, _ ->
- add_po_translation_domain domain t.po_content translation
- | None, Some domain ->
- add_po_translation_domain domain t.po_content translation
- | None, None ->
- add_po_translation_no_domain t.po_content translation
- in
- {t with
- po_content = po_content;
- translated = translated}
-
- let output_translations ?output_file t =
- let fd =
- match output_file with
- | Some f -> open_out f
- | None -> stdout
- in
- Marshal.to_channel fd t.po_content []
-
- (* Check if the given node belong to the given functions *)
- let is_like e functions =
- let rec function_name e =
- match e with
- | <:ident<$_$.$id:e$>> ->
- function_name e
- | <:ident<$lid:s$>> ->
- s
- | _ ->
- raise Not_found
- in
- try
- List.mem (function_name e) functions
- with Not_found ->
- false
-
- class visitor = object
- inherit Ast.fold as super
-
- val t =
- {
- po_content = empty_po;
- translated = SetString.empty;
- }
-
- method t = t
-
- method expr = function
- | <:expr@loc< $id:e$ $str:singular$ >> when
- is_like e ["s_"; "f_"] ->
- (* Add a singular / default domain string *)
- {< t = add_translation t loc singular None None >}
-
- | <:expr@loc< $id:e$ $str:singular$ $str:plural$ >> when
- is_like e ["sn_"; "fn_"] ->
- (* Add a plural / default domain string *)
- {< t = add_translation t loc singular (Some plural) None >}
-
- | <:expr@loc< $id:e$ $expr$ $str:singular$ >> when
- is_like e ["gettext"; "fgettext"] ->
- (* Add a singular / default domain string *)
- {< t = add_translation t loc singular None None >}
-
- | <:expr@loc< $id:e$ $expr$ $str:domain$ $str:singular$ >> when
- is_like e ["dgettext"; "fdgettext"; "dcgettext"; "fdcgettext"] ->
- (* Add a singular / defined domain string *)
- {< t = add_translation t loc singular None (Some domain) >}
-
- | <:expr@loc< $id:e$ $expr$ $str:singular$ $str:plural$ >> when
- is_like e ["ngettext"; "fngettext"] ->
- (* Add a plural / default domain string *)
- {< t = add_translation t loc singular (Some plural) None >}
-
- | <:expr@loc< $id:e$ $expr$ $str:domain$ $str:singular$ $str:plural$ >> when
- is_like e ["dngettext"; "fdngettext"; "dcngettext"; "fdcngettext"] ->
- (* Add a plural / defined domain string *)
- {< t = add_translation t loc singular (Some plural) (Some domain) >}
-
- | e -> super#expr e
-
- end
-
- (* Called on *.mli files, but cannot contain translateable strings. *)
- let print_interf ?input_file ?output_file _ = ()
-
- (* Called on *.ml files. *)
- let print_implem ?input_file ?output_file ast =
- let visitor = (new visitor)#str_item in
- let t = (visitor ast)#t in
- output_translations ?output_file t
-end
-
-(* Register the new printer. *)
-module M = Camlp4.Register.OCamlPrinter(Id)(Make) ;;
-
-(* XXX How to do this?
-Pcaml.add_option "-default-textdomain"
- (Arg.String ( fun textdomain -> default_textdomain := Some textdomain ) )
- "<textdomain> Defines the default textdomain"
-;;
-*)
diff --git a/ocaml-gettext/Makefile b/ocaml-gettext/Makefile
index d5f37fa..0c1199e 100644
--- a/ocaml-gettext/Makefile
+++ b/ocaml-gettext/Makefile
@@ -61,14 +61,9 @@ install: ocaml-xgettext-install
uninstall: ocaml-xgettext-uninstall
-ocaml-xgettext: $(BUILDBIN)
- $(OCAMLC) \
- -I +camlp4 dynlink.cma camlp4lib.cma \
- `$(OCAMLFIND) query -r -predicates byte gettext.extract -i-format` \
- `$(OCAMLFIND) query -r -predicates byte gettext.extract -a-format` \
- `$(OCAMLFIND) query -r -predicates byte gettext.extract -o-format` \
- Camlp4Bin.cmo \
- -o $@
+ocaml-xgettext: xgettext.ml
+ $(OCAMLC) -I ../libgettext-ocaml -I +compiler-libs \
+ ocamlcommon.cma gettextBase.cma gettextExtension.cma $< -o $@
$(INSTALL_SCRIPT) -t $(BUILDBIN) $@
ocaml-xgettext-install:
diff --git a/ocaml-gettext/OCamlGettext.ml b/ocaml-gettext/OCamlGettext.ml
index 837057e..d643a9b 100644
--- a/ocaml-gettext/OCamlGettext.ml
+++ b/ocaml-gettext/OCamlGettext.ml
@@ -283,7 +283,7 @@ let () =
{
action_option = None;
extract_command = "ocaml-xgettext";
- extract_default_option = "-I +camlp4 pa_o.cmo";
+ extract_default_option = "";
extract_filename_options = [];
extract_pot = "messages.pot";
compile_output_file_option = None;
diff --git a/ocaml-gettext/xgettext.ml b/ocaml-gettext/xgettext.ml
new file mode 100644
index 0000000..76232d8
--- /dev/null
+++ b/ocaml-gettext/xgettext.ml
@@ -0,0 +1,228 @@
+(**************************************************************************)
+(* ocaml-gettext: a library to translate messages *)
+(* *)
+(* Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> *)
+(* *)
+(* This library is free software; you can redistribute it and/or *)
+(* modify it under the terms of the GNU Lesser General Public *)
+(* License as published by the Free Software Foundation; either *)
+(* version 2.1 of the License, or (at your option) any later version; *)
+(* with the OCaml static compilation exception. *)
+(* *)
+(* This library 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 *)
+(* Lesser General Public License for more details. *)
+(* *)
+(* You should have received a copy of the GNU Lesser General Public *)
+(* License along with this library; if not, write to the Free Software *)
+(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)
+(* USA *)
+(**************************************************************************)
+
+(** PPX dumper to extract strings.
+ @author Richard W.M. Jones
+ @author Sylvain Le Gall
+ *)
+
+(* Extract the string which should be used for a gettext translation. Output a
+ po_content list through the function Marshal.to_channel
+ Functions that are looked for :
+
+Functions Arg 1 Arg 2 Arg 3 Arg 4 Arg 5 Arg 6 ...
+s_ singular
+f_ singular
+sn_ singular plural _
+fn_ singular plural _
+gettext _ singular
+fgettext _ singular
+dgettext _ domain singular
+fdgettext _ domain singular
+dcgettext _ domain singular _
+fdcgettext _ domain singular _
+ngettext _ singular plural _
+fngettext _ singular plural _
+dngettext _ domain singular plural _
+fdngettext _ domain singular plural _
+dcngettext _ domain singular plural _ _
+fdcngettext _ domain singular plural _ _
+
+All this function name should also be matched when they are called using a
+module.
+
+*)
+
+open GettextTypes
+open GettextPo
+open Parsetree
+open Longident
+open Location
+
+type t = {
+ po_content: po_content;
+ translated: SetString.t;
+}
+
+let string_of_ocaml_string str =
+ Scanf.sscanf
+ (Printf.sprintf "\"%s\"" str)
+ "%S"
+ (fun s -> s)
+
+let translations = ref { po_content = empty_po; translated = SetString.empty }
+
+let default_textdomain = ref None
+
+let current_file = ref ""
+
+let add_translation loc ocaml_singular plural_opt domain =
+ let t = !translations in
+
+ let filepos =
+ let start = loc.Location.loc_start in
+ let fname =
+ match start.Lexing.pos_fname with "" -> !current_file
+ | fname -> fname in
+ fname, start.Lexing.pos_lnum
+ in
+ let singular =
+ string_of_ocaml_string ocaml_singular
+ in
+ let translated =
+ SetString.add ocaml_singular t.translated
+ in
+ let translated, translation =
+ match plural_opt with
+ | Some ocaml_plural ->
+ let plural =
+ string_of_ocaml_string ocaml_plural
+ in
+ SetString.add ocaml_plural translated,
+ {
+ po_comment_special = [];
+ po_comment_filepos = [filepos];
+ po_comment_translation = PoPlural([singular],[plural],[[""];[""]]);
+ }
+ | None ->
+ translated,
+ {
+ po_comment_special = [];
+ po_comment_filepos = [filepos];
+ po_comment_translation = PoSingular([singular],[""]);
+ }
+ in
+ let po_content =
+ match domain, !default_textdomain with
+ | Some domain, _ ->
+ add_po_translation_domain domain t.po_content translation
+ | None, Some domain ->
+ add_po_translation_domain domain t.po_content translation
+ | None, None ->
+ add_po_translation_no_domain t.po_content translation
+ in
+
+ translations := { po_content; translated }
+
+let output_translations ?output_file t =
+ let fd =
+ match output_file with
+ | Some f -> open_out f
+ | None -> stdout
+ in
+ Marshal.to_channel fd t.po_content []
+
+let rec is_like lid = function
+ | [] -> false
+ | func :: functions ->
+ match lid with
+ | Lident f
+ | Ldot (_, f) when f = func -> true
+ | _ -> is_like lid functions
+
+let visit_expr (iterator : Ast_iterator.iterator) expr =
+ let loc = expr.pexp_loc in
+ match expr.pexp_desc with
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ _)
+ when is_like lid ["s_"; "f_"] ->
+ (* Add a singular / default domain string *)
+ add_translation loc singular None None
+
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (plural, _)) }) ::
+ _)
+ when is_like lid ["sn_"; "fn_"] ->
+ (* Add a plural / default domain string *)
+ add_translation loc singular (Some plural) None
+
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (_ ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ _))
+ when is_like lid ["gettext"; "fgettext"] ->
+ (* Add a singular / default domain string *)
+ add_translation loc singular None None
+
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (_ ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (domain, _)) }) ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ _))
+ when is_like lid ["dgettext"; "fdgettext"; "dcgettext"; "fdcgettext"] ->
+ (* Add a singular / defined domain string *)
+ add_translation loc singular None (Some domain)
+
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (_ ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (plural, _)) }) ::
+ _))
+ when is_like lid ["ngettext"; "fngettext"] ->
+ (* Add a plural / default domain string *)
+ add_translation loc singular (Some plural) None
+
+ | Pexp_apply (
+ { pexp_desc = Pexp_ident ({ Asttypes.txt = lid })},
+ (_ ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (domain, _)) }) ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (singular, _)) }) ::
+ (Asttypes.Nolabel,
+ { pexp_desc = Pexp_constant (Pconst_string (plural, _)) }) ::
+ _))
+ when is_like lid ["dngettext"; "fdngettext"; "dcngettext"; "fdcngettext"] ->
+ (* Add a plural / defined domain string *)
+ add_translation loc singular (Some plural) (Some domain)
+
+ | _ ->
+ Ast_iterator.default_iterator.expr iterator expr
+
+let ast_iterator =
+ { Ast_iterator.default_iterator with expr = visit_expr }
+
+let go fn =
+ current_file := fn;
+ let lexbuf = Lexing.from_channel (open_in fn) in
+ let structure = Parse.implementation lexbuf in
+ ast_iterator.Ast_iterator.structure ast_iterator structure
+
+let () =
+ (* XXX Add -default-textdomain option which sets default_textdomain. *)
+ Arg.parse [] go "";
+ output_translations !translations
diff --git a/test/test.ml b/test/test.ml
index bf59889..331c677 100644
--- a/test/test.ml
+++ b/test/test.ml
@@ -353,9 +353,7 @@ let compatibility_test tests =
(*******************************************)
let extract_test tests =
- let default_options =
- "-I +camlp4 pa_o.cmo"
- in
+ let default_options = "" in
let filename_options =
MapString.empty
in
--
2.22.0

View File

@ -1,33 +0,0 @@
From 5030d465a8b7b8232b3559d48cf9aba592efefab Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 19 Jul 2019 11:23:09 +0100
Subject: [PATCH 10/11] xgettext: Print filename when exceptions are thrown.
---
ocaml-gettext/xgettext.ml | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/ocaml-gettext/xgettext.ml b/ocaml-gettext/xgettext.ml
index 76232d8..569d40d 100644
--- a/ocaml-gettext/xgettext.ml
+++ b/ocaml-gettext/xgettext.ml
@@ -218,9 +218,13 @@ let ast_iterator =
let go fn =
current_file := fn;
- let lexbuf = Lexing.from_channel (open_in fn) in
- let structure = Parse.implementation lexbuf in
- ast_iterator.Ast_iterator.structure ast_iterator structure
+ try
+ let lexbuf = Lexing.from_channel (open_in fn) in
+ let structure = Parse.implementation lexbuf in
+ ast_iterator.Ast_iterator.structure ast_iterator structure
+ with
+ exn ->
+ failwith (fn ^ ": " ^ Printexc.to_string exn)
let () =
(* XXX Add -default-textdomain option which sets default_textdomain. *)
--
2.22.0

View File

@ -1,61 +0,0 @@
From e15ca7b11c6da676097c1458df8306355044e817 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 19 Jul 2019 11:34:28 +0100
Subject: [PATCH 11/11] xgettext: Remove attempt to convert strings from "OCaml
strings" to strings.
---
ocaml-gettext/xgettext.ml | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/ocaml-gettext/xgettext.ml b/ocaml-gettext/xgettext.ml
index 569d40d..111514c 100644
--- a/ocaml-gettext/xgettext.ml
+++ b/ocaml-gettext/xgettext.ml
@@ -63,19 +63,13 @@ type t = {
translated: SetString.t;
}
-let string_of_ocaml_string str =
- Scanf.sscanf
- (Printf.sprintf "\"%s\"" str)
- "%S"
- (fun s -> s)
-
let translations = ref { po_content = empty_po; translated = SetString.empty }
let default_textdomain = ref None
let current_file = ref ""
-let add_translation loc ocaml_singular plural_opt domain =
+let add_translation loc singular plural_opt domain =
let t = !translations in
let filepos =
@@ -85,19 +79,13 @@ let add_translation loc ocaml_singular plural_opt domain =
| fname -> fname in
fname, start.Lexing.pos_lnum
in
- let singular =
- string_of_ocaml_string ocaml_singular
- in
let translated =
- SetString.add ocaml_singular t.translated
+ SetString.add singular t.translated
in
let translated, translation =
match plural_opt with
- | Some ocaml_plural ->
- let plural =
- string_of_ocaml_string ocaml_plural
- in
- SetString.add ocaml_plural translated,
+ | Some plural ->
+ SetString.add plural translated,
{
po_comment_special = [];
po_comment_filepos = [filepos];
--
2.22.0

View File

@ -1,33 +0,0 @@
--- ocaml-gettext-0.3.4/TopMakefile.old 2013-09-14 08:54:04.713986462 +0100
+++ ocaml-gettext-0.3.4/TopMakefile 2013-09-14 08:54:18.319006115 +0100
@@ -102,7 +102,7 @@
%.cmxa %.a %.so:
$(if $(STUBSOBJS), \
$(OCAMLMKLIB) -o $* $^ $(OCAMLMKLIB_FLAGS), \
- $(OCAMLOPT) -a -o $*.cmxa $^ \
+ $(OCAMLOPT) -g -a -o $*.cmxa $^ \
)
%.cma %.a %.so:
@@ -161,7 +161,7 @@
OLIBS = $(addsuffix .cmxa,$(LIBS))
install-buildprog-opt: $(CMX)
- $(OCAMLOPT) -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
+ $(OCAMLOPT) -g -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
-predicates "$(PREDICATES)" $(OLIBS) $(CMX)
$(INSTALL) -d $(BUILDBIN)
$(INSTALL_SCRIPT) -t $(BUILDBIN) $(NAME)
@@ -300,10 +300,10 @@
$(OCAMLC) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.ml.o:
- $(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
+ $(OCAMLOPT) -g $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.ml.cmx:
- $(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
+ $(OCAMLOPT) -g $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.mll.ml:
$(OCAMLLEX) $<

View File

@ -1,39 +1,24 @@
%global opt %(test -x %{_bindir}/ocamlopt && echo 1 || echo 0)
Name: ocaml-gettext
Version: 0.3.7
Release: 13%{?dist}
Version: 0.3.8
Release: 0.1.git3aecf8e5350f%{?dist}
Summary: OCaml library for i18n
License: LGPLv2+ with exceptions
URL: https://github.com/gildor478/ocaml-gettext
Source0: https://github.com/gildor478/%{name}/archive/%{version}.tar.gz
Patch0: ocaml-gettext-0.3.4-use-ocamlopt-g.patch
# All patches from upstream since 0.3.7 was released. In particular
# these fix immutable strings and remove the dependency on camlp4, as
# well as fixing some warnings and other minor issues.
Patch0001: 0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
Patch0002: 0002-pr_gettext-stop-printing-extracted-strings.patch
Patch0003: 0003-add-more-generated-files-to-.gitignore.patch
Patch0004: 0004-.gitignore-Add-a-few-more-ignored-files-and-director.patch
Patch0005: 0005-Miscellaneous-changes-to-remove-deprecated-features.patch
Patch0006: 0006-ocaml-gettext-Use-cpp-instead-of-camlp4-for-ifdef-ma.patch
Patch0007: 0007-Fix-warnings-in-newer-OCaml.patch
Patch0008: 0008-Fix-probable-incorrect-definition-of-unit-type.patch
Patch0009: 0009-Convert-from-camlp4-to-ppx-for-translatable-string-e.patch
# https://github.com/gildor478/ocaml-gettext/pull/5
Patch0010: 0010-xgettext-Print-filename-when-exceptions-are-thrown.patch
Patch0011: 0011-xgettext-Remove-attempt-to-convert-strings-from-OCam.patch
#Source0: https://github.com/gildor478/%{name}/archive/%{version}.tar.gz
# Temporarily using a preview of 0.3.8 built from git:
# git archive --format=tar --prefix=ocaml-gettext-0.3.8/ 3aecf8e5350f | gzip > ocaml-gettext-0.3.8-3aecf8e5350f.tar.gz
Source0: ocaml-gettext-0.3.8-3aecf8e5350f.tar.gz
BuildRequires: ocaml >= 4.00.1
BuildRequires: ocaml-findlib-devel >= 1.3.3-3
BuildRequires: ocaml-compiler-libs
BuildRequires: ocaml-ocamldoc
BuildRequires: ocaml-fileutils-devel >= 0.4.4-4
BuildRequires: ocaml-dune-devel
BuildRequires: docbook-style-xsl
BuildRequires: libxslt
BuildRequires: libxml2
@ -106,59 +91,29 @@ signature files for developing applications that use
%prep
%setup -q
%autopatch -p1
#autopatch -p1
autoreconf -i
# Remove dependency on batteries.
sed -i -e 's/batteries//' test/dune
sed -i -e 's/batteries//' test/test-stub/dune
%build
# Parallel builds don't work.
unset MAKEFLAGS
CFLAGS="$RPM_OPT_FLAGS" \
./configure \
--libdir=%{_libdir} \
%if 0%{?rhel}
--disable-camomile \
%else
--enable-test \
%endif
--with-docbook-stylesheet=/usr/share/sgml/docbook/xsl-stylesheets
make all
make build
%check
# Some of these tests fail, and unfortunately the test program doesn't
# exit with a failure code. However I have examined the test failures
# together with upstream to check that there is nothing important.
%if %opt
%if !0%{?rhel}
pushd test
../_build/bin/test
popd
%endif
%endif
#check
# Tests require batteries, so they are disabled at present.
# Under discussion with upstream.
%install
# make install in the package is screwed up completely. Install
# by hand instead.
export DESTDIR=$RPM_BUILD_ROOT
export OCAMLFIND_DESTDIR=$RPM_BUILD_ROOT%{_libdir}/ocaml
mkdir -p $OCAMLFIND_DESTDIR $OCAMLFIND_DESTDIR/stublibs
mkdir -p $RPM_BUILD_ROOT%{_libdir}/ocaml
mkdir -p $RPM_BUILD_ROOT%{_bindir}
dune install --destdir=$RPM_BUILD_ROOT
# Remove *.o files - these shouldn't be distributed.
find _build -name '*.o' -exec rm {} \;
ocamlfind install gettext _build/lib/gettext/*
ocamlfind install gettext-stub _build/lib/gettext-stub/*
%if !0%{?rhel}
ocamlfind install gettext-camomile _build/lib/gettext-camomile/*
%endif
install -m 0755 _build/bin/ocaml-gettext $RPM_BUILD_ROOT%{_bindir}/
install -m 0755 _build/bin/ocaml-xgettext $RPM_BUILD_ROOT%{_bindir}/
chrpath --delete $OCAMLFIND_DESTDIR/stublibs/dll*.so
# Remove this, we will use our own rules for documentation.
rm -rf $RPM_BUILD_ROOT/usr/doc
%files
@ -168,31 +123,34 @@ chrpath --delete $OCAMLFIND_DESTDIR/stublibs/dll*.so
%if %opt
%exclude %{_libdir}/ocaml/gettext/*.a
%exclude %{_libdir}/ocaml/gettext/*.cmxa
%exclude %{_libdir}/ocaml/gettext/*.cmx
%exclude %{_libdir}/ocaml/gettext/*/*.a
%exclude %{_libdir}/ocaml/gettext/*/*.cmxa
%exclude %{_libdir}/ocaml/gettext/*/*.cmx
%exclude %{_libdir}/ocaml/gettext-stub/*.a
%exclude %{_libdir}/ocaml/gettext-stub/*.cmxa
%exclude %{_libdir}/ocaml/gettext-stub/*.cmx
%endif
%exclude %{_libdir}/ocaml/gettext/*.ml
%exclude %{_libdir}/ocaml/gettext/*.mli
%exclude %{_libdir}/ocaml/gettext/*/*.ml
%exclude %{_libdir}/ocaml/gettext/*/*.mli
%exclude %{_libdir}/ocaml/gettext-stub/*.ml
%{_libdir}/ocaml/stublibs/*.so
%{_libdir}/ocaml/stublibs/*.so.owner
%files devel
%doc README CHANGELOG TODO
%doc README.md CHANGELOG THANKS TODO.md
# %doc build/share/doc/html/*
%if %opt
%{_libdir}/ocaml/gettext/*.a
%{_libdir}/ocaml/gettext/*.cmxa
%{_libdir}/ocaml/gettext/*.cmx
%{_libdir}/ocaml/gettext/*/*.a
%{_libdir}/ocaml/gettext/*/*.cmxa
%{_libdir}/ocaml/gettext/*/*.cmx
%{_libdir}/ocaml/gettext-stub/*.a
%{_libdir}/ocaml/gettext-stub/*.cmxa
%{_libdir}/ocaml/gettext-stub/*.cmx
%endif
%{_libdir}/ocaml/gettext/*.ml
%{_libdir}/ocaml/gettext/*.mli
%{_libdir}/ocaml/gettext/*/*.ml
%{_libdir}/ocaml/gettext/*/*.mli
%{_libdir}/ocaml/gettext-stub/*.ml
%{_bindir}/ocaml-gettext
%{_bindir}/ocaml-xgettext
@ -211,7 +169,7 @@ chrpath --delete $OCAMLFIND_DESTDIR/stublibs/dll*.so
%files camomile-devel
%doc README
%doc README.md
%if %opt
%{_libdir}/ocaml/gettext-camomile/*.a
%{_libdir}/ocaml/gettext-camomile/*.cmxa
@ -222,6 +180,10 @@ chrpath --delete $OCAMLFIND_DESTDIR/stublibs/dll*.so
%changelog
* Tue Oct 1 2019 Richard W.M. Jones <rjones@redhat.com> - 0.3.8-0.1
- Move to pre-release of 0.3.8.
- Requires dune.
* Fri Aug 16 2019 Richard W.M. Jones <rjones@redhat.com> - 0.3.7-13
- Bump release and rebuild.

View File

@ -1 +1 @@
SHA512 (0.3.7.tar.gz) = 1358320359b9d2f3fd97a47d69b2a619942a65605c1e5cbf25e33ef42a10273167b526bca15e6c9523b87d8ea9dfd3215334050ad8eb84a8c41d4feef880a27a
SHA512 (ocaml-gettext-0.3.8-3aecf8e5350f.tar.gz) = f35f6e7a1cef84eb24f3c5ec03c8d0646dcc1151cd1182f5448b181aa765d653042eebcef148fef59643dbb38f3349b393a17d824ee74f106f537f1314fc9550