From 73c0169ce2a8f0c2f0a738641429b47baaa9bc67 Mon Sep 17 00:00:00 2001 From: Spiros Eliopoulos Date: Tue, 17 Jun 2014 10:33:26 -0400 Subject: [PATCH] v0.3.0 --- Makefile | 5 +- _oasis | 2 +- _tags | 28 +-- lib/META | 6 +- myocamlbuild.ml | 146 +++++++++----- setup.ml | 499 +++++++++++++++++++++++++++++------------------- 6 files changed, 413 insertions(+), 273 deletions(-) diff --git a/Makefile b/Makefile index 1e26683..3639f14 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 7b2408909643717852b95f994b273fee) +# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954) SETUP = ocaml setup.ml @@ -33,6 +33,9 @@ distclean: setup.data: $(SETUP) -configure $(CONFIGUREFLAGS) +configure: + $(SETUP) -configure $(CONFIGUREFLAGS) + .PHONY: build doc test all install uninstall reinstall clean distclean configure # OASIS_STOP diff --git a/_oasis b/_oasis index 2b92d33..8adac36 100644 --- a/_oasis +++ b/_oasis @@ -1,6 +1,6 @@ OASISFormat: 0.3 Name: packet -Version: 0.2.1 +Version: 0.3.0 Synopsis: Serialization for some common network packets, including ethernet frames, IP, TCP, and ARP. Authors: https://github.com/frenetic-lang/ocaml-packet/contributors diff --git a/_tags b/_tags index 30f725a..7b734db 100644 --- a/_tags +++ b/_tags @@ -1,5 +1,5 @@ # OASIS_START -# DO NOT EDIT (digest: 3c7e732d4e333ae1acfd5e06c0b2d31a) +# DO NOT EDIT (digest: c53dcb3b24d3ca38ca313d3ea6cbeb08) # Ignore VCS directories, you can use the same kind of rule outside # OASIS_START/STOP if you want to exclude directories that contains # useless stuff for the build process @@ -21,38 +21,38 @@ : oasis_library_packet_byte "lib/checksum_stubs.c": oasis_library_packet_byte : use_libpacket_stubs -: pkg_str : pkg_cstruct : pkg_cstruct.syntax -"lib/checksum_stubs.c": pkg_str +: pkg_str "lib/checksum_stubs.c": pkg_cstruct "lib/checksum_stubs.c": pkg_cstruct.syntax +"lib/checksum_stubs.c": pkg_str # Library quickcheck "quickcheck/quickcheck.cmxs": use_quickcheck -: use_packet -: pkg_quickcheck -: pkg_str : pkg_cstruct : pkg_cstruct.syntax +: pkg_quickcheck +: pkg_str +: use_packet # Executable testtool -"test/Test.byte": use_quickcheck -"test/Test.byte": use_packet +"test/Test.byte": pkg_cstruct +"test/Test.byte": pkg_cstruct.syntax "test/Test.byte": pkg_oUnit "test/Test.byte": pkg_pa_ounit "test/Test.byte": pkg_pa_ounit.syntax "test/Test.byte": pkg_quickcheck "test/Test.byte": pkg_str -"test/Test.byte": pkg_cstruct -"test/Test.byte": pkg_cstruct.syntax -: use_quickcheck -: use_packet +"test/Test.byte": use_packet +"test/Test.byte": use_quickcheck +: pkg_cstruct +: pkg_cstruct.syntax : pkg_oUnit : pkg_pa_ounit : pkg_pa_ounit.syntax : pkg_quickcheck : pkg_str -: pkg_cstruct -: pkg_cstruct.syntax +: use_packet +: use_quickcheck # OASIS_STOP : syntax_camlp4o : syntax_camlp4o diff --git a/lib/META b/lib/META index b248b13..984d5b3 100644 --- a/lib/META +++ b/lib/META @@ -1,6 +1,6 @@ # OASIS_START -# DO NOT EDIT (digest: e11d8d1a4f860583d2201977fec001a4) -version = "0.2.1" +# DO NOT EDIT (digest: c8676216e1e3826c9bcde71bc3aab806) +version = "0.3.0" description = "Serialization for some common network packets, including ethernet frames, IP, TCP, and ARP." requires = "str cstruct cstruct.syntax" @@ -10,7 +10,7 @@ archive(native) = "packet.cmxa" archive(native, plugin) = "packet.cmxs" exists_if = "packet.cma" package "quickcheck" ( - version = "0.2.1" + version = "0.3.0" description = "Serialization for some common network packets, including ethernet frames, IP, TCP, and ARP." requires = "packet quickcheck" diff --git a/myocamlbuild.ml b/myocamlbuild.ml index 35cf9f6..c5a388d 100644 --- a/myocamlbuild.ml +++ b/myocamlbuild.ml @@ -1,5 +1,5 @@ (* OASIS_START *) -(* DO NOT EDIT (digest: e270c2e88368dd27093c3e0e7085db75) *) +(* DO NOT EDIT (digest: 7e1f2e1d53bf2952193c34fd943d0c23) *) module OASISGettext = struct (* # 22 "src/oasis/OASISGettext.ml" *) @@ -39,10 +39,10 @@ module OASISExpr = struct open OASISGettext - type test = string + type test = string - type flag = string + type flag = string type t = @@ -52,10 +52,10 @@ module OASISExpr = struct | EOr of t * t | EFlag of flag | ETest of test * string - - type 'a choices = (t * 'a) list + + type 'a choices = (t * 'a) list let eval var_get t = @@ -204,26 +204,27 @@ module BaseEnvLight = struct end - let var_get name env = - let rec var_expand str = - let buff = - Buffer.create ((String.length str) * 2) - in - Buffer.add_substitute - buff - (fun var -> - try - var_expand (MapString.find var env) - with Not_found -> - failwith - (Printf.sprintf - "No variable %s defined when trying to expand %S." - var - str)) - str; - Buffer.contents buff + let rec var_expand str env = + let buff = + Buffer.create ((String.length str) * 2) in - var_expand (MapString.find name env) + Buffer.add_substitute + buff + (fun var -> + try + var_expand (MapString.find var env) env + with Not_found -> + failwith + (Printf.sprintf + "No variable %s defined when trying to expand %S." + var + str)) + str; + Buffer.contents buff + + + let var_get name env = + var_expand (MapString.find name env) env let var_choose lst env = @@ -233,7 +234,7 @@ module BaseEnvLight = struct end -# 236 "myocamlbuild.ml" +# 237 "myocamlbuild.ml" module MyOCamlbuildFindlib = struct (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *) @@ -258,6 +259,31 @@ module MyOCamlbuildFindlib = struct Ocamlbuild_pack.Lexers.blank_sep_strings + let exec_from_conf exec = + let exec = + let env_filename = Pathname.basename BaseEnvLight.default_filename in + let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in + try + BaseEnvLight.var_get exec env + with Not_found -> + Printf.eprintf "W: Cannot get variable %s\n" exec; + exec + in + let fix_win32 str = + if Sys.os_type = "Win32" then begin + let buff = Buffer.create (String.length str) in + (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'. + *) + String.iter + (fun c -> Buffer.add_char buff (if c = '\\' then '/' else c)) + str; + Buffer.contents buff + end else begin + str + end + in + fix_win32 exec + let split s ch = let buf = Buffer.create 13 in let x = ref [] in @@ -285,17 +311,7 @@ module MyOCamlbuildFindlib = struct with Not_found -> s (* ocamlfind command *) - let ocamlfind x = - let ocamlfind_prog = - let env_filename = Pathname.basename BaseEnvLight.default_filename in - let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in - try - BaseEnvLight.var_get "ocamlfind" env - with Not_found -> - Printf.eprintf "W: Cannot get variable ocamlfind"; - "ocamlfind" - in - S[Sh ocamlfind_prog; x] + let ocamlfind x = S[Sh (exec_from_conf "ocamlfind"); x] (* This lists all supported packages. *) let find_packages () = @@ -306,9 +322,25 @@ module MyOCamlbuildFindlib = struct let find_syntaxes () = ["camlp4o"; "camlp4r"] + let well_known_syntax = [ + "camlp4.quotations.o"; + "camlp4.quotations.r"; + "camlp4.exceptiontracer"; + "camlp4.extend"; + "camlp4.foldgenerator"; + "camlp4.listcomprehension"; + "camlp4.locationstripper"; + "camlp4.macro"; + "camlp4.mapgenerator"; + "camlp4.metagenerator"; + "camlp4.profiler"; + "camlp4.tracer" + ] + + let dispatch = function - | Before_options -> + | After_options -> (* By using Before_options one let command line options have an higher * priority on the contrary using After_options will guarantee to have * the higher priority override default commands by ocamlfind ones *) @@ -331,13 +363,17 @@ module MyOCamlbuildFindlib = struct List.iter begin fun pkg -> let base_args = [A"-package"; A pkg] in + (* TODO: consider how to really choose camlp4o or camlp4r. *) let syn_args = [A"-syntax"; A "camlp4o"] in let args = - (* Heuristic to identify syntax extensions: whether they end in - * ".syntax"; some might not *) - if Filename.check_suffix pkg "syntax" - then syn_args @ base_args - else base_args + (* Heuristic to identify syntax extensions: whether they end in + ".syntax"; some might not. + *) + if Filename.check_suffix pkg "syntax" || + List.mem pkg well_known_syntax then + syn_args @ base_args + else + base_args in flag ["ocaml"; "compile"; "pkg_"^pkg] & S args; flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args; @@ -394,10 +430,10 @@ module MyOCamlbuildBase = struct module OC = Ocamlbuild_pack.Ocaml_compiler - type dir = string - type file = string - type name = string - type tag = string + type dir = string + type file = string + type name = string + type tag = string (* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) @@ -412,7 +448,7 @@ module MyOCamlbuildBase = struct * directory. *) includes: (dir * dir list) list; - } + } let env_filename = @@ -455,7 +491,7 @@ module MyOCamlbuildBase = struct try opt := no_trailing_dot (BaseEnvLight.var_get var env) with Not_found -> - Printf.eprintf "W: Cannot get variable %s" var) + Printf.eprintf "W: Cannot get variable %s\n" var) [ Options.ext_obj, "ext_obj"; Options.ext_lib, "ext_lib"; @@ -531,10 +567,14 @@ module MyOCamlbuildBase = struct (* Add flags *) List.iter (fun (tags, cond_specs) -> - let spec = - BaseEnvLight.var_choose cond_specs env + let spec = BaseEnvLight.var_choose cond_specs env in + let rec eval_specs = + function + | S lst -> S (List.map eval_specs lst) + | A str -> A (BaseEnvLight.var_expand str env) + | spec -> spec in - flag tags & spec) + flag tags & (eval_specs spec)) t.flags | _ -> () @@ -551,7 +591,7 @@ module MyOCamlbuildBase = struct end -# 554 "myocamlbuild.ml" +# 594 "myocamlbuild.ml" open Ocamlbuild_plugin;; let package_default = { @@ -575,6 +615,6 @@ let package_default = let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; -# 579 "myocamlbuild.ml" +# 619 "myocamlbuild.ml" (* OASIS_STOP *) Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/setup.ml b/setup.ml index 8087891..5c464a9 100644 --- a/setup.ml +++ b/setup.ml @@ -1,9 +1,9 @@ (* setup.ml generated for the first time by OASIS v0.3.0 *) (* OASIS_START *) -(* DO NOT EDIT (digest: b16821acf833b7560ee1257ce9b521a0) *) +(* DO NOT EDIT (digest: 0417e985e2a2c5c99343ea52c127d006) *) (* - Regenerated by OASIS v0.4.1 + Regenerated by OASIS v0.4.4 Visit http://oasis.forge.ocamlcore.org for more information and documentation about functions used in this file. *) @@ -52,6 +52,7 @@ module OASISContext = struct type t = { + (* TODO: replace this by a proplist. *) quiet: bool; info: bool; debug: bool; @@ -88,19 +89,31 @@ module OASISContext = struct {!default with quiet = true} - let args () = + let fspecs () = + (* TODO: don't act on default. *) + let ignore_plugins = ref false in ["-quiet", Arg.Unit (fun () -> default := {!default with quiet = true}), - (s_ " Run quietly"); + s_ " Run quietly"; "-info", Arg.Unit (fun () -> default := {!default with info = true}), - (s_ " Display information message"); + s_ " Display information message"; "-debug", Arg.Unit (fun () -> default := {!default with debug = true}), - (s_ " Output debug message")] + s_ " Output debug message"; + + "-ignore-plugins", + Arg.Set ignore_plugins, + s_ " Ignore plugin's field."; + + "-C", + (* TODO: remove this chdir. *) + Arg.String (fun str -> Sys.chdir str), + s_ "dir Change directory before running."], + fun () -> {!default with ignore_plugins = !ignore_plugins} end module OASISString = struct @@ -245,29 +258,62 @@ module OASISUtils = struct open OASISGettext - module MapString = Map.Make(String) + module MapExt = + struct + module type S = + sig + include Map.S + val add_list: 'a t -> (key * 'a) list -> 'a t + val of_list: (key * 'a) list -> 'a t + val to_list: 'a t -> (key * 'a) list + end + + module Make (Ord: Map.OrderedType) = + struct + include Map.Make(Ord) + + let rec add_list t = + function + | (k, v) :: tl -> add_list (add k v t) tl + | [] -> t + let of_list lst = add_list empty lst - let map_string_of_assoc assoc = - List.fold_left - (fun acc (k, v) -> MapString.add k v acc) - MapString.empty - assoc + let to_list t = fold (fun k v acc -> (k, v) :: acc) t [] + end + end - module SetString = Set.Make(String) + module MapString = MapExt.Make(String) - let set_string_add_list st lst = - List.fold_left - (fun acc e -> SetString.add e acc) - st - lst + module SetExt = + struct + module type S = + sig + include Set.S + val add_list: t -> elt list -> t + val of_list: elt list -> t + val to_list: t -> elt list + end + + module Make (Ord: Set.OrderedType) = + struct + include Set.Make(Ord) + + let rec add_list t = + function + | e :: tl -> add_list (add e t) tl + | [] -> t + + let of_list lst = add_list empty lst + + let to_list = elements + end + end - let set_string_of_list = - set_string_add_list - SetString.empty + module SetString = SetExt.Make(String) let compare_csl s1 s2 = @@ -286,6 +332,13 @@ module OASISUtils = struct Hashtbl.hash (String.lowercase s) end) + module SetStringCsl = + SetExt.Make + (struct + type t = string + let compare = compare_csl + end) + let varname_of_string ?(hyphen='_') s = if String.length s = 0 then @@ -686,7 +739,7 @@ module OASISVersion = struct type s = string - type t = string + type t = string type comparator = @@ -697,7 +750,7 @@ module OASISVersion = struct | VLesserEqual of t | VOr of comparator * comparator | VAnd of comparator * comparator - + (* Range of allowed characters *) @@ -892,17 +945,17 @@ module OASISLicense = struct - type license = string + type license = string - type license_exception = string + type license_exception = string type license_version = | Version of OASISVersion.t | VersionOrLater of OASISVersion.t | NoVersion - + type license_dep_5_unit = @@ -911,20 +964,19 @@ module OASISLicense = struct excption: license_exception option; version: license_version; } - + type license_dep_5 = | DEP5Unit of license_dep_5_unit | DEP5Or of license_dep_5 list | DEP5And of license_dep_5 list - type t = | DEP5License of license_dep_5 | OtherLicense of string (* URL *) - + end @@ -939,10 +991,10 @@ module OASISExpr = struct open OASISGettext - type test = string + type test = string - type flag = string + type flag = string type t = @@ -952,10 +1004,10 @@ module OASISExpr = struct | EOr of t * t | EFlag of flag | ETest of test * string - - type 'a choices = (t * 'a) list + + type 'a choices = (t * 'a) list let eval var_get t = @@ -1028,6 +1080,21 @@ module OASISExpr = struct end +module OASISText = struct +(* # 22 "src/oasis/OASISText.ml" *) + + + + type elt = + | Para of string + | Verbatim of string + | BlankLine + + + type t = elt list + +end + module OASISTypes = struct (* # 22 "src/oasis/OASISTypes.ml" *) @@ -1035,40 +1102,40 @@ module OASISTypes = struct - type name = string - type package_name = string - type url = string - type unix_dirname = string - type unix_filename = string - type host_dirname = string - type host_filename = string - type prog = string - type arg = string - type args = string list - type command_line = (prog * arg list) + type name = string + type package_name = string + type url = string + type unix_dirname = string + type unix_filename = string + type host_dirname = string + type host_filename = string + type prog = string + type arg = string + type args = string list + type command_line = (prog * arg list) - type findlib_name = string - type findlib_full = string + type findlib_name = string + type findlib_full = string type compiled_object = | Byte | Native | Best - + type dependency = | FindlibPackage of findlib_full * OASISVersion.comparator option | InternalLibrary of name - + type tool = | ExternalTool of name | InternalExecutable of name - + type vcs = @@ -1081,7 +1148,7 @@ module OASISTypes = struct | Arch | Monotone | OtherVCS of url - + type plugin_kind = @@ -1109,7 +1176,7 @@ module OASISTypes = struct ] - type 'a plugin = 'a * name * OASISVersion.t option + type 'a plugin = 'a * name * OASISVersion.t option type all_plugin = plugin_kind plugin @@ -1121,7 +1188,7 @@ module OASISTypes = struct (* # 115 "src/oasis/OASISTypes.ml" *) - type 'a conditional = 'a OASISExpr.choices + type 'a conditional = 'a OASISExpr.choices type custom = @@ -1129,7 +1196,7 @@ module OASISTypes = struct pre_command: (command_line option) conditional; post_command: (command_line option) conditional; } - + type common_section = @@ -1138,7 +1205,7 @@ module OASISTypes = struct cs_data: PropList.Data.t; cs_plugin_data: plugin_data; } - + type build_section = @@ -1158,7 +1225,7 @@ module OASISTypes = struct bs_byteopt: args conditional; bs_nativeopt: args conditional; } - + type library = @@ -1169,28 +1236,28 @@ module OASISTypes = struct lib_findlib_parent: findlib_name option; lib_findlib_name: findlib_name option; lib_findlib_containers: findlib_name list; - } + } type object_ = { obj_modules: string list; obj_findlib_fullname: findlib_name list option; - } + } type executable = { exec_custom: bool; exec_main_is: unix_filename; - } + } type flag = { flag_description: string option; flag_default: bool conditional; - } + } type source_repository = @@ -1202,7 +1269,7 @@ module OASISTypes = struct src_repo_branch: string option; src_repo_tag: string option; src_repo_subdir: unix_filename option; - } + } type test = @@ -1213,7 +1280,7 @@ module OASISTypes = struct test_working_directory: unix_filename option; test_run: bool conditional; test_tools: tool list; - } + } type doc_format = @@ -1224,7 +1291,7 @@ module OASISTypes = struct | Info of unix_filename | DVI | OtherDoc - + type doc = @@ -1240,7 +1307,7 @@ module OASISTypes = struct doc_format: doc_format; doc_data_files: (unix_filename * unix_filename option) list; doc_build_tools: tool list; - } + } type section = @@ -1251,7 +1318,7 @@ module OASISTypes = struct | SrcRepo of common_section * source_repository | Test of common_section * test | Doc of common_section * doc - + type section_kind = @@ -1260,42 +1327,43 @@ module OASISTypes = struct type package = { - oasis_version: OASISVersion.t; - ocaml_version: OASISVersion.comparator option; - findlib_version: OASISVersion.comparator option; - alpha_features: string list; - beta_features: string list; - name: package_name; - version: OASISVersion.t; - license: OASISLicense.t; - license_file: unix_filename option; - copyrights: string list; - maintainers: string list; - authors: string list; - homepage: url option; - synopsis: string; - description: string option; - categories: url list; - - conf_type: [`Configure] plugin; - conf_custom: custom; - - build_type: [`Build] plugin; - build_custom: custom; - - install_type: [`Install] plugin; - install_custom: custom; - uninstall_custom: custom; - - clean_custom: custom; - distclean_custom: custom; - - files_ab: unix_filename list; - sections: section list; - plugins: [`Extra] plugin list; - schema_data: PropList.Data.t; - plugin_data: plugin_data; - } + oasis_version: OASISVersion.t; + ocaml_version: OASISVersion.comparator option; + findlib_version: OASISVersion.comparator option; + alpha_features: string list; + beta_features: string list; + name: package_name; + version: OASISVersion.t; + license: OASISLicense.t; + license_file: unix_filename option; + copyrights: string list; + maintainers: string list; + authors: string list; + homepage: url option; + synopsis: string; + description: OASISText.t option; + categories: url list; + + conf_type: [`Configure] plugin; + conf_custom: custom; + + build_type: [`Build] plugin; + build_custom: custom; + + install_type: [`Install] plugin; + install_custom: custom; + uninstall_custom: custom; + + clean_custom: custom; + distclean_custom: custom; + + files_ab: unix_filename list; + sections: section list; + plugins: [`Extra] plugin list; + disable_oasis_section: unix_filename list; + schema_data: PropList.Data.t; + plugin_data: plugin_data; + } end @@ -1348,6 +1416,24 @@ module OASISFeatures = struct let plugin_version plugin_kind plugin_name t = MapPlugin.find (plugin_kind, plugin_name) t.plugin_versions + + let to_string t = + Printf.sprintf + "oasis_version: %s; alpha_features: %s; beta_features: %s; \ + plugins_version: %s" + (OASISVersion.string_of_version t.oasis_version) + (String.concat ", " t.alpha_features) + (String.concat ", " t.beta_features) + (String.concat ", " + (MapPlugin.fold + (fun (_, plg) ver_opt acc -> + (plg^ + (match ver_opt with + | Some v -> + " "^(OASISVersion.string_of_version v) + | None -> "")) + :: acc) + t.plugin_versions [])) end type origin = @@ -1388,6 +1474,17 @@ module OASISFeatures = struct let beta = InDev Beta + let to_string t = + Printf.sprintf + "feature: %s; plugin: %s; publication: %s" + t.name + (match t.plugin with + | None -> "" + | Some (_, nm, _) -> nm) + (match t.publication with + | InDev stage -> string_of_stage stage + | SinceVersion ver -> ">= "^(OASISVersion.string_of_version ver)) + let data_check t data origin = let no_message = "no message" in @@ -1620,6 +1717,18 @@ module OASISFeatures = struct create "dynrun_for_release" alpha (fun () -> s_ "Make '-setup-update dynamic' suitable for releasing project.") + + + let compiled_setup_ml = + create "compiled_setup_ml" alpha + (fun () -> + s_ "It compiles the setup.ml and speed-up actions done with it.") + + let disable_oasis_section = + create "disable_oasis_section" alpha + (fun () -> + s_ "Allows the OASIS section comments and digest to be omitted in \ + generated files.") end module OASISUnixPath = struct @@ -2708,14 +2817,17 @@ module OASISFileUtil = struct let rmdir ~ctxt tgt = - if Sys.readdir tgt = [||] then - begin - match Sys.os_type with - | "Win32" -> - OASISExec.run ~ctxt "rd" [q tgt] - | _ -> - OASISExec.run ~ctxt "rm" ["-r"; q tgt] - end + if Sys.readdir tgt = [||] then begin + match Sys.os_type with + | "Win32" -> + OASISExec.run ~ctxt "rd" [q tgt] + | _ -> + OASISExec.run ~ctxt "rm" ["-r"; q tgt] + end else begin + OASISMessage.error ~ctxt + (f_ "Cannot remove directory '%s': not empty.") + tgt + end let glob ~ctxt fn = @@ -2763,7 +2875,7 @@ module OASISFileUtil = struct end -# 2766 "setup.ml" +# 2878 "setup.ml" module BaseEnvLight = struct (* # 22 "src/base/BaseEnvLight.ml" *) @@ -2838,26 +2950,27 @@ module BaseEnvLight = struct end - let var_get name env = - let rec var_expand str = - let buff = - Buffer.create ((String.length str) * 2) - in - Buffer.add_substitute - buff - (fun var -> - try - var_expand (MapString.find var env) - with Not_found -> - failwith - (Printf.sprintf - "No variable %s defined when trying to expand %S." - var - str)) - str; - Buffer.contents buff + let rec var_expand str env = + let buff = + Buffer.create ((String.length str) * 2) in - var_expand (MapString.find name env) + Buffer.add_substitute + buff + (fun var -> + try + var_expand (MapString.find var env) env + with Not_found -> + failwith + (Printf.sprintf + "No variable %s defined when trying to expand %S." + var + str)) + str; + Buffer.contents buff + + + let var_get name env = + var_expand (MapString.find name env) env let var_choose lst env = @@ -2867,15 +2980,15 @@ module BaseEnvLight = struct end -# 2870 "setup.ml" +# 2983 "setup.ml" module BaseContext = struct (* # 22 "src/base/BaseContext.ml" *) - + (* TODO: get rid of this module. *) open OASISContext - let args = args + let args () = fst (fspecs ()) let default = default @@ -5006,11 +5119,14 @@ module BaseSetup = struct s_ " Don't try to update setup.ml, even if _oasis has changed.") + let default_oasis_fn = "_oasis" + + let update_setup_ml t = let oasis_fn = match t.oasis_fn with | Some fn -> fn - | None -> "_oasis" + | None -> default_oasis_fn in let oasis_exec = match t.oasis_exec with @@ -5108,7 +5224,8 @@ module BaseSetup = struct try match t.oasis_digest with | Some dgst -> - if Sys.file_exists oasis_fn && dgst <> Digest.file "_oasis" then + if Sys.file_exists oasis_fn && + dgst <> Digest.file default_oasis_fn then begin do_update (); true @@ -5274,7 +5391,7 @@ module BaseSetup = struct end -# 5277 "setup.ml" +# 5394 "setup.ml" module InternalConfigurePlugin = struct (* # 22 "src/plugins/internal/InternalConfigurePlugin.ml" *) @@ -6123,7 +6240,7 @@ module InternalInstallPlugin = struct end -# 6126 "setup.ml" +# 6243 "setup.ml" module OCamlbuildCommon = struct (* # 22 "src/plugins/ocamlbuild/OCamlbuildCommon.ml" *) @@ -6135,10 +6252,15 @@ module OCamlbuildCommon = struct open OASISGettext open BaseEnv open BaseStandardVar + open OASISTypes - let ocamlbuild_clean_ev = - "ocamlbuild-clean" + + + type extra_args = string list + + + let ocamlbuild_clean_ev = "ocamlbuild-clean" let ocamlbuildflags = @@ -6261,27 +6383,7 @@ module OCamlbuildPlugin = struct ref (fun lst -> lst) - type ocamlbuild_plugin = - { - plugin_tags: string option; - extra_args: string list; - } - - - let check_ocaml_version version pkg = - match pkg.ocaml_version with - | Some ocaml_version -> - let min_ocaml_version = OASISVersion.version_of_string version in - OASISVersion.comparator_ge min_ocaml_version ocaml_version - | None -> - false - - - let ocamlbuild_supports_ocamlfind = check_ocaml_version "3.12.1" - let ocamlbuild_supports_plugin_tags = check_ocaml_version "4.01" - - - let build t pkg argv = + let build extra_args pkg argv = (* Return the filename in build directory *) let in_build_dir fn = Filename.concat @@ -6425,33 +6527,13 @@ module OCamlbuildPlugin = struct (BaseBuilt.register bt bnm lst) in - let cond_targets = - (* Run the hook *) - !cond_targets_hook cond_targets - in - - let extra_args = - match t.plugin_tags with - | Some tags -> "-plugin-tags" :: ("'" ^ tags ^ "'") :: t.extra_args - | None -> t.extra_args - in - let extra_args = - if ocamlbuild_supports_ocamlfind pkg then - "-use-ocamlfind" :: extra_args - else - extra_args - in + (* Run the hook *) + let cond_targets = !cond_targets_hook cond_targets in - (* Run a list of target... *) - run_ocamlbuild - (List.flatten - (List.map snd cond_targets) - @ extra_args) - argv; - (* ... and register events *) - List.iter - check_and_register - (List.flatten (List.map fst cond_targets)) + (* Run a list of target... *) + run_ocamlbuild (List.flatten (List.map snd cond_targets) @ extra_args) argv; + (* ... and register events *) + List.iter check_and_register (List.flatten (List.map fst cond_targets)) let clean pkg extra_args = @@ -6488,12 +6570,18 @@ module OCamlbuildDocPlugin = struct + type run_t = + { + extra_args: string list; + run_path: unix_filename; + } + - let doc_build path pkg (cs, doc) argv = + let doc_build run pkg (cs, doc) argv = let index_html = OASISUnixPath.make [ - path; + run.run_path; cs.cs_name^".docdir"; "index.html"; ] @@ -6502,11 +6590,11 @@ module OCamlbuildDocPlugin = struct OASISHostPath.make [ build_dir argv; - OASISHostPath.of_unix path; + OASISHostPath.of_unix run.run_path; cs.cs_name^".docdir"; ] in - run_ocamlbuild [index_html] argv; + run_ocamlbuild (index_html :: run.extra_args) argv; List.iter (fun glb -> BaseBuilt.register @@ -6517,7 +6605,7 @@ module OCamlbuildDocPlugin = struct ["*.html"; "*.css"] - let doc_clean t pkg (cs, doc) argv = + let doc_clean run pkg (cs, doc) argv = run_clean argv; BaseBuilt.unregister BaseBuilt.BDoc cs.cs_name @@ -6525,7 +6613,7 @@ module OCamlbuildDocPlugin = struct end -# 6528 "setup.ml" +# 6616 "setup.ml" module CustomPlugin = struct (* # 22 "src/plugins/custom/CustomPlugin.ml" *) @@ -6548,7 +6636,7 @@ module CustomPlugin = struct cmd_main: command_line conditional; cmd_clean: (command_line option) conditional; cmd_distclean: (command_line option) conditional; - } + } let run = BaseCustom.run @@ -6673,15 +6761,13 @@ module CustomPlugin = struct end -# 6676 "setup.ml" +# 6764 "setup.ml" open OASISTypes;; let setup_t = { BaseSetup.configure = InternalConfigurePlugin.configure; - build = - OCamlbuildPlugin.build - {OCamlbuildPlugin.plugin_tags = None; extra_args = []}; + build = OCamlbuildPlugin.build []; test = [ ("all_tests", @@ -6696,7 +6782,12 @@ let setup_t = cmd_distclean = [(OASISExpr.EBool true, None)] }) ]; - doc = [("doc", OCamlbuildDocPlugin.doc_build "lib")]; + doc = + [ + ("doc", + OCamlbuildDocPlugin.doc_build + {OCamlbuildDocPlugin.extra_args = []; run_path = "lib"}) + ]; install = InternalInstallPlugin.install; uninstall = InternalInstallPlugin.uninstall; clean = [OCamlbuildPlugin.clean]; @@ -6714,7 +6805,12 @@ let setup_t = cmd_distclean = [(OASISExpr.EBool true, None)] }) ]; - clean_doc = [("doc", OCamlbuildDocPlugin.doc_clean "lib")]; + clean_doc = + [ + ("doc", + OCamlbuildDocPlugin.doc_clean + {OCamlbuildDocPlugin.extra_args = []; run_path = "lib"}) + ]; distclean = []; distclean_test = [ @@ -6739,7 +6835,7 @@ let setup_t = alpha_features = []; beta_features = []; name = "packet"; - version = "0.2.1"; + version = "0.3.0"; license = OASISLicense.DEP5License (OASISLicense.DEP5Unit @@ -6987,12 +7083,13 @@ let setup_t = ]; plugins = [(`Extra, "META", Some "0.3"); (`Extra, "DevFiles", Some "0.3")]; + disable_oasis_section = []; schema_data = PropList.Data.create (); plugin_data = [] }; oasis_fn = Some "_oasis"; - oasis_version = "0.4.1"; - oasis_digest = Some "p0\128\249\191\242\255\025\229\225]JG\128\199\224"; + oasis_version = "0.4.4"; + oasis_digest = Some "\189\195\181d8\b3\128\216\190\002V%\172\139\195"; oasis_exec = None; oasis_setup_args = []; setup_update = false @@ -7000,6 +7097,6 @@ let setup_t = let setup () = BaseSetup.setup setup_t;; -# 7004 "setup.ml" +# 7101 "setup.ml" (* OASIS_STOP *) let () = setup ();;