Skip to content

Commit a3ee2e0

Browse files
authored
ocaml 5 (#397)
1 parent 71cdc72 commit a3ee2e0

46 files changed

Lines changed: 215 additions & 366 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

comby-kernel.opam

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ build: [
1818
]
1919
]
2020
depends: [
21-
"dune" {>= "2.8.0"}
22-
"ocaml" {>= "4.08.1"}
23-
"core_kernel"
21+
"dune" {>= "3.11.0"}
22+
"ocaml" {>= "5.1.0"}
23+
"core_kernel" {>= "v0.17" & < "v0.18~"}
2424
"ppx_deriving"
25-
"ppx_deriving_yojson" {>= "3.6.0"}
26-
"yojson" {>= "1.6.0" < "2.0.0"}
25+
"ppx_deriving_yojson" {>= "3.6.0" & < "4.0.0"}
26+
"yojson" {>= "1.6.0" & < "3.0.0"}
2727
"pcre"
2828
# vendored dependencies
2929
"bigstringaf"

comby-semantic.opam

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ build: [
1818
]
1919
]
2020
depends: [
21-
"dune" {>= "2.8.0"}
22-
"ocaml" {>= "4.08.1"}
23-
"core_kernel"
21+
"dune" {>= "3.11.0"}
22+
"ocaml" {>= "5.1.0"}
23+
"core_kernel" {>= "v0.17" & < "v0.18~"}
2424
"ppx_deriving"
2525
"lwt"
2626
"cohttp"
2727
"cohttp-lwt-unix"
28-
"yojson" {>= "1.6.0" < "2.0.0"}
28+
"yojson" {>= "1.6.0" & < "3.0.0"}
2929
"bisect_ppx" {with-test & dev & >= "2.5.0"}
3030
]
3131
synopsis: "A match engine for structural code search and replace that supports ~every language"

