diff --git a/example/jbuild b/example/jbuild index a1fd8a54..879b1ad5 100644 --- a/example/jbuild +++ b/example/jbuild @@ -15,7 +15,7 @@ let gen_example example = (deps ((files_recursively_in %s))) (action (chdir %s - (run ${exe:../test/run.exe} -- ${bin:jbuilder} build -j1 --root . @install))))) + (run ${exe:../test/run.exe} -- ${bin:jbuilder} build -j1 --root . @install @runtest))))) |} dir dir diff --git a/example/sample-projects/hello_world/README.org b/example/sample-projects/hello_world/README.org new file mode 100644 index 00000000..168132f0 --- /dev/null +++ b/example/sample-projects/hello_world/README.org @@ -0,0 +1,22 @@ +This project is called =hello_world=. It defines one library called +=hello_world= and one executable called =hello_world=. + +The library is defined in =lib= and the executable in =bin=. It also +defines a test in =test=. + +At the toplevel of the project, there is a =hello_world.opam= +file. This file is required so that =jbuilder= knows that this is the +=hello_world= project. + +To build everything that is meant to be installed in this project, +type: + +#+begin_src +$ jbuilder build @install +#+end_src + +To run the tests, type: + +#+begin_src +$ jbuilder runtest +#+end_src diff --git a/example/sample-projects/hello_world/bin/jbuild b/example/sample-projects/hello_world/bin/jbuild new file mode 100644 index 00000000..9c7439fb --- /dev/null +++ b/example/sample-projects/hello_world/bin/jbuild @@ -0,0 +1,9 @@ +(jbuild_version 1) + +(executables + ((names (main)) + (libraries (hello_world)))) + +(install + ((section bin) + (files ((main.exe as hello_world))))) diff --git a/example/sample-projects/hello_world/bin/main.ml b/example/sample-projects/hello_world/bin/main.ml new file mode 100644 index 00000000..4ea06ed5 --- /dev/null +++ b/example/sample-projects/hello_world/bin/main.ml @@ -0,0 +1 @@ +let () = print_endline Hello_world.message diff --git a/example/sample-projects/hello_world/hello_world.opam b/example/sample-projects/hello_world/hello_world.opam new file mode 100644 index 00000000..21efae0f --- /dev/null +++ b/example/sample-projects/hello_world/hello_world.opam @@ -0,0 +1,11 @@ +opam-version: "1.2" +version: "1.0" +maintainer: "bob@sponge.com" +authors: ["SpongeBob"] +homepage: "https://github.com/SpongeBob/hello_world" +bug-reports: "https://github.com/SpongeCob/hello_world/issues" +dev-repo: "https://github.com/SpongeBob/hello_world.git" +license: "Apache-2.0" +build: [ + ["jbuilder" "build" "--only" "hello_world" "--root" "." "-j" jobs "@install"] +] diff --git a/example/sample-projects/hello_world/lib/hello_world.ml b/example/sample-projects/hello_world/lib/hello_world.ml new file mode 100644 index 00000000..e9066706 --- /dev/null +++ b/example/sample-projects/hello_world/lib/hello_world.ml @@ -0,0 +1 @@ +let message = "Hello, world!" diff --git a/example/sample-projects/hello_world/lib/jbuild b/example/sample-projects/hello_world/lib/jbuild new file mode 100644 index 00000000..f3ebcb4c --- /dev/null +++ b/example/sample-projects/hello_world/lib/jbuild @@ -0,0 +1,5 @@ +(jbuild_version 1) + +(library + ((name hello_world) + (public_name hello_world))) diff --git a/example/sample-projects/hello_world/test/hello_world.expected b/example/sample-projects/hello_world/test/hello_world.expected new file mode 100644 index 00000000..af5626b4 --- /dev/null +++ b/example/sample-projects/hello_world/test/hello_world.expected @@ -0,0 +1 @@ +Hello, world! diff --git a/example/sample-projects/hello_world/test/jbuild b/example/sample-projects/hello_world/test/jbuild new file mode 100644 index 00000000..9bcfc37f --- /dev/null +++ b/example/sample-projects/hello_world/test/jbuild @@ -0,0 +1,9 @@ +(jbuild_version 1) + +(rule + ((targets (hello_world.output)) + (action (with-stdout-to ${@} (run ${bin:hello_world}))))) + +(alias + ((name runtest) + (action (run diff -u ${path:hello_world.expected} ${path:hello_world.output}))))