Skip to content

Commit

Permalink
Port to jbuilder
Browse files Browse the repository at this point in the history
Effects:

- `.merlin` files are auto-generated, allowing editor auto-complete, etc.
- You can develop capnp-ocaml together with a program or library using
  it by simply putting them both in the same jbuilder workspace, without
  having to `opam reinstall` (full rebuild) on each change.
- 320 lines of `OMakefile` are replaced by 102 lines of `jbuild` files.
- Built files go under `_build`, without polluting the source
  directories.

I also copied in the schema files, rather than cloning the entire
capnproto repository. This is much faster, and prevents the build from
breaking when the temporary directory is cleaned.

The new tests/.capnp schema files were imported from https://github.com/kentonv/capnproto.git
commit 25509cf4f1fe6b3f5a6faa2f42b865f7571db8c4.

The new benchmark/.capnp schema files were imported from https://github.com/kentonv/capnproto.git
commit f536c8cfbc749f98e43b679242b24afbab8e74b2.

These were the revisions that the old omake build used.

I also added a `Makefile` that provides a quick way to build, run the
tests, etc, for people not familiar with jbuilder.

Also, I removed the 2.1M gmon.out file, which I assume wasn't supposed
to be there.
  • Loading branch information
Thomas Leonard committed May 23, 2017
1 parent 048f088 commit f1cb585
Show file tree
Hide file tree
Showing 38 changed files with 1,142 additions and 439 deletions.
58 changes: 3 additions & 55 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
*.o
*.a
*.swp
*.swo
*.cmi
*.cmo
*.cmx
*.cma
*.cmxa
*.cmxs
*.byte
*.native
*.opt
.omakedb
.omakedb.lock
*.omc
src/compiler/capnpc-ocaml
src/tests/run-tests
src/tests/run-tests.opt
src/tests/run-tests.run
src/tests/test.mli
src/tests/test.ml
src/tests/.capnp-repo
src/tests/testLists.mli
src/tests/testLists.ml
src/tests/c2b2b.mli
src/tests/c2b2b.ml
src/tests/test_import.mli
src/tests/test_import.ml
src/tests/c2b2b_defun.ml
src/tests/testLists_defun.ml
src/tests/test_defun.ml
src/tests/test_import_defun.ml
src/benchmark/bench
src/benchmark/bench.opt
src/benchmark/bench.run
src/benchmark/.capnp-repo
src/benchmark/c2b2b.mli
src/benchmark/c2b2b.ml
src/benchmark/catrank.mli
src/benchmark/catrank.ml
src/benchmark/carsales.mli
src/benchmark/carsales.ml
src/benchmark/eval.mli
src/benchmark/eval.ml
src/benchmark/carsales
src/benchmark/catrank
src/benchmark/eval
src/compiler/includes.ml
src/benchmark/c2b2b_defun.ml
src/benchmark/carsales_defun.ml
src/benchmark/catrank_defun.ml
src/benchmark/eval_defun.ml
oUnit*.cache
oUnit*.log
_build
.merlin
capnp.install
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
all:
jbuilder build --dev

test:
jbuilder runtest --dev

clean:
rm -rf _build

benchmark:
python src/benchmark/test.py
42 changes: 0 additions & 42 deletions OMakefile

This file was deleted.

4 changes: 0 additions & 4 deletions OMakeroot

This file was deleted.

11 changes: 7 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,16 @@ subdirectories may be helpful to look at.
Installation
------------
capnp-ocaml requires OCaml >= 4.01.
capnp-ocaml requires OCaml >= 4.02.

You should be able to install capnp-ocaml with
http://opam.ocaml.org[OPAM] using using `opam install capnp`.

