From 752748244825d0bfc70a646b5bd4c037c59bdba9 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 22:28:27 +0900 Subject: [PATCH 01/13] add `install.mli` --- src/command/install.ml | 5 +---- src/command/install.mli | 27 +++++++++++++++++++++++++++ src/command/lint_module_dependency.ml | 4 ++-- src/library.ml | 1 + src/library.mli | 4 ++++ 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 src/command/install.mli diff --git a/src/command/install.ml b/src/command/install.ml index dad5882..28270bb 100644 --- a/src/command/install.ml +++ b/src/command/install.ml @@ -2,10 +2,7 @@ open Core open Satyrographos module Autogen = Satyrographos_autogen -module StringSet = Set.Make(String) - -(* TODO Abstract this *) -module StringMap = Map.Make(String) +module StringSet = Library.StringSet type persistent_autogen = Satyrographos_lockdown.LockdownFile.autogen diff --git a/src/command/install.mli b/src/command/install.mli new file mode 100644 index 0000000..1b44f7b --- /dev/null +++ b/src/command/install.mli @@ -0,0 +1,27 @@ +open Satyrographos + +type persistent_autogen = Satyrographos_lockdown.LockdownFile.autogen + +val get_library_map : + outf:Format.formatter -> + system_font_prefix:string option -> + autogen_libraries:string list -> + libraries:string list option -> + env:Environment.t -> + persistent_autogen:persistent_autogen -> + unit -> + (string, Library.t, Library.StringSet.Elt.comparator_witness) Base.Map.t + +val install : + string -> + outf:Format.formatter -> + system_font_prefix:string option -> + ?autogen_libraries:string list -> + libraries:string list option -> + verbose:bool -> + ?safe:bool -> + copy:bool -> + env:Environment.t -> + persistent_autogen:persistent_autogen -> + unit -> + unit diff --git a/src/command/lint_module_dependency.ml b/src/command/lint_module_dependency.ml index 4fb9e7f..94d56b3 100644 --- a/src/command/lint_module_dependency.ml +++ b/src/command/lint_module_dependency.ml @@ -3,7 +3,7 @@ open Satyrographos open Lint_prim -module StringSet = Set.Make(String) +module StringSet = Library.StringSet let dummy_formatter = Format.make_formatter (fun _ _ _ -> ()) ignore @@ -44,7 +44,7 @@ let get_libraries ~locs ~env ~library_override m = ~system_font_prefix:None ~libraries:(Some libraries) ~autogen_libraries - ~persistent_autogen:[] + ~persistent_autogen:[] ~env () |> (fun m -> Map.merge_skewed ~combine m library_override) diff --git a/src/library.ml b/src/library.ml index 98ad0bc..9b0207e 100644 --- a/src/library.ml +++ b/src/library.ml @@ -21,6 +21,7 @@ end module Dependency = Set.Make(String) module StringMap = Map.Make(String) +module StringSet = Set.Make(String) module JsonSet = Set.Make(Json) module Rename = struct type t = { diff --git a/src/library.mli b/src/library.mli index 32b4cac..775cd6f 100644 --- a/src/library.mli +++ b/src/library.mli @@ -22,6 +22,10 @@ module StringMap : sig include Core.Map.S with type Key.t = String.t end +module StringSet : sig + include Core.Set.S with type Elt.t = String.t +end + module JsonSet : sig include Core.Set.S with type Elt.t = Json.t end From 86f851dd7e78c9cdc94b3a0fba5cdd323306fefd Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 22:36:22 +0900 Subject: [PATCH 02/13] add `build.mli` --- src/command/build.mli | 27 +++++++++++++++++++++++++++ src/command/runSatysfi.ml | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/command/build.mli diff --git a/src/command/build.mli b/src/command/build.mli new file mode 100644 index 0000000..72f86c4 --- /dev/null +++ b/src/command/build.mli @@ -0,0 +1,27 @@ +open Satyrographos + +val read_module : + outf:Format.formatter -> + verbose:bool -> + build_module:BuildScript_prim.m -> + buildscript_path:string -> + string * Library.t + +val build : + outf:Format.formatter -> + build_dir:string option -> + verbose:bool -> + build_module:BuildScript_prim.m -> + buildscript_path:string -> + system_font_prefix:string option -> + env:Environment.t -> + unit + +val build_command : + outf:Format.formatter -> + buildscript_path:string -> + names:string list option -> + verbose:bool -> + env:Environment.t -> + build_dir:string option -> + unit diff --git a/src/command/runSatysfi.ml b/src/command/runSatysfi.ml index 20ead19..72b4a48 100644 --- a/src/command/runSatysfi.ml +++ b/src/command/runSatysfi.ml @@ -4,7 +4,7 @@ open Satyrographos module Process = Shexp_process module P = Process -module StringMap = Map.Make(String) +module StringMap = Library.StringMap let library_dir prefix (buildscript: BuildScript.m) = let libdir = Filename.concat prefix "share/satysfi" in From 843912ee59d291d65157fce934185352effa5c2c Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 22:44:50 +0900 Subject: [PATCH 03/13] add `new.mli` --- src/command/new.mli | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/command/new.mli diff --git a/src/command/new.mli b/src/command/new.mli new file mode 100644 index 0000000..d77ae8c --- /dev/null +++ b/src/command/new.mli @@ -0,0 +1,6 @@ + +val template_map : (string * string) list Core.String.Map.t + +val template_descriptions : (string * string) list + +val create_project : string -> string option -> (string * string) list -> unit From 2c30ff33536341d75d5ceb025bbcef7a247f8581 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 22:51:27 +0900 Subject: [PATCH 04/13] add `runSatysfi.mli` --- src/command/runSatysfi.ml | 4 ++-- src/command/runSatysfi.mli | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/command/runSatysfi.mli diff --git a/src/command/runSatysfi.ml b/src/command/runSatysfi.ml index 72b4a48..8f07f4f 100644 --- a/src/command/runSatysfi.ml +++ b/src/command/runSatysfi.ml @@ -5,7 +5,7 @@ module Process = Shexp_process module P = Process module StringMap = Library.StringMap - +(* let library_dir prefix (buildscript: BuildScript.m) = let libdir = Filename.concat prefix "share/satysfi" in Filename.concat libdir (BuildScript.get_name buildscript) @@ -19,7 +19,7 @@ let read_module ~outf ~verbose ~build_module ~buildscript_path = Format.fprintf outf "@." end; (src_dir, p) - +*) let test_satysfi_option options = let open P in let open P.Infix in diff --git a/src/command/runSatysfi.mli b/src/command/runSatysfi.mli new file mode 100644 index 0000000..d1e7062 --- /dev/null +++ b/src/command/runSatysfi.mli @@ -0,0 +1,14 @@ +open Satyrographos + +val run_satysfi_command : satysfi_runtime:string -> string list -> unit Shexp_process.t + +val satysfi_command : + outf:Format.formatter -> + system_font_prefix:string option -> + autogen_libraries:string list -> + libraries:string list option -> + verbose:bool -> + project_env:Environment.project_env option -> + env:Environment.t -> + string list -> + int Shexp_process.t From e1006bbf68a24c4a03cd7991951d6468b7e74598 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 22:56:17 +0900 Subject: [PATCH 05/13] add `lint.mli` --- src/command/lint.mli | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/command/lint.mli diff --git a/src/command/lint.mli b/src/command/lint.mli new file mode 100644 index 0000000..78245da --- /dev/null +++ b/src/command/lint.mli @@ -0,0 +1,12 @@ +open Satyrographos + +val lint : + outf:Format.formatter -> + satysfi_version:Satyrographos_satysfi.Version.t -> + warning_expr:bool Glob.TokenMatcher.t option -> + verbose:bool -> + buildscript_path:string option -> + env:Environment.t -> + int + +val get_opam_name : opam:OpamFile.OPAM.t -> opam_path:string -> string From 3f036d6d14c6a125d8f94fa55fe5a0e0cba57cb2 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Wed, 2 Nov 2022 23:49:33 +0900 Subject: [PATCH 06/13] restrict the version of `yojson` --- satyrographos.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satyrographos.opam b/satyrographos.opam index f1e447a..b2c7c0e 100644 --- a/satyrographos.opam +++ b/satyrographos.opam @@ -42,7 +42,7 @@ depends: [ "uri-sexp" {>= "3.0.0"} "yaml" {>= "3.0" & < "4.0"} "yaml-sexp" {>= "3.0" & < "4.0"} - "yojson" + "yojson" {< "2.0.0"} # Janestreet Libs "core" {>= "v0.14" & < "v0.15"} From a6ea30b00be484884888ec062ac931326fafa9d6 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 00:26:38 +0900 Subject: [PATCH 07/13] add `fontInfo.mli` --- src/command/runSatysfi.ml | 2 ++ src/fontInfo.ml | 2 ++ src/fontInfo.mli | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 src/fontInfo.mli diff --git a/src/command/runSatysfi.ml b/src/command/runSatysfi.ml index 8f07f4f..3216a51 100644 --- a/src/command/runSatysfi.ml +++ b/src/command/runSatysfi.ml @@ -5,6 +5,7 @@ module Process = Shexp_process module P = Process module StringMap = Library.StringMap + (* let library_dir prefix (buildscript: BuildScript.m) = let libdir = Filename.concat prefix "share/satysfi" in @@ -20,6 +21,7 @@ let read_module ~outf ~verbose ~build_module ~buildscript_path = end; (src_dir, p) *) + let test_satysfi_option options = let open P in let open P.Infix in diff --git a/src/fontInfo.ml b/src/fontInfo.ml index 48c5ac7..2c14f0e 100644 --- a/src/fontInfo.ml +++ b/src/fontInfo.ml @@ -139,11 +139,13 @@ let fc_format_data = module DistinctFontMap = Map.Make(DistinctFont) +(* let system_font_info_list_task = let open P.Infix in P.echo "(" >> P.run "fc-list" ["-f"; fc_format_data] >> P.echo ")" +*) (* TODO Handle extremely long argument lists *) let font_info_list_task fonts = diff --git a/src/fontInfo.mli b/src/fontInfo.mli new file mode 100644 index 0000000..128add3 --- /dev/null +++ b/src/fontInfo.mli @@ -0,0 +1,46 @@ +module Font : sig + type lang = string + [@@deriving sexp, compare] + + type t = { + file: string; + postscriptname: string; + index: int; + fontformat: string; + family: (string * lang) list; + style: (string * lang) list; + fullname: (string * lang) list; + slant: int; + weight: float; + width: int; + foundry: string; + verticallayout: string; (* TODO It should be int, though*) + outline: bool; + scalable: bool; + color: bool; + charset: string; + lang: lang list; + fontversion: int; + fontfeatures: string; + namelang: string; + prgname: string; + } [@@deriving sexp, compare] + +end + +module DistinctFont : sig + type t = { + file: string; + index: int; + } [@@deriving sexp, compare] + + val of_font : Font.t -> t +end + +module DistinctFontMap : sig + include Core.Map.S with type Key.t = DistinctFont.t +end + +val font_info_list_task : string list -> unit Shexp_process.t + +val font_list_task : outf:Format.formatter -> unit Shexp_process.t -> Font.t DistinctFontMap.t Shexp_process.t From 921e09155588e01891dfde42df8ff69ca1e873e4 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 00:39:15 +0900 Subject: [PATCH 08/13] add `glob.mli` --- src/glob.ml | 2 ++ src/glob.mli | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/glob.mli diff --git a/src/glob.ml b/src/glob.ml index d158f63..7e0b9aa 100644 --- a/src/glob.ml +++ b/src/glob.ml @@ -294,11 +294,13 @@ module TokenMatcherSemantics = struct type value = bool type glob = value -> value TokenMatcher.t +(* let id_char = Re.alt [ Re.alnum; Re.set "_-."; ] +*) let star : glob = fun v -> TokenMatcher.node (Some v) [] let atom x : glob = fun v -> diff --git a/src/glob.mli b/src/glob.mli new file mode 100644 index 0000000..89131df --- /dev/null +++ b/src/glob.mli @@ -0,0 +1,11 @@ +module TokenMatcher : sig + type 'a t + + val empty : 'a t + + val exec : 'a t -> string list -> 'a option +end + +val parse_as_tm_exn : Lexing.lexbuf -> bool TokenMatcher.t + +val split_on_slash : string -> string list From 627c3ae0ef05d3ea5dc227af483d943b062b3128 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 01:10:26 +0900 Subject: [PATCH 09/13] add `libraryMap.mli` --- src/libraryMap.ml | 8 ++++---- src/libraryMap.mli | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 src/libraryMap.mli diff --git a/src/libraryMap.ml b/src/libraryMap.ml index 10b77e9..d401cab 100644 --- a/src/libraryMap.ml +++ b/src/libraryMap.ml @@ -8,10 +8,12 @@ let empty_set_of (type k cmp) another_set: (k, cmp) Base.Set.t = let comparator = (Set.comparator another_set) end) -module StringSet = Set.Make(String) -module StringMap = Map.Make(String) +module StringSet = Library.StringSet +module StringMap = Library.StringMap +(* type t = Library.t StringMap.t +*) (** Calculate a transitive closure. *) let transitive_closure map init = @@ -67,5 +69,3 @@ let%expect_test "transitive_closure: non-closed" = transitive_closure map init |> [%sexp_of: StringSet.t] |> Sexp.to_string_hum |> print_endline; [%expect{| (c) |}] - - diff --git a/src/libraryMap.mli b/src/libraryMap.mli new file mode 100644 index 0000000..95c3ecd --- /dev/null +++ b/src/libraryMap.mli @@ -0,0 +1,3 @@ +val transitive_closure : + (string, Library.Dependency.t, Library.StringSet.Elt.comparator_witness) Base.Map.t -> + Library.Dependency.t -> Library.Dependency.t From fd0a1272beb09b9f0c337b0ab14c9efc07f57656 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 01:20:08 +0900 Subject: [PATCH 10/13] add `location.mli` --- src/location.ml | 3 ++- src/location.mli | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 src/location.mli diff --git a/src/location.ml b/src/location.ml index 3498089..4b5cf0b 100644 --- a/src/location.ml +++ b/src/location.ml @@ -104,6 +104,7 @@ let%expect_test "position_of_offset: empty content" = 4: ((lnum 1) (cnum 1)) 5: ((lnum 2) (cnum 0)) |}] +(* let offset_of_position content pos = let rec sub off cur = if equal_position pos cur @@ -115,4 +116,4 @@ let offset_of_position content pos = else sub off {pos with cnum = pos.cnum + 1;} in sub 0 {lnum=0; cnum=0;} - +*) diff --git a/src/location.mli b/src/location.mli new file mode 100644 index 0000000..b86675b --- /dev/null +++ b/src/location.mli @@ -0,0 +1,31 @@ +type position +[@@deriving sexp, equal, compare, hash] + +type column_range = { + rstart: position; + rend: position; +} +[@@deriving sexp, equal, compare, hash] + +type line_range = { + rstart: int; + rend: int; +} +[@@deriving sexp, equal, compare, hash] + +type position_or_range = + | Line of int + | Column of position + | LineRange of line_range + | ColumnRange of column_range +[@@deriving sexp, equal, compare, hash] + +type t = { + path: string; + range: position_or_range option; +} +[@@deriving sexp, equal, compare, hash] + +val position_of_offset : string -> int -> position + +val display : t -> string From 6ae3435badafec8f0e8eb6a0571dd5fe784eec58 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 01:32:56 +0900 Subject: [PATCH 11/13] add `metadata.mli` --- src/metadata.ml | 6 ++++++ src/metadata.mli | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/metadata.mli diff --git a/src/metadata.ml b/src/metadata.ml index 027b67f..989f8e1 100644 --- a/src/metadata.ml +++ b/src/metadata.ml @@ -4,11 +4,15 @@ open Core module Uri_sexp = struct include Uri_sexp +(* let compare = Uri.compare +*) end type library_name = string +(* exception RegisteredAlready of library_name +*) module Libraries = String.Map type entry = { @@ -45,7 +49,9 @@ let with_modifying_file file ~f = let list reg = with_reading_file reg ~f:(fun m -> Libraries.keys m.libraries) let find reg name = with_reading_file reg ~f:(fun m -> Libraries.find m.libraries name) let mem reg name = with_reading_file reg ~f:(fun m -> Libraries.mem m.libraries name) +(* let remove reg name = with_modifying_file reg ~f:(fun m -> {libraries = Libraries.remove m.libraries name}) +*) let remove_multiple reg names = let name_set = String.Set.of_list names in with_modifying_file reg ~f:(fun m -> diff --git a/src/metadata.mli b/src/metadata.mli new file mode 100644 index 0000000..b619514 --- /dev/null +++ b/src/metadata.mli @@ -0,0 +1,19 @@ +type library_name = string + +type entry = { + url: Uri_sexp.t; +} [@@deriving sexp] + +type store + +val initialize : store -> unit + +val list : store -> library_name list + +val find : store -> library_name -> entry option + +val mem : store -> library_name -> bool + +val remove_multiple : store -> library_name list -> unit + +val add : store -> library_name -> entry -> unit From 8bc80f8972ecaaeae34d418d52557c514475565c Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 01:40:07 +0900 Subject: [PATCH 12/13] add `opamSatysfiRegistry.mli` --- src/opamSatysfiRegistry.ml | 2 ++ src/opamSatysfiRegistry.mli | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/opamSatysfiRegistry.mli diff --git a/src/opamSatysfiRegistry.ml b/src/opamSatysfiRegistry.ml index e24571a..77b8ba8 100644 --- a/src/opamSatysfiRegistry.ml +++ b/src/opamSatysfiRegistry.ml @@ -12,4 +12,6 @@ let read registry_dir = else None let list reg = FileUtil.ls reg.registry_dir |> List.map FilePath.basename let directory reg name = Filename.concat reg.registry_dir name +(* let mem reg name = directory reg name |> FileUtil.test FileUtil.Is_dir +*) diff --git a/src/opamSatysfiRegistry.mli b/src/opamSatysfiRegistry.mli new file mode 100644 index 0000000..ec68e7c --- /dev/null +++ b/src/opamSatysfiRegistry.mli @@ -0,0 +1,8 @@ +type t +[@@deriving sexp] + +val read : string -> t option + +val list : t -> string list + +val directory : t -> string -> string From cb2c4d1ceb9008246b832e9391827c5dff944128 Mon Sep 17 00:00:00 2001 From: gfngfn Date: Thu, 3 Nov 2022 14:19:27 +0900 Subject: [PATCH 13/13] allow upgrade of `core` to `v0.15` (but `json-derivers` seems preventing it) --- satyrographos.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/satyrographos.opam b/satyrographos.opam index b2c7c0e..bf79928 100644 --- a/satyrographos.opam +++ b/satyrographos.opam @@ -45,7 +45,7 @@ depends: [ "yojson" {< "2.0.0"} # Janestreet Libs - "core" {>= "v0.14" & < "v0.15"} + "core" {>= "v0.14" & < "v0.16"} "ppx_jane" "shexp" ]