Skip to content

Commit 73c0169

Browse files
committed
v0.3.0
1 parent 8f6f43f commit 73c0169

File tree

6 files changed

+413
-273
lines changed

6 files changed

+413
-273
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 7b2408909643717852b95f994b273fee)
2+
# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954)
33

44
SETUP = ocaml setup.ml
55

@@ -33,6 +33,9 @@ distclean:
3333
setup.data:
3434
$(SETUP) -configure $(CONFIGUREFLAGS)
3535

36+
configure:
37+
$(SETUP) -configure $(CONFIGUREFLAGS)
38+
3639
.PHONY: build doc test all install uninstall reinstall clean distclean configure
3740

3841
# OASIS_STOP

_oasis

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
OASISFormat: 0.3
22
Name: packet
3-
Version: 0.2.1
3+
Version: 0.3.0
44
Synopsis: Serialization for some common network packets, including
55
ethernet frames, IP, TCP, and ARP.
66
Authors: https://github.com/frenetic-lang/ocaml-packet/contributors

_tags

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: 3c7e732d4e333ae1acfd5e06c0b2d31a)
2+
# DO NOT EDIT (digest: c53dcb3b24d3ca38ca313d3ea6cbeb08)
33
# Ignore VCS directories, you can use the same kind of rule outside
44
# OASIS_START/STOP if you want to exclude directories that contains
55
# useless stuff for the build process
@@ -21,38 +21,38 @@
2121
<lib/*.ml{,i}>: oasis_library_packet_byte
2222
"lib/checksum_stubs.c": oasis_library_packet_byte
2323
<lib/packet.{cma,cmxa}>: use_libpacket_stubs
24-
<lib/*.ml{,i}>: pkg_str
2524
<lib/*.ml{,i}>: pkg_cstruct
2625
<lib/*.ml{,i}>: pkg_cstruct.syntax
27-
"lib/checksum_stubs.c": pkg_str
26+
<lib/*.ml{,i}>: pkg_str
2827
"lib/checksum_stubs.c": pkg_cstruct
2928
"lib/checksum_stubs.c": pkg_cstruct.syntax
29+
"lib/checksum_stubs.c": pkg_str
3030
# Library quickcheck
3131
"quickcheck/quickcheck.cmxs": use_quickcheck
32-
<quickcheck/*.ml{,i}>: use_packet
33-
<quickcheck/*.ml{,i}>: pkg_quickcheck
34-
<quickcheck/*.ml{,i}>: pkg_str
3532
<quickcheck/*.ml{,i}>: pkg_cstruct
3633
<quickcheck/*.ml{,i}>: pkg_cstruct.syntax
34+
<quickcheck/*.ml{,i}>: pkg_quickcheck
35+
<quickcheck/*.ml{,i}>: pkg_str
36+
<quickcheck/*.ml{,i}>: use_packet
3737
# Executable testtool
38-
"test/Test.byte": use_quickcheck
39-
"test/Test.byte": use_packet
38+
"test/Test.byte": pkg_cstruct
39+
"test/Test.byte": pkg_cstruct.syntax
4040
"test/Test.byte": pkg_oUnit
4141
"test/Test.byte": pkg_pa_ounit
4242
"test/Test.byte": pkg_pa_ounit.syntax
4343
"test/Test.byte": pkg_quickcheck
4444
"test/Test.byte": pkg_str
45-
"test/Test.byte": pkg_cstruct
46-
"test/Test.byte": pkg_cstruct.syntax
47-
<test/*.ml{,i}>: use_quickcheck
48-
<test/*.ml{,i}>: use_packet
45+
"test/Test.byte": use_packet
46+
"test/Test.byte": use_quickcheck
47+
<test/*.ml{,i}>: pkg_cstruct
48+
<test/*.ml{,i}>: pkg_cstruct.syntax
4949
<test/*.ml{,i}>: pkg_oUnit
5050
<test/*.ml{,i}>: pkg_pa_ounit
5151
<test/*.ml{,i}>: pkg_pa_ounit.syntax
5252
<test/*.ml{,i}>: pkg_quickcheck
5353
<test/*.ml{,i}>: pkg_str
54-
<test/*.ml{,i}>: pkg_cstruct
55-
<test/*.ml{,i}>: pkg_cstruct.syntax
54+
<test/*.ml{,i}>: use_packet
55+
<test/*.ml{,i}>: use_quickcheck
5656
# OASIS_STOP
5757
<lib/*.ml>: syntax_camlp4o
5858
<test/*.ml>: syntax_camlp4o

lib/META

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OASIS_START
2-
# DO NOT EDIT (digest: e11d8d1a4f860583d2201977fec001a4)
3-
version = "0.2.1"
2+
# DO NOT EDIT (digest: c8676216e1e3826c9bcde71bc3aab806)
3+
version = "0.3.0"
44
description =
55
"Serialization for some common network packets, including ethernet frames, IP, TCP, and ARP."
66
requires = "str cstruct cstruct.syntax"
@@ -10,7 +10,7 @@ archive(native) = "packet.cmxa"
1010
archive(native, plugin) = "packet.cmxs"
1111
exists_if = "packet.cma"
1212
package "quickcheck" (
13-
version = "0.2.1"
13+
version = "0.3.0"
1414
description =
1515
"Serialization for some common network packets, including ethernet frames, IP, TCP, and ARP."
1616
requires = "packet quickcheck"

myocamlbuild.ml

Lines changed: 93 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(* OASIS_START *)
2-
(* DO NOT EDIT (digest: e270c2e88368dd27093c3e0e7085db75) *)
2+
(* DO NOT EDIT (digest: 7e1f2e1d53bf2952193c34fd943d0c23) *)
33
module OASISGettext = struct
44
(* # 22 "src/oasis/OASISGettext.ml" *)
55

@@ -39,10 +39,10 @@ module OASISExpr = struct
3939
open OASISGettext
4040

4141

42-
type test = string
42+
type test = string
4343

4444

45-
type flag = string
45+
type flag = string
4646

4747

4848
type t =
@@ -52,10 +52,10 @@ module OASISExpr = struct
5252
| EOr of t * t
5353
| EFlag of flag
5454
| ETest of test * string
55-
5655

5756

58-
type 'a choices = (t * 'a) list
57+
58+
type 'a choices = (t * 'a) list
5959

6060

6161
let eval var_get t =
@@ -204,26 +204,27 @@ module BaseEnvLight = struct
204204
end
205205

206206

207-
let var_get name env =
208-
let rec var_expand str =
209-
let buff =
210-
Buffer.create ((String.length str) * 2)
211-
in
212-
Buffer.add_substitute
213-
buff
214-
(fun var ->
215-
try
216-
var_expand (MapString.find var env)
217-
with Not_found ->
218-
failwith
219-
(Printf.sprintf
220-
"No variable %s defined when trying to expand %S."
221-
var
222-
str))
223-
str;
224-
Buffer.contents buff
207+
let rec var_expand str env =
208+
let buff =
209+
Buffer.create ((String.length str) * 2)
225210
in
226-
var_expand (MapString.find name env)
211+
Buffer.add_substitute
212+
buff
213+
(fun var ->
214+
try
215+
var_expand (MapString.find var env) env
216+
with Not_found ->
217+
failwith
218+
(Printf.sprintf
219+
"No variable %s defined when trying to expand %S."
220+
var
221+
str))
222+
str;
223+
Buffer.contents buff
224+
225+
226+
let var_get name env =
227+
var_expand (MapString.find name env) env
227228

228229

229230
let var_choose lst env =
@@ -233,7 +234,7 @@ module BaseEnvLight = struct
233234
end
234235

235236

236-
# 236 "myocamlbuild.ml"
237+
# 237 "myocamlbuild.ml"
237238
module MyOCamlbuildFindlib = struct
238239
(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
239240

@@ -258,6 +259,31 @@ module MyOCamlbuildFindlib = struct
258259
Ocamlbuild_pack.Lexers.blank_sep_strings
259260

260261

262+
let exec_from_conf exec =
263+
let exec =
264+
let env_filename = Pathname.basename BaseEnvLight.default_filename in
265+
let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in
266+
try
267+
BaseEnvLight.var_get exec env
268+
with Not_found ->
269+
Printf.eprintf "W: Cannot get variable %s\n" exec;
270+
exec
271+
in
272+
let fix_win32 str =
273+
if Sys.os_type = "Win32" then begin
274+
let buff = Buffer.create (String.length str) in
275+
(* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'.
276+
*)
277+
String.iter
278+
(fun c -> Buffer.add_char buff (if c = '\\' then '/' else c))
279+
str;
280+
Buffer.contents buff
281+
end else begin
282+
str
283+
end
284+
in
285+
fix_win32 exec
286+
261287
let split s ch =
262288
let buf = Buffer.create 13 in
263289
let x = ref [] in
@@ -285,17 +311,7 @@ module MyOCamlbuildFindlib = struct
285311
with Not_found -> s
286312

287313
(* ocamlfind command *)
288-
let ocamlfind x =
289-
let ocamlfind_prog =
290-
let env_filename = Pathname.basename BaseEnvLight.default_filename in
291-
let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in
292-
try
293-
BaseEnvLight.var_get "ocamlfind" env
294-
with Not_found ->
295-
Printf.eprintf "W: Cannot get variable ocamlfind";
296-
"ocamlfind"
297-
in
298-
S[Sh ocamlfind_prog; x]
314+
let ocamlfind x = S[Sh (exec_from_conf "ocamlfind"); x]
299315

300316
(* This lists all supported packages. *)
301317
let find_packages () =
@@ -306,9 +322,25 @@ module MyOCamlbuildFindlib = struct
306322
let find_syntaxes () = ["camlp4o"; "camlp4r"]
307323

308324

325+
let well_known_syntax = [
326+
"camlp4.quotations.o";
327+
"camlp4.quotations.r";
328+
"camlp4.exceptiontracer";
329+
"camlp4.extend";
330+
"camlp4.foldgenerator";
331+
"camlp4.listcomprehension";
332+
"camlp4.locationstripper";
333+
"camlp4.macro";
334+
"camlp4.mapgenerator";
335+
"camlp4.metagenerator";
336+
"camlp4.profiler";
337+
"camlp4.tracer"
338+
]
339+
340+
309341
let dispatch =
310342
function
311-
| Before_options ->
343+
| After_options ->
312344
(* By using Before_options one let command line options have an higher
313345
* priority on the contrary using After_options will guarantee to have
314346
* the higher priority override default commands by ocamlfind ones *)
@@ -331,13 +363,17 @@ module MyOCamlbuildFindlib = struct
331363
List.iter
332364
begin fun pkg ->
333365
let base_args = [A"-package"; A pkg] in
366+
(* TODO: consider how to really choose camlp4o or camlp4r. *)
334367
let syn_args = [A"-syntax"; A "camlp4o"] in
335368
let args =
336-
(* Heuristic to identify syntax extensions: whether they end in
337-
* ".syntax"; some might not *)
338-
if Filename.check_suffix pkg "syntax"
339-
then syn_args @ base_args
340-
else base_args
369+
(* Heuristic to identify syntax extensions: whether they end in
370+
".syntax"; some might not.
371+
*)
372+
if Filename.check_suffix pkg "syntax" ||
373+
List.mem pkg well_known_syntax then
374+
syn_args @ base_args
375+
else
376+
base_args
341377
in
342378
flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
343379
flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
@@ -394,10 +430,10 @@ module MyOCamlbuildBase = struct
394430
module OC = Ocamlbuild_pack.Ocaml_compiler
395431

396432

397-
type dir = string
398-
type file = string
399-
type name = string
400-
type tag = string
433+
type dir = string
434+
type file = string
435+
type name = string
436+
type tag = string
401437

402438

403439
(* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
@@ -412,7 +448,7 @@ module MyOCamlbuildBase = struct
412448
* directory.
413449
*)
414450
includes: (dir * dir list) list;
415-
}
451+
}
416452

417453

418454
let env_filename =
@@ -455,7 +491,7 @@ module MyOCamlbuildBase = struct
455491
try
456492
opt := no_trailing_dot (BaseEnvLight.var_get var env)
457493
with Not_found ->
458-
Printf.eprintf "W: Cannot get variable %s" var)
494+
Printf.eprintf "W: Cannot get variable %s\n" var)
459495
[
460496
Options.ext_obj, "ext_obj";
461497
Options.ext_lib, "ext_lib";
@@ -531,10 +567,14 @@ module MyOCamlbuildBase = struct
531567
(* Add flags *)
532568
List.iter
533569
(fun (tags, cond_specs) ->
534-
let spec =
535-
BaseEnvLight.var_choose cond_specs env
570+
let spec = BaseEnvLight.var_choose cond_specs env in
571+
let rec eval_specs =
572+
function
573+
| S lst -> S (List.map eval_specs lst)
574+
| A str -> A (BaseEnvLight.var_expand str env)
575+
| spec -> spec
536576
in
537-
flag tags & spec)
577+
flag tags & (eval_specs spec))
538578
t.flags
539579
| _ ->
540580
()
@@ -551,7 +591,7 @@ module MyOCamlbuildBase = struct
551591
end
552592

553593

554-
# 554 "myocamlbuild.ml"
594+
# 594 "myocamlbuild.ml"
555595
open Ocamlbuild_plugin;;
556596
let package_default =
557597
{
@@ -575,6 +615,6 @@ let package_default =
575615

576616
let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
577617

578-
# 579 "myocamlbuild.ml"
618+
# 619 "myocamlbuild.ml"
579619
(* OASIS_STOP *)
580620
Ocamlbuild_plugin.dispatch dispatch_default;;

0 commit comments

Comments
 (0)