Skip to content

Commit

Permalink
Generate endpoints.ml via dune
Browse files Browse the repository at this point in the history
  • Loading branch information
Nymphium authored and tmcgilchrist committed Jul 4, 2023
1 parent 3b3bd76 commit ac554ca
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion aws-gen.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bug-reports: "https://github.com/inhabitedtype/ocaml-aws/issues"
dev-repo: "git+https://github.com/inhabitedtype/ocaml-aws.git"
depends: [
"ocaml" {>= "4.08"}
"atdgen"
"atdgen" {>= "2.10"}
"yojson"
"base-unix"
"cmdliner" {>= "1.1.0"}
Expand Down
5 changes: 5 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
((action
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{input-file}))
syntax))))

(rule
(targets endpoints.ml endpoints.mli)
(deps endpoints.atd)
(action (run atdgen %{deps} -json)))
12 changes: 6 additions & 6 deletions src/endpoint_gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let write_endpoint
svc_name
dns_suffix
(default_hostname : string option)
((region, endpoint) : string * Endpoints_t.endpoint) =
((region, endpoint) : string * Endpoints.endpoint) =
Syntax.(
let host =
match endpoint.hostname, default_hostname with
Expand All @@ -25,8 +25,8 @@ let write_endpoint

let write_service
dns_suffix
(partition_defaults : Endpoints_t.partition_defaults)
((svc_name, svc) : string * Endpoints_t.service) =
(partition_defaults : Endpoints.partition_defaults)
((svc_name, svc) : string * Endpoints.service) =
Syntax.(
( svc_name
, matchstrs
Expand All @@ -35,7 +35,7 @@ let write_service
|> List.map (write_endpoint svc_name dns_suffix partition_defaults.hostname))
(ident "None") ))

let write_partition (p : Endpoints_t.partition) =
let write_partition (p : Endpoints.partition) =
Syntax.(
let_
"endpoint_of"
Expand Down Expand Up @@ -65,10 +65,10 @@ let main input outdir =
let inc = open_in input in
let n = in_channel_length inc in
let endpoint_data = really_input_string inc n in
let endpoints = Endpoints_j.endpoints_of_string endpoint_data in
let endpoints = Endpoints.endpoints_of_string endpoint_data in
let aws =
endpoints.partitions
|> List.find (fun p -> String.equal Endpoints_t.(p.partition) "aws")
|> List.find (fun p -> String.equal Endpoints.(p.partition) "aws")
in
let outfile = outdir </> "endpoints.ml" in
let syntax = write_partition aws in
Expand Down
Loading

0 comments on commit ac554ca

Please sign in to comment.