Skip to content

Commit

Permalink
Add OASIS autogen for the sexp accessor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
avsm committed May 26, 2014
1 parent ff27e17 commit 56d9b57
Show file tree
Hide file tree
Showing 10 changed files with 418 additions and 263 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.5.0 (trunk):
* Add `with sexp` serializers to all the Ipaddr types.

2.4.0 (2014-02-11):
* Add `Ipaddr.V6.Prefix.of_netmask` for conversion from an IPv6
address/netmask to prefix (useful for some binary interfaces). See #27.
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 7b2408909643717852b95f994b273fee)
# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954)

SETUP = ocaml setup.ml

Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions _oasis
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
OASISFormat: 0.3
Name: ipaddr
Version: 2.4.0
Version: 2.5.0
Synopsis: A library for manipulation of IP (and MAC) address representations
Authors: David Sheets, Anil Madhavapeddy, Hugo Heuzard
License: ISC
Plugins: META (0.3), DevFiles (0.3)
BuildTools: ocamlbuild

Flag unix
Description: build the unix library
Description: build the Unix library
Default: true

Flag top
Expand All @@ -18,6 +18,8 @@ Flag top
Library ipaddr
Path: lib
Findlibname: ipaddr
BuildDepends: sexplib, sexplib.syntax
XMETARequires: sexplib
Modules: Ipaddr, Macaddr
NativeOpt: -w @f@p@u@s@40
ByteOpt: -w @f@p@u@s@40
Expand Down
6 changes: 4 additions & 2 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 6e3d75e627e8d27796e5d44e56fed7b0)
# DO NOT EDIT (digest: f9f16d223cb17e92bb389adad5387e15)
# 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 @@ -21,8 +21,10 @@
<lib/*.ml{,i}>: oasis_library_ipaddr_native
# Library ipaddr_unix
"lib/ipaddr_unix.cmxs": use_ipaddr_unix
<lib/*.ml{,i}>: use_ipaddr
<lib/*.ml{,i}>: pkg_sexplib
<lib/*.ml{,i}>: pkg_sexplib.syntax
<lib/*.ml{,i}>: pkg_unix
<lib/*.ml{,i}>: use_ipaddr
# Library ipaddr_top
"top/ipaddr_top.cmxs": use_ipaddr_top
# OASIS_STOP
Expand Down
9 changes: 5 additions & 4 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# OASIS_START
# DO NOT EDIT (digest: aace2be48ddf413aa8036abe8779d04c)
version = "2.4.0"
# DO NOT EDIT (digest: 4d54b77b02bee6839206a4b1e1a2a4ad)
version = "2.5.0"
description =
"A library for manipulation of IP (and MAC) address representations"
requires = "sexplib"
archive(byte) = "ipaddr.cma"
archive(byte, plugin) = "ipaddr.cma"
archive(native) = "ipaddr.cmxa"
archive(native, plugin) = "ipaddr.cmxs"
exists_if = "ipaddr.cma"
package "unix" (
version = "2.4.0"
version = "2.5.0"
description =
"A library for manipulation of IP (and MAC) address representations"
requires = "unix ipaddr"
Expand All @@ -21,7 +22,7 @@ package "unix" (
)

package "top" (
version = "2.4.0"
version = "2.5.0"
description = "Toplevel printers for IP addresses"
requires = "ipaddr"
archive(byte) = "ipaddr_top.cma"
Expand Down
5 changes: 5 additions & 0 deletions lib/ipaddr.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: d87e9ce6150361cb3829c7282ce6c915)
Ipaddr
Macaddr
# OASIS_STOP
4 changes: 4 additions & 0 deletions lib/ipaddr_unix.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# OASIS_START
# DO NOT EDIT (digest: ee982b4e45569cc57d5ac614e4a92b5b)
Ipaddr_unix
# OASIS_STOP
146 changes: 93 additions & 53 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: b9f1896c4b44f5c023c34582ffa087bd) *)
(* DO NOT EDIT (digest: bad12c52d2295e9705af01fa611f2526) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -39,10 +39,10 @@ module OASISExpr = struct
open OASISGettext


type test = string
type test = string


type flag = string
type flag = string


type t =
Expand All @@ -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 =
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 @@ -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" *)
Expand All @@ -412,7 +448,7 @@ module MyOCamlbuildBase = struct
* directory.
*)
includes: (dir * dir list) list;
}
}


let env_filename =
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 Down Expand Up @@ -583,7 +623,7 @@ let package_default =

let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;

# 587 "myocamlbuild.ml"
# 627 "myocamlbuild.ml"
(* OASIS_STOP *)
let () =
let additional_rules = function
Expand Down
Loading

0 comments on commit 56d9b57

Please sign in to comment.