This commit is contained in:
Richard W.M. Jones 2020-08-24 10:48:48 +01:00
parent e699447e52
commit 12c4bb55a5
2 changed files with 86 additions and 2 deletions

View File

@ -0,0 +1,83 @@
From 1a9bd729b97db408022995f93b19678706a79ca7 Mon Sep 17 00:00:00 2001
From: Rudi Grinberg <me@rgrinberg.com>
Date: Mon, 24 Aug 2020 02:39:59 -0700
Subject: [PATCH] [configurator] more workaround for extracting #define
allow duplicate values if they are the same _after_ conversion
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
---
otherlibs/configurator/src/v1.ml | 46 ++++++++++++++++++--------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/otherlibs/configurator/src/v1.ml b/otherlibs/configurator/src/v1.ml
index 721c0e7384..7e5dc19883 100644
--- a/otherlibs/configurator/src/v1.ml
+++ b/otherlibs/configurator/src/v1.ml
@@ -466,10 +466,6 @@ module C_define = struct
| Switch of bool
| Int of int
| String of string
-
- let switch b = Switch b
-
- let int i = Int i
end
let extract_program ?prelude includes vars =
@@ -544,29 +540,39 @@ const char *s%i = "BEGIN-%i-false-END";
Error [ v; v' ] )))
in
List.mapi vars ~f:(fun i (name, t) ->
- let raw_val =
+ let raw_vals =
match Int.Map.find values i with
+ | Some (Ok v) -> [ v ]
+ | Some (Error vs) -> vs
| None -> die "Unable to get value for %s" name
- | Some (Ok v) -> v
- | Some (Error vs) ->
- let vs = List.sort_uniq ~cmp:compare vs in
+ in
+ let parse_val_or_exn f =
+ let f x =
+ match f x with
+ | Some s -> s
+ | None ->
+ die
+ "Unable to read variable %S of type %s. Invalid value %S in %s \
+ found"
+ name (Type.name t) x obj_file
+ in
+ let vs =
+ List.map ~f:(fun x -> (x, f x)) raw_vals
+ |> List.sort_uniq ~cmp:(fun (_, x) (_, y) -> compare x y)
+ in
+ match vs with
+ | [] -> assert false
+ | [ (_, v) ] -> v
+ | vs ->
+ let vs = List.map ~f:fst vs in
die "Duplicate values for %s:\n%s" name
(vs |> List.map ~f:(sprintf "- %s") |> String.concat ~sep:"\n")
in
let value =
match t with
- | Type.Switch -> Bool.of_string raw_val |> Option.map ~f:Value.switch
- | Int -> Int.of_string raw_val |> Option.map ~f:Value.int
- | String -> Some (String raw_val)
- in
- let value =
- match value with
- | Some v -> v
- | None ->
- die
- "Unable to read variable %S of type %s. Invalid value %S in %s \
- found"
- name (Type.name t) raw_val obj_file
+ | Type.Switch -> Value.Switch (parse_val_or_exn Bool.of_string)
+ | Int -> Value.Int (parse_val_or_exn Int.of_string)
+ | String -> String (parse_val_or_exn (fun x -> Some x))
in
(name, value))

View File

@ -6,7 +6,7 @@
Name: ocaml-%{libname}
Version: 2.7.0
Release: 3%{?dist}
Release: 5%{?dist}
Summary: A composable build system for OCaml
# Dune itself is MIT. Some bundled libraries have a different license:
@ -25,6 +25,7 @@ Source0: https://github.com/ocaml/%{libname}/archive/%{version}/%{libname
# https://github.com/ocaml/dune/issues/3736
# https://github.com/ocaml/dune/pull/3739
Patch1: 3739.patch
Patch2: 1a9bd729b97db408022995f93b19678706a79ca7.patch
BuildRequires: emacs
BuildRequires: ocaml >= 4.08
@ -195,7 +196,7 @@ cp -ar README.md CHANGES.md MIGRATION.md doc/_build/* %{buildroot}%{_pkgdocdir}/
%{_emacs_sitelispdir}/dune*
%changelog
* Mon Aug 24 2020 Richard W.M. Jones <rjones@redhat.com> - 2.7.0-3
* Mon Aug 24 2020 Richard W.M. Jones <rjones@redhat.com> - 2.7.0-5
- Add fix for https://github.com/ocaml/dune/issues/3736
* Fri Aug 21 2020 Richard W.M. Jones <rjones@redhat.com> - 2.7.0-2