If you prefer to compile manually, you will need OMake, Findlib, and OCaml
If you prefer to compile manually, you will need jbuilder, Findlib, and OCaml
packages `core_kernel`, `extunix`, `uint`, `ocplib-endian`, and `res`.
Run `omake` to build both the compiler and the runtime library, and then use
`omake install` to copy them into appropriate places within your filesystem.
Run `jbuilder build` to build both the compiler and the runtime library,
and then use `jbuilder install` to copy them into appropriate places within your
filesystem.

Contact
-------
Expand Down Expand Up @@ -579,3 +580,5 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Some of the `.capnp` schema files are imported from the Cap'n Proto repository
and have their own license (at the top of each file).
16 changes: 7 additions & 9 deletions opam → capnp.opam
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ bug-reports: "https://github.com/pelzlpj/capnp-ocaml/issues"
dev-repo: "https://github.com/pelzlpj/capnp-ocaml.git"
author: "Paul Pelzl <pelzlpj@gmail.com>"
maintainer: "Paul Pelzl <pelzlpj@gmail.com>"
build: [["env" "PREFIX=%{prefix}%" "omake"]]
build-test: [
["env" "PREFIX=%{prefix}%" "omake" "src/tests/run-tests"]
[ocaml "./src/tests/run-tests.run"]
]
install: [["env" "PREFIX=%{prefix}%" "omake" "install"]]
remove: [["env" "PREFIX=%{prefix}%" "omake" "uninstall"]]

build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "build" "@runtest" "@src/benchmark/benchmarks"]

depends: [
"omake"
"jbuilder" {build}
"ocamlfind" {>= "1.5.1"}
"core_kernel"
"sexplib" {< "v0.9.0"}
"extunix"
"ocplib-endian" {>= "0.7"}
"res"
"uint"
"core" {test}
]
depexts: [
[["debian"] ["capnproto"]]
[["debian"] ["capnproto" "libcapnp-dev"]]
]
available: [ ocaml-version >= "4.02.0" ]
Empty file added jbuild-workspace.dev
Empty file.
7 changes: 0 additions & 7 deletions src/OMakefile

This file was deleted.

93 changes: 0 additions & 93 deletions src/benchmark/OMakefile

This file was deleted.

80 changes: 80 additions & 0 deletions src/benchmark/carsales.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

using Cxx = import "/capnp/c++.capnp";

@0xff75ddc6a36723c9;
$Cxx.namespace("capnp::benchmark::capnp");

struct ParkingLot {
cars@0: List(Car);
}

struct TotalValue {
amount@0: UInt64;
}

struct Car {
make@0: Text;
model@1: Text;
color@2: Color;
seats@3: UInt8;
doors@4: UInt8;
wheels@5: List(Wheel);
length@6: UInt16;
width@7: UInt16;
height@8: UInt16;
weight@9: UInt32;
engine@10: Engine;
fuelCapacity@11: Float32;
fuelLevel@12: Float32;
hasPowerWindows@13: Bool;
hasPowerSteering@14: Bool;
hasCruiseControl@15: Bool;
cupHolders@16: UInt8;
hasNavSystem@17: Bool;
}

enum Color {
black @0;
white @1;
red @2;
green @3;
blue @4;
cyan @5;
magenta @6;
yellow @7;
silver @8;
}

struct Wheel {
diameter@0: UInt16;
airPressure@1: Float32;
snowTires@2: Bool;
}

struct Engine {
horsepower@0: UInt16;
cylinders@1: UInt8;
cc@2: UInt32;
usesGas@3: Bool;
usesElectric@4: Bool;
}
35 changes: 35 additions & 0 deletions src/benchmark/catrank.capnp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
# Licensed under the MIT License:
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

using Cxx = import "/capnp/c++.capnp";

@0x82beb8e37ff79aba;
$Cxx.namespace("capnp::benchmark::capnp");

struct SearchResultList {
results@0: List(SearchResult);
}

struct SearchResult {
url@0: Text;
score@1: Float64;
snippet@2: Text;
}
Loading

0 comments on commit f1cb585

Please sign in to comment.