Skip to content

Commit

Permalink
Merge pull request #60 from lefessan/z-2020-11-23-fix-skeleton-toml-name
Browse files Browse the repository at this point in the history
up version to 0.2.0
  • Loading branch information
lefessan authored Nov 23, 2020
2 parents 76725ec + 977a978 commit 0245d05
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 90 deletions.
12 changes: 6 additions & 6 deletions .drom
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# hash of toml configuration files
# used for generation of all files
a54f1599539c69089fc5e867841802f3:.
71559c6419131ce072ff68d83d359276:.
# end context for .

# begin context for .github/workflows/doc-deploy.yml
Expand All @@ -12,7 +12,7 @@ fa97e8d29135d03ad98579323218d9ce:.github/workflows/doc-deploy.yml

# begin context for .github/workflows/workflow.yml
# file .github/workflows/workflow.yml
20a7ac507806f2258bdf8c72d25f19d7:.github/workflows/workflow.yml
2578e01a3fd098263d6d8506582058bd:.github/workflows/workflow.yml
# end context for .github/workflows/workflow.yml

# begin context for .gitignore
Expand Down Expand Up @@ -82,7 +82,7 @@ b091dd96e8b553dd7a7df285279d7d9e:README.md

# begin context for drom.opam
# file drom.opam
ee64c3075a8538db8e430a1e1ad14d3d:drom.opam
951188831e6b29ee305ea54caab73f7e:drom.opam
# end context for drom.opam

# begin context for drom.toml
Expand All @@ -92,7 +92,7 @@ ee64c3075a8538db8e430a1e1ad14d3d:drom.opam

# begin context for drom_lib.opam
# file drom_lib.opam
16eb05d75ddf91d8aea523005465416a:drom_lib.opam
1927b0d399d665c2b970b4d562d20af5:drom_lib.opam
# end context for drom_lib.opam

# begin context for dune
Expand All @@ -102,7 +102,7 @@ ff0b2308dfc7350e6ac7d519836f9e47:dune

# begin context for dune-project
# file dune-project
7b6756c8e6e5798c10edfbe0b34f41e3:dune-project
aa76c66654677b588d8ee450e2394814:dune-project
# end context for dune-project

# begin context for dune_
Expand Down Expand Up @@ -187,7 +187,7 @@ dfda02aaec08f18742582243e9cd6748:src/drom_lib/index.mld

# begin context for src/drom_lib/version.ml
# file src/drom_lib/version.ml
fab8224b1866cef1103bca89068b73fe:src/drom_lib/version.ml
608bdb1fe23e8d01fe656ffa9b139bdb:src/drom_lib/version.ml
# end context for src/drom_lib/version.ml

# begin context for test/expect-tests/dune
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
os:
- macos-latest
- ubuntu-latest
# - windows-latest
- windows-latest
ocaml-version:
- 4.10.0
skip_test:
Expand Down
2 changes: 1 addition & 1 deletion drom.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "drom"
version: "0.1.0"
version: "0.2.0"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis:
"The drom tool is a wrapper over opam/dune in an attempt to provide a cargo-like user experience"
Expand Down
4 changes: 2 additions & 2 deletions drom.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ min-edition = "4.07.0"
mode = "binary"
name = "drom"
synopsis = "The drom tool is a wrapper over opam/dune in an attempt to provide a cargo-like user experience"
version = "0.1.0"
windows-ci = false
version = "0.2.0"
windows-ci = true

