Skip to content

Commit

Permalink
Merge pull request #239 from avsm/master
Browse files Browse the repository at this point in the history
Augment STACKV4 with an IPV4 module in addition to TCPV4 and UDPV4
  • Loading branch information
avsm committed Apr 29, 2014
2 parents 4bc8628 + 2064a1c commit 01ad037
Show file tree
Hide file tree
Showing 8 changed files with 357 additions and 209 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
1.1.2 (trunk):
1.1.2 (2014-04-01):
* Improvement to the Amazon EC2 deployment script.
* [types] Augment STACKV4 with an IPV4 module in addition to TCPV4 and UDPV4.
* Regenerate with OASIS 0.4.4 (which adds natdynlink support)

1.1.1 (2014-02-21):
* Man page fixes for typos and terminology (#220).
Expand Down
2 changes: 1 addition & 1 deletion _oasis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
OASISFormat: 0.3
Name: mirage
Version: 1.1.1
Version: 1.1.2
Synopsis: Mirage configuration tool
Authors: Thomas Gazagnaire, Anil Madhavapeddy
License: ISC
Expand Down
14 changes: 7 additions & 7 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: f9e9e8887a738a0464af473eb5620648)
# DO NOT EDIT (digest: faddbf53eff71e4790cbe626b35876bb)
# 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
Expand All @@ -16,21 +16,21 @@
# Library mirage
"lib/mirage.cmxs": use_mirage
# Executable mirage
<lib/main.{native,byte}>: use_mirage
<lib/main.{native,byte}>: pkg_cmdliner
<lib/main.{native,byte}>: pkg_ipaddr
<lib/main.{native,byte}>: pkg_unix
<lib/main.{native,byte}>: pkg_dynlink
<lib/main.{native,byte}>: pkg_ipaddr
<lib/main.{native,byte}>: pkg_lwt
<lib/main.{native,byte}>: pkg_mirage-types
<lib/main.{native,byte}>: pkg_mirage-types.lwt
<lib/*.ml{,i}>: use_mirage
<lib/main.{native,byte}>: pkg_unix
<lib/main.{native,byte}>: use_mirage
<lib/*.ml{,i}>: pkg_cmdliner
<lib/*.ml{,i}>: pkg_ipaddr
<lib/*.ml{,i}>: pkg_unix
<lib/*.ml{,i}>: pkg_dynlink
<lib/*.ml{,i}>: pkg_ipaddr
<lib/*.ml{,i}>: pkg_lwt
<lib/*.ml{,i}>: pkg_mirage-types
<lib/*.ml{,i}>: pkg_mirage-types.lwt
<lib/*.ml{,i}>: pkg_unix
<lib/*.ml{,i}>: use_mirage
# OASIS_STOP
true: debug, bin_annot, annot, principal
4 changes: 2 additions & 2 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OASIS_START
# DO NOT EDIT (digest: 007387b8593a99cdfb19e64b960a967c)
version = "1.1.1"
# DO NOT EDIT (digest: bd7bedce825b92b75eb0db02221633b8)
version = "1.1.2"
description = "Mirage configuration tool"
requires = "ipaddr unix dynlink lwt mirage-types mirage-types.lwt"
archive(byte) = "mirage.cma"
Expand Down
5 changes: 5 additions & 0 deletions lib/mirage.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: d28054d192776ddeb5b487f12e7e9d48)
Mirage
Mirage_misc
# OASIS_STOP
128 changes: 84 additions & 44 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 8ebc12b747c9c1c3387b16144f6b7d47) *)
(* DO NOT EDIT (digest: c1013f75ee0bc6850b390e90d3654b28) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -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 =
Expand All @@ -233,7 +234,7 @@ module BaseEnvLight = struct
end


# 236 "myocamlbuild.ml"
# 237 "myocamlbuild.ml"
module MyOCamlbuildFindlib = struct
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)

Expand All @@ -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
Expand Down Expand Up @@ -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 () =
Expand All @@ -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 *)
Expand All @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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
| _ ->
()
Expand All @@ -551,7 +591,7 @@ module MyOCamlbuildBase = struct
end


# 554 "myocamlbuild.ml"
# 594 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{
Expand All @@ -564,6 +604,6 @@ let package_default =

let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;

# 568 "myocamlbuild.ml"
# 608 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;

0 comments on commit 01ad037

Please sign in to comment.