Skip to content

Commit

Permalink
[wip] better OpamFormat interface
Browse files Browse the repository at this point in the history
compiling version, but badly broken: depends are missing
  • Loading branch information
AltGr committed Oct 19, 2015
1 parent 9460844 commit 3f51f3e
Show file tree
Hide file tree
Showing 17 changed files with 2,264 additions and 1,485 deletions.
18 changes: 14 additions & 4 deletions doc/pages/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,13 @@ It has the following fields:
- One of <a id="urlfield-src">`src: <string>`</a> or
<a id="urlfield-archive">`archive: <string>`</a>,
specifying the URL where the package can be downloaded from. When using HTTP
or FTP, this should be an archive. The older alternative field names <a
id="urlfield-http">`http:`</a>, <a id="urlfield-local">`local:`</a>, <a
id="urlfield-git">`git:`</a>, <a id="urlfield-hg">`hg:`</a> and <a
id="urlfield-darcs">`darcs:`</a> are deprecated, prefer explicit URLs.
or FTP, this should be an archive. The older alternative field names
<a id="urlfield-http">`http:`</a>,
<a id="urlfield-local">`local:`</a>,
<a id="urlfield-git">`git:`</a>,
<a id="urlfield-hg">`hg:`</a> and
<a id="urlfield-darcs">`darcs:`</a>
are deprecated, prefer explicit URLs.

On the official repository, this should always point to a stable archive
over HTTP or FTP.
Expand Down Expand Up @@ -704,6 +707,13 @@ recommended to check the validity and quality of your `opam` files.
auto-installed and run with `opam <name>` (since OPAM 1.2.2 ; the use is
discouraged in the 1.2 branch for compatibility, use `tag: "flags:plugin"`
instead)
- <a id="opamflag-compiler">`compiler`</a>:
the package is to be treated as a compiler, and available through the
`opam switch` command. This as several consequences:
- when installed this way, the package and all its dependencies will be
immutable and excluded from `opam switch rebuild`
- the package _must_ include or generate a `global-config.config` file at its root
-

- <a id="opamfield-features">
`features: [ <ident> <string> { <filter> } ... ]`</a> (EXPERIMENTAL):
Expand Down
24 changes: 12 additions & 12 deletions opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ opam-version: "1.2"
name: "opam-lib"
version: "1.3.0~dev"
maintainer: "[email protected]"
homepage: "https://opam.ocaml.org/"
dev-repo: "https://github.com/ocaml/opam.git"
bug-reports: "https://github.com/ocaml/opam/issues"
authors: [
"Thomas Gazagnaire <[email protected]>"
"Anil Madhavapeddy <[email protected]>"
"Fabrice Le Fessant <[email protected]>"
"Frederic Tuong <[email protected]>"
"Louis Gesbert <[email protected]>"
"Guillem Rieu <[email protected]>"
"Vincent Bernardoff <[email protected]>"
"Roberto Di Cosmo <[email protected]>"
"Thomas Gazagnaire <[email protected]>"
"Anil Madhavapeddy <[email protected]>"
"Fabrice Le Fessant <[email protected]>"
"Frederic Tuong <[email protected]>"
"Louis Gesbert <[email protected]>"
"Guillem Rieu <[email protected]>"
"Vincent Bernardoff <[email protected]>"
"Roberto Di Cosmo <[email protected]>"
]
homepage: "https://opam.ocaml.org/"
bug-reports: "https://github.com/ocaml/opam/issues"
dev-repo: "https://github.com/ocaml/opam.git"
build: [
["./configure"]
[make]
Expand All @@ -23,7 +23,7 @@ build: [
depends: [
"ocamlgraph"
"cmdliner"
"dose" {>= "3.2.2+opam" & < "4"}
"dose" {>= "3.2.2+opam"}
"cudf"
"re" {>= "1.2.0"}
"ocamlfind" {build}
Expand Down
4 changes: 2 additions & 2 deletions src/core/opamFilename.ml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ module Attribute = struct
let perm t = t.perm

let create base md5 perm =
{ base; md5; perm=Some perm }
{ base; md5; perm=perm }

let to_string_list t =
let perm = match t.perm with
Expand Down Expand Up @@ -453,4 +453,4 @@ let to_attribute root file =
let s = Unix.stat (to_string file) in
s.Unix.st_perm in
let digest = digest file in
Attribute.create basename digest perm
Attribute.create basename digest (Some perm)
2 changes: 1 addition & 1 deletion src/core/opamFilename.mli
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ module Attribute: sig
val perm: t -> int option

(** Constructor*)
val create: Base.t -> string -> int -> t
val create: Base.t -> string -> int option -> t

end

Expand Down
18 changes: 18 additions & 0 deletions src/core/opamStd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module type SET = sig
val to_string: t -> string
val to_json: t -> OpamJson.t
val find: (elt -> bool) -> t -> elt
val safe_add: elt -> t -> t

module Op : sig
val (++): t -> t -> t
val (--): t -> t -> t
Expand All @@ -38,6 +40,7 @@ module type MAP = sig
val values: 'a t -> 'a list
val union: ('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t
val of_list: (key * 'a) list -> 'a t
val safe_add: key -> 'a -> 'a t -> 'a t
end
module type ABSTRACT = sig
type t
Expand Down Expand Up @@ -164,6 +167,10 @@ module Set = struct
let (%%) = inter
end

let safe_add elt t =
if mem elt t
then failwith (Printf.sprintf "duplicate entry %s" (O.to_string elt))
else add elt t
end

end
Expand Down Expand Up @@ -226,6 +233,11 @@ module Map = struct
) bindings in
`A jsons

let safe_add k v map =
if mem k map
then failwith (Printf.sprintf "duplicate entry %s" (O.to_string k))
else add k v map

end

end
Expand Down Expand Up @@ -285,6 +297,12 @@ module Option = struct
| Some x -> f x
| None -> none

let some x = Some x
let none _ = None

let of_Not_found f x =
try Some (f x) with Not_found -> None

module Op = struct
let (>>=) = function
| None -> fun _ -> None
Expand Down
13 changes: 13 additions & 0 deletions src/core/opamStd.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module type SET = sig
val to_json: t -> OpamJson.t
val find: (elt -> bool) -> t -> elt

(** Raises Failure in case the element is already present *)
val safe_add: elt -> t -> t

module Op : sig
val (++): t -> t -> t (** Infix set union *)

Expand Down Expand Up @@ -59,6 +62,9 @@ module type MAP = sig

val of_list: (key * 'a) list -> 'a t

(** Raises Failure in case the element is already present *)
val safe_add: key -> 'a -> 'a t -> 'a t

end

(** A signature for handling abstract keys and collections thereof *)
Expand Down Expand Up @@ -118,6 +124,13 @@ module Option: sig

val to_string: ?none:string -> ('a -> string) -> 'a option -> string

val some: 'a -> 'a option

val none: 'a -> 'b option

(** [of_Not_found f x] calls [f x], catches [Not_found] and returns [None] *)
val of_Not_found: ('a -> 'b) -> 'a -> 'b option

module Op: sig
val (>>=): 'a option -> ('a -> 'b option) -> 'b option
val (>>|): 'a option -> ('a -> 'b) -> 'b option
Expand Down
1 change: 1 addition & 0 deletions src/format/format.ocp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ begin library "opam-format"
"opamTypes.mli"
"opamTypesBase.ml"
"opamFormat.ml"
"pp.ml"
"opamParser.mly"
"opamLexer.mll"
"opamLineLexer.mll"
Expand Down
2 changes: 1 addition & 1 deletion src/format/opamCompiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module Version = struct

let of_string str =
if OpamStd.String.contains str '+' then
raise (Invalid_argument "'+' is not allowed in compiler versions");
failwith "'+' is not allowed in compiler versions";
of_string str

type constr = (OpamFormula.relop * t) OpamFormula.formula
Expand Down
Loading

0 comments on commit 3f51f3e

Please sign in to comment.