Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ _build/**
*.byte
*.install
pkg/META

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

This file was deleted.

3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ before_install:
- opam switch "$OCAML_VERSION"
- eval `opam config env`
- opam update
- opam install -y re
before_script:
- opam pin add -y ReasonNativeProject .
script:
- ./test-with-version.sh "$OCAML_VERSION"
- make run
- git diff --exit-code
env:
- OCAML_VERSION=4.02.3
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# topkg (https://github.com/dbuenzli/topkg) is a small native packager for your lib
# http://erratique.ch/software/topkg/doc/Topkg.html#basics
build:
cp pkg/META.in pkg/META
ocamlbuild -package topkg pkg/build.native
./build.native build
jbuilder build

run: build
./_build/install/default/bin/reason-native-bin

test:
jbuilder runtest

# some boilerplate to publish a new version to GitHub
release:
Expand All @@ -14,6 +16,6 @@ release:
git push "git@github.com:reasonml/ReasonNativeProject.git" tag $(version)

clean:
ocamlbuild -clean
rm -rf _build *.install

.PHONY: build release
.PHONY: build release test
7 changes: 3 additions & 4 deletions opam → ReasonNativeProject.opam
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ doc: "https://reasonml.github.io/ReasonNativeProject/"
bug-reports: "https://github.com/reasonml/ReasonNativeProject/issues"
dev-repo: "git://github.com/reasonml/ReasonNativeProject.git"
tags: [ "reason" "example" ]
substs: [ "pkg/META" ]
build: [
[make "build"]
["jbuilder" "build" "-p" name "-j" jobs]
]
depends: [
"topkg" {>= "0.8.1" & < "0.9"}
"reason" {= "1.13.3"}
"jbuilder" {build}
"reason" {= "2.0.0"}
]
available: [ ocaml-version >= "4.02" & ocaml-version < "4.05" ]
1 change: 0 additions & 1 deletion _tags

This file was deleted.

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

(executable
((name test)
; This will be installable as a global binary
(public_name reason-native-bin)
; and it depends on 2 local libraries
(libraries (lib internal))))
3 changes: 3 additions & 0 deletions src/test.re → bin/test.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ let msg = "Hello Reason!";
print_string msg;
print_newline ();
print_string "!!!!!!\n";
print_endline Internal.GoodValues.message;

let a = Lib.LifeTheUniverseAndEverything.answer;
Printf.printf "Answer: %d\n" a
6 changes: 6 additions & 0 deletions internal/GoodValues.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

/* Getting a value from another module within this directory */
let message = "value from " ^ (Something.format);

/* Getting a value from an external library (specified in jbuild) */
let rx = Re.str "hello";
7 changes: 7 additions & 0 deletions internal/Something.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

(* we can have ocaml as well as reason sources *)
let opt = Re.opt

let format = "OCaml"

let calculate x = x * 2
9 changes: 9 additions & 0 deletions internal/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(jbuild_version 1)

;; why is this lib internal?
;; because it doesn't have a public_name
;; so it won't be exposed to opam as an
;; installable/distributable library
(library
((name internal)
(libraries (re))))
3 changes: 3 additions & 0 deletions lib/LifeTheUniverseAndEverything.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

let answer = 42;
let nested = Sub.Nested.value;
7 changes: 7 additions & 0 deletions lib/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(jbuild_version 1)

(library
((name lib)
; this will be exported & installable as a library via OPAM
(public_name ReasonNativeProject)
(libraries (re sub))))
2 changes: 2 additions & 0 deletions lib/sub/Nested.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

let value = 34;
4 changes: 4 additions & 0 deletions lib/sub/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(jbuild_version 1)

(library
((name sub)))
7 changes: 0 additions & 7 deletions pkg/META.in

This file was deleted.

17 changes: 0 additions & 17 deletions pkg/build.ml

This file was deleted.

4 changes: 2 additions & 2 deletions test-with-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ make clean
opam switch "${OCAML_VERSION}"
eval `opam config env`
opam update
opam install -y re
opam pin add -y ReasonNativeProject .
make
./test.native
make run
git diff --exit-code
10 changes: 10 additions & 0 deletions tests/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(jbuild_version 1)

(executable
((name test)
(libraries (internal))))

(alias
((name runtest)
(deps (test.exe))
(action (run ${<}))))
13 changes: 13 additions & 0 deletions tests/test.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

let res = Internal.Something.calculate 4;
let main () => {
if (Internal.Something.calculate 4 != 8) {
print_endline "Test failure!!";
exit 1;
} else {
print_endline "Tests passed";
exit 0;
}
};

main();