Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this project simpler #27

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@ _build/**
*.opt
*.native
*.byte
*.install
pkg/META

/node_modules/
5 changes: 5 additions & 0 deletions META
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version = "0.0.1"
description = "My reason example project."

archive(byte) = "ReasonNativeProject.cma"
archive(native) = "ReasonNativeProject.cmxa"
19 changes: 13 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# 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)."
git push "[email protected]:reasonml/ReasonNativeProject.git"
git push "[email protected]:reasonml/ReasonNativeProject.git" tag $(version)

clean:
ocamlbuild -clean
rm -rf _build ReasonNativeProject.byte

.PHONY: build release
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.
12 changes: 12 additions & 0 deletions ReasonNativeProject.install
Original file line number Diff line number Diff line change
@@ -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"} ]
6 changes: 6 additions & 0 deletions _tags
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
<node_modules>: -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)
22 changes: 8 additions & 14 deletions opam
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
opam-version: "1.2"
name: "ReasonNativeProject"
version: "0.0.1"
maintainer: "Jordan Walke <[email protected]>"
authors: [
"Jordan Walke <[email protected]>"
"Maxwell Bernstein <[email protected]>"
]
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 <[email protected]>"
authors: [ "FirstName LastName <[email protected]>" ]
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" ]
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "ReasonNativeProject",
"version": "0.0.1",
"description": "My reason example project.",
"author": "FirstName LastName <[email protected]>",
"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"
}
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.

1 change: 0 additions & 1 deletion src/test.re → src/ReasonNativeProject.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ let msg = "Hello Reason!";
print_string msg;
print_newline ();
print_string "!!!!!!\n";

4 changes: 2 additions & 2 deletions test-with-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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