From cf55d654a4974c361dd0668d8da76910e79457db Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 12:01:45 -0700 Subject: [PATCH 01/11] Update example project to be simpler. No need for topkg and ocamlbuild and ocamlfind. I mean you do need them but for the user they're just calling `rebuild`. --- Makefile | 12 ++++++------ _tags | 6 ++++++ pkg/META.in | 7 ------- pkg/build.ml | 17 ----------------- src/{test.re => index.re} | 1 - 5 files changed, 12 insertions(+), 31 deletions(-) delete mode 100644 pkg/META.in delete mode 100644 pkg/build.ml rename src/{test.re => index.re} (99%) diff --git a/Makefile b/Makefile index 3f2310c..93545ab 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -# 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 + build: - cp pkg/META.in pkg/META - ocamlbuild -package topkg pkg/build.native - ./build.native build + rebuild -use-ocamlfind src/index.native # some boilerplate to publish a new version to GitHub release: @@ -14,6 +14,6 @@ release: git push "git@github.com:reasonml/ReasonNativeProject.git" tag $(version) clean: - ocamlbuild -clean + rm -rf _build .PHONY: build release 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/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/index.re similarity index 99% rename from src/test.re rename to src/index.re index f6f03c9..9b7fc28 100644 --- a/src/test.re +++ b/src/index.re @@ -6,4 +6,3 @@ let msg = "Hello Reason!"; print_string msg; print_newline (); print_string "!!!!!!\n"; - From 3975032e86567aa82d4ba2460809c581a0eae026 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 12:04:12 -0700 Subject: [PATCH 02/11] Update clean --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 93545ab..3d8321c 100644 --- a/Makefile +++ b/Makefile @@ -15,5 +15,6 @@ release: clean: rm -rf _build + rm index.native .PHONY: build release From 7dbeaeb6b3cdfaf8ec386afb1fd4a21e20e19240 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 12:10:57 -0700 Subject: [PATCH 03/11] Update readme. --- README.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9722c61..861c347 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,17 @@ 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. + +Before publishing onto opam you'll need to edit your `opam` file so that you depend on a particular opam package and range of versions. 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 @@ -65,6 +64,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`. From 4195c848d1f00f35383977217c921d7e201aaf07 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 18:13:25 -0700 Subject: [PATCH 04/11] Fix opam file, hopefully this makes travis happy. --- opam | 1 - 1 file changed, 1 deletion(-) diff --git a/opam b/opam index 5bd3e3b..1ab7818 100644 --- a/opam +++ b/opam @@ -12,7 +12,6 @@ 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"] ] From 3b0381c859d85f0c2e7d2baf680e44c54a2a03b4 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 18:20:15 -0700 Subject: [PATCH 05/11] Commit .install file to make opam happy. --- .gitignore | 2 -- ReasonNativeProject.install | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 ReasonNativeProject.install 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/ReasonNativeProject.install b/ReasonNativeProject.install new file mode 100644 index 0000000..e2f6d09 --- /dev/null +++ b/ReasonNativeProject.install @@ -0,0 +1,4 @@ +# ReasonNativeProject + +bin: [ + "_build/src/index.native" {"index"} ] From 48f3a77fa8b1a8483e706654c49cf319d0af42e6 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 22:49:11 -0700 Subject: [PATCH 06/11] Fixes for Travis. --- Makefile | 3 +-- test-with-version.sh | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3d8321c..beabcda 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,6 @@ release: git push "git@github.com:reasonml/ReasonNativeProject.git" tag $(version) clean: - rm -rf _build - rm index.native + rm -rf _build index.native .PHONY: build release diff --git a/test-with-version.sh b/test-with-version.sh index 077975f..9cdba16 100755 --- a/test-with-version.sh +++ b/test-with-version.sh @@ -10,5 +10,5 @@ eval `opam config env` opam update opam pin add -y ReasonNativeProject . make -./test.native +./index.native git diff --exit-code From 3138e0fc7ab4b411b99bb9c5f9e2fc7bcc03f7ae Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 15 Apr 2017 22:49:49 -0700 Subject: [PATCH 07/11] No need to depend on topkg anymore! :) --- opam | 1 - 1 file changed, 1 deletion(-) diff --git a/opam b/opam index 1ab7818..400ce9f 100644 --- a/opam +++ b/opam @@ -16,7 +16,6 @@ build: [ [make "build"] ] depends: [ - "topkg" {>= "0.8.1" & < "0.9"} "reason" {= "1.13.3"} ] available: [ ocaml-version >= "4.02" & ocaml-version < "4.05" ] From 7c780629e5f9e690521268415649a61be3164b84 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Tue, 16 May 2017 22:03:09 -0700 Subject: [PATCH 08/11] Depend on opam_of_packagejson. --- META | 5 +++++ ReasonNativeProject.install | 12 ++++++++++-- opam | 21 ++++++--------------- package.json | 21 +++++++++++++++++++++ 4 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 META create mode 100644 package.json 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/ReasonNativeProject.install b/ReasonNativeProject.install index e2f6d09..c1c789b 100644 --- a/ReasonNativeProject.install +++ b/ReasonNativeProject.install @@ -1,4 +1,12 @@ # ReasonNativeProject -bin: [ - "_build/src/index.native" {"index"} ] +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/opam b/opam index 400ce9f..7309d21 100644 --- a/opam +++ b/opam @@ -1,21 +1,12 @@ opam-version: "1.2" -name: "ReasonNativeProject" version: "0.0.1" -maintainer: "Jordan Walke " -authors: [ - "Jordan Walke " - "Maxwell Bernstein " +dev-repo: "https://github.com/reasonml/ReasonNativeProject.git" +maintainer: "FirstName LastName " +authors: [ "FirstName LastName " ] +depends: [ + "reason" { build & >= "1.13.3" } ] -license: "BSD" -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" ] build: [ - [make "build"] -] -depends: [ - "reason" {= "1.13.3"} + [ 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..4b0a2ca --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "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": "opam_of_packagejson -gen-meta -gen-opam -gen-install package.json && opam publish" + }, + "devDependencies": { + "opam_of_packagejson": "*" + }, + "opam": { + "dependencies": { + "reason": "build & >= \"1.13.3\"" + } + } +} From d09833342d3e15dafa35b0a3bca60de55c4068db Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Tue, 16 May 2017 22:07:29 -0700 Subject: [PATCH 09/11] Add license. --- opam | 1 + package.json | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/opam b/opam index 7309d21..8bb4dba 100644 --- a/opam +++ b/opam @@ -1,5 +1,6 @@ opam-version: "1.2" version: "0.0.1" +license: "BSD" dev-repo: "https://github.com/reasonml/ReasonNativeProject.git" maintainer: "FirstName LastName " authors: [ "FirstName LastName " ] diff --git a/package.json b/package.json index 4b0a2ca..fe8566f 100644 --- a/package.json +++ b/package.json @@ -17,5 +17,6 @@ "dependencies": { "reason": "build & >= \"1.13.3\"" } - } + }, + "license": "BSD" } From 28ddebe81402436ddc8aac318f40816cab599239 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 20 May 2017 00:51:40 -0700 Subject: [PATCH 10/11] One last update. --- Makefile | 1 + README.md | 17 +++++------------ opam | 4 ++++ package.json | 8 +++----- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index beabcda..01afb95 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ build: # 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)." diff --git a/README.md b/README.md index 861c347..4e56e86 100644 --- a/README.md +++ b/README.md @@ -40,22 +40,15 @@ The built output is in `_build` but the final binary is symlinked `_build/src/in 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. -Before publishing onto opam you'll need to edit your `opam` file so that you depend on a particular opam package and range of versions. +##### Releasing -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) -... -``` +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 diff --git a/opam b/opam index 8bb4dba..ba7bde9 100644 --- a/opam +++ b/opam @@ -1,10 +1,14 @@ opam-version: "1.2" +name: "ReasonNativeProject" version: "0.0.1" license: "BSD" dev-repo: "https://github.com/reasonml/ReasonNativeProject.git" +homepage: "https://github.com/reasonml/ReasonNativeProject" +bug-reports: "https://github.com/reasonml/ReasonNativeProject/issues" maintainer: "FirstName LastName " authors: [ "FirstName LastName " ] depends: [ + "opam_of_packagejson" { build & >= "0.1.2" } "reason" { build & >= "1.13.3" } ] build: [ diff --git a/package.json b/package.json index fe8566f..ebc2794 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,12 @@ "url": "https://github.com/reasonml/ReasonNativeProject.git" }, "scripts": { - "release": "opam_of_packagejson -gen-meta -gen-opam -gen-install package.json && opam publish" - }, - "devDependencies": { - "opam_of_packagejson": "*" + "release": "make release" }, "opam": { "dependencies": { - "reason": "build & >= \"1.13.3\"" + "reason": "build & >= \"1.13.3\"", + "opam_of_packagejson": "build & >= \"0.1.2\"" } }, "license": "BSD" From a2952b9d069b0d5e8668994abf909cbaee0652d8 Mon Sep 17 00:00:00 2001 From: Benjamin San Souci Date: Sat, 20 May 2017 01:47:04 -0700 Subject: [PATCH 11/11] Fix build. --- Makefile | 10 ++++++++-- src/{index.re => ReasonNativeProject.re} | 0 test-with-version.sh | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) rename src/{index.re => ReasonNativeProject.re} (100%) diff --git a/Makefile b/Makefile index 01afb95..731be11 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,14 @@ # ocamlbuild. # Docs: https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc +all: byte library + +byte: + rebuild -use-ocamlfind src/ReasonNativeProject.byte + build: - rebuild -use-ocamlfind src/index.native + rebuild -use-ocamlfind src/ReasonNativeProject.cma + rebuild -use-ocamlfind src/ReasonNativeProject.cmxa # some boilerplate to publish a new version to GitHub release: @@ -15,6 +21,6 @@ release: git push "git@github.com:reasonml/ReasonNativeProject.git" tag $(version) clean: - rm -rf _build index.native + rm -rf _build ReasonNativeProject.byte .PHONY: build release diff --git a/src/index.re b/src/ReasonNativeProject.re similarity index 100% rename from src/index.re rename to src/ReasonNativeProject.re diff --git a/test-with-version.sh b/test-with-version.sh index 9cdba16..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 -./index.native +make byte +./ReasonNativeProject.byte git diff --exit-code