Skip to content
Permalink
Browse files

Replace configure bash script by ocaml script

  • Loading branch information
sagotch committed Nov 26, 2019
1 parent c24d2c4 commit d5d5a4bd2aabc2bf709604c472a0eff91e6e5d23
Showing with 115 additions and 145 deletions.
  1. +7 −7 Makefile
  2. +2 −2 README.md
  3. +0 −132 configure
  4. +100 −0 configure.ml
  5. +1 −1 geneweb-api.opam
  6. +4 −2 geneweb-bin.opam
  7. +1 −1 geneweb.opam
@@ -1,9 +1,9 @@
ifneq ($(MAKECMDGOALS),ci)
Makefile.config: configure
Makefile.config: configure.ml
@if [ -e "$@" ]; then \
echo "configure file has changed. Please rerun ./configure"; exit 1; \
echo "configure file has changed. Please rerun ocaml ./configure.ml"; exit 1; \
else \
echo "Please run ./configure first"; exit 1; \
echo "Please run ocaml ./configure.ml first"; exit 1; \
fi
include Makefile.config
endif
@@ -231,11 +231,11 @@ clean:


ci:
@./configure && BENCH_NAME=vanilla $(MAKE) -s clean test bench-marshal clean
@./configure --sosa-num && BENCH_NAME=num $(MAKE) -s clean test bench-marshal clean
@./configure --sosa-zarith && BENCH_NAME=zarith $(MAKE) -s clean test bench-marshal clean
@ocaml ./configure.ml && BENCH_NAME=vanilla $(MAKE) -s clean test bench-marshal clean
@ocaml ./configure.ml --sosa-num && BENCH_NAME=num $(MAKE) -s clean test bench-marshal clean
@ocaml ./configure.ml --sosa-zarith && BENCH_NAME=zarith $(MAKE) -s clean test bench-marshal clean
ifndef OS
@./configure --api && BENCH_NAME=api $(MAKE) -s clean bench-marshal test clean
@ocaml ./configure.ml --api && BENCH_NAME=api $(MAKE) -s clean bench-marshal test clean
endif
@$(MAKE) -s bench-tabulate
.PHONY: ci
@@ -66,7 +66,7 @@ $ opam install camlp5 cppo dune markup ounit

1. Run the configuration script
```
$ ./configure
$ ocaml ./configure.ml
```
2. Build the distibution
```
@@ -88,7 +88,7 @@ $ opam install ocurl piqi piqilib redis redis-sync yojson
Then, tell the configure script to enable API.

```
$ ./configure --api
$ ocaml ./configure.ml --api
```

### Coding style
132 configure

This file was deleted.

@@ -0,0 +1,100 @@
(* ocaml ./configure.ml *)

#use "topfind" ;;
#require "unix" ;;

let strip = ref true
let rm = ref ""
let ext = ref ""
let os_type = ref ""

let installed pkg =
0 = Sys.command ("ocamlfind query -qo -qe " ^ pkg)

let errmsg = "usage: " ^ Sys.argv.(0) ^ " [options]"

let api = ref false
let sosa = ref `None
let gwdb = ref `None

let set_api () = api := true

let set_sosa_zarith () = assert (!sosa = `None) ; sosa := `Zarith

let set_sosa_num () = assert (!sosa = `None) ; sosa := `Num

let set_gwdb_legacy () = assert (!gwdb = `None) ; gwdb := `Legacy

let speclist =
[ ( "--api"
, Arg.Unit set_api
, "Enable API support" )
; ( "--gwdb-legacy"
, Arg.Unit set_gwdb_legacy
, "Use legacy backend" )
; ( "--sosa-num"
, Arg.Unit set_sosa_num
, "Use Sosa module implementation based on `num` library" )
; ( "--sosa-zarith"
, Arg.Unit set_sosa_zarith
, "Sosa module implementation based on `zarith` library" )
]

let () =
Arg.parse speclist failwith errmsg ;
let dune_dirs_exclude = ref "" in
let exclude_dir s = dune_dirs_exclude := !dune_dirs_exclude ^ " " ^ s in
let api_d, api_pkg =
match !api with
| true -> "-D API", "piqirun.ext redis-sync yojson curl"
| false -> "", ""
in
let sosa_pkg =
match !sosa with
| `None ->
exclude_dir "sosa.num" ;
exclude_dir "sosa.zarith" ;
"geneweb-sosa"
| `Num ->
exclude_dir "sosa.array" ;
exclude_dir "sosa.zarith" ;
"geneweb-sosa-num"
| `Zarith ->
exclude_dir "sosa.array" ;
exclude_dir "sosa.num" ;
"geneweb-sosa-zarith"
in
let wserver_pkg = "geneweb-wserver" in
let gwdb_d, gwdb_pkg =
match !gwdb with
| `None
| `Legacy ->
"-D GWDB1", "geneweb-gwdb-legacy geneweb-gwdb-legacy.internal"
in
let os_type, camlp5f, ext, rm, strip =
match
let p = Unix.open_process_in "uname -s" in
let line = input_line p in
close_in p ;
line
with
| "Linux" | "Darwin" as os_type -> os_type, "", "", "/bin/rm -f", "strip"
| _ -> "Win", " -D WINDOWS", ".exe", "rm -f", "true"
in

let ch = open_out "Makefile.config" in
let writeln s = output_string ch @@ s ^ "\n" in
let var name value = writeln @@ name ^ "=" ^ value in
writeln @@ "# This file is generated by " ^ Sys.argv.(0) ^ "." ;
var "OS_TYPE" os_type ;
var "STRIP" strip ;
var "RM" rm ;
var "EXT" ext ;
var "API_D" api_d ;
var "API_PKG" api_pkg ;
var "GWDB_D" gwdb_d ;
var "GWDB_PKG" gwdb_pkg ;
var "SOSA_PKG" sosa_pkg ;
var "WSERVER_PKG" wserver_pkg ;
var "DUNE_DIRS_EXCLUDE" !dune_dirs_exclude ;
close_out ch
@@ -15,7 +15,7 @@ dev-repo: "git://github.com/geneweb/geneweb"
bug-reports: "https://github.com/geneweb/geneweb/issues"

build: [
[ "./configure" "--api" ]
[ "ocaml" "./configure.ml" "--api" ]
[ "dune" "build" "-p" name "-j" jobs ]
]

@@ -13,8 +13,8 @@ dev-repo: "git://github.com/geneweb/geneweb"
bug-reports: "https://github.com/geneweb/geneweb/issues"

build: [
[ "./configure" ]
[ "dune" "build" "-p" "geneweb" "-j" jobs ]
[ "ocaml" "./configure.ml" ]
[ "dune" "build" "-p" name "-j" jobs ]
]

depends: [
@@ -28,3 +28,5 @@ depends: [
"stdlib-shims"
"unidecode" { = "0.2.0" }
]

conflict-class: [ "geneweb-bin" ]
@@ -13,7 +13,7 @@ dev-repo: "git://github.com/geneweb/geneweb"
bug-reports: "https://github.com/geneweb/geneweb/issues"

build: [
[ "./configure" ]
[ "ocaml" "./configure.ml" ]
[ "dune" "build" "-p" name "-j" jobs ]
]

0 comments on commit d5d5a4b

Please sign in to comment.
You can’t perform that action at this time.