The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Select `unsafe.ml` with just dune rules

It is not necessary to use configurator to select a file depending on
the OCaml version. This pattern looks like this:

- a `config.exe` program (with no dependencies) checks
`Sys.ocaml_version` (`scanf` will only look at the beginning of the
string, so no need to parse the patch version etc) and just outputs
the name of the file to copy
- a rule links a file name to the output of `config.exe`
- a rule copies the content of that file to `unsafe.ml`

+12 -59
-1
vendor/opam/base64/base64.opam
··· 17 17 depends: [ 18 18 "ocaml" {>="4.03.0"} 19 19 "base-bytes" 20 - "dune-configurator" 21 20 "dune" {>= "2.0"} 22 21 "bos" {with-test} 23 22 "rresult" {with-test}
+5 -52
vendor/opam/base64/config/config.ml
··· 1 - module Config = Configurator.V1 2 - 3 - let pre407 = 4 - {ocaml|external unsafe_set_uint16 : bytes -> int -> int -> unit = "%caml_string_set16u" [@@noalloc]|ocaml} 5 - 6 - let standard = 7 - {ocaml|external unsafe_set_uint16 : bytes -> int -> int -> unit = "%caml_bytes_set16u" [@@noalloc]|ocaml} 8 - 9 - type t = { major : int; minor : int; patch : int option; extra : string option } 10 - 11 - let v ?patch ?extra major minor = { major; minor; patch; extra } 12 - 13 - let parse s = 14 - try 15 - Scanf.sscanf s "%d.%d.%d+%s" (fun major minor patch extra -> 16 - v ~patch ~extra major minor) 17 - with End_of_file | Scanf.Scan_failure _ -> ( 18 - try 19 - Scanf.sscanf s "%d.%d+%s" (fun major minor extra -> v ~extra major minor) 20 - with End_of_file | Scanf.Scan_failure _ -> ( 21 - try 22 - Scanf.sscanf s "%d.%d.%d" (fun major minor patch -> 23 - v ~patch major minor) 24 - with End_of_file | Scanf.Scan_failure _ -> 25 - Scanf.sscanf s "%d.%d" (fun major minor -> v major minor))) 26 - 27 - let ( >|= ) x f = match x with Some x -> Some (f x) | None -> None 28 - 29 - let ocaml_cp ~src ~dst = 30 - let ic = open_in src in 31 - let oc = open_out dst in 32 - let bf = Bytes.create 0x1000 in 33 - let rec go () = 34 - match input ic bf 0 (Bytes.length bf) with 35 - | 0 -> () 36 - | len -> 37 - output oc bf 0 len ; 38 - go () 39 - | exception End_of_file -> () in 40 - go () ; 41 - close_in ic ; 42 - close_out oc 1 + let parse s = Scanf.sscanf s "%d.%d" (fun major minor -> (major, minor)) 43 2 44 3 let () = 45 - Config.main ~name:"config-base64" @@ fun t -> 46 - match Config.ocaml_config_var t "version" >|= parse with 47 - | Some version -> 48 - let dst = "unsafe.ml" in 49 - 50 - if (version.major, version.minor) >= (4, 7) 51 - then ocaml_cp ~src:"unsafe_stable.ml" ~dst 52 - else ocaml_cp ~src:"unsafe_pre407.ml" ~dst 53 - | None -> Config.die "OCaml version is not available" 54 - | exception exn -> Config.die "Got an exception: %s" (Printexc.to_string exn) 4 + let version = parse Sys.ocaml_version in 5 + if version >= (4, 7) 6 + then print_string "unsafe_stable.ml" 7 + else print_string "unsafe_pre407.ml"
+6 -2
vendor/opam/base64/config/dune
··· 1 1 (executable 2 - (name config) 3 - (libraries dune-configurator)) 2 + (name config)) 3 + 4 + (rule 5 + (with-stdout-to 6 + which-unsafe-file 7 + (run ./config.exe)))
+1 -4
vendor/opam/base64/src/dune
··· 5 5 (libraries bytes)) 6 6 7 7 (rule 8 - (targets unsafe.ml) 9 - (deps unsafe_pre407.ml unsafe_stable.ml) 10 - (action 11 - (run ../config/config.exe))) 8 + (copy %{read:../config/which-unsafe-file} unsafe.ml)) 12 9 13 10 (library 14 11 (name base64_rfc2045)