Skip to content

Commit

Permalink
Merge pull request #132 from robhoes/transform
Browse files Browse the repository at this point in the history
Add v6 interface
  • Loading branch information
robhoes authored Oct 5, 2016
2 parents 8ef6624 + b670dd8 commit e6d3f41
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 218 deletions.
8 changes: 8 additions & 0 deletions _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ Library xcp_memory
Modules: Memory_interface, Memory_client
BuildDepends: xcp, threads, rpclib, rpclib.syntax

Library xapi_v6
CompiledObject: best
Path: v6
Findlibname: v6
Findlibparent: xcp
Modules: V6_interface, V6_client
BuildDepends: xcp, threads, rpclib, rpclib.syntax

Executable channel_helper
CompiledObject: best
Path: lib
Expand Down
23 changes: 22 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 81cad0ff981440e9ded0e9f52c8ea879)
# DO NOT EDIT (digest: 2a0befa551f398e32c56a759b1351c69)
# 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 Down Expand Up @@ -158,6 +158,26 @@ true: annot, bin_annot
<memory/*.ml{,i,y}>: pkg_xcp-inventory
<memory/*.ml{,i,y}>: pkg_xmlm
<memory/*.ml{,i,y}>: use_xcp
# Library xapi_v6
"v6/xapi_v6.cmxs": use_xapi_v6
<v6/*.ml{,i,y}>: pkg_cmdliner
<v6/*.ml{,i,y}>: pkg_cohttp
<v6/*.ml{,i,y}>: pkg_fd-send-recv
<v6/*.ml{,i,y}>: pkg_message_switch
<v6/*.ml{,i,y}>: pkg_message_switch.unix
<v6/*.ml{,i,y}>: pkg_re
<v6/*.ml{,i,y}>: pkg_rpclib
<v6/*.ml{,i,y}>: pkg_rpclib.syntax
<v6/*.ml{,i,y}>: pkg_rpclib.xml
<v6/*.ml{,i,y}>: pkg_sexplib
<v6/*.ml{,i,y}>: pkg_sexplib.syntax
<v6/*.ml{,i,y}>: pkg_threads
<v6/*.ml{,i,y}>: pkg_unix
<v6/*.ml{,i,y}>: pkg_uri
<v6/*.ml{,i,y}>: pkg_xapi-backtrace
<v6/*.ml{,i,y}>: pkg_xcp-inventory
<v6/*.ml{,i,y}>: pkg_xmlm
<v6/*.ml{,i,y}>: use_xcp
# Executable channel_helper
<lib/channel_helper.{native,byte}>: pkg_cmdliner
<lib/channel_helper.{native,byte}>: pkg_cohttp
Expand Down Expand Up @@ -301,5 +321,6 @@ true: annot, bin_annot
<network/network_interface.ml>: pkg_rpclib.idl
<rrd/data_source.ml>: pkg_rpclib.idl
<rrd/rrd_interface.ml>: pkg_rpclib.idl
<v6/v6_interface.ml>: pkg_rpclib.idl
<lib/xcp_channel.ml>: pkg_rpclib.syntax
<lib/channel_helper.ml>: pkg_lwt.syntax
14 changes: 13 additions & 1 deletion lib/META
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: d0b737f17a49130e1b0fc0d82c3f4307)
# DO NOT EDIT (digest: 4c2fff058ec9d19d5bacfab9163ebe98)
version = "1.2.0"
description =
"Interface definitions and common boilerplate for the xapi toolstack"
Expand All @@ -22,6 +22,18 @@ package "xen" (
exists_if = "xcp_xen.cma"
)

package "v6" (
version = "1.2.0"
description =
"Interface definitions and common boilerplate for the xapi toolstack"
requires = "xcp threads rpclib rpclib.syntax"
archive(byte) = "xapi_v6.cma"
archive(byte, plugin) = "xapi_v6.cma"
archive(native) = "xapi_v6.cmxa"
archive(native, plugin) = "xapi_v6.cmxs"
exists_if = "xapi_v6.cma"
)

package "storage" (
version = "1.2.0"
description =
Expand Down
178 changes: 10 additions & 168 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 4f11ff746aff43b8a7f3260b62d4b8d4) *)
(* DO NOT EDIT (digest: 1c35a77ee4b7460c9a976af0c323b7ea) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -29,166 +29,6 @@ module OASISGettext = struct

end

module OASISString = struct
(* # 22 "src/oasis/OASISString.ml" *)


(** Various string utilities.
Mostly inspired by extlib and batteries ExtString and BatString libraries.
@author Sylvain Le Gall
*)


let nsplitf str f =
if str = "" then
[]
else
let buf = Buffer.create 13 in
let lst = ref [] in
let push () =
lst := Buffer.contents buf :: !lst;
Buffer.clear buf
in
let str_len = String.length str in
for i = 0 to str_len - 1 do
if f str.[i] then
push ()
else
Buffer.add_char buf str.[i]
done;
push ();
List.rev !lst


(** [nsplit c s] Split the string [s] at char [c]. It doesn't include the
separator.
*)
let nsplit str c =
nsplitf str ((=) c)


let find ~what ?(offset=0) str =
let what_idx = ref 0 in
let str_idx = ref offset in
while !str_idx < String.length str &&
!what_idx < String.length what do
if str.[!str_idx] = what.[!what_idx] then
incr what_idx
else
what_idx := 0;
incr str_idx
done;
if !what_idx <> String.length what then
raise Not_found
else
!str_idx - !what_idx


let sub_start str len =
let str_len = String.length str in
if len >= str_len then
""
else
String.sub str len (str_len - len)


let sub_end ?(offset=0) str len =
let str_len = String.length str in
if len >= str_len then
""
else
String.sub str 0 (str_len - len)


let starts_with ~what ?(offset=0) str =
let what_idx = ref 0 in
let str_idx = ref offset in
let ok = ref true in
while !ok &&
!str_idx < String.length str &&
!what_idx < String.length what do
if str.[!str_idx] = what.[!what_idx] then
incr what_idx
else
ok := false;
incr str_idx
done;
if !what_idx = String.length what then
true
else
false


let strip_starts_with ~what str =
if starts_with ~what str then
sub_start str (String.length what)
else
raise Not_found


let ends_with ~what ?(offset=0) str =
let what_idx = ref ((String.length what) - 1) in
let str_idx = ref ((String.length str) - 1) in
let ok = ref true in
while !ok &&
offset <= !str_idx &&
0 <= !what_idx do
if str.[!str_idx] = what.[!what_idx] then
decr what_idx
else
ok := false;
decr str_idx
done;
if !what_idx = -1 then
true
else
false


let strip_ends_with ~what str =
if ends_with ~what str then
sub_end str (String.length what)
else
raise Not_found


let replace_chars f s =
let buf = Buffer.create (String.length s) in
String.iter (fun c -> Buffer.add_char buf (f c)) s;
Buffer.contents buf

let lowercase_ascii =
replace_chars
(fun c ->
if (c >= 'A' && c <= 'Z') then
Char.chr (Char.code c + 32)
else
c)

let uncapitalize_ascii s =
if s <> "" then
(lowercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
else
s

let uppercase_ascii =
replace_chars
(fun c ->
if (c >= 'a' && c <= 'z') then
Char.chr (Char.code c - 32)
else
c)

let capitalize_ascii s =
if s <> "" then
(uppercase_ascii (String.sub s 0 1)) ^ (String.sub s 1 ((String.length s) - 1))
else
s

end

module OASISExpr = struct
(* # 22 "src/oasis/OASISExpr.ml" *)

Expand Down Expand Up @@ -289,7 +129,7 @@ module OASISExpr = struct
end


# 292 "myocamlbuild.ml"
# 132 "myocamlbuild.ml"
module BaseEnvLight = struct
(* # 22 "src/base/BaseEnvLight.ml" *)

Expand Down Expand Up @@ -394,7 +234,7 @@ module BaseEnvLight = struct
end


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

Expand Down Expand Up @@ -676,7 +516,7 @@ module MyOCamlbuildBase = struct
| nm, [], intf_modules ->
ocaml_lib nm;
let cmis =
List.map (fun m -> (OASISString.uncapitalize_ascii m) ^ ".cmi")
List.map (fun m -> (String.uncapitalize m) ^ ".cmi")
intf_modules in
dep ["ocaml"; "link"; "library"; "file:"^nm^".cma"] cmis
| nm, dir :: tl, intf_modules ->
Expand All @@ -689,7 +529,7 @@ module MyOCamlbuildBase = struct
["compile"; "infer_interface"; "doc"])
tl;
let cmis =
List.map (fun m -> dir^"/"^(OASISString.uncapitalize_ascii m)^".cmi")
List.map (fun m -> dir^"/"^(String.uncapitalize m)^".cmi")
intf_modules in
dep ["ocaml"; "link"; "library"; "file:"^dir^"/"^nm^".cma"]
cmis)
Expand Down Expand Up @@ -763,7 +603,7 @@ module MyOCamlbuildBase = struct
end


# 766 "myocamlbuild.ml"
# 606 "myocamlbuild.ml"
open Ocamlbuild_plugin;;
let package_default =
{
Expand All @@ -774,13 +614,15 @@ let package_default =
("xcp_network", ["network"], []);
("xcp_rrd", ["rrd"], []);
("xcp_xen", ["xen"], []);
("xcp_memory", ["memory"], [])
("xcp_memory", ["memory"], []);
("xapi_v6", ["v6"], [])
];
lib_c = [("xcp", "lib", [])];
flags = [];
includes =
[
("xen", ["lib"]);
("v6", ["lib"]);
("storage", ["lib"]);
("rrd", ["lib"]);
("network", ["lib"]);
Expand All @@ -795,6 +637,6 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 799 "myocamlbuild.ml"
# 641 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;
Loading

0 comments on commit e6d3f41

Please sign in to comment.