# keys that you could also define:
# build-profile = "...build-profile..."
Expand Down
4 changes: 2 additions & 2 deletions drom_lib.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Do not modify or add to the `skip` field of `drom.toml`.
opam-version: "2.0"
name: "drom_lib"
version: "0.1.0"
version: "0.2.0"
license: "LGPL-2.1-only with OCaml-LGPL-linking-exception"
synopsis:
"The drom tool is a wrapper over opam/dune in an attempt to provide a cargo-like user experience"
Expand Down Expand Up @@ -43,7 +43,7 @@ depends: [
"ocaml" {>= "4.07.0"}
"dune" {>= "2.6.0"}
"toml" {>= "5.0.0" & < "6.0.0"}
"opam-file-format" {>= "2.0.0" & < "3.0.0"}
"opam-file-format" {>= "2.1.1" & < "3.0.0"}
"ez_file" {>= "0.2.0" & < "1.0.0"}
"ez_config" {>= "0.1.0" & < "1.0.0"}
"ez_cmdliner" {>= "0.1.0" & < "1.0.0"}
Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(name drom)
(allow_approximate_merlin)
(generate_opam_files false)
(version 0.1.0)
(version 0.2.0)
(formatting (enabled_for ocaml reason))

(package
Expand All @@ -26,7 +26,7 @@
(depends
(ocaml (>= 4.07.0))
(toml (and (>= 5.0.0) (< 6.0.0)))
(opam-file-format (and (>= 2.0.0) (< 3.0.0)))
(opam-file-format (and (>= 2.1.1) (< 3.0.0)))
(ez_file (and (>= 0.2.0) (< 1.0.0)))
(ez_config (and (>= 0.1.0) (< 1.0.0)))
(ez_cmdliner (and (>= 0.1.0) (< 1.0.0)))
Expand Down
148 changes: 74 additions & 74 deletions src/drom_lib/opam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ open Types
open EzFile.OP

module OpamParser = struct
let value_from_string s f =
try OpamParser.value_from_string s f
with exn ->
Printf.eprintf "Error with [%s]:\n" s;
raise exn
module FullPos = struct
let value_from_string s f =
try OpamParser.FullPos.value_from_string s f
with exn ->
Printf.eprintf "Error with [%s]:\n" s;
raise exn
end
end

let dev_repo p =
Expand All @@ -26,13 +28,15 @@ let dev_repo p =

let opam_of_project kind package =
let p = package.project in
let open OpamParserTypes in
let file_name = "opam" in
let pos = (file_name, 0, 0) in
let string s = String (pos, s) in
let list v = List (pos, v) in
let var_string s v = Variable (pos, s, string v) in
let var_list s v = Variable (pos, s, list v) in
let open OpamParserTypes.FullPos in
let filename = "opam" in
let pos = { filename ; start = 0,0 ; stop = 0, 0 } in
let elem pelem = { pelem ; pos } in
let string s = elem ( String s ) in
let list v = elem ( List ( elem v )) in
let var s v = elem ( Variable ( elem s, v)) in
let var_string s v = var s ( string v ) in
let var_list s v = var s ( list v ) in
let optionals = ref [] in
let add_optional_string s = function
| None -> ()
Expand All @@ -44,20 +48,20 @@ let opam_of_project kind package =
add_optional_string "dev-repo" (dev_repo p);
add_optional_string "tags"
( match p.github_organization with
| None -> None
| Some github_organization ->
Some (Printf.sprintf "org:%s" github_organization) );
| None -> None
| Some github_organization ->
Some (Printf.sprintf "org:%s" github_organization) );

let build_commands =
match kind, package.kind with
| Deps, _
| _, Virtual -> []
| _ ->
[ Variable
( pos,
"build",
OpamParser.value_from_string
{|
[
var "build"
(
OpamParser.FullPos.value_from_string
{|
[
["dune" "subst"] {pinned}
["dune" "build" "-p" name "-j" jobs "@install"
Expand All @@ -66,65 +70,61 @@ let opam_of_project kind package =
]
]
|}
file_name )
]
filename )
]
in
let depend_of_dep name d =
let b = Buffer.create 100 in
Printf.bprintf b {| "%s" { |} name;
List.iteri
(fun i version ->
if i > 0 then Printf.bprintf b "& ";
match version with
| Version -> Printf.bprintf b "= version"
| NoVersion -> ()
| Semantic (major, minor, fix) ->
Printf.bprintf b {|>= "%d.%d.%d" & < "%d.0.0" |} major minor fix
(major + 1)
| Lt version -> Printf.bprintf b {| < "%s" |} version
| Le version -> Printf.bprintf b {| <= "%s" |} version
| Eq version -> Printf.bprintf b {| = "%s" |} version
| Ge version -> Printf.bprintf b {| >= "%s" |} version
| Gt version -> Printf.bprintf b {| > "%s" |} version)
if i > 0 then Printf.bprintf b "& ";
match version with
| Version -> Printf.bprintf b "= version"
| NoVersion -> ()
| Semantic (major, minor, fix) ->
Printf.bprintf b {|>= "%d.%d.%d" & < "%d.0.0" |} major minor fix
(major + 1)
| Lt version -> Printf.bprintf b {| < "%s" |} version
| Le version -> Printf.bprintf b {| <= "%s" |} version
| Eq version -> Printf.bprintf b {| = "%s" |} version
| Ge version -> Printf.bprintf b {| >= "%s" |} version
| Gt version -> Printf.bprintf b {| > "%s" |} version)
d.depversions;
if d.deptest then Printf.bprintf b " with-test ";
if d.depdoc then Printf.bprintf b " with-doc ";
Printf.bprintf b "}\n";
(* Printf.eprintf "parse: %s\n%!" s; *)
OpamParser.value_from_string (Buffer.contents b) file_name
OpamParser.FullPos.value_from_string (Buffer.contents b) filename
in
let depends =
[ Variable
( pos,
"depends",
[ var "depends" (
match kind with
| ProgramPart ->
List
( pos,
[ OpamParser.value_from_string
list
[ OpamParser.FullPos.value_from_string
(Printf.sprintf
{|
"%s" { = version }
|}
(Misc.package_lib package))
file_name
] )
filename
]
| Single
| LibraryPart
| Deps ->
List
( pos,
OpamParser.value_from_string
(Printf.sprintf {| "ocaml" { >= "%s" } |} p.min_edition)
file_name
:: OpamParser.value_from_string
(Printf.sprintf {| "dune" { >= "%s" } |}
Globals.current_dune_version)
file_name
:: List.map
(fun (name, d) -> depend_of_dep name d)
(Misc.p_dependencies package)
@ List.map
list
( OpamParser.FullPos.value_from_string
(Printf.sprintf {| "ocaml" { >= "%s" } |} p.min_edition)
filename
:: OpamParser.FullPos.value_from_string
(Printf.sprintf {| "dune" { >= "%s" } |}
Globals.current_dune_version)
filename
:: List.map
(fun (name, d) -> depend_of_dep name d)
(Misc.p_dependencies package)
@ List.map
(fun (name, d) -> depend_of_dep name d)
(Misc.p_tools package) ) )
]
Expand All @@ -133,39 +133,39 @@ let opam_of_project kind package =
[ var_string "opam-version" "2.0";
var_string "name"
( match kind with
| LibraryPart -> Misc.package_lib package
| Single
| ProgramPart ->
package.name
| Deps -> package.name );
| LibraryPart -> Misc.package_lib package
| Single
| ProgramPart ->
package.name
| Deps -> package.name );
var_string "version" (Misc.p_version package);
var_string "license" (License.name p);
var_string "synopsis"
( match kind with
| LibraryPart -> Misc.p_synopsis package ^ " (library)"
| Deps -> Misc.p_synopsis package
| Single
| ProgramPart ->
Misc.p_synopsis package );
| LibraryPart -> Misc.p_synopsis package ^ " (library)"
| Deps -> Misc.p_synopsis package
| Single
| ProgramPart ->
Misc.p_synopsis package );
var_string "description" (Misc.p_description package);
var_list "authors" (List.map string (Misc.p_authors package));
var_list "maintainer" (List.map string p.authors)
]
@ List.rev !optionals @ build_commands @ depends
in
let f = { file_contents; file_name } in
let s = OpamPrinter.opamfile f in
let f = { file_contents; file_name = filename } in
let s = OpamPrinter.FullPos.opamfile f in
String.concat "\n"
( [ "# This file was generated by `drom` from `drom.toml`.";
"# Do not modify or add to the `skip` field of `drom.toml`.";
s
]
@
let s = Subst.package_paren ("", package) "opam-trailer" in
if s = "" then
[]
else
[ s ] )
@
let s = Subst.package_paren ("", package) "opam-trailer" in
if s = "" then
[]
else
[ s ] )

let () = Unix.putenv "OPAMCLI" "2.0"

Expand Down
2 changes: 1 addition & 1 deletion src/drom_lib/package.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ directories = "0.2"
ez_cmdliner = "0.1.0"
ez_config = "0.1.0"
ez_file = "0.2.0"
opam-file-format = "2.0.0"
opam-file-format = "2.1.1"
toml = "5.0.0"
[fields]
dune-libraries = "bigarray"
2 changes: 1 addition & 1 deletion src/drom_lib/version.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let version = "0.1.0"
let version = "0.2.0"

0 comments on commit 0245d05

Please sign in to comment.