M Makefile => Makefile +2 -2
@@ 11,7 11,7 @@ lib/res.ml: res res/doap.rdf res/doap2html.xslt
# opam install ocp-ocamlres
ocp-ocamlres -format ocaml $< -o $@
-$(dst): _build/default/bin/geohash.exe
+$(dst): _build/default/bin/main.exe
cp $< $@
chmod u+w $@
strip $@
@@ 28,7 28,7 @@ test/assert.ml:
build: lib/res.ml
@echo "let git_sha = \""`git rev-parse --short HEAD`"\"" > bin/version.ml
- dune build bin/geohash.exe
+ dune build bin/main.exe
all: build
M bin/cgi.ml => bin/cgi.ml +2 -2
@@ 26,7 26,7 @@ open Lib.Cgi
let handle_hash oc req =
match req.path_info |> String.split_on_char '/' with
| [ ""; hash ] -> (
- match Lib.Geohash.decode hash with
+ match Geohash.decode hash with
| Error _ -> error oc 406 "Cannot decode hash."
| Ok ((lat, lon), (dlat, dlon)) ->
let mime = "text/xml"
@@ 87,7 87,7 @@ let handle oc req =
|> max 2
|> min 12
in
- match co |> Lib.Geohash.encode prec with
+ match co |> Geohash.encode prec with
| Error _ -> error oc 406 "Cannot encode coords."
| Ok hash -> hash |> redirect oc)))
| _ -> handle_hash oc req)
M bin/dune => bin/dune +3 -31
@@ 3,35 3,7 @@
; https://stackoverflow.com/a/53325230/349514
(executable
- (name geohash)
- (libraries Lib)
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; Prepare for static linking
-;
-; http://rgrinberg.com/posts/static-binaries-tutorial/
-; https://discuss.ocaml.org/t/statically-link/1464/9
-; Issue https://discuss.ocaml.org/t/statically-link/1464/13
-; https://www.systutorials.com/how-to-statically-link-ocaml-programs/
-;
-; $ date
-; Tue Mar 24 11:36:40 CET 2020
-; $ uname -o -m
-; x86_64 GNU/Linux
-; $ cat /etc/issue
-; Devuan GNU/Linux 1 \n \l
-;
-; # on Ubuntu Bionic note
-; # https://github.com/ocaml/ocaml/issues/9131#issuecomment-599765888
-; $ sudo add-apt-repository ppa:avsm/musl
-;
-; $ sudo apt-get install musl-tools
-; $ eval (opam env)
-; $ opam switch create 4.10.0+musl+static+flambda
-; $ opam switch 4.10.0+musl+static+flambda
-; $ eval (opam env)
-; $ opam install dune
-; $ make clean build
-; $ file _build/default/bin/*.exe
-; _build/default/bin/meta.exe: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
- (link_flags (:include link_flags.sexp))
+ (name main)
+ (libraries lib)
+ ; (link_flags (:include link_flags.sexp))
)
R bin/geohash.ml => bin/main.ml +1 -1
@@ 1,5 1,5 @@
(*
- * geohash.ml
+ * main.ml
*
* Created by Marcus Rohrmoser on 16.05.20.
* Copyright © 2020-2021 Marcus Rohrmoser mobile Software http://mro.name/~me. All rights reserved.
M doc/dune => doc/dune +1 -1
@@ 1,1 1,1 @@
-(documentation (package geohash))>
\ No newline at end of file
+(documentation (package geohash_bin))
M dune-project => dune-project +14 -4
@@ 1,4 1,4 @@
-(lang dune 2.7)
+(lang dune 2.8)
; https://dune.readthedocs.io/en/latest/opam.html#generating-opam-files
(name geohash)
@@ 16,10 16,9 @@
(package
(name geohash)
- (synopsis "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file.")
+ (synopsis "#🌐 geohash converter 🐫 library.")
(description "Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
-[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
-statically linked, single-file, zero-config.")
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back.")
(tags (Social Web GeoHash CGI RFC3875))
(depends
(optint (>= 0.3))
@@ 27,3 26,14 @@ statically linked, single-file, zero-config.")
(odoc :with-doc)
(ocaml (and (>= 4.05) (< 4.12)))
))
+
+(package
+ (name geohash_bin)
+ (synopsis "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file.")
+ (description "Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
+statically linked, single-file, zero-config.")
+ (tags (Social Web GeoHash CGI RFC3875))
+ (depends
+ ocp-ocamlres
+))
M geohash.opam => geohash.opam +5 -7
@@ 1,11 1,9 @@
# This file is generated by dune, edit dune-project instead
opam-version: "2.0"
-synopsis:
- "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file."
+synopsis: "#🌐 geohash converter 🐫 library."
description: """
Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
-[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
-statically linked, single-file, zero-config."""
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back."""
maintainer: ["Marcus Rohrmoser <work@mro.name>"]
authors: ["The GeoHash# programmers"]
license: "GPLv3"
@@ 13,9 11,9 @@ tags: ["Social" "Web" "GeoHash" "CGI" "RFC3875"]
homepage: "https://demo.mro.name/geohash.cgi"
bug-reports: "https://codeberg.org/mro/geohash/issues"
depends: [
- "dune" {>= "2.7"}
- "optint" {>= "1.0"}
- "tyre"
+ "dune" {>= "2.8"}
+ "optint" {>= "0.3"}
+ "tyre" {>= "0.5"}
"odoc" {with-doc}
"ocaml" {>= "4.05" & < "4.12"}
]
A geohash_bin.opam => geohash_bin.opam +34 -0
@@ 0,0 1,34 @@
+# This file is generated by dune, edit dune-project instead
+opam-version: "2.0"
+synopsis:
+ "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file."
+description: """
+Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
+statically linked, single-file, zero-config."""
+maintainer: ["Marcus Rohrmoser <work@mro.name>"]
+authors: ["The GeoHash# programmers"]
+license: "GPLv3"
+tags: ["Social" "Web" "GeoHash" "CGI" "RFC3875"]
+homepage: "https://demo.mro.name/geohash.cgi"
+bug-reports: "https://codeberg.org/mro/geohash/issues"
+depends: [
+ "dune" {>= "2.8"}
+ "ocp-ocamlres"
+ "odoc" {with-doc}
+]
+build: [
+ ["dune" "subst"] {dev}
+ [
+ "dune"
+ "build"
+ "-p"
+ name
+ "-j"
+ jobs
+ "@install"
+ "@runtest" {with-test}
+ "@doc" {with-doc}
+ ]
+]
+dev-repo: "git+ssh://codeberg.org/mro/geohash.git"
M lib/dune => lib/dune +2 -11
@@ 1,17 1,8 @@
(library
- (name Lib)
+ (name lib)
(libraries
tyre
optint
)
+ (public_name geohash.whitebox)
)
-
-;(rule
-; (target version.ml)
-; (action
-; (with-stdout-to %{target}
-; (echo "let git_sha = \"foo")
-; (run git rev-parse --short HEAD)
-; (echo "bar\"")
-; ))
-; )
A public/dune => public/dune +5 -0
@@ 0,0 1,5 @@
+(library
+ (name geohash)
+ (libraries lib)
+ (public_name geohash)
+)
A public/geohash.ml => public/geohash.ml +1 -0
@@ 0,0 1,1 @@
+include Lib.Geohash
R lib/geohash.mli => public/geohash.mli +1 -1
@@ 6,4 6,4 @@
val encode : int -> (float * float) -> (string, int) result
(** decode a geohash base32 string to a WGS84 coordinate region center,delta. *)
- val decode : string -> (((float * float) * (float * float)), string) result
+ val decode : string -> (((float * float) * (float * float)), char) result
M test/dune => test/dune +1 -1
@@ 5,4 5,4 @@
cgi_test
route_test
)
- (libraries Lib))
+ (libraries lib))