package opam-format

  1. Overview
  2. Docs

Module OpamFile.OPAMSource

OPAM files

Sourcetype t = private {
  1. opam_version : OpamTypes.opam_version;
  2. name : OpamTypes.name option;
  3. version : OpamTypes.version option;
  4. depends : OpamTypes.filtered_formula;
  5. depopts : OpamTypes.filtered_formula;
  6. conflicts : OpamTypes.filtered_formula;
  7. conflict_class : OpamTypes.name list;
  8. available : OpamTypes.filter;
  9. flags : OpamTypes.package_flag list;
  10. env : OpamTypes.env_update list;
  11. build : OpamTypes.command list;
  12. run_test : OpamTypes.command list;
  13. install : OpamTypes.command list;
  14. remove : OpamTypes.command list;
  15. substs : OpamTypes.basename list;
  16. patches : (OpamTypes.basename * OpamTypes.filter option) list;
  17. build_env : OpamTypes.env_update list;
  18. features : (OpamVariable.t * OpamTypes.filtered_formula * string) list;
  19. extra_sources : (OpamTypes.basename * URL.t) list;
  20. messages : (string * OpamTypes.filter option) list;
  21. post_messages : (string * OpamTypes.filter option) list;
  22. depexts : (string list * OpamTypes.filter) list;
  23. libraries : (string * OpamTypes.filter option) list;
  24. syntax : (string * OpamTypes.filter option) list;
  25. dev_repo : OpamTypes.url option;
  26. pin_depends : (OpamTypes.package * OpamTypes.url) list;
  27. maintainer : string list;
  28. author : string list;
  29. license : string list;
  30. tags : string list;
  31. homepage : string list;
  32. doc : string list;
  33. bug_reports : string list;
  34. extensions : (OpamTypes.pos * OpamTypes.value) OpamStd.String.Map.t;
  35. url : URL.t option;
  36. descr : Descr.t option;
  37. metadata_dir : OpamTypes.dirname option;
  38. extra_files : (OpamFilename.Base.t * OpamHash.t) list option;
  39. format_errors : (string * OpamPp.bad_format) list;
  40. ocaml_version : (OpamFormula.relop * string) OpamFormula.formula option;
  41. os : (bool * string) OpamTypes.generic_formula;
  42. deprecated_build_test : OpamTypes.command list;
  43. deprecated_build_doc : OpamTypes.command list;
}
include IO_FILE with type t := t
Sourceval write : t typed_file -> t -> unit

Write some contents to a file

Sourceval read : t typed_file -> t

Read file contents. Raise an error if the file does not exist.

Sourceval read_opt : t typed_file -> t option

Returns None on non-existing file

Sourceval safe_read : t typed_file -> t

Read file contents. Return empty if the file does not exist.

Sourceval read_from_channel : ?filename:t typed_file -> in_channel -> t
Sourceval read_from_string : ?filename:t typed_file -> string -> t
Sourceval write_to_channel : ?filename:t typed_file -> out_channel -> t -> unit
Sourceval write_to_string : ?filename:t typed_file -> t -> string
Sourceval empty : t
Sourceval create : OpamTypes.package -> t

Create an opam file

Sourceval effective_part : t -> t

Returns the opam value (including url, descr) with all non-effective (i.e. user-directed information that doesn't change opam's view on the package) fields set to their empty values. Useful for comparisons.

Sourceval effectively_equal : t -> t -> bool

Returns true if the effective parts of the two package definitions are equal

Sourceval equal : t -> t -> bool

Compares two package definitions, ignoring the virtual fields bound to file location (metadata_dir...)

Sourceval print_errors : ?file:t typed_file -> t -> unit

Prints the format errors that were found when the file was read

Sourceval opam_version : t -> OpamTypes.opam_version

Get OPAM version.

Sourceval name : t -> OpamTypes.name

Package name

Sourceval name_opt : t -> OpamTypes.name option
Sourceval version : t -> OpamTypes.version

Package version

Sourceval version_opt : t -> OpamTypes.version option
Sourceval package : t -> OpamTypes.package

The informations in both the name and version fields, as a package

Sourceval available : t -> OpamTypes.filter

Availability formula (OS + compiler constraints)

Sourceval maintainer : t -> string list

Package maintainer(s)

Sourceval substs : t -> OpamTypes.basename list

File substitutions

Sourceval build_env : t -> OpamTypes.env_update list

List of environment variables to set-up for the build

Sourceval build : t -> OpamTypes.command list

List of command to run for building the package

Sourceval install : t -> OpamTypes.command list

List of command to run for installing the package

Sourceval remove : t -> OpamTypes.command list

List of command to run for removing the package

Package dependencies

Optional dependencies

Sourceval depexts : t -> (string list * OpamTypes.filter) list

External dependencies

Sourceval extra_sources : t -> (OpamTypes.basename * URL.t) list

All extended "x-" fields as a map

Sourceval extended : t -> string -> (OpamTypes.value -> 'a) -> 'a option

Parse a single extended field (reports proper file position)

Sourceval with_messages : (string * OpamTypes.filter option) list -> t -> t
Sourceval with_post_messages : (string * OpamTypes.filter option) list -> t -> t

Package conflicts

Sourceval conflict_class : t -> OpamTypes.name list
Sourceval features : t -> (OpamVariable.t * OpamTypes.filtered_formula * string) list

Contents of the 'features' field

Sourceval libraries : t -> (string * OpamTypes.filter option) list

List of exported libraries

Sourceval syntax : t -> (string * OpamTypes.filter option) list

List of exported syntax extensions

Sourceval patches : t -> (OpamTypes.basename * OpamTypes.filter option) list

Patches

Sourceval homepage : t -> string list

Homepage(s)

Sourceval author : t -> string list

Author(s)

Sourceval license : t -> string list

License(s)

Sourceval doc : t -> string list

API documentation

Sourceval tags : t -> string list

Classification tags

Sourceval run_test : t -> OpamTypes.command list

Commands to build and run the tests

Sourceval deprecated_build_doc : t -> OpamTypes.command list

Commands to build the documentation

Sourceval deprecated_build_test : t -> OpamTypes.command list

Commands to build the tests

Sourceval messages : t -> (string * OpamTypes.filter option) list

Messages to display before taking action

Sourceval post_messages : t -> (string * OpamTypes.filter option) list

Messages to display at end of install

Sourceval bug_reports : t -> string list

Where to post bug reports.

Sourceval flags : t -> OpamTypes.package_flag list

The package flags that are present for this package.

Sourceval has_flag : OpamTypes.package_flag -> t -> bool

Check the package for the given flag. Allows flags specified through tags for compatibility

Sourceval env : t -> OpamTypes.env_update list

The environment variables that this package exports

Sourceval descr : t -> Descr.t option
Sourceval synopsis : t -> string option
Sourceval descr_body : t -> string option
Sourceval url : t -> URL.t option
Sourceval get_url : t -> OpamTypes.url option
Sourceval metadata_dir : t -> OpamTypes.dirname option

Related metadata directory (not an actual field of the file, linked to the file location). This can be used to locate e.g. the files/ overlays

Sourceval extra_files : t -> (OpamFilename.Base.t * OpamHash.t) list option

Names and hashes of the files below files/

Sourceval get_extra_files : t -> (OpamTypes.filename * OpamTypes.basename * OpamHash.t) list

Looks up the extra files, and returns their full paths, relative path to the package source, and hash. Doesn't check the hashes.

Sourceval format_errors : t -> (string * OpamPp.bad_format) list

Returns the errors that were found when parsing the file, associated to their fields (that were consequently ignored)

Sourceval with_opam_version : OpamTypes.opam_version -> t -> t

Sets the opam version

Sourceval dev_repo : t -> OpamTypes.url option

The package source repository address

Sourceval pin_depends : t -> (OpamTypes.package * OpamTypes.url) list
Sourceval with_name : OpamTypes.name -> t -> t

construct as name

Sourceval with_name_opt : OpamTypes.name option -> t -> t
Sourceval with_version : OpamTypes.version -> t -> t

construct as version

Sourceval with_version_opt : OpamTypes.version option -> t -> t
Sourceval with_depends : OpamTypes.filtered_formula -> t -> t

Construct as depends

Sourceval with_depopts : OpamTypes.filtered_formula -> t -> t

Construct as depopts

Sourceval with_conflicts : OpamTypes.filtered_formula -> t -> t
Sourceval with_conflict_class : OpamTypes.name list -> t -> t
Sourceval with_features : (OpamVariable.t * OpamTypes.filtered_formula * string) list -> t -> t
Sourceval with_build : OpamTypes.command list -> t -> t

Construct as build

Sourceval with_run_test : OpamTypes.command list -> t -> t
Sourceval with_install : OpamTypes.command list -> t -> t
Sourceval with_remove : OpamTypes.command list -> t -> t

Construct as remove

Sourceval with_libraries : (string * OpamTypes.filter option) list -> t -> t

Construct as libraries

Sourceval with_syntax : (string * OpamTypes.filter option) list -> t -> t

Replace the syntax field of the given OPAM file.

Sourceval with_substs : OpamTypes.basename list -> t -> t

Construct as substs

Sourceval with_build_env : OpamTypes.env_update list -> t -> t
Sourceval with_available : OpamTypes.filter -> t -> t
Sourceval with_maintainer : string list -> t -> t

Construct as maintainer

Sourceval with_author : string list -> t -> t
Sourceval with_homepage : string list -> t -> t
Sourceval with_license : string list -> t -> t
Sourceval with_patches : (OpamTypes.basename * OpamTypes.filter option) list -> t -> t

Construct as patches

Sourceval with_bug_reports : string list -> t -> t

Construct using bug_reports

Sourceval with_depexts : (string list * OpamTypes.filter) list -> t -> t

Construct using depexts

Sourceval with_flags : OpamTypes.package_flag list -> t -> t
Sourceval add_flags : OpamTypes.package_flag list -> t -> t
Sourceval with_tags : string list -> t -> t
Sourceval with_env : OpamTypes.env_update list -> t -> t
Sourceval with_dev_repo : OpamTypes.url -> t -> t
Sourceval with_dev_repo_opt : OpamTypes.url option -> t -> t
Sourceval with_pin_depends : (OpamTypes.package * OpamTypes.url) list -> t -> t
Sourceval with_extra_sources : (OpamTypes.basename * URL.t) list -> t -> t
Sourceval with_extensions : OpamTypes.value OpamStd.String.Map.t -> t -> t
Sourceval add_extension : t -> string -> OpamTypes.value -> t
Sourceval with_deprecated_build_doc : OpamTypes.command list -> t -> t
Sourceval with_deprecated_build_test : OpamTypes.command list -> t -> t
Sourceval with_descr : Descr.t -> t -> t
Sourceval with_descr_opt : Descr.t option -> t -> t
Sourceval with_synopsis : string -> t -> t
Sourceval with_descr_body : string -> t -> t

If synopsis is not already set, split the string and use the first line as synopsis.

Sourceval with_url : URL.t -> t -> t
Sourceval with_url_opt : URL.t option -> t -> t
Sourceval with_metadata_dir : OpamTypes.dirname option -> t -> t
Sourceval with_extra_files : (OpamFilename.Base.t * OpamHash.t) list -> t -> t
Sourceval with_extra_files_opt : (OpamFilename.Base.t * OpamHash.t) list option -> t -> t
Sourceval with_format_errors : (string * OpamPp.bad_format) list -> t -> t
Sourceval to_string_with_preserved_format : ?format_from:t typed_file -> ?format_from_string:string -> t typed_file -> t -> string

Prints to a string, while keeping the format of the original file as much as possible. The original format is read from the given format_from_string, the file format_from, or the output file if it exists

Sourceval write_with_preserved_format : ?format_from:t typed_file -> ?format_from_string:string -> t typed_file -> t -> unit

Writes an opam file, but preserving the existing formatting as much as possible. The original format is read from the given format_from_string, the file format_from, or the output file if it exists

Low-level values used for linting and similar processing

Sourceval flag_of_tag : string -> OpamTypes.package_flag option

Allow 'flag:xxx' tags as flags, for compat

Sourceval sections : (t, (string option * OpamTypes.opamfile_item list) list) OpamFormat.I.fields_def
Sourceval pp_raw_fields : (OpamTypes.opamfile_item list, t) OpamPp.t

Doesn't handle package name encoded in directory name

Sourceval contents : ?filename:'a typed_file -> t -> OpamTypes.opamfile

Returns the raw print-AST contents of the file

Sourceval to_list : ?filename:'a typed_file -> t -> (string * OpamTypes.value) list

Returns all fields of the file as print-AST. Fields within sections are accessed through dot-separated paths (e.g. url.checksum)

Sourceval print_field_as_syntax : string -> t -> OpamTypes.value option

Gets the print-AST for a single field in the file structure. Fields within sections can be accessed through section.field.

OCaml

Innovation. Community. Security.