Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
seliopou committed Jun 17, 2014
1 parent 8f6f43f commit 73c0169
Show file tree
Hide file tree
Showing 6 changed files with 413 additions and 273 deletions.
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
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: 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
Expand Down
28 changes: 14 additions & 14 deletions _tags
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,38 +21,38 @@
<lib/*.ml{,i}>: oasis_library_packet_byte
"lib/checksum_stubs.c": oasis_library_packet_byte
<lib/packet.{cma,cmxa}>: use_libpacket_stubs
<lib/*.ml{,i}>: pkg_str
<lib/*.ml{,i}>: pkg_cstruct
<lib/*.ml{,i}>: pkg_cstruct.syntax
"lib/checksum_stubs.c": pkg_str
<lib/*.ml{,i}>: 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
<quickcheck/*.ml{,i}>: use_packet
<quickcheck/*.ml{,i}>: pkg_quickcheck
<quickcheck/*.ml{,i}>: pkg_str
<quickcheck/*.ml{,i}>: pkg_cstruct
<quickcheck/*.ml{,i}>: pkg_cstruct.syntax
<quickcheck/*.ml{,i}>: pkg_quickcheck
<quickcheck/*.ml{,i}>: pkg_str
<quickcheck/*.ml{,i}>: 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
<test/*.ml{,i}>: use_quickcheck
<test/*.ml{,i}>: use_packet
"test/Test.byte": use_packet
"test/Test.byte": use_quickcheck
<test/*.ml{,i}>: pkg_cstruct
<test/*.ml{,i}>: pkg_cstruct.syntax
<test/*.ml{,i}>: pkg_oUnit
<test/*.ml{,i}>: pkg_pa_ounit
<test/*.ml{,i}>: pkg_pa_ounit.syntax
<test/*.ml{,i}>: pkg_quickcheck
<test/*.ml{,i}>: pkg_str
<test/*.ml{,i}>: pkg_cstruct
<test/*.ml{,i}>: pkg_cstruct.syntax
<test/*.ml{,i}>: use_packet
<test/*.ml{,i}>: use_quickcheck
# OASIS_STOP
<lib/*.ml>: syntax_camlp4o
<test/*.ml>: syntax_camlp4o
6 changes: 3 additions & 3 deletions lib/META
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
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: e270c2e88368dd27093c3e0e7085db75) *)
(* DO NOT EDIT (digest: 7e1f2e1d53bf2952193c34fd943d0c23) *)
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 All @@ -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;;
Loading

0 comments on commit 73c0169

Please sign in to comment.