OpamFile.OPAMOPAM files
type t = private {opam_version : OpamTypes.opam_version; |
name : OpamTypes.name option; |
version : OpamTypes.version option; |
depends : OpamTypes.filtered_formula; |
depopts : OpamTypes.filtered_formula; |
conflicts : OpamTypes.filtered_formula; |
conflict_class : OpamTypes.name list; |
available : OpamTypes.filter; |
flags : OpamTypes.package_flag list; |
env : OpamTypes.env_update list; |
build : OpamTypes.command list; |
run_test : OpamTypes.command list; |
install : OpamTypes.command list; |
remove : OpamTypes.command list; |
substs : OpamTypes.basename list; |
patches : (OpamTypes.basename * OpamTypes.filter option) list; |
build_env : OpamTypes.env_update list; |
features : (OpamVariable.t * OpamTypes.filtered_formula * string) list; |
extra_sources : (OpamTypes.basename * URL.t) list; |
messages : (string * OpamTypes.filter option) list; |
post_messages : (string * OpamTypes.filter option) list; |
depexts : (OpamSysPkg.Set.t * OpamTypes.filter) list; |
libraries : (string * OpamTypes.filter option) list; |
syntax : (string * OpamTypes.filter option) list; |
dev_repo : OpamTypes.url option; |
pin_depends : (OpamTypes.package * OpamTypes.url) list; |
maintainer : string list; |
author : string list; |
license : string list; |
tags : string list; |
homepage : string list; |
doc : string list; |
bug_reports : string list; |
extensions : OpamParserTypes.FullPos.value OpamStd.String.Map.t; |
url : URL.t option; |
descr : Descr.t option; |
metadata_dir : (OpamTypes.repository_name option * string) option; |
extra_files : (OpamFilename.Base.t * OpamHash.t) list option; |
format_errors : (string * OpamPp.bad_format) list; |
ocaml_version : (OpamFormula.relop * string) OpamFormula.formula option; |
os : (bool * string) OpamTypes.generic_formula; |
deprecated_build_test : OpamTypes.command list; |
deprecated_build_doc : OpamTypes.command list; |
}include IO_FILE with type t := tval format_version : OpamVersion.tval write : t typed_file -> t -> unitWrite some contents to a file
val read : t typed_file -> tRead file contents. Raise an error if the file does not exist.
val read_opt : t typed_file -> t optionReturns None on non-existing file
val safe_read : t typed_file -> tRead file contents. Return empty if the file does not exist.
val read_from_channel : ?filename:t typed_file -> in_channel -> tval read_from_string : ?filename:t typed_file -> string -> tval write_to_channel : ?filename:t typed_file -> out_channel -> t -> unitval write_to_string : ?filename:t typed_file -> t -> stringval empty : tval create : OpamTypes.package -> tCreate an opam file
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.
Returns true if the effective parts of the two package definitions are equal
Compares two package definitions, ignoring the virtual fields bound to file location (metadata_dir...)
val print_errors : ?file:t typed_file -> t -> unitPrints the format errors that were found when the file was read
val opam_version : t -> OpamTypes.opam_versionGet OPAM version.
val name : t -> OpamTypes.namePackage name
val name_opt : t -> OpamTypes.name optionval version : t -> OpamTypes.versionPackage version
val version_opt : t -> OpamTypes.version optionval package : t -> OpamTypes.packageThe informations in both the name and version fields, as a package
val available : t -> OpamTypes.filterAvailability formula (OS + compiler constraints)
val maintainer : t -> string listPackage maintainer(s)
val substs : t -> OpamTypes.basename listFile substitutions
val build_env : t -> OpamTypes.env_update listList of environment variables to set-up for the build
val build : t -> OpamTypes.command listList of command to run for building the package
val install : t -> OpamTypes.command listList of command to run for installing the package
val remove : t -> OpamTypes.command listList of command to run for removing the package
val depends : t -> OpamTypes.filtered_formulaPackage dependencies
val depopts : t -> OpamTypes.filtered_formulaOptional dependencies
val depexts : t -> (OpamSysPkg.Set.t * OpamTypes.filter) listExternal dependencies
val extra_sources : t -> (OpamTypes.basename * URL.t) listval extensions : t -> OpamParserTypes.FullPos.value OpamStd.String.Map.tAll extended "x-" fields as a map
val extended : t -> string -> (OpamParserTypes.FullPos.value -> 'a) -> 'a optionParse a single extended field (reports proper file position)
val with_messages : (string * OpamTypes.filter option) list -> t -> tval with_post_messages : (string * OpamTypes.filter option) list -> t -> tval conflicts : t -> OpamTypes.filtered_formulaPackage conflicts
val conflict_class : t -> OpamTypes.name listval features : t -> (OpamVariable.t * OpamTypes.filtered_formula * string) listContents of the 'features' field
val libraries : t -> (string * OpamTypes.filter option) listList of exported libraries
val syntax : t -> (string * OpamTypes.filter option) listList of exported syntax extensions
val patches : t -> (OpamTypes.basename * OpamTypes.filter option) listPatches
val homepage : t -> string listHomepage(s)
val author : t -> string listAuthor(s)
val license : t -> string listLicense(s)
val doc : t -> string listAPI documentation
val tags : t -> string listClassification tags
val run_test : t -> OpamTypes.command listCommands to build and run the tests
val deprecated_build_doc : t -> OpamTypes.command listCommands to build the documentation
val deprecated_build_test : t -> OpamTypes.command listCommands to build the tests
val messages : t -> (string * OpamTypes.filter option) listMessages to display before taking action
val post_messages : t -> (string * OpamTypes.filter option) listMessages to display at end of install
val bug_reports : t -> string listWhere to post bug reports.
val flags : t -> OpamTypes.package_flag listThe package flags that are present for this package.
val has_flag : OpamTypes.package_flag -> t -> boolCheck the package for the given flag. Allows flags specified through tags for compatibility
val env : t -> OpamTypes.env_update listThe environment variables that this package exports
val synopsis : t -> string optionval descr_body : t -> string optionval get_url : t -> OpamTypes.url optionval metadata_dir : t -> (OpamTypes.repository_name option * string) optionRelated metadata directory (either repository name + relative path, or absolute path; not an actual field of the file, linked to the file location). This can be used to locate e.g. the files/ overlays
val get_metadata_dir : repos_roots:(OpamTypes.repository_name -> OpamTypes.dirname) -> t -> OpamTypes.dirname optionGets the resolved metadata dir, given a mapping of repository names to their roots
val extra_files : t -> (OpamFilename.Base.t * OpamHash.t) list optionNames and hashes of the files below files/
val get_extra_files : repos_roots:(OpamTypes.repository_name -> OpamTypes.dirname) -> t -> (OpamTypes.filename * OpamTypes.basename * OpamHash.t) listLooks up the extra files, and returns their full paths, relative path to the package source, and hash. Doesn't check the hashes.
val format_errors : t -> (string * OpamPp.bad_format) listReturns the errors that were found when parsing the file, associated to their fields (that were consequently ignored)
val with_opam_version : OpamTypes.opam_version -> t -> tSets the opam version
val dev_repo : t -> OpamTypes.url optionThe package source repository address
val pin_depends : t -> (OpamTypes.package * OpamTypes.url) listval with_name : OpamTypes.name -> t -> tconstruct as name
val with_name_opt : OpamTypes.name option -> t -> tval with_version : OpamTypes.version -> t -> tconstruct as version
val with_version_opt : OpamTypes.version option -> t -> tval with_depends : OpamTypes.filtered_formula -> t -> tConstruct as depends
val with_depopts : OpamTypes.filtered_formula -> t -> tConstruct as depopts
val with_conflicts : OpamTypes.filtered_formula -> t -> tval with_conflict_class : OpamTypes.name list -> t -> tval with_features : (OpamVariable.t * OpamTypes.filtered_formula * string) list -> t -> tval with_build : OpamTypes.command list -> t -> tConstruct as build
val with_run_test : OpamTypes.command list -> t -> tval with_install : OpamTypes.command list -> t -> tval with_remove : OpamTypes.command list -> t -> tConstruct as remove
val with_libraries : (string * OpamTypes.filter option) list -> t -> tConstruct as libraries
val with_syntax : (string * OpamTypes.filter option) list -> t -> tReplace the syntax field of the given OPAM file.
val with_substs : OpamTypes.basename list -> t -> tConstruct as substs
val with_build_env : OpamTypes.env_update list -> t -> tval with_available : OpamTypes.filter -> t -> tval with_patches : (OpamTypes.basename * OpamTypes.filter option) list -> t -> tConstruct as patches
val with_depexts : (OpamSysPkg.Set.t * OpamTypes.filter) list -> t -> tConstruct using depexts
val with_flags : OpamTypes.package_flag list -> t -> tval add_flags : OpamTypes.package_flag list -> t -> tval with_env : OpamTypes.env_update list -> t -> tval with_dev_repo : OpamTypes.url -> t -> tval with_dev_repo_opt : OpamTypes.url option -> t -> tval with_pin_depends : (OpamTypes.package * OpamTypes.url) list -> t -> tval with_extra_sources : (OpamTypes.basename * URL.t) list -> t -> tval with_extensions : OpamParserTypes.FullPos.value OpamStd.String.Map.t -> t -> tval add_extension : t -> string -> OpamParserTypes.FullPos.value -> tval with_deprecated_build_doc : OpamTypes.command list -> t -> tval with_deprecated_build_test : OpamTypes.command list -> t -> tIf synopsis is not already set, split the string and use the first line as synopsis.
val with_metadata_dir : (OpamTypes.repository_name option * string) option -> t -> tval with_extra_files : (OpamFilename.Base.t * OpamHash.t) list -> t -> tval with_extra_files_opt : (OpamFilename.Base.t * OpamHash.t) list option -> t -> tval with_format_errors : (string * OpamPp.bad_format) list -> t -> tval to_string_with_preserved_format : ?format_from:t typed_file ->
?format_from_string:string -> t typed_file -> t -> stringPrints 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
val write_with_preserved_format : ?format_from:t typed_file -> ?format_from_string:string ->
t typed_file -> t -> unitWrites 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
val flag_of_tag : string -> OpamTypes.package_flag optionAllow 'flag:xxx' tags as flags, for compat
val fields : (t, OpamParserTypes.FullPos.value) OpamFormat.I.fields_defval sections : (t, (string option * OpamParserTypes.FullPos.opamfile_item list) list) OpamFormat.I.fields_defval pp_raw_fields : (OpamParserTypes.FullPos.opamfile_item list, t) OpamPp.tDoesn't handle package name encoded in directory name
val contents : ?filename:'a typed_file -> t -> OpamParserTypes.FullPos.opamfileReturns the raw print-AST contents of the file
val to_list : ?filename:'a typed_file -> t -> (string * OpamParserTypes.FullPos.value) listReturns all fields of the file as print-AST. Fields within sections are accessed through dot-separated paths (e.g. url.checksum)
val print_field_as_syntax : string -> t -> OpamParserTypes.FullPos.value optionGets the print-AST for a single field in the file structure. Fields within sections can be accessed through section.field.