Skip to content
Browse files

Continue to refactor opam API

We now have opamCompiler.ml which contains compiler name, version and alias and opamVersion.ml which contains OPAM versions.
  • Loading branch information...
1 parent b8e5e44 commit 188231ae7b11d45aa50d7d66b72760e7ec8d5194 @samoht samoht committed
View
4 configure
@@ -3718,7 +3718,7 @@ echo "$as_me: error: Your version of OCaml: $OCAMLVERSION is not supported" >&2;
fi
-ac_config_files="$ac_config_files Makefile.config src/opamGlobals.ml"
+ac_config_files="$ac_config_files Makefile.config src/opamVersion.ml"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -4288,7 +4288,7 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
- "src/opamGlobals.ml") CONFIG_FILES="$CONFIG_FILES src/opamGlobals.ml" ;;
+ "src/opamVersion.ml") CONFIG_FILES="$CONFIG_FILES src/opamVersion.ml" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
View
2 configure.ac
@@ -22,7 +22,7 @@ fi
AC_CONFIG_FILES(
Makefile.config
- src/opamGlobals.ml
+ src/opamVersion.ml
)
AC_OUTPUT
View
49 opam.install
@@ -7,28 +7,29 @@ lib: [
"_obuild/opam-lib/opam-lib.cma"
"_obuild/opam-lib/opam-lib.cmxa"
"_obuild/opam-lib/opam-lib.a"
- "_obuild/opam-lib//opamAlias.cmi"
- "_obuild/opam-lib//opamClient.cmi"
- "_obuild/opam-lib//opamCurl.cmi"
- "_obuild/opam-lib//opamFile.cmi"
- "_obuild/opam-lib//opamFilename.cmi"
- "_obuild/opam-lib//opamFormat.cmi"
- "_obuild/opam-lib//opamFormula.cmi"
- "_obuild/opam-lib//opamGit.cmi"
- "_obuild/opam-lib//opamGlobals.cmi"
- "_obuild/opam-lib//opamLexer.cmi"
- "_obuild/opam-lib//opamLineLexer.cmi"
- "_obuild/opam-lib//opamMisc.cmi"
- "_obuild/opam-lib//opamPackage.cmi"
- "_obuild/opam-lib//opamParallel.cmi"
- "_obuild/opam-lib//opamParser.cmi"
- "_obuild/opam-lib//opamPath.cmi"
- "_obuild/opam-lib//opamProcess.cmi"
- "_obuild/opam-lib//opamRepository.cmi"
- "_obuild/opam-lib//opamRsync.cmi"
- "_obuild/opam-lib//opamSolver.cmi"
- "_obuild/opam-lib//opamSystem.cmi"
- "_obuild/opam-lib//opamTypes.cmi"
- "_obuild/opam-lib//opamVariable.cmi"
- "_obuild/opam-lib//opamVersion.cmi"
+ "_obuild/opam-lib/opamAlias.cmi"
+ "_obuild/opam-lib/opamClient.cmi"
+ "_obuild/opam-lib/opamCurl.cmi"
+ "_obuild/opam-lib/opamFile.cmi"
+ "_obuild/opam-lib/opamFilename.cmi"
+ "_obuild/opam-lib/opamFormat.cmi"
+ "_obuild/opam-lib/opamFormula.cmi"
+ "_obuild/opam-lib/opamGit.cmi"
+ "_obuild/opam-lib/opamGlobals.cmi"
+ "_obuild/opam-lib/opamLexer.cmi"
+ "_obuild/opam-lib/opamLineLexer.cmi"
+ "_obuild/opam-lib/opamMisc.cmi"
+ "_obuild/opam-lib/opamPackage.cmi"
+ "_obuild/opam-lib/opamParallel.cmi"
+ "_obuild/opam-lib/opamParser.cmi"
+ "_obuild/opam-lib/opamPath.cmi"
+ "_obuild/opam-lib/opamProcess.cmi"
+ "_obuild/opam-lib/opamRepository.cmi"
+ "_obuild/opam-lib/opamRsync.cmi"
+ "_obuild/opam-lib/opamSolver.cmi"
+ "_obuild/opam-lib/opamSystem.cmi"
+ "_obuild/opam-lib/opamTypes.cmi"
+ "_obuild/opam-lib/opamVariable.cmi"
+ "_obuild/opam-lib/opamVersion.cmi"
+ "_obuild/opam-lib/opamCompiler.cmi"
]
View
3 opam.ocp
@@ -13,13 +13,14 @@ begin library "opam-lib"
files = [
"opamGlobals.ml"
"opamMisc.ml"
+ "opamVersion.ml"
"opamProcess.ml"
"opamSystem.ml"
"opamParallel.ml"
"opamFilename.ml"
"opamPackage.ml"
"opamFormula.ml"
- "opamVersion.ml"
+ "opamCompiler.ml"
"opamVariable.ml"
"opamAlias.ml"
"opamTypes.ml"
View
2 src/opamAlias.ml
@@ -14,3 +14,5 @@
(***********************************************************************)
include OpamMisc.Base
+
+let default = of_string OpamGlobals.default_alias
View
3 src/opamAlias.mli
@@ -16,3 +16,6 @@
(** Compiler aliases. *)
include OpamMisc.ABSTRACT
+
+(** Default alias *)
+val default: t
View
165 src/opamClient.ml
@@ -28,16 +28,17 @@ let () =
type state = {
root: OpamPath.t;
alias: alias;
- compiler: compiler_version option;
+ compiler: compiler option;
+ compiler_version: compiler_version option;
repositories: repository list;
packages: package_set;
available_packages: package_set Lazy.t;
- aliases: (alias * compiler_version) list;
- pinned: pin_option name_map;
- installed: package_set;
- reinstall: package_set;
+ aliases: OpamFile.Aliases.t;
+ pinned: OpamFile.Pinned.t;
+ installed: OpamFile.Installed.t;
+ reinstall: OpamFile.Reinstall.t;
config: OpamFile.Config.t;
- repo_index: string list name_map;
+ repo_index: OpamFile.Repo_index.t;
}
let print_state t =
@@ -50,20 +51,19 @@ let print_state t =
String.concat ", " (List.map s r) in
log "ROOT : %s" (OpamFilename.Dir.to_string (OpamPath.root t.root));
log "ALIAS : %s" (OpamAlias.to_string t.alias);
- log "COMPILER : %s" (match t.compiler with None -> "<none>" | Some c -> OpamVersion.Compiler.to_string c);
+ log "COMPILER : %s" (match t.compiler with None -> "<none>" | Some c -> OpamCompiler.to_string c);
log "REPO : %s" (string_of_repos t.repositories);
log "AVAILABLE : %s" (OpamPackage.Set.to_string t.packages);
log "INSTALLED : %s" (OpamPackage.Set.to_string t.installed);
log "REINSTALL : %s" (OpamPackage.Set.to_string t.reinstall)
-let available_packages root compiler config pinned packages =
+let available_packages root compiler_version config pinned packages =
(* Remove the packages which does not fullfil the compiler
constraints *)
let ocaml_version =
let opam_version = OpamFile.Config.alias config in
- let default_version = OpamAlias.of_string OpamGlobals.default_alias in
- if opam_version = default_version then (
- let current = OpamVersion.Compiler.current () in
+ if opam_version = OpamAlias.default then (
+ let current = OpamCompiler.Version.current () in
let system = OpamFile.Config.system_version config in
match current, system with
| None , None -> OpamGlobals.error_and_exit "No OCaml compiler installed."
@@ -77,20 +77,20 @@ let available_packages root compiler config pinned packages =
&& not (OpamMisc.confirm "The version of OCaml in your path (%S) \
is not the same as the one OPAM has been \
initialized with (%S). Continue ?"
- (OpamVersion.Compiler.to_string c)
- (OpamVersion.Compiler.to_string s)) then
+ (OpamCompiler.Version.to_string c)
+ (OpamCompiler.Version.to_string s)) then
OpamGlobals.exit 1
else
s
| Some c, None -> c
) else
- match compiler with
+ match compiler_version with
| Some v -> v
| None -> OpamGlobals.error_and_exit "No OCaml compiler defined."in
let filter nv =
let opam = OpamFile.OPAM.read (OpamPath.opam root nv) in
let consistent_ocaml_version =
- let atom (r,v) = OpamVersion.Compiler.compare ocaml_version r v in
+ let atom (r,v) = OpamCompiler.Version.compare ocaml_version r v in
match OpamFile.OPAM.ocaml_version opam with
| None -> true
| Some c -> OpamFormula.eval atom c in
@@ -127,11 +127,11 @@ let compilers_in_dir t =
(OpamFilename.chop_extension
|> OpamFilename.basename
|> OpamFilename.Base.to_string
- |> OpamVersion.Compiler.of_string)
+ |> OpamCompiler.of_string)
files in
- OpamVersion.Compiler.Set.of_list l
+ OpamCompiler.Set.of_list l
) else
- OpamVersion.Compiler.Set.empty
+ OpamCompiler.Set.empty
let compiler_of_alias t alias =
try Some (List.assoc alias t.aliases)
@@ -147,6 +147,11 @@ let load_state () =
let compiler =
try Some (List.assoc alias aliases)
with Not_found -> None in
+ let compiler_version = match compiler with
+ | None -> None
+ | Some c ->
+ let comp = OpamFile.Comp.read (OpamPath.compiler root c) in
+ Some (OpamFile.Comp.version comp) in
let repositories = OpamFile.Config.repositories config in
let repo_index =
let repo_index = OpamFile.Repo_index.safe_read (OpamPath.repo_index root) in
@@ -172,9 +177,9 @@ let load_state () =
let installed = OpamFile.Installed.safe_read (OpamPath.Alias.installed root alias) in
let reinstall = OpamFile.Reinstall.safe_read (OpamPath.Alias.reinstall root alias) in
let packages = packages_in_dir (OpamPath.opam_dir root) in
- let available_packages = lazy (available_packages root compiler config pinned packages) in
+ let available_packages = lazy (available_packages root compiler_version config pinned packages) in
let t = {
- root; alias; compiler; repositories;
+ root; alias; compiler; compiler_version; repositories;
packages; available_packages; installed; reinstall;
repo_index; config; aliases; pinned;
} in
@@ -338,25 +343,24 @@ let print_updated t updated pinned_updated =
let print_compilers t compilers repo =
let repo_p = OpamPath.Repository.create t.root repo in
let repo_compilers = OpamRepository.compilers repo_p in
- let (--) = OpamVersion.Compiler.Set.diff in
+ let (--) = OpamCompiler.Set.diff in
let new_compilers = repo_compilers -- compilers in
- if not (OpamVersion.Compiler.Set.is_empty new_compilers) then
+ if not (OpamCompiler.Set.is_empty new_compilers) then
OpamGlobals.msg "New compiler descriptions available:\n";
- OpamVersion.Compiler.Set.iter (fun v ->
- OpamGlobals.msg " - %s\n" (OpamVersion.Compiler.to_string v)
+ OpamCompiler.Set.iter (fun v ->
+ OpamGlobals.msg " - %s\n" (OpamCompiler.to_string v)
) new_compilers;
let all_compilers =
List.fold_left (fun set repo ->
let repo_p = OpamPath.Repository.create t.root repo in
let repo_compilers = OpamRepository.compilers repo_p in
- OpamVersion.Compiler.Set.union repo_compilers set;
- ) OpamVersion.Compiler.Set.empty t.repositories in
- let default = OpamVersion.Compiler.of_string OpamGlobals.default_alias in
- let del_compilers = compilers -- all_compilers -- (OpamVersion.Compiler.Set.singleton default) in
- if not (OpamVersion.Compiler.Set.is_empty del_compilers) then
+ OpamCompiler.Set.union repo_compilers set;
+ ) OpamCompiler.Set.empty t.repositories in
+ let del_compilers = compilers -- all_compilers -- (OpamCompiler.Set.singleton OpamCompiler.default) in
+ if not (OpamCompiler.Set.is_empty del_compilers) then
OpamGlobals.msg "Some compilers are not available anymore:\n";
- OpamVersion.Compiler.Set.iter (fun v ->
- OpamGlobals.msg " - %s\n" (OpamVersion.Compiler.to_string v)
+ OpamCompiler.Set.iter (fun v ->
+ OpamGlobals.msg " - %s\n" (OpamCompiler.to_string v)
) del_compilers
let install_conf_ocaml_config root alias =
@@ -505,10 +509,9 @@ let update_repo_index t =
let base_packages = List.map OpamPackage.Name.of_string [ "base-unix"; "base-bigarray"; "base-threads" ]
let create_default_compiler_description t =
- let ocaml_version = OpamVersion.Compiler.of_string OpamGlobals.default_alias in
let f =
OpamFile.Comp.create_preinstalled
- ocaml_version
+ OpamCompiler.default OpamCompiler.Version.default
(if !OpamGlobals.base_packages then base_packages else [])
[ ("CAML_LD_LIBRARY_PATH", "=",
"%{lib}%/stublibs"
@@ -517,7 +520,7 @@ let create_default_compiler_description t =
| Some d -> Filename.concat d "stublibs"
| None -> assert false))
] in
- let comp = OpamPath.compiler t.root ocaml_version in
+ let comp = OpamPath.compiler t.root OpamCompiler.default in
OpamFile.Comp.write comp f
let update_repositories t ~show_compilers repos =
@@ -533,8 +536,8 @@ let update_repositories t ~show_compilers repos =
(* XXX: we could have a special index for compiler descriptions as
well, but that's become a bit too heavy *)
- OpamVersion.Compiler.Set.iter (fun comp ->
- if OpamVersion.Compiler.to_string comp <> OpamGlobals.default_alias
+ OpamCompiler.Set.iter (fun comp ->
+ if comp <> OpamCompiler.default
&& not (List.exists (fun (_,c) -> comp = c) t.aliases) then (
let comp_f = OpamPath.compiler t.root comp in
OpamFilename.remove comp_f;
@@ -544,7 +547,7 @@ let update_repositories t ~show_compilers repos =
let repo_p = OpamPath.Repository.create t.root repo in
let comps = OpamRepository.compilers repo_p in
let comp_dir = OpamPath.compilers_dir t.root in
- OpamVersion.Compiler.Set.iter (fun o ->
+ OpamCompiler.Set.iter (fun o ->
let comp_g = OpamPath.compiler t.root o in
let comp_f = OpamPath.Repository.compiler repo_p o in
if not (OpamFilename.exists comp_g) && OpamFilename.exists comp_f then
@@ -552,8 +555,7 @@ let update_repositories t ~show_compilers repos =
) comps
) t.repositories;
(* If system.comp has been deleted, create it *)
- let default_compiler =
- OpamPath.compiler t.root (OpamVersion.Compiler.of_string OpamGlobals.default_alias) in
+ let default_compiler = OpamPath.compiler t.root OpamCompiler.default in
if not (OpamFilename.exists default_compiler) then
create_default_compiler_description t
@@ -715,14 +717,14 @@ let contents_of_variable t v =
try S (Sys.getenv var_str)
with Not_found ->
if var_str = "ocaml-version" then (
- match t.compiler with
+ match t.compiler_version with
| None -> S "<none>"
| Some comp ->
- let comp_str = OpamVersion.Compiler.to_string comp in
+ let comp_str = OpamCompiler.Version.to_string comp in
if comp_str = OpamGlobals.default_alias then
match OpamFile.Config.system_version t.config with
| None -> S "<none>"
- | Some v -> S (OpamVersion.Compiler.to_string v)
+ | Some v -> S (OpamCompiler.Version.to_string v)
else
S comp_str
) else if var_str = "preinstalled" then (
@@ -957,10 +959,10 @@ let print_env_warning ?(add_profile = false) t =
opam_root
add_profile
-let add_alias alias ocaml_version =
- log "adding alias %s %s" (OpamAlias.to_string alias) (OpamVersion.Compiler.to_string ocaml_version);
+let add_alias alias compiler =
+ log "adding alias %s %s" (OpamAlias.to_string alias) (OpamCompiler.to_string compiler);
let t = load_state () in
- if ocaml_version = OpamVersion.Compiler.of_string OpamGlobals.default_alias then
+ if compiler = OpamCompiler.default then
(* we create a dummy compiler description file the the system-wide
OCaml configuration *)
create_default_compiler_description t;
@@ -970,25 +972,25 @@ let add_alias alias ocaml_version =
(* Install the initial package and reload the global state *)
install_conf_ocaml ();
(* Update the list of aliases *)
- OpamFile.Aliases.write aliases_f ((alias, ocaml_version) :: aliases);
+ OpamFile.Aliases.write aliases_f ((alias, compiler) :: aliases);
end
(* - compiles and install $opam/compiler/[ocaml_version].comp in $opam/[alias]
- update $opam/alias
- update $opam/config *)
-let init_ocaml t quiet alias ocaml_version =
- log "init_ocaml alias=%s ocaml_version=%s"
+let init_ocaml t quiet alias compiler =
+ log "init_ocaml alias=%s compiler=%s"
(OpamAlias.to_string alias)
- (OpamVersion.Compiler.to_string ocaml_version);
+ (OpamCompiler.to_string compiler);
- if ocaml_version = OpamVersion.Compiler.of_string OpamGlobals.default_alias then
+ if compiler = OpamCompiler.default then
create_default_compiler_description t;
- let comp_f = OpamPath.compiler t.root ocaml_version in
+ let comp_f = OpamPath.compiler t.root compiler in
if not (OpamFilename.exists comp_f) then (
OpamGlobals.msg "Cannot find %s: %s is not a valid compiler name.\n"
(OpamFilename.to_string comp_f)
- (OpamVersion.Compiler.to_string ocaml_version);
+ (OpamCompiler.to_string compiler);
OpamGlobals.exit 0;
);
@@ -1011,7 +1013,7 @@ let init_ocaml t quiet alias ocaml_version =
| None ->
OpamGlobals.error_and_exit
"No source for compiler %s"
- (OpamVersion.Compiler.to_string ocaml_version) in
+ (OpamCompiler.to_string compiler) in
let build_dir = OpamPath.Alias.build_ocaml t.root alias in
let comp_src_raw = OpamFilename.to_string comp_src in
if Sys.file_exists comp_src_raw && Sys.is_directory comp_src_raw then
@@ -1048,7 +1050,7 @@ let init_ocaml t quiet alias ocaml_version =
(* write the new version in the configuration file *)
let config = OpamFile.Config.with_alias t.config alias in
OpamFile.Config.write (OpamPath.config t.root) config;
- add_alias alias ocaml_version
+ add_alias alias compiler
with e ->
if not !OpamGlobals.debug then
@@ -2003,15 +2005,15 @@ let upgrade names =
let check_opam_version () =
let t = load_state () in
let n = OpamPackage.Name.of_string "opam" in
- let current_version = OpamPackage.Version.of_string OpamGlobals.version in
match find_package_by_name t n with
| None -> ()
| Some _ ->
let max_version = OpamPackage.Version.Set.max_elt (available_versions t n) in
- if OpamPackage.Version.compare max_version current_version > 0 then (
+ let max_version = OpamVersion.of_string (OpamPackage.Version.to_string max_version) in
+ if OpamVersion.compare max_version OpamVersion.current > 0 then (
if OpamMisc.confirm "Your version of opam (%s) is not up-to-date. Do you want to upgrade to version %s ?"
- (OpamPackage.Version.to_string current_version)
- (OpamPackage.Version.to_string max_version)
+ (OpamVersion.to_string OpamVersion.current)
+ (OpamVersion.to_string max_version)
then
upgrade (OpamPackage.Name.Set.singleton n)
)
@@ -2050,7 +2052,7 @@ let update repos =
) else
OpamGlobals.msg "Already up-to-date.\n"
-let init repo ocaml_version cores =
+let init repo compiler cores =
log "init %s" (OpamRepository.to_string repo);
let root = OpamPath.default () in
let config_f = OpamPath.config root in
@@ -2059,8 +2061,7 @@ let init repo ocaml_version cores =
else try
let repo_p = OpamPath.Repository.create root repo in
(* Create (possibly empty) configuration files *)
- let opam_version = OpamVersion.OPAM.of_string OpamGlobals.opam_version in
- OpamFile.Config.write config_f (OpamFile.Config.create opam_version [repo] cores);
+ OpamFile.Config.write config_f (OpamFile.Config.create OpamVersion.current [repo] cores);
OpamFile.Repo_index.write (OpamPath.repo_index root) OpamPackage.Name.Map.empty;
OpamFile.Repo_config.write (OpamPath.Repository.config repo_p) repo;
OpamRepository.init repo;
@@ -2070,7 +2071,7 @@ let init repo ocaml_version cores =
OpamFilename.mkdir (OpamPath.compilers_dir root);
let t = load_state () in
update_repositories t ~show_compilers:false t.repositories;
- let system_ocaml_version = OpamVersion.Compiler.current () in
+ let system_ocaml_version = OpamCompiler.Version.current () in
begin match system_ocaml_version with
| None -> ()
| Some v ->
@@ -2078,18 +2079,18 @@ let init repo ocaml_version cores =
OpamFile.Config.write (OpamPath.config t.root) config
end;
let t = load_state () in
- let ocaml_version = match ocaml_version, system_ocaml_version with
- | None , Some _ -> OpamVersion.Compiler.of_string OpamGlobals.default_alias
+ let compiler = match compiler, system_ocaml_version with
+ | None , Some _ -> OpamCompiler.default
| Some v, _ -> v
| None , None ->
OpamGlobals.msg "No compiler found.\n";
OpamGlobals.exit 1 in
- let alias = OpamAlias.of_string (OpamVersion.Compiler.to_string ocaml_version) in
- let quiet = (system_ocaml_version = Some ocaml_version) in
- init_ocaml t quiet alias ocaml_version;
+ let alias = OpamAlias.of_string (OpamCompiler.to_string compiler) in
+ let quiet = (compiler = OpamCompiler.default) in
+ init_ocaml t quiet alias compiler;
update_packages t ~show_packages:false t.repositories;
let t = load_state () in
- let wish_install = Heuristic.get_comp_packages t ocaml_version Heuristic.v_any in
+ let wish_install = Heuristic.get_comp_packages t compiler Heuristic.v_any in
let _solution = Heuristic.resolve ~force:true `init t
[ { wish_install
; wish_remove = []
@@ -2632,27 +2633,31 @@ let compiler_list () =
OpamGlobals.msg "--- Installed compilers ---\n";
List.iter (fun (n,c) ->
let current = if n = OpamFile.Config.alias t.config then "*" else " " in
- let ocaml_version = OpamVersion.Compiler.to_string c in
+ let compiler = OpamCompiler.to_string c in
let alias_name = OpamAlias.to_string n in
- if alias_name = ocaml_version then
+ if alias_name = compiler then
OpamGlobals.msg " %s %s\n" current alias_name
else
- OpamGlobals.msg " %s %s [%s]\n" current ocaml_version alias_name
+ OpamGlobals.msg " %s %s [%s]\n" current compiler alias_name
) aliases;
OpamGlobals.msg "\n--- Available compilers ---\n";
- OpamVersion.Compiler.Set.iter (fun c ->
+ OpamCompiler.Set.iter (fun c ->
let comp = OpamFile.Comp.read (OpamPath.compiler t.root c) in
let preinstalled = if OpamFile.Comp.preinstalled comp then "~" else " " in
- OpamGlobals.msg " %s %s\n" preinstalled (OpamVersion.Compiler.to_string c)
+ let v = OpamFile.Comp.version comp in
+ OpamGlobals.msg " %s %s %s\n"
+ preinstalled
+ (OpamCompiler.to_string c)
+ (OpamCompiler.Version.to_string v)
) descrs
-let compiler_install quiet alias ocaml_version =
+let compiler_install quiet alias compiler =
log "compiler_install %b %s %s" quiet
(OpamAlias.to_string alias)
- (OpamVersion.Compiler.to_string ocaml_version);
+ (OpamCompiler.to_string compiler);
(* install the new OCaml version *)
- init_ocaml (load_state ()) quiet alias ocaml_version;
+ init_ocaml (load_state ()) quiet alias compiler;
(* install the compiler packages *)
let t = load_state () in
@@ -2660,7 +2665,7 @@ let compiler_install quiet alias ocaml_version =
OpamPackage.Name.Map.of_list
(List.rev_map
(function (name, _), _ as nv -> OpamPackage.Name.of_string name, nv)
- (Heuristic.get_comp_packages t ocaml_version Heuristic.v_eq)) in
+ (Heuristic.get_comp_packages t compiler Heuristic.v_eq)) in
let is_ok =
OpamPackage.Name.Map.for_all (fun n c ->
@@ -2685,14 +2690,14 @@ let compiler_switch quiet alias =
log "compiler_switch alias=%s" (OpamAlias.to_string alias);
let t = load_state () in
let comp_dir = OpamPath.Alias.root t.root alias in
- let ocaml_version = OpamVersion.Compiler.of_string (OpamAlias.to_string alias) in
- let comp_f = OpamPath.compiler t.root ocaml_version in
+ let compiler = OpamCompiler.of_string (OpamAlias.to_string alias) in
+ let comp_f = OpamPath.compiler t.root compiler in
if not (OpamFilename.exists_dir comp_dir) && not (OpamFilename.exists comp_f) then (
OpamGlobals.error "The compiler's description for %s does not exist.\n" (OpamAlias.to_string alias);
OpamGlobals.exit 1;
);
if not (OpamFilename.exists_dir comp_dir) then
- compiler_install quiet alias ocaml_version
+ compiler_install quiet alias compiler
else
let config = OpamFile.Config.with_alias t.config alias in
OpamFile.Config.write (OpamPath.config t.root) config;
View
4 src/opamClient.mli
@@ -23,7 +23,7 @@ open OpamTypes
- [oversion] is the version of the compiler. [None] means we
are using the system-wide installed compiler.
- [cores] is the number of cores *)
-val init : repository -> compiler_version option -> int -> unit
+val init : repository -> compiler option -> int -> unit
(** Display all available packages that matches any of the regexps. *)
val list : print_short:bool -> installed_only:bool -> ?name_only:bool -> ?case_sensitive:bool
@@ -64,7 +64,7 @@ val remove : OpamPackage.Name.Set.t -> unit
val remote : remote -> unit
(** Install the given compiler. Take the global file lock. *)
-val compiler_install: bool -> alias -> compiler_version -> unit
+val compiler_install: bool -> alias -> compiler -> unit
(** Import the packages from a file. Take the global file lock. *)
val compiler_import: filename -> unit
View
62 src/opamCompiler.ml
@@ -0,0 +1,62 @@
+(***********************************************************************)
+(* *)
+(* Copyright 2012 OCamlPro *)
+(* Copyright 2012 INRIA *)
+(* *)
+(* All rights reserved. This file is distributed under the terms of *)
+(* the GNU Public License version 3.0. *)
+(* *)
+(* OPAM is distributed in the hope that it will be useful, *)
+(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
+(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
+(* GNU General Public License for more details. *)
+(* *)
+(***********************************************************************)
+
+open OpamMisc.OP
+
+type relop = [`Eq|`Geq|`Gt|`Leq|`Lt]
+
+module Version = struct
+
+ include OpamMisc.Base
+
+ type constr = (relop * t) OpamFormula.formula
+
+ let current () =
+ match OpamSystem.ocaml_version () with
+ | None -> None
+ | Some o -> Some (of_string o)
+
+ let compare v1 r v2 =
+ let v1 = to_string v1 in
+ let v2 = to_string v2 in
+ match r with
+ | `Eq -> Debian.Version.equal v1 v2
+ | `Geq -> Debian.Version.compare v1 v2 >= 0
+ | `Gt -> Debian.Version.compare v1 v2 > 0
+ | `Leq -> Debian.Version.compare v1 v2 <= 0
+ | `Lt -> Debian.Version.compare v1 v2 < 0
+
+ let default = of_string OpamGlobals.default_alias
+
+end
+
+include OpamMisc.Base
+
+let list t =
+ if OpamFilename.exists_dir t then (
+ let files = OpamFilename.list_files t in
+ let files = List.filter (fun f -> OpamFilename.check_suffix f ".comp") files in
+ let l =
+ List.map
+ (OpamFilename.chop_extension
+ |> OpamFilename.basename
+ |> OpamFilename.Base.to_string
+ |> of_string)
+ files in
+ Set.of_list l
+ ) else
+ Set.empty
+
+let default = of_string OpamGlobals.default_alias
View
48 src/opamCompiler.mli
@@ -0,0 +1,48 @@
+(***********************************************************************)
+(* *)
+(* Copyright 2012 OCamlPro *)
+(* Copyright 2012 INRIA *)
+(* *)
+(* All rights reserved. This file is distributed under the terms of *)
+(* the GNU Public License version 3.0. *)
+(* *)
+(* OPAM is distributed in the hope that it will be useful, *)
+(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
+(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
+(* GNU General Public License for more details. *)
+(* *)
+(***********************************************************************)
+
+(** Compiler and OPAM versions *)
+
+(** Binary relations *)
+type relop = [`Eq|`Geq|`Gt|`Leq|`Lt]
+
+(** OCaml compiler versions *)
+module Version: sig
+
+ include OpamMisc.ABSTRACT
+
+ (** Compiler constraint *)
+ type constr = (relop * t) OpamFormula.formula
+
+ (** Return the version of the compiler currently installed *)
+ val current: unit -> t option
+
+ (** Compare OCaml versions *)
+ val compare: t -> relop -> t -> bool
+
+ (** Default compiler version *)
+ val default: t
+
+end
+
+(** Compiler names *)
+include OpamMisc.ABSTRACT
+
+(** List the compiler available in a directory *)
+val list: OpamFilename.Dir.t -> Set.t
+
+(** Default compiler *)
+val default: t
+
View
57 src/opamFile.ml
@@ -368,7 +368,7 @@ module Aliases = struct
let internal = "aliases"
- type t = (alias * compiler_version) list
+ type t = (alias * compiler) list
let empty = []
@@ -376,7 +376,7 @@ module Aliases = struct
let l =
List.map
(fun (alias,oversion) -> [OpamAlias.to_string alias;
- OpamVersion.Compiler.to_string oversion])
+ OpamCompiler.to_string oversion])
t in
Lines.to_string filename l
@@ -385,7 +385,7 @@ module Aliases = struct
List.fold_left (fun accu -> function
| [] -> accu
| [alias; oversion] -> (OpamAlias.of_string alias,
- OpamVersion.Compiler.of_string oversion) :: accu
+ OpamCompiler.of_string oversion) :: accu
| _ -> failwith "switches"
) [] l
@@ -432,7 +432,7 @@ module Config = struct
{ opam_version ; repositories ; alias = None ; system_version = None ; cores }
let empty = {
- opam_version = OpamVersion.OPAM.of_string OpamGlobals.opam_version;
+ opam_version = OpamVersion.of_string OpamGlobals.opam_version;
repositories = [];
alias = None;
system_version = None;
@@ -460,7 +460,7 @@ module Config = struct
let s = Syntax.of_string filename f in
Syntax.check s valid_fields;
let opam_version =
- OpamFormat.assoc s.file_contents s_opam_version (OpamFormat.parse_string |> OpamVersion.OPAM.of_string) in
+ OpamFormat.assoc s.file_contents s_opam_version (OpamFormat.parse_string |> OpamVersion.of_string) in
let repositories =
OpamFormat.assoc_list s.file_contents s_repositories
(OpamFormat.parse_list
@@ -470,9 +470,9 @@ module Config = struct
let alias2 =
OpamFormat.assoc_option s.file_contents s_alias (OpamFormat.parse_string |> OpamAlias.of_string) in
let system_version =
- OpamFormat.assoc_option s.file_contents s_system_version (OpamFormat.parse_string |> OpamVersion.Compiler.of_string) in
+ OpamFormat.assoc_option s.file_contents s_system_version (OpamFormat.parse_string |> OpamCompiler.Version.of_string) in
let system_version2 =
- OpamFormat.assoc_option s.file_contents s_system_version2 (OpamFormat.parse_string |> OpamVersion.Compiler.of_string) in
+ OpamFormat.assoc_option s.file_contents s_system_version2 (OpamFormat.parse_string |> OpamCompiler.Version.of_string) in
let system_version =
match system_version, system_version2 with
| Some v, _
@@ -490,7 +490,7 @@ module Config = struct
let s = {
file_name = OpamFilename.to_string filename;
file_contents = [
- Variable (s_opam_version , OpamFormat.make_string (OpamVersion.OPAM.to_string t.opam_version));
+ Variable (s_opam_version , OpamFormat.make_string (OpamVersion.to_string t.opam_version));
Variable (s_repositories , OpamFormat.make_list of_repo t.repositories);
Variable (s_cores , OpamFormat.make_int t.cores);
]
@@ -502,7 +502,7 @@ module Config = struct
@ (
match t.system_version with
| None -> []
- | Some v -> [ Variable (s_system_version, OpamFormat.make_string (OpamVersion.Compiler.to_string v)) ]
+ | Some v -> [ Variable (s_system_version, OpamFormat.make_string (OpamCompiler.Version.to_string v)) ]
)
} in
Syntax.to_string filename s
@@ -1066,7 +1066,8 @@ module Comp = struct
type t = {
opam_version : opam_version ;
- name : compiler_version ;
+ name : compiler ;
+ version : compiler_version ;
preinstalled : bool;
src : filename option ;
patches : filename list ;
@@ -1084,8 +1085,9 @@ module Comp = struct
}
let empty = {
- opam_version = OpamVersion.OPAM.of_string OpamGlobals.opam_version;
- name = OpamVersion.Compiler.of_string "<none>";
+ opam_version = OpamVersion.of_string OpamGlobals.opam_version;
+ name = OpamCompiler.of_string "<none>";
+ version = OpamCompiler.Version.of_string "<none>";
src = None;
preinstalled = false;
patches = [];
@@ -1102,15 +1104,16 @@ module Comp = struct
env = [];
}
- let create_preinstalled name packages env =
+ let create_preinstalled name version packages env =
let mk n = Atom (n, Empty) in
let rec aux accu t = match accu, t with
| Empty, x -> mk x
| _ , x -> And(accu, mk x) in
let packages = List.fold_left aux OpamFormula.Empty packages in
- { empty with name; preinstalled = true; packages; env }
+ { empty with name; version; preinstalled = true; packages; env }
let s_name = "name"
+ let s_version = "version"
let s_src = "src"
let s_patches = "patches"
let s_configure = "configure"
@@ -1129,6 +1132,7 @@ module Comp = struct
let valid_fields = [
s_opam_version;
s_name;
+ s_version;
s_src;
s_patches;
s_configure;
@@ -1146,6 +1150,7 @@ module Comp = struct
]
let name t = t.name
+ let version t = t.version
let patches t = t.patches
let configure t = t.configure
let make t = t.make
@@ -1174,8 +1179,21 @@ module Comp = struct
("string-list", OpamFormat.parse_string_list |> fun x -> Some (Cmd x));
] in
let opam_version =
- OpamFormat.assoc s s_opam_version (OpamFormat.parse_string |> OpamVersion.OPAM.of_string) in
- let name = OpamFormat.assoc s s_name (OpamFormat.parse_string |> OpamVersion.Compiler.of_string) in
+ OpamFormat.assoc s s_opam_version (OpamFormat.parse_string |> OpamVersion.of_string) in
+ let name_d, version_d =
+ let base = (
+ OpamFilename.chop_extension
+ |> OpamFilename.basename
+ |> OpamFilename.Base.to_string
+ ) filename in
+ match OpamMisc.cut_at base '+' with
+ | None -> OpamCompiler.of_string base, OpamCompiler.Version.of_string base
+ | Some (n,_) -> OpamCompiler.of_string base, OpamCompiler.Version.of_string n in
+ let name =
+ OpamFormat.assoc_default name_d s s_name (OpamFormat.parse_string |> OpamCompiler.of_string) in
+ let version =
+ OpamFormat.assoc_default version_d s s_version
+ (OpamFormat.parse_string |> OpamCompiler.Version.of_string) in
let src = OpamFormat.assoc_option s s_src (OpamFormat.parse_string |> OpamFilename.raw_file) in
let patches =
OpamFormat.assoc_list s s_patches
@@ -1202,7 +1220,7 @@ module Comp = struct
OpamGlobals.error_and_exit "You should either specify an url (with 'sources') \
or use 'preinstalled: true' to pick the already installed \
compiler version.";
- { opam_version; name; src;
+ { opam_version; name; version; src;
patches; configure; make; build;
bytecomp; asmcomp; bytelink; asmlink; packages;
requires; pp;
@@ -1216,8 +1234,9 @@ module Comp = struct
Syntax.to_string filename {
file_name = OpamFilename.to_string filename;
file_contents = [
- Variable (s_opam_version, OpamFormat.make_string (OpamVersion.OPAM.to_string s.opam_version));
- Variable (s_name, OpamFormat.make_string (OpamVersion.Compiler.to_string s.name));
+ Variable (s_opam_version, OpamFormat.make_string (OpamVersion.to_string s.opam_version));
+ Variable (s_name, OpamFormat.make_string (OpamCompiler.to_string s.name));
+ Variable (s_version, OpamFormat.make_string (OpamCompiler.Version.to_string s.version));
] @ (match s.src with
| None -> []
| Some s -> [Variable (s_src, OpamFormat.make_string (OpamFilename.to_string s))]
View
9 src/opamFile.mli
@@ -176,7 +176,7 @@ module Descr: sig
end
(** Compiler aliases: [$opam/aliases] *)
-module Aliases: IO_FILE with type t = (alias * compiler_version) list
+module Aliases: IO_FILE with type t = (alias * compiler) list
(** List of installed packages: [$opam/$oversion/installed] *)
module Installed: IO_FILE with type t = package_set
@@ -197,13 +197,16 @@ module Comp: sig
(** Create a pre-installed compiler description file *)
val create_preinstalled:
- compiler_version -> name list -> (string * string * string) list -> t
+ compiler -> compiler_version -> name list -> (string * string * string) list -> t
(** Is it a pre-installed compiler description file *)
val preinstalled: t -> bool
(** Return the compiler name *)
- val name: t -> compiler_version
+ val name: t -> compiler
+
+ (** Return the compiler version *)
+ val version: t -> compiler_version
(** Return the url of the compiler *)
val src: t -> filename option
View
4 src/opamFormat.ml
@@ -362,7 +362,7 @@ let rec parse_compiler_constraint t =
match t with
| [] -> F.Empty
| [Symbol r; String v ] ->
- (try F.Atom (parse_relop r, OpamVersion.Compiler.of_string v)
+ (try F.Atom (parse_relop r, OpamCompiler.Version.of_string v)
with _ -> bad_format "Expecting a relop, got %s" r)
| [Group g] -> parse_compiler_constraint g
| e1::e2 :: Symbol "|" :: e3 -> F.Or (parse_compiler_constraint [e1;e2], parse_compiler_constraint e3)
@@ -377,7 +377,7 @@ let rec make_compiler_constraint t =
let module F = OpamFormula in
match t with
| F.Empty -> []
- | F.Atom (r, v) -> [Symbol (string_of_relop r); String (OpamVersion.Compiler.to_string v)]
+ | F.Atom (r, v) -> [Symbol (string_of_relop r); String (OpamCompiler.Version.to_string v)]
| F.Block f -> [Group (make_compiler_constraint f)]
| F.And(e,f) -> make_compiler_constraint e @ [Symbol "|"] @ make_compiler_constraint f
| F.Or(e,f) -> make_compiler_constraint e @ [Symbol "|"] @ make_compiler_constraint f
View
13 src/opamGlobals.ml.in → src/opamGlobals.ml
@@ -27,8 +27,6 @@ let base_packages = ref true
let verify_checksums = ref true
let yes = ref false
-let version = "@PACKAGE_VERSION@"
-
let default_repository_name = "default"
let default_repository_address = "http://opam.ocamlpro.com"
let default_repository_kind = "curl"
@@ -123,16 +121,5 @@ let makecmd = ref (match os with FreeBSD | OpenBSD -> "gmake" | _ -> "make") (*
let default_cores = 1
-let version_msg () =
- Printf.printf "\
-%s version %s
-
-Copyright (C) 2012 OCamlPro - INRIA
-
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
- Sys.argv.(0) version;
- exit 0
-
let exit i =
raise (Exit i)
View
8 src/opamMain.ml
@@ -40,7 +40,7 @@ let global_args = [
"--debug" , Arg.Set OpamGlobals.debug , " Print internal debug messages (very verbose)";
"--verbose" , Arg.Set OpamGlobals.verbose , " Display the output of subprocesses";
"--quiet" , Arg.Clear quiet , " Do not display the output of subprocesses";
- "--version" , Arg.Unit OpamGlobals.version_msg, " Display version information";
+ "--version" , Arg.Unit OpamVersion.message, " Display version information";
"--yes" , Arg.Set OpamGlobals.yes , " Answer yes to all questions";
"--makecmd" , Arg.Set_string OpamGlobals.makecmd,
Printf.sprintf " Set the 'make' program used when compiling packages (default is %s)" !OpamGlobals.makecmd;
@@ -75,7 +75,7 @@ let init =
synopsis = "Initial setup";
help = "Create the initial config files";
specs = [
- ("-comp" , Arg.String (fun s -> comp := Some (OpamVersion.Compiler.of_string s)), " Which compiler version to use");
+ ("-comp" , Arg.String (fun s -> comp := Some (OpamCompiler.of_string s)), " Which compiler version to use");
("-cores", Arg.Set_int cores , " Set the number of cores");
("-kind" , Arg.String (fun s -> kind := Some s) , " Set the repository kind");
("-no-base-packages", Arg.Clear OpamGlobals.base_packages, " Do not install the base packages");
@@ -362,8 +362,8 @@ let switch =
if !alias_of <> "" then
bad_argument "switch" "invalid -alias-of option" in
let mk_comp alias = match !alias_of with
- | "" -> OpamVersion.Compiler.of_string alias
- | comp -> OpamVersion.Compiler.of_string comp in
+ | "" -> OpamCompiler.of_string alias
+ | comp -> OpamCompiler.of_string comp in
{
name = "switch";
usage = "[compiler-name]";
View
4 src/opamPath.ml
@@ -36,7 +36,7 @@ let opam t nv = opam_dir t // (OpamPackage.to_string nv ^ ".opam")
let compilers_dir t = t / "compilers"
-let compiler t ov = compilers_dir t // (OpamVersion.Compiler.to_string ov ^ ".comp")
+let compiler t ov = compilers_dir t // (OpamCompiler.to_string ov ^ ".comp")
let descr_dir t = t / "descr"
@@ -130,7 +130,7 @@ module Repository = struct
let compilers_dir t = t / "compilers"
- let compiler t ov = compilers_dir t // (OpamVersion.Compiler.to_string ov ^ ".comp")
+ let compiler t ov = compilers_dir t // (OpamCompiler.to_string ov ^ ".comp")
let url t nv = package t nv // "url"
View
4 src/opamPath.mli
@@ -38,7 +38,7 @@ val aliases: t -> filename
val opam: t -> package -> filename
(** Compiler files: {i $opam/compilers/$OVERSION.comp} *)
-val compiler: t -> compiler_version -> filename
+val compiler: t -> compiler -> filename
(** Compiler files: {i $opam/compilers/} *)
val compilers_dir: t -> dirname
@@ -200,7 +200,7 @@ module Repository: sig
val upload_dir: r -> dirname
(** Compiler files: {i $opam/repo/$repo/compilers/$OVERSION.comp} *)
- val compiler: r -> compiler_version -> filename
+ val compiler: r -> compiler -> filename
(** Compiler files: {i $opam/repo/$repo/compilers/} *)
val compilers_dir: r -> dirname
View
11 src/opamRepository.ml
@@ -302,15 +302,14 @@ let check_version repo =
(OpamPath.Repository.version |>
OpamFilename.read |>
OpamMisc.strip |>
- OpamPackage.Version.of_string
+ OpamVersion.of_string
) repo
with e ->
- OpamPackage.Version.of_string "0.7.5" in
- let current_version = OpamPackage.Version.of_string OpamGlobals.version in
- if OpamPackage.Version.compare repo_version current_version >= 0 then
+ OpamVersion.of_string "0.7.5" in
+ if OpamVersion.compare repo_version OpamVersion.current >= 0 then
OpamGlobals.error_and_exit
"\nThe current version of OPAM cannot read the repository. \
- You should upgrade to at least the version %s.\n" (OpamPackage.Version.to_string repo_version)
+ You should upgrade to at least the version %s.\n" (OpamVersion.to_string repo_version)
let update r =
log "update %s" (to_string r);
@@ -381,7 +380,7 @@ let archives r =
OpamFilename.Set.empty
let compilers r =
- OpamVersion.Compiler.list (OpamPath.Repository.compilers_dir r)
+ OpamCompiler.list (OpamPath.Repository.compilers_dir r)
let files r nv =
let l =
View
2 src/opamRepository.mli
@@ -103,7 +103,7 @@ val make_archive: ?gener_digest:bool -> ?local_path:dirname -> package -> unit
val packages: OpamPath.Repository.r -> package_set
(** Get the list of compilers *)
-val compilers: OpamPath.Repository.r -> compiler_version_set
+val compilers: OpamPath.Repository.r -> compiler_set
(** Get the available versions for a given compiler *)
val versions: OpamPath.Repository.r -> name -> version_set
View
10 src/opamTypes.ml
@@ -85,11 +85,13 @@ type file_attribute = OpamFilename.Attribute.t
type file_attribute_set = OpamFilename.Attribute.Set.t
-type compiler_version = OpamVersion.Compiler.t
+type compiler = OpamCompiler.t
-type compiler_version_set = OpamVersion.Compiler.Set.t
+type compiler_set = OpamCompiler.Set.t
-type opam_version = OpamVersion.OPAM.t
+type compiler_version = OpamCompiler.Version.t
+
+type opam_version = OpamVersion.t
type 'a generic_formula = 'a OpamFormula.formula =
| Empty
@@ -102,7 +104,7 @@ type formula = OpamFormula.t
type conjunction = OpamFormula.conjunction
-type compiler_constraint = OpamVersion.Compiler.constr
+type compiler_constraint = OpamCompiler.Version.constr
type ppflag =
| Camlp4 of string list
View
17 src/opamTypes.mli
@@ -69,19 +69,22 @@ type version = OpamPackage.Version.t
(** Set of package versions *)
type version_set = OpamPackage.Version.Set.t
-(** {2 Versions} *)
+(** {2 Compilers} *)
-(** Compiler versions *)
-type compiler_version = OpamVersion.Compiler.t
+(** Compiler names *)
+type compiler = OpamCompiler.t
+
+(** Set of compiler names *)
+type compiler_set = OpamCompiler.Set.t
-(** Set of compiler versions *)
-type compiler_version_set = OpamVersion.Compiler.Set.t
+(** Compiler versions *)
+type compiler_version = OpamCompiler.Version.t
(** OPAM versions *)
-type opam_version = OpamVersion.OPAM.t
+type opam_version = OpamVersion.t
(** Compiler constraints *)
-type compiler_constraint = OpamVersion.Compiler.constr
+type compiler_constraint = OpamCompiler.Version.constr
(** {2 Variables} *)
View
70 src/opamVersion.ml
@@ -13,46 +13,36 @@
(* *)
(***********************************************************************)
-open OpamMisc.OP
-
-type relop = [`Eq|`Geq|`Gt|`Leq|`Lt]
-
-module Compiler = struct
-
- include OpamMisc.Base
-
- type constr = (relop * t) OpamFormula.formula
-
- let current () =
- match OpamSystem.ocaml_version () with
- | None -> None
- | Some o -> Some (of_string o)
-
- let compare v1 r v2 =
- let v1 = to_string v1 in
- let v2 = to_string v2 in
- match r with
- | `Eq -> Debian.Version.equal v1 v2
- | `Geq -> Debian.Version.compare v1 v2 >= 0
- | `Gt -> Debian.Version.compare v1 v2 > 0
- | `Leq -> Debian.Version.compare v1 v2 <= 0
- | `Lt -> Debian.Version.compare v1 v2 < 0
-
- let list t =
- if OpamFilename.exists_dir t then (
- let files = OpamFilename.list_files t in
- let files = List.filter (fun f -> OpamFilename.check_suffix f ".comp") files in
- let l =
- List.map
- (OpamFilename.chop_extension
- |> OpamFilename.basename
- |> OpamFilename.Base.to_string
- |> of_string)
- files in
- Set.of_list l
- ) else
- Set.empty
+type t = string
+let to_string x = x
+
+let of_string x = x
+
+let compare = Debian.Version.compare
+
+module O = struct
+ type t = string
+ let to_string = to_string
+ let compare = compare
end
-module OPAM = OpamMisc.Base
+module Set = OpamMisc.Set.Make(O)
+
+module Map = OpamMisc.Map.Make(O)
+
+let current_raw = "0.7.7"
+
+let current = of_string current_raw
+
+let message () =
+ Printf.printf "\
+%s version %s
+
+Copyright (C) 2012 OCamlPro - INRIA
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+ Sys.argv.(0) current_raw;
+ exit 0
+
View
48 src/opamVersion.ml.in
@@ -0,0 +1,48 @@
+(***********************************************************************)
+(* *)
+(* Copyright 2012 OCamlPro *)
+(* Copyright 2012 INRIA *)
+(* *)
+(* All rights reserved. This file is distributed under the terms of *)
+(* the GNU Public License version 3.0. *)
+(* *)
+(* OPAM is distributed in the hope that it will be useful, *)
+(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
+(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
+(* GNU General Public License for more details. *)
+(* *)
+(***********************************************************************)
+
+type t = string
+
+let to_string x = x
+
+let of_string x = x
+
+let compare = Debian.Version.compare
+
+module O = struct
+ type t = string
+ let to_string = to_string
+ let compare = compare
+end
+
+module Set = OpamMisc.Set.Make(O)
+
+module Map = OpamMisc.Map.Make(O)
+
+let current_raw = "@PACKAGE_VERSION@"
+
+let current = of_string current_raw
+
+let message () =
+ Printf.printf "\
+%s version %s
+
+Copyright (C) 2012 OCamlPro - INRIA
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+ Sys.argv.(0) current_raw;
+ exit 0
+
View
31 src/opamVersion.mli
@@ -13,30 +13,15 @@
(* *)
(***********************************************************************)
-(** Compiler and OPAM versions *)
-
-(** Binary relations *)
-type relop = [`Eq|`Geq|`Gt|`Leq|`Lt]
-
-(** OCaml compiler versions *)
-module Compiler: sig
-
- include OpamMisc.ABSTRACT
-
- (** Compiler constraint *)
- type constr = (relop * t) OpamFormula.formula
-
- (** Return the version of the compiler currently installed *)
- val current: unit -> t option
-
- (** Compare OCaml versions *)
- val compare: t -> relop -> t -> bool
+(** OPAM versions *)
- (** List the compiler available in a directory *)
- val list: OpamFilename.Dir.t -> Set.t
+include OpamMisc.ABSTRACT
-end
+(** The current OPAM version *)
+val current: t
-(** OPAM versions *)
-module OPAM: OpamMisc.ABSTRACT
+(** Display the version message *)
+val message: unit -> unit
+(** Version comparison *)
+val compare: t -> t -> int
View
2 src/scripts/opam_check.ml
@@ -23,7 +23,7 @@ let label = ref ""
let spec = Arg.align [
("--root", Arg.Set_string OpamGlobals.root_dir, " Set opam path");
("-l" , Arg.Set_string label , " Set a test label");
- ("--version", Arg.Unit OpamGlobals.version_msg , " Display version information");
+ ("--version", Arg.Unit OpamVersion.message , " Display version information");
]
let packages = ref []
View
4 src/scripts/opam_mk_repo.ml
@@ -32,8 +32,8 @@ let all, index, packages, gener_digest, dryrun, recurse =
let dryrun = ref false in
let recurse = ref false in
let specs = Arg.align [
- ("-v" , Arg.Unit OpamGlobals.version_msg, " Display version information");
- ("--version", Arg.Unit OpamGlobals.version_msg, " Display version information");
+ ("-v" , Arg.Unit OpamVersion.message, " Display version information");
+ ("--version", Arg.Unit OpamVersion.message, " Display version information");
("-a" , Arg.Set all, "");
("--all", Arg.Set all , Printf.sprintf " Build all package archives (default is %b)" !all);
View
4 src/scripts/opam_repo_check.ml
@@ -20,7 +20,7 @@ open OpamFilename.OP
let () =
let usage = Printf.sprintf "Usage: %s" Sys.argv.(0) in
let specs = [
- ("--version", Arg.Unit OpamGlobals.version_msg, " Display version information")
+ ("--version", Arg.Unit OpamVersion.message, " Display version information")
] in
let ano x =
Printf.eprintf "%s: invalid argument" x in
@@ -56,6 +56,6 @@ let () =
let comps = OpamFilename.list_files (OpamPath.Repository.compilers_dir t) in
List.iter (fun comp ->
let comp_ = OpamFile.Comp.read comp in
- OpamGlobals.msg "Processing (compiler) %s\n" (OpamVersion.Compiler.to_string (OpamFile.Comp.name comp_));
+ OpamGlobals.msg "Processing (compiler) %s\n" (OpamCompiler.to_string (OpamFile.Comp.name comp_));
OpamFile.Comp.write comp comp_;
) comps

0 comments on commit 188231a

Please sign in to comment.
Something went wrong with that request. Please try again.