diff --git a/.gitignore b/.gitignore index 213ffe7..f0c113d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,5 @@ _build/** *.byte *.install pkg/META - +.merlin /node_modules/ diff --git a/.merlin b/.merlin deleted file mode 100644 index 7893d97..0000000 --- a/.merlin +++ /dev/null @@ -1,6 +0,0 @@ -# This is a Merlin configuration file that enables your editor integration -# https://github.com/ocaml/merlin/wiki/project-configuration - -PKG topkg reason # the OPAM packages -B ./_build/src # built artifacts location -S ./src # source location diff --git a/.travis.yml b/.travis.yml index de5a771..e6dc974 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index 3f2310c..4db0a36 100644 --- a/Makefile +++ b/Makefile @@ -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: @@ -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 diff --git a/opam b/ReasonNativeProject.opam similarity index 85% rename from opam rename to ReasonNativeProject.opam index 5bd3e3b..f82f56f 100644 --- a/opam +++ b/ReasonNativeProject.opam @@ -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" ] diff --git a/_tags b/_tags deleted file mode 100644 index 3a10ef5..0000000 --- a/_tags +++ /dev/null @@ -1 +0,0 @@ -: -traverse diff --git a/bin/jbuild b/bin/jbuild new file mode 100644 index 0000000..26496b0 --- /dev/null +++ b/bin/jbuild @@ -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)))) diff --git a/src/test.re b/bin/test.re similarity index 54% rename from src/test.re rename to bin/test.re index f6f03c9..42c2340 100644 --- a/src/test.re +++ b/bin/test.re @@ -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 \ No newline at end of file diff --git a/internal/GoodValues.re b/internal/GoodValues.re new file mode 100644 index 0000000..1b6893a --- /dev/null +++ b/internal/GoodValues.re @@ -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"; \ No newline at end of file diff --git a/internal/Something.ml b/internal/Something.ml new file mode 100644 index 0000000..44ef0ac --- /dev/null +++ b/internal/Something.ml @@ -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 \ No newline at end of file diff --git a/internal/jbuild b/internal/jbuild new file mode 100644 index 0000000..ffeca5f --- /dev/null +++ b/internal/jbuild @@ -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)))) \ No newline at end of file diff --git a/lib/LifeTheUniverseAndEverything.re b/lib/LifeTheUniverseAndEverything.re new file mode 100644 index 0000000..d912447 --- /dev/null +++ b/lib/LifeTheUniverseAndEverything.re @@ -0,0 +1,3 @@ + +let answer = 42; +let nested = Sub.Nested.value; \ No newline at end of file diff --git a/lib/jbuild b/lib/jbuild new file mode 100644 index 0000000..c3e81a8 --- /dev/null +++ b/lib/jbuild @@ -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)))) \ No newline at end of file diff --git a/lib/sub/Nested.re b/lib/sub/Nested.re new file mode 100644 index 0000000..787d95d --- /dev/null +++ b/lib/sub/Nested.re @@ -0,0 +1,2 @@ + +let value = 34; \ No newline at end of file diff --git a/lib/sub/jbuild b/lib/sub/jbuild new file mode 100644 index 0000000..f40ec04 --- /dev/null +++ b/lib/sub/jbuild @@ -0,0 +1,4 @@ +(jbuild_version 1) + +(library + ((name sub))) diff --git a/pkg/META.in b/pkg/META.in deleted file mode 100644 index f9d0e0e..0000000 --- a/pkg/META.in +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2015-present, Facebook, Inc. All rights reserved. - -version = "%{version}%" -description = "ReasonNativeProject: Example project for Reason" - -archive(byte) = "ReasonNativeProject.cma" -archive(native) = "ReasonNativeProject.cmxa" diff --git a/pkg/build.ml b/pkg/build.ml deleted file mode 100644 index 1188890..0000000 --- a/pkg/build.ml +++ /dev/null @@ -1,17 +0,0 @@ -(* http://erratique.ch/software/topkg/doc/Topkg.html#basics *) - -open Topkg - -let () = - let cmd c os files = - let ocamlbuild = Conf.tool "rebuild" os in - OS.Cmd.run @@ Cmd.(ocamlbuild % "-use-ocamlfind" - %% (v "-I" % "src") - %% of_list files) - in - let build = Pkg.build ~cmd () in - Pkg.describe "ReasonNativeProject" ~build ~change_logs:[] ~licenses:[] ~readmes:[] (fun c -> - Ok [ - Pkg.lib "pkg/META"; - Pkg.bin ~auto:true ~dst:"test" "src/test"; - ]) diff --git a/test-with-version.sh b/test-with-version.sh index 077975f..e6fcef8 100755 --- a/test-with-version.sh +++ b/test-with-version.sh @@ -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 diff --git a/tests/jbuild b/tests/jbuild new file mode 100644 index 0000000..ad047b1 --- /dev/null +++ b/tests/jbuild @@ -0,0 +1,10 @@ +(jbuild_version 1) + +(executable + ((name test) + (libraries (internal)))) + +(alias + ((name runtest) + (deps (test.exe)) + (action (run ${<})))) diff --git a/tests/test.re b/tests/test.re new file mode 100644 index 0000000..6fbaf75 --- /dev/null +++ b/tests/test.re @@ -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(); \ No newline at end of file