diff --git a/.gitignore b/.gitignore index 213ffe7..ecfa9e7 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,5 @@ _build/** *.opt *.native *.byte -*.install -pkg/META /node_modules/ diff --git a/META b/META new file mode 100644 index 0000000..ff75b28 --- /dev/null +++ b/META @@ -0,0 +1,5 @@ +version = "0.0.1" +description = "My reason example project." + +archive(byte) = "ReasonNativeProject.cma" +archive(native) = "ReasonNativeProject.cmxa" diff --git a/Makefile b/Makefile index 3f2310c..731be11 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,19 @@ -# topkg (https://github.com/dbuenzli/topkg) is a small native packager for your lib -# http://erratique.ch/software/topkg/doc/Topkg.html#basics +# This example project uses rebuild, which is a simple wrapper around +# ocamlbuild. +# Docs: https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc + +all: byte library + +byte: + rebuild -use-ocamlfind src/ReasonNativeProject.byte + build: - cp pkg/META.in pkg/META - ocamlbuild -package topkg pkg/build.native - ./build.native build + rebuild -use-ocamlfind src/ReasonNativeProject.cma + rebuild -use-ocamlfind src/ReasonNativeProject.cmxa # some boilerplate to publish a new version to GitHub release: + opam_of_packagejson.exe -gen-meta -gen-opam -gen-install package.json git add package.json opam git commit -m "Version $(version)" git tag -a $(version) -m "Version $(version)." @@ -14,6 +21,6 @@ release: git push "git@github.com:reasonml/ReasonNativeProject.git" tag $(version) clean: - ocamlbuild -clean + rm -rf _build ReasonNativeProject.byte .PHONY: build release diff --git a/README.md b/README.md index 9722c61..4e56e86 100644 --- a/README.md +++ b/README.md @@ -30,33 +30,25 @@ make clean # clean the compiled artifacts A single test file `./src/test.re` is included. Make a simple change to it and then run the commands above to see it effect the output. -The built output is in `_build`. Try running it with `_build/src/test.native`. +The built output is in `_build` but the final binary is symlinked `_build/src/index.native -> index.native`. ## Developing Your Project -`ReasonNativeProject` is meant to be the starting point of your own project. You'll -want to make use of existing libraries in your app, so browse the growing set -of `opam` packages in the [opam repository](http://opam.ocaml.org/packages/). +`ReasonNativeProject` is meant to be the starting point of your own project. You'll want to make use of existing libraries in your app, so browse the growing set of `opam` packages in the [opam repository](http://opam.ocaml.org/packages/). ##### Add Another Dependency -Edit your `opam` file so that you depend on a particular opam package and range -of versions. +While developing you can simply modify the `_tags` file which is what `rebuild uses to figure out what you depend on. See inside that file for more instructions. -In addition you may have to tweak the buildstep to recognize the dependency, by changing `build.ml` within the `pkg` folder. and add the following for you dependency: -```ocaml -... -OS.Cmd.run @@ Cmd.( - ocamlbuild % "-use-ocamlfind" - %% (v "-I" % "src") - %% (v "-pkg" % "[PACKAGE]") (* <---- only change is this line*) - %% of_list files) -... -``` +##### Releasing + +Before publishing onto all you'll need to do is run `make release` to generate all of the files necessary for opam. Then you can follow the steps [here](https://opam.ocaml.org/doc/Packaging.html#GettingafullOPAMpackage). + +If you've added extra opam dependencies you'll need to update the package.json under `opam > dependencies`. You can see all of the possible fields you can tweak on the [opam_of_packagejson](https://github.com/bsansouci/opam_of_packagejson) github. Finally For your editor to pick up the dependency and fancy autocomplete etc. make sure to add the package in your `.merlin` file: ```ocaml -PKG topkg reason [PACKAGE] +PKG reason [PACKAGE] ``` ### Creating Libraries @@ -65,6 +57,4 @@ See the [OPAM instructions](https://opam.ocaml.org/doc/Packaging.html). ## Troubleshooting -In general, if something goes wrong, try upgrading your install of the project -by running `opam upgrade ReasonNativeProject`, or if it failed to install and you -later fixed it, `opam install ReasonNativeProject`. +In general, if something goes wrong, try upgrading your install of the project by running `opam upgrade ReasonNativeProject`, or if it failed to install and you later fixed it, `opam install ReasonNativeProject`. diff --git a/ReasonNativeProject.install b/ReasonNativeProject.install new file mode 100644 index 0000000..c1c789b --- /dev/null +++ b/ReasonNativeProject.install @@ -0,0 +1,12 @@ +# ReasonNativeProject + +lib: [ + "./META" {"META"} + "./opam" {"opam"} + "_build/src/ReasonNativeProject.a" {"ReasonNativeProject.a"} + "_build/src/ReasonNativeProject.cma" {"ReasonNativeProject.cma"} + "_build/src/ReasonNativeProject.cmi" {"ReasonNativeProject.cmi"} + "_build/src/ReasonNativeProject.cmo" {"ReasonNativeProject.cmo"} + "_build/src/ReasonNativeProject.cmx" {"ReasonNativeProject.cmx"} + "_build/src/ReasonNativeProject.cmxa" {"ReasonNativeProject.cmxa"} + "_build/src/ReasonNativeProject.o" {"ReasonNativeProject.o"} ] diff --git a/_tags b/_tags index 3a10ef5..e1a8030 100644 --- a/_tags +++ b/_tags @@ -1 +1,7 @@ : -traverse + + +# To add opam dependencies you can comment out the line below and list however +# many deps like: package(unix), package(lwt), package(whateverelse) +# +# true: package(unix) diff --git a/opam b/opam index 5bd3e3b..ba7bde9 100644 --- a/opam +++ b/opam @@ -1,23 +1,17 @@ opam-version: "1.2" name: "ReasonNativeProject" version: "0.0.1" -maintainer: "Jordan Walke " -authors: [ - "Jordan Walke " - "Maxwell Bernstein " -] license: "BSD" +dev-repo: "https://github.com/reasonml/ReasonNativeProject.git" homepage: "https://github.com/reasonml/ReasonNativeProject" -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"] -] +maintainer: "FirstName LastName " +authors: [ "FirstName LastName " ] depends: [ - "topkg" {>= "0.8.1" & < "0.9"} - "reason" {= "1.13.3"} + "opam_of_packagejson" { build & >= "0.1.2" } + "reason" { build & >= "1.13.3" } +] +build: [ + [ make "build" ] ] available: [ ocaml-version >= "4.02" & ocaml-version < "4.05" ] diff --git a/package.json b/package.json new file mode 100644 index 0000000..ebc2794 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "ReasonNativeProject", + "version": "0.0.1", + "description": "My reason example project.", + "author": "FirstName LastName ", + "repository": { + "type": "git", + "url": "https://github.com/reasonml/ReasonNativeProject.git" + }, + "scripts": { + "release": "make release" + }, + "opam": { + "dependencies": { + "reason": "build & >= \"1.13.3\"", + "opam_of_packagejson": "build & >= \"0.1.2\"" + } + }, + "license": "BSD" +} 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/src/test.re b/src/ReasonNativeProject.re similarity index 99% rename from src/test.re rename to src/ReasonNativeProject.re index f6f03c9..9b7fc28 100644 --- a/src/test.re +++ b/src/ReasonNativeProject.re @@ -6,4 +6,3 @@ let msg = "Hello Reason!"; print_string msg; print_newline (); print_string "!!!!!!\n"; - diff --git a/test-with-version.sh b/test-with-version.sh index 077975f..6a5c966 100755 --- a/test-with-version.sh +++ b/test-with-version.sh @@ -9,6 +9,6 @@ opam switch "${OCAML_VERSION}" eval `opam config env` opam update opam pin add -y ReasonNativeProject . -make -./test.native +make byte +./ReasonNativeProject.byte git diff --exit-code