Skip to content

Commit edb7f70

Browse files
committed
Merge pull request xapi-project#37 from jonludlam/xenguestbin_flag
Conditionally build xenguest.
2 parents d1de165 + 26d6bd9 commit edb7f70

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ setup.bin: setup.ml
2222
@rm -f setup.cmx setup.cmi setup.o setup.cmo
2323

2424
setup.data: setup.bin
25-
@./setup.bin -configure $(ENABLE_XEN) $(ENABLE_XENLIGHT) $(ENABLE_LIBVIRT)
25+
@./setup.bin -configure $(ENABLE_XEN) $(ENABLE_XENLIGHT) $(ENABLE_LIBVIRT) $(ENABLE_XENGUESTBIN)
2626

2727
build: setup.data setup.bin
2828
@./setup.bin -build -j $(J)

_oasis

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Flag simulator
2323
Description: Build server with simulator support
2424
Default: true
2525

26+
Flag xenguestbin
27+
Description: Build the xenguest binary
28+
Default: true
29+
2630
Library xenopsd
2731
CompiledObject: best
2832
Path: lib
@@ -34,7 +38,7 @@ Executable xenguest
3438
CompiledObject: best
3539
Path: xenguest
3640
MainIs: xenguest_main.ml
37-
Build$: flag(xen)
41+
Build$: flag(xen) && flag(xenguestbin)
3842
Custom: true
3943
Install: false
4044
BuildDepends: xenctrl, unix

configure.ml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,34 @@ let find_ocamlfind verbose name =
4141
if verbose then Printf.fprintf stderr "querying for ocamlfind package %s: %s" name (if found then "ok" else "missing");
4242
found
4343

44-
4544
let output_file filename lines =
4645
let oc = open_out filename in
4746
let lines = List.map (fun line -> line ^ "\n") lines in
4847
List.iter (output_string oc) lines;
4948
close_out oc
5049

50+
let find_ml_val verbose name libs =
51+
let ml_program = [
52+
Printf.sprintf "let f = %s" name;
53+
] in
54+
let basename = Filename.temp_file "looking_for_val" "" in
55+
let ml_file = basename ^ ".ml" in
56+
let cmo_file = basename ^ ".cmo" in
57+
let cmi_file = basename ^ ".cmi" in
58+
output_file ml_file ml_program;
59+
let found = Sys.command (Printf.sprintf "ocamlfind ocamlc -package %s -c %s %s" (String.concat "," libs) ml_file (if verbose then "" else "2>/dev/null")) = 0 in
60+
if Sys.file_exists ml_file then Sys.remove ml_file;
61+
if Sys.file_exists cmo_file then Sys.remove cmo_file;
62+
if Sys.file_exists cmi_file then Sys.remove cmi_file;
63+
Printf.printf "Looking for %s: %s\n" name (if found then "ok" else "missing");
64+
found
65+
5166
let configure bindir sbindir libexecdir scriptsdir etcdir =
5267
let xenctrl = find_ocamlfind false "xenctrl" in
5368
let xenlight = find_ocamlfind false "xenlight" in
5469
let libvirt = find_ocamlfind false "libvirt" in
70+
let xenguest = find_ml_val true "Xenguest.init" ["xenctrl"] in
71+
5572
Printf.printf "Configuring with:\n\tbindir=%s\n\tsbindir=%s\n\tlibexecdir=%s\n\tscriptsdir=%s\n\tetcdir=%s\n\txenctrl=%b\n\txenlight=%b\n\tlibvirt=%b\n\n" bindir sbindir libexecdir scriptsdir etcdir xenctrl xenlight libvirt;
5673

5774
(* Write config.mk *)
@@ -66,6 +83,7 @@ let configure bindir sbindir libexecdir scriptsdir etcdir =
6683
Printf.sprintf "ENABLE_XEN=--%s-xen" (if xenctrl then "enable" else "disable");
6784
Printf.sprintf "ENABLE_XENLIGHT=--%s-xenlight" (if xenlight then "enable" else "disable");
6885
Printf.sprintf "ENABLE_LIBVIRT=--%s-libvirt" (if libvirt then "enable" else "disable");
86+
Printf.sprintf "ENABLE_XENGUESTBIN=--%s-xenguestbin" (if xenguest then "enable" else "disable");
6987
] in
7088
output_file config_mk lines
7189

setup.ml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(* setup.ml generated for the first time by OASIS v0.3.0 *)
22

33
(* OASIS_START *)
4-
(* DO NOT EDIT (digest: d2f67611ff247d68337005d5da1d7e50) *)
4+
(* DO NOT EDIT (digest: 2db37ae3212d2989c6c4ff0d5f3011da) *)
55
(*
66
Regenerated by OASIS v0.3.0
77
Visit http://oasis.forge.ocamlcore.org for more information and
@@ -5674,6 +5674,16 @@ let setup_t =
56745674
Some "Build server with simulator support";
56755675
flag_default = [(OASISExpr.EBool true, true)];
56765676
});
5677+
Flag
5678+
({
5679+
cs_name = "xenguestbin";
5680+
cs_data = PropList.Data.create ();
5681+
cs_plugin_data = [];
5682+
},
5683+
{
5684+
flag_description = Some "Build the xenguest binary";
5685+
flag_default = [(OASISExpr.EBool true, true)];
5686+
});
56775687
Library
56785688
({
56795689
cs_name = "xenopsd";
@@ -5753,7 +5763,10 @@ let setup_t =
57535763
bs_build =
57545764
[
57555765
(OASISExpr.EBool true, false);
5756-
(OASISExpr.EFlag "xen", true)
5766+
(OASISExpr.EAnd
5767+
(OASISExpr.EFlag "xen",
5768+
OASISExpr.EFlag "xenguestbin"),
5769+
true)
57575770
];
57585771
bs_install = [(OASISExpr.EBool true, false)];
57595772
bs_path = "xenguest";
@@ -5941,14 +5954,14 @@ let setup_t =
59415954
};
59425955
oasis_fn = Some "_oasis";
59435956
oasis_version = "0.3.0";
5944-
oasis_digest = Some "\1820\199gQ\20568}\206Q\188(\017\004\021";
5957+
oasis_digest = Some "t9|\020R>E\230\153\146\1555-C/9";
59455958
oasis_exec = None;
59465959
oasis_setup_args = [];
59475960
setup_update = false;
59485961
};;
59495962

59505963
let setup () = BaseSetup.setup setup_t;;
59515964

5952-
# 5953 "setup.ml"
5965+
# 5966 "setup.ml"
59535966
(* OASIS_STOP *)
59545967
let () = setup ();;

0 commit comments

Comments
 (0)