Skip to content

Commit

Permalink
Merge pull request #69 from kc284/master
Browse files Browse the repository at this point in the history
CP-26711: Ported xapi-storage to jbuilder.
  • Loading branch information
kc284 authored Jan 30, 2018
2 parents 1d9df0f + d4861e1 commit 2624423
Show file tree
Hide file tree
Showing 43 changed files with 353 additions and 16,369 deletions.
34 changes: 5 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
*.swp
_build/
setup.data
setup.log
setup.bin
*.docdir
*.native
*.byte
*.cmx
*.cmi
*.cmo
*.o
*.a
*.aux
*.log
*.toc
*~
#*
generator/_build
generator/main.native
ocaml/lib/datapath.ml
ocaml/lib/plugin.ml
ocaml/lib/volume.ml
python/xapi/storage/api/datapath.py
python/xapi/storage/api/plugin.py
python/xapi/storage/api/volume.py
ocaml/examples
python/build
*.pyc
*.pyo
*.install
.merlin

*.rej
*.orig
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ python:
install:
- wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh
- pip install --user flake8
env:
global:
- OCAML_VERSION=4.04
- DISTRO=debian-stable
- PACKAGE=xapi-storage
- EXTRA_REMOTES=git://github.com/xapi-project/xs-opam
script:
- flake8 --show-source python
- bash -ex .travis-opam.sh
env:
- OCAML_VERSION=4.02 PACKAGE=xapi-storage
66 changes: 37 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
PYTHON_PREFIX?=/usr
OPAM_PREFIX?=$(shell opam config var prefix)
OPAM_LIBDIR?=$(shell opam config var lib)

default: build
.PHONY: release build install uninstall clean test examples html doc reindent

release:
jbuilder build @install
jbuilder build @python
make -C _build/default/python

.PHONY: build
build:
(cd generator; make)
mkdir -p ocaml/examples
mkdir -p python/xapi/storage/api
./generator/main.native
make -C ocaml
make -C python

.PHONY: html
html: build
./generator/main.native -html
rsync -av ./doc/static/ ./doc/gen/

.PHONY: install
jbuilder build @install --dev
jbuilder build @python --dev
make -C _build/default/python

install:
make -C ocaml install
make -C python install
jbuilder install --prefix=$(OPAM_PREFIX) --libdir=$(OPAM_LIBDIR) xapi-storage
make -C _build/default/python install PREFIX=$(PYTHON_PREFIX)

.PHONY: uninstall
uninstall:
make -C ocaml uninstall
make -C python uninstall

.PHONY: reinstall
reinstall:
make -C ocaml reinstall
make -C python reinstall
jbuilder uninstall --prefix=$(OPAM_PREFIX) --libdir=$(OPAM_LIBDIR) xapi-storage
make -C _build/default/python uninstall

.PHONY: clean
clean:
make -C generator clean
make -C ocaml clean
make -C python clean
jbuilder clean

test:
jbuilder runtest

examples:
jbuilder build @gen_examples

html:
jbuilder build @gen_html

# requires odoc
doc:
jbuilder build @doc

reindent:
git ls-files '*.ml*' | xargs ocp-indent --syntax cstruct -i


.DEFAULT_GOAL := release
4 changes: 3 additions & 1 deletion doc/gen/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
This is where the generaed docs go
# HTML Documentation

This can be autogenerated by running `make html` in the root of this repo.
15 changes: 15 additions & 0 deletions doc/gen/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(jbuild_version 1)

(alias (
(name gen_html)
(deps (
../../generator/html/www.exe
(files_recursively_in ../static)
(files_recursively_in ../templates)
))
(action (progn
(run ${<})
(run rsync -av ../static/ .)
))
))

6 changes: 0 additions & 6 deletions generator/.merlin

This file was deleted.

25 changes: 0 additions & 25 deletions generator/Makefile

This file was deleted.

16 changes: 0 additions & 16 deletions generator/_oasis

This file was deleted.

25 changes: 0 additions & 25 deletions generator/_tags

This file was deleted.

10 changes: 10 additions & 0 deletions generator/html/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(jbuild_version 1)

(executable (
(name www)
(libraries (
generator_lib
cow
caml2html
))
))
50 changes: 29 additions & 21 deletions generator/src/www.ml → generator/html/www.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ let sidebar env x =
li (a ~href:(uri target) name)
in
let of_method name m =
let target =
let target =
Printf.sprintf "#a-%s-%s" name m.Method.name
|> uri
|> uri
in
let name = string m.Method.name in
li (a ~href:target name)
Expand All @@ -86,7 +86,7 @@ let sidebar env x =
list [li ~cls:"docs-nav-title" (string ("interface:" ^ name))];
list (List.map (of_typedecl (Some i.Interface.name)) i.Interface.type_decls);
list (List.map (of_method i.Interface.name) i.Interface.methods)
]
]
in
div ~cls:"large-3 medium-3 columns" (
ul ~cls:"menu vertical" ([
Expand Down Expand Up @@ -170,7 +170,7 @@ let tabs_of env is i m =
div ~cls:"tabs-content" ~attrs:["data-tabs-content", id_tab] (list [
div ~cls:"tabs-panel is-active" ~id:id_defn (
of_args env (
(List.map (fun m -> true, m) m.Method.inputs)
(List.map (fun m -> true, m) m.Method.inputs)
@ (List.map (fun m -> false, m) m.Method.outputs))
);
div ~cls:"tabs-panel" ~id:id_ocaml (list [
Expand Down Expand Up @@ -270,11 +270,11 @@ let topbar pages =
in
list [
div ~cls:"title-bar" ~attrs:[
"data-responsive-toggle","main-menu";
"data-hide-for","medium"]
"data-responsive-toggle","main-menu";
"data-hide-for","medium"]
(list[
tag "button" ~cls:"menu-icon" ~attrs:[
"type","button";
"type","button";
"data-toggle",""] empty;
div ~cls:"title-bar-title" (string "Menu")
]);
Expand Down Expand Up @@ -326,7 +326,7 @@ let index_html oc pages =
);
hr empty;
h2 (string "Who is this for?");
p (string
p (string
"This is for anyone who has a storage system which is not \
supported by xapi out-of-the-box.")
]));
Expand All @@ -335,7 +335,7 @@ let index_html oc pages =
img ~alt:"Your bit here" (uri "img/your-bit-here.svg")
);
div ~cls:"large-6 columns" (list [
p (string
p (string
"This is also for anyone who wants to manage their \
storage in a customized way. If you can make your volumes appear \
as Linux block devices "
Expand All @@ -348,14 +348,14 @@ let index_html oc pages =
++ tt (string "rbd://")
++ string " then this documentation is for you."
);
p ~attrs:["style","font-weight: bold;"]
p ~attrs:["style","font-weight: bold;"]
(string "No Xapi or Xen specific knowledge is required.")
])
]);
div ~cls:"row" (
div ~cls:"large-12 columns panel callout" (list [
h2 (string "Status of this documentation");
p (string
p (string
"This documentation is a draft intended for discussion only. \
Please: ");
ul ([
Expand All @@ -375,27 +375,27 @@ let index_html oc pages =
)
])
in
print_file_to oc ("doc/static/header.html");
print_file_to oc ("../static/header.html");
output_string oc (Cow.Html.to_string (topbar pages));
output_string oc (Cow.Html.to_string header);
print_file_to oc ("doc/static/footer.html")
print_file_to oc ("../static/footer.html")

let placeholder_html oc pages body =
let header = div ~cls:"row" (
div ~cls:"large-12 columns panel callout"
(p (string "This is a placeholder"))
) in
print_file_to oc ("doc/static/header.html");
print_file_to oc ("../static/header.html");
output_string oc (Cow.Html.to_string (topbar pages));
if Sys.file_exists body
then print_file_to oc body
else output_string oc (Cow.Html.to_string header);
print_file_to oc ("doc/static/footer.html")
print_file_to oc ("../static/footer.html")

let page_of_api api = {
name = api.Interfaces.name;
title = api.Interfaces.title;
path = "doc/gen/" ^ api.Interfaces.name ^ ".html";
path = api.Interfaces.name ^ ".html";
filename = api.Interfaces.name ^ ".html";
description = api.Interfaces.description;
api = api;
Expand All @@ -408,21 +408,21 @@ let write apis =
(fun page ->
with_output_file page.path
(fun oc ->
print_file_to oc ("doc/static/header.html");
print_file_to oc ("../static/header.html");
output_string oc (Cow.Html.to_string (topbar pages));
let idents, api = Types.resolve_refs_in_api page.api in
output_string oc (to_string idents api);
print_file_to oc ("doc/static/footer.html")
print_file_to oc ("../static/footer.html")
);
) pages;
with_output_file "doc/index.html"
with_output_file "../index.html"
(fun oc ->
index_html oc pages
);
List.iter
(fun placeholder ->
let out_filename = Printf.sprintf "doc/gen/%s" placeholder in
let in_filename = Printf.sprintf "doc/templates/%s.body" placeholder in
let out_filename = Printf.sprintf "%s" placeholder in
let in_filename = Printf.sprintf "../templates/%s.body" placeholder in
with_output_file out_filename
(fun oc ->
placeholder_html oc pages in_filename
Expand All @@ -436,3 +436,11 @@ let write apis =
"learn.html";
"architecture.html";
]

let _ =
let open Types in
let open Files in
let apis = [ Plugin.api; Control.api; Data.api; ] in
(* Prepend the debug_info argument *)
let apis = List.map Types.prepend_dbg apis in
write apis
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2624423

Please sign in to comment.