Skip to content

Commit

Permalink
_
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Sep 3, 2020
1 parent a43692c commit 3cf6329
Showing 1 changed file with 24 additions and 48 deletions.
72 changes: 24 additions & 48 deletions src/dune_engine/section.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@ include Dune_section

let compare : t -> t -> Ordering.t = Poly.compare

let allmap =
[ ("lib", Lib)
; ("lib_root", Lib_root)
; ("libexec", Libexec)
; ("libexec_root", Libexec_root)
; ("bin", Bin)
; ("sbin", Sbin)
; ("toplevel", Toplevel)
; ("share", Share)
; ("share_root", Share_root)
; ("etc", Etc)
; ("doc", Doc)
; ("stublibs", Stublibs)
; ("man", Man)
; ("misc", Misc)
]

let to_dyn x =
let s =
List.find_map ~f:(fun (s, v) -> Option.some_if (x = v) s) allmap
|> Option.value_exn
in
let open Dyn.Encoder in
match x with
| Lib -> constr "Lib" []
| Lib_root -> constr "Lib_root" []
| Libexec -> constr "Libexec" []
| Libexec_root -> constr "Libexec_root" []
| Bin -> constr "Bin" []
| Sbin -> constr "Sbin" []
| Toplevel -> constr "Toplevel" []
| Share -> constr "Share" []
| Share_root -> constr "Share_root" []
| Etc -> constr "Etc" []
| Doc -> constr "Doc" []
| Stublibs -> constr "Stublibs" []
| Man -> constr "Man" []
| Misc -> constr "Misc" []
constr (String.uppercase_ascii s) []

module Key = struct
type nonrec t = t
Expand All @@ -40,44 +47,13 @@ let parse_string s =

let decode =
let open Dune_lang.Decoder in
enum
[ ("lib", Lib)
; ("lib_root", Lib_root)
; ("libexec", Libexec)
; ("libexec_root", Libexec_root)
; ("bin", Bin)
; ("sbin", Sbin)
; ("toplevel", Toplevel)
; ("share", Share)
; ("share_root", Share_root)
; ("etc", Etc)
; ("doc", Doc)
; ("stublibs", Stublibs)
; ("man", Man)
; ("misc", Misc)
]
enum allmap

let encode v =
let open Dune_lang.Encoder in
string (to_string v)

let all =
Set.of_list
[ Lib
; Lib_root
; Libexec
; Libexec_root
; Bin
; Sbin
; Toplevel
; Share
; Share_root
; Etc
; Doc
; Stublibs
; Man
; Misc
]
let all = Set.of_list (List.map ~f:snd allmap)

let should_set_executable_bit = function
| Lib
Expand Down

0 comments on commit 3cf6329

Please sign in to comment.