comby.opam

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ build: [
1818
]
1919
]
2020
depends: [
21-
"dune" {>= "2.8.0"}
22-
"ocaml" {>= "4.08.1"}
21+
"dune" {>= "3.11.0"}
22+
"ocaml" {>= "5.1.0"}
2323
"conf-autoconf"
2424
"conf-gmp"
2525
"conf-libev" {os-distribution != "ol"}
@@ -31,21 +31,21 @@ depends: [
3131
"cohttp-lwt-unix"
3232
"comby-kernel" {= version}
3333
"comby-semantic" {= version}
34-
"core"
34+
"core" {>= "v0.17" & < "v0.18~"}
35+
"core_unix" {>= "v0.17" & < "v0.18~"}
3536
"cstruct-lwt"
36-
"hack_parallel" {arch != "arm32" & arch != "arm64"}
3737
"lwt"
3838
"lwt_react"
3939
"lwt_ssl"
4040
"parany" {>= "12.0.3"}
41-
"patience_diff" {>= "v0.14" & < "v0.15"}
41+
"patience_diff" {>= "v0.17" & < "v0.18~"}
4242
"ppx_deriving"
43-
"ppx_deriving_yojson" {>= "3.6.0"}
44-
"yojson" {>= "1.6.0" < "2.0.0"}
43+
"ppx_deriving_yojson" {>= "3.6.0" & < "4.0.0"}
44+
"yojson" {>= "1.6.0" & < "3.0.0"}
4545
"pcre"
46-
"shell"
47-
"tar" {< "3.0.0"}
48-
"tar-unix" {< "3.0.0"}
46+
"shell" {>= "v0.17" & < "v0.18~"}
47+
"tar"
48+
"tar-unix"
4949
"toml" {>= "6.0.0"}
5050
"bisect_ppx" {with-test & dev & >= "2.5.0"}
5151
]

docs/third-party-licenses/ALL.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
9090
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
9191
THE SOFTWARE.
9292

93-
LICENSE FOR hack_parallel:
94-
95-
MIT License
96-
97-
Copyright (c) 2013-present, Facebook, Inc.
98-
Modified work Copyright (c) 2018-2019 Rijnard van Tonder
99-
100-
Permission is hereby granted, free of charge, to any person obtaining a copy
101-
of this software and associated documentation files (the "Software"), to deal
102-
in the Software without restriction, including without limitation the rights
103-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
104-
copies of the Software, and to permit persons to whom the Software is
105-
furnished to do so, subject to the following conditions:
106-
107-
The above copyright notice and this permission notice shall be included in all
108-
copies or substantial portions of the Software.
109-
110-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
111-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
113-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
114-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
115-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
116-
SOFTWARE.
117-
11893
LICENSE FOR opium:
11994

12095
# This file is generated by dune, edit dune-project instead
@@ -1492,4 +1467,3 @@ whether future versions of the GNU Lesser General Public License shall
14921467
apply, that proxy's public statement of acceptance of any version is
14931468
permanent authorization for you to choose that version for the
14941469
Library.
1495-

docs/third-party-licenses/hack_parallel/LICENSE

Lines changed: 0 additions & 22 deletions
This file was deleted.

docs/third-party-licenses/pull-and-update-release-scripts.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
LIBS="ppx_deriving_yojson core ppxlib ppx_deriving hack_parallel opium pcre-ocaml ocaml-tls camlzip bisect_ppx ocaml-ci-scripts patdiff lwt toml"
3+
LIBS="ppx_deriving_yojson core ppxlib ppx_deriving opium pcre-ocaml ocaml-tls camlzip bisect_ppx ocaml-ci-scripts patdiff lwt toml"
44

55
rm ALL.txt 2> /dev/null
66
for l in $LIBS; do rm -rf $l; done
@@ -25,10 +25,6 @@ wget -P ppxlib https://raw.githubusercontent.com/ocaml-ppx/ppxlib/master/LICENSE
2525
mkdir ppx_deriving && \
2626
wget -P ppx_deriving https://raw.githubusercontent.com/ocaml-ppx/ppx_deriving/master/LICENSE.txt
2727

28-
# MIT
29-
mkdir hack_parallel && \
30-
wget -P hack_parallel https://raw.githubusercontent.com/rvantonder/hack-parallel/master/LICENSE
31-
3228
# MIT
3329
mkdir opium && \
3430
wget -P opium https://raw.githubusercontent.com/rgrinberg/opium/master/opium.opam

lib/app/configuration/command_configuration.ml

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
open Core
22
open Camlzip
3-
open Polymorphic_compare
3+
open Poly
44
open Comby_kernel
55

6-
let debug = Sys.getenv "DEBUG_COMBY" |> Option.is_some
6+
let debug = Stdlib.Sys.getenv_opt "DEBUG_COMBY" |> Option.is_some
7+
8+
let ls_dir path = Stdlib.Sys.readdir path |> Array.to_list
9+
10+
let is_directory path =
11+
try Stdlib.Sys.is_directory path with
12+
| Sys_error _ -> false
13+
14+
let is_file path = Stdlib.Sys.file_exists path && not (is_directory path)
715

816
(* skip or continue directory descent *)
917
type 'a next =
@@ -12,18 +20,18 @@ type 'a next =
1220

1321
let fold_directory ?(sorted = false) root ~init ~f =
1422
let rec aux acc absolute_path depth =
15-
if Sys.is_file absolute_path = `Yes then (
23+
if is_file absolute_path then (
1624
match f acc ~depth ~absolute_path ~is_file:true with
1725
| Continue acc | Skip acc -> acc)
18-
else if Sys.is_directory absolute_path = `Yes then (
26+
else if is_directory absolute_path then (
1927
match f acc ~depth ~absolute_path ~is_file:false with
2028
| Skip acc -> acc
2129
| Continue acc ->
2230
let dir_contents =
2331
if Option.is_some (Sys.getenv "COMBY_TEST") || sorted then
24-
Sys.ls_dir absolute_path |> List.sort ~compare:String.compare |> List.rev
32+
ls_dir absolute_path |> List.sort ~compare:String.compare |> List.rev
2533
else
26-
Sys.ls_dir absolute_path
34+
ls_dir absolute_path
2735
in
2836
List.fold dir_contents ~init:acc ~f:(fun acc subdir ->
2937
aux acc (Filename.concat absolute_path subdir) (depth + 1)))
@@ -44,7 +52,7 @@ let parse_source_directories
4452
let exact_file_paths, file_patterns =
4553
List.partition_map file_filters ~f:(fun path ->
4654
let is_exact path =
47-
(String.contains path '/' && Sys.is_file path = `Yes) || Sys.is_file ("." ^/ path) = `Yes
55+
(String.contains path '/' && is_file path) || is_file ("." ^/ path)
4856
(* See if it matches something in the current directory *)
4957
in
5058
if is_exact path then Either.First path else Either.Second path)
@@ -161,8 +169,8 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
161169
let f acc ~depth:_ ~absolute_path ~is_file =
162170
let is_leaf_directory absolute_path =
163171
(not is_file)
164-
&& Sys.ls_dir absolute_path
165-
|> List.for_all ~f:(fun path -> Sys.is_directory (absolute_path ^/ path) = `No)
172+
&& ls_dir absolute_path
173+
|> List.for_all ~f:(fun path -> not (is_directory (absolute_path ^/ path)))
166174
in
167175
if is_leaf_directory absolute_path then (
168176
match parse_directory absolute_path with
@@ -172,7 +180,7 @@ let parse_templates ?metasyntax ?(warn_for_missing_file_in_dir = false) paths =
172180
Continue acc
173181
in
174182
List.concat_map paths ~f:(fun path ->
175-
if Sys.is_directory path = `Yes then
183+
if is_directory path then
176184
fold_directory path ~sorted:true ~init:[] ~f
177185
else
178186
parse_toml ?metasyntax path)
@@ -223,7 +231,6 @@ type user_input_options =
223231

224232
type compute_mode =
225233
[ `Sequential
226-
| `Hack_parallel of int
227234
| `Parany of int
228235
]
229236

@@ -411,11 +418,11 @@ let parse_metasyntax metasyntax_path =
411418
match metasyntax_path with
412419
| None -> Matchers.Metasyntax.default_metasyntax
413420
| Some metasyntax_path ->
414-
(match Sys.file_exists metasyntax_path with
415-
| `No | `Unknown ->
421+
(match Stdlib.Sys.file_exists metasyntax_path with
422+
| false ->
416423
Format.eprintf "Could not open file: %s@." metasyntax_path;
417424
exit 1
418-
| `Yes ->
425+
| true ->
419426
Yojson.Safe.from_file metasyntax_path
420427
|> Matchers.Metasyntax.of_yojson
421428
|> (function
@@ -462,26 +469,26 @@ let emit_errors { input_options; output_options; _ } =
462469
; ( Option.is_some input_options.directory_depth
463470
&& Option.value_exn input_options.directory_depth < 0
464471
, "-depth must be 0 or greater." )
465-
; ( Sys.is_directory input_options.target_directory = `No
472+
; ( not (is_directory input_options.target_directory)
466473
, "Directory specified with -d or -directory is not a directory." )
467474
; ( output_options.json_only_diff && not output_options.json_lines
468475
, "-json-only-diff can only be supplied with -json-lines." )
469476
; ( Option.is_some output_options.chunk_matches && Option.is_some input_options.zip_file
470477
, "chunk-matches output format is not supported for zip files." )
471478
; ( Option.is_some output_options.interactive_review
472-
&& not (String.equal input_options.target_directory (Sys.getcwd ()))
479+
&& not (String.equal input_options.target_directory (Stdlib.Sys.getcwd ()))
473480
, "Please remove the -d option and `cd` to the directory where you want to review from. The \
474481
-review, -editor, or -default-no options should only be run at the root directory of the \
475482
project files to patch." )
476483
; (let message =
477484
match input_options.templates with
478485
| Some inputs ->
479486
List.find_map inputs ~f:(fun input ->
480-
if Sys.is_file input = `Yes then (
487+
if is_file input then (
481488
match Toml.Parser.from_filename input with
482489
| `Error (s, _) -> Some s
483490
| _ -> None)
484-
else if not (Sys.is_directory input = `Yes) then
491+
else if not (is_directory input) then
485492
Some
486493
(Format.sprintf "Directory %S specified with -templates is not a directory." input)
487494
else
@@ -598,11 +605,11 @@ let filter_zip_entries file_filters exclude_directory_prefix exclude_file_prefix
598605
&& has_acceptable_suffix filename)
599606

600607
let syntax custom_matcher_path =
601-
match Sys.file_exists custom_matcher_path with
602-
| `No | `Unknown ->
608+
match Stdlib.Sys.file_exists custom_matcher_path with
609+
| false ->
603610
Format.eprintf "Could not open file: %s@." custom_matcher_path;
604611
exit 1
605-
| `Yes ->
612+
| true ->
606613
Yojson.Safe.from_file custom_matcher_path
607614
|> Matchers.Language.Syntax.of_yojson
608615
|> (function
@@ -783,7 +790,7 @@ let create
783790
| Directory ->
784791
let target_directory =
785792
if target_directory = "." then
786-
Filename.realpath target_directory
793+
Filename_unix.realpath target_directory
787794
else
788795
target_directory
789796
in

lib/app/configuration/command_configuration.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type user_input_options =
6464

6565
type compute_mode =
6666
[ `Sequential
67-
| `Hack_parallel of int
6867
| `Parany of int
6968
]
7069

lib/app/configuration/dune

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
comby.patdiff
1212
comby.camlzip
1313
core
14+
core_unix
15+
core_unix.filename_unix
1416
pcre
1517
yojson
1618
ppx_deriving_yojson

lib/app/configuration/external_semantic.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
open Comby_semantic
22

3-
let debug =
4-
match Sys.getenv "DEBUG_COMBY" with
5-
| exception Not_found -> false
6-
| _ -> true
3+
let debug = Stdlib.Sys.getenv_opt "DEBUG_COMBY" |> Option.is_some
74

85
let lsif_endpoint =
9-
match Sys.getenv "LSIF_SERVER" with
10-
| exception Not_found -> "https://sourcegraph.com/.api/graphql"
11-
| address -> address
6+
Stdlib.Sys.getenv_opt "LSIF_SERVER"
7+
|> Option.value ~default:"https://sourcegraph.com/.api/graphql"
128

139
let repository_remote () =
1410
let open Core in
15-
In_channel.input_all (Unix.open_process_in "git config --get remote.origin.url")
11+
In_channel.input_all (Core_unix.open_process_in "git config --get remote.origin.url")
1612

1713
let revision () =
1814
let open Core in
19-
In_channel.input_all (Unix.open_process_in "git rev-parse HEAD")
15+
In_channel.input_all (Core_unix.open_process_in "git rev-parse HEAD")
2016

2117
let lsif_hover ~name:_ ~filepath ~line ~column =
2218
let open Core_kernel in
@@ -29,7 +25,7 @@ let lsif_hover ~name:_ ~filepath ~line ~column =
2925
in
3026
let revision = revision () |> String.rstrip in
3127
if debug then Format.printf "Repository remote: %s\nRevision: %s@." repository revision;
32-
String.chop_prefix_if_exists filepath ~prefix:(Sys.getcwd ())
28+
String.chop_prefix_if_exists filepath ~prefix:(Stdlib.Sys.getcwd ())
3329
|> fun filepath_relative_root ->
3430
if debug then Format.printf "File relative root: %s@." filepath;
3531
if debug then Format.printf "Querying type at %d::%d@." line column;

0 commit comments

Comments
 (0)