Skip to content

Commit

Permalink
Removed #ifdef API. API is now always built.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagotch committed Sep 20, 2021
1 parent eba30f7 commit 1fd33d5
Show file tree
Hide file tree
Showing 24 changed files with 2 additions and 130 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ lib/gwlib.ml:
@echo " with Not_found -> \"$(PREFIX)\"" | sed -e 's|\\|/|g' >> $@
@echo " Done!"

CPPO_D=$(API_D) $(GWDB_D) $(OS_D) $(SYSLOG_D)
CPPO_D=$(GWDB_D) $(OS_D) $(SYSLOG_D)

ifeq ($(DUNE_PROFILE),dev)
CPPO_D+= -D DEBUG
Expand All @@ -37,7 +37,6 @@ endif
| cppo -n $(CPPO_D) \
| sed \
-e "s/%%%CPPO_D%%%/$(CPPO_D)/g" \
-e "s/%%%API_PKG%%%/$(API_PKG)/g" \
-e "s/%%%SOSA_PKG%%%/$(SOSA_PKG)/g" \
-e "s/%%%GWDB_PKG%%%/$(GWDB_PKG)/g" \
-e "s/%%%SYSLOG_PKG%%%/$(SYSLOG_PKG)/g" \
Expand Down
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,6 @@ You can have a description of available configuration options using
$ ocaml ./configure.ml --help
```

### Building the API

The API uses the Google Protocol Buffer to exchange information
encoded as pb, json, xml.

Install [protoc](https://github.com/protocolbuffers/protobuf#protocol-compiler-installation),
and these extra dependencies:

```
$ opam install ocurl piqi piqilib redis redis-sync yojson
```

Then, tell the configure script to enable API.

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

### Coding style

* Try to keep the same coding style as the existing one.
Expand Down
13 changes: 0 additions & 13 deletions bin/gwd/gwd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ let use_auth_digest_scheme = ref false
let wizard_just_friend = ref false
let wizard_passwd = ref ""

#ifdef API
let selected_api_host = ref "127.0.0.1"
let selected_api_port = ref 2322
#endif

let is_multipart_form =
let s = "multipart/form-data" in
fun content_type ->
Expand Down Expand Up @@ -1134,11 +1129,7 @@ let make_conf from_addr request script_name env =
let wizard_just_friend = if manitou then false else wizard_just_friend in
let conf =
{from = from_addr;
#ifdef API
api_host = !selected_api_host;
api_port = !selected_api_port;
api_mode = false;
#endif
manitou = manitou;
supervisor = supervisor; wizard = ar.ar_wizard && not wizard_just_friend;
is_printed_by_template = true;
Expand Down Expand Up @@ -1868,10 +1859,6 @@ let main () =
; ("-max_clients", Arg.Int (fun x -> max_clients := Some x), "<NUM> Max number of clients treated at the same time (default: no limit) (not cgi).")
; ("-conn_tmout", Arg.Int (fun x -> conn_timeout := x), "<SEC> Connection timeout (default " ^ string_of_int !conn_timeout ^ "s; 0 means no limit)." )
; ("-daemon", Arg.Set daemon, " Unix daemon mode.")
#endif
#ifdef API
; ("-api_h", Arg.String (fun x -> selected_api_host := x), "<HOST> Host for GeneWeb API (default = " ^ !selected_api_host ^ ").")
; ("-api_p", Arg.Int (fun x -> selected_api_port := x), "<NUMBER> Port number for GeneWeb API (default = " ^ string_of_int !selected_api_port ^ ").")
#endif
]
in
Expand Down
12 changes: 1 addition & 11 deletions configure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ let set_gwdb_legacy_x_arangodb () = assert (!gwdb = `None) ; gwdb := `LegacyAran
let release = ref true

let speclist =
[ ( "--api"
, Arg.Unit set_api
, "Enable API support" )
; ( "--gwdb-legacy"
[ ( "--gwdb-legacy"
, Arg.Unit set_gwdb_legacy
, "Use legacy backend" )
; ( "--gwdb-legacy-x-arangodb"
Expand Down Expand Up @@ -70,11 +67,6 @@ 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 syslog_d, syslog_pkg =
match !syslog with
| true -> " -D SYSLOG", "syslog"
Expand Down Expand Up @@ -131,11 +123,9 @@ let () =
var "STRIP" strip ;
var "RM" rm ;
var "EXT" ext ;
var "API_D" api_d ;
var "GWDB_D" gwdb_d ;
var "OS_D" os_d ;
var "SYSLOG_D" syslog_d ;
var "API_PKG" api_pkg ;
var "GWDB_PKG" gwdb_pkg ;
var "SOSA_PKG" sosa_pkg ;
var "SYSLOG_PKG" syslog_pkg ;
Expand Down
8 changes: 0 additions & 8 deletions lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ type output_conf =

type config =
{ from : string;
#ifdef API
api_host : string;
api_port : int;
api_mode : bool;
#endif
manitou : bool;
supervisor : bool;
wizard : bool;
Expand Down Expand Up @@ -105,11 +101,7 @@ let empty =
; manitou = false
; supervisor = false
; wizard = false
#ifdef API
; api_host = ""
; api_port = 0
; api_mode = false
#endif
; is_printed_by_template = false
; debug = false
; friend = false
Expand Down
1 change: 0 additions & 1 deletion lib/dune.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
(synopsis "GeneWeb library")
(preprocess (action (run %{bin:cppo} %%%CPPO_D%%% -V OCAML:%{ocaml_version} %{input-file})))
(libraries unix
%%%API_PKG%%%
str
stdlib-shims
camlp5
Expand Down
4 changes: 0 additions & 4 deletions lib/update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,13 @@ let print_continue
print_aux conf param value continue

let prerr conf _err fn =
#ifdef API
if not conf.api_mode then begin
#endif
let title _ = Output.print_string conf (Utf8.capitalize_fst (transl conf "error")) in
Hutil.rheader conf title ;
fn () ;
Hutil.trailer conf;
Output.flush conf ;
#ifdef API
end ;
#endif
raise @@ ModErr _err

let print_err_unknown conf _base (f, s, o) =
Expand Down
2 changes: 0 additions & 2 deletions lib/updateFamOk.ml
Original file line number Diff line number Diff line change
Expand Up @@ -857,13 +857,11 @@ let aux_effective_mod conf base nsck sfam scpl sdes fi origin_file =
let nfath_p = poi base (Adef.father ncpl) in
let nmoth_p = poi base (Adef.mother ncpl) in
let nfam = update_family_with_fevents conf base nfam in
#ifdef API
let nfam =
(* En mode api, on gère directement la relation de même sexe. *)
if conf.api_mode then {nfam with relation = sfam.relation}
else nfam
in
#endif
if not nsck then begin
begin match get_sex nfath_p with
| Female -> print_err_father_sex conf base nfath_p
Expand Down
10 changes: 0 additions & 10 deletions lib/updateIndOk.ml
Original file line number Diff line number Diff line change
Expand Up @@ -715,18 +715,14 @@ let check_person conf p =
| None -> Update.check_missing_witnesses_names conf (fun e -> e.epers_witnesses) p.pevents

let error_person conf err =
#ifdef API
if not conf.api_mode then begin
#endif
let title _ = Output.print_string conf (Utf8.capitalize_fst (transl conf "error")) in
Hutil.rheader conf title;
Output.print_string conf (Utf8.capitalize_fst err);
Output.print_string conf "\n";
Update.print_return conf;
Hutil.trailer conf;
#ifdef API
end ;
#endif
let err =
Printf.sprintf "%s%s%s"
(Utf8.capitalize_fst (transl conf "error"))
Expand Down Expand Up @@ -772,9 +768,7 @@ let strip_person p =
List.filter (fun r -> r.r_fath <> None || r.r_moth <> None) p.rparents}

let print_conflict conf base p =
#ifdef API
if not conf.api_mode then begin
#endif
let title _ = Output.print_string conf (Utf8.capitalize_fst (transl conf "error")) in
Hutil.rheader conf title;
Update.print_error conf base (AlreadyDefined p);
Expand Down Expand Up @@ -811,9 +805,7 @@ let print_conflict conf base p =
Output.print_string conf "</form>\n";
Update.print_same_name conf base p;
Hutil.trailer conf;
#ifdef API
end ;
#endif
let err =
Printf.sprintf
(fcapitale (ftransl conf "name %s already used by %tthis person%t"))
Expand All @@ -838,9 +830,7 @@ let default_prerr conf base = function
| _ -> assert false

let print_cannot_change_sex ?(prerr = default_prerr) conf base p =
#ifdef API
if not conf.api_mode then
#endif
prerr conf base (BadSexOfMarriedPerson p) ;
let err =
Printf.sprintf "%s." (Utf8.capitalize_fst (transl conf "cannot change sex of a married person"))
Expand Down
4 changes: 0 additions & 4 deletions plugins/api/api.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -788,5 +786,3 @@ let name_frequency conf base =
M.Name_frequency_result_list.({ result = list ; total = Int32.of_int len })
|> Mext.gen_name_frequency_result_list
|> print_result conf

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_graph.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -501,5 +499,3 @@ let print_cpl_relation conf base =
in
let data = conv_data_list_person conf base filters list in
print_result conf data

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_piqi_util.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

open Geneweb
open Def
open Config
Expand Down Expand Up @@ -405,5 +403,3 @@ let piqi_access_to_access = function
| `access_iftitles -> IfTitles
| `access_public -> Public
| `access_private -> Private

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_saisie_autocomplete.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

open Geneweb
open Config
open Def
Expand Down Expand Up @@ -104,5 +102,3 @@ let rec get_list_from_cache ?(retry = true) conf base mode max_res s =
raise e

end

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_saisie_read.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module Mread = Api_saisie_read_piqi
module Mext_read = Api_saisie_read_piqi_ext

Expand Down Expand Up @@ -2668,5 +2666,3 @@ let print_graph_tree_v2 conf base =
let params = get_params conf Mext_read.parse_graph_tree_params in
let identifier_person = params.Mread.Graph_tree_params.identifier_person in
print_from_identifier_person conf base print_result_graph_tree_v2 identifier_person

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_saisie_write.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module Mwrite = Api_saisie_write_piqi
module Mext_write = Api_saisie_write_piqi_ext
module M = Api_piqi
Expand Down Expand Up @@ -2715,5 +2713,3 @@ let print_add_first_fam_ok conf base =
in
let data = compute_modification_status conf base !ip !ifam resp in
print_result conf data

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_search.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -823,5 +821,3 @@ let search_person_list base surname first_name =
| (None, Some fn) ->
select_start_with_person base get_first_name fn
| (None, None) -> []

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_stats.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module Mstats = Api_stats_piqi
module Mext_stats = Api_stats_piqi_ext

Expand Down Expand Up @@ -1680,5 +1678,3 @@ let print_stats conf base =
if params.Mstats.Stats_params.i <> None
then print_ind_stats conf base
else print_all_stats conf base

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_update_family.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module Mwrite = Api_saisie_write_piqi
module Mext_write = Api_saisie_write_piqi_ext

Expand Down Expand Up @@ -480,5 +478,3 @@ let print_mod conf base ip mod_f =
end
in
print_mod_aux conf base mod_f callback

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_update_person.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module Mwrite = Api_saisie_write_piqi
module Mext_write = Api_saisie_write_piqi_ext

Expand Down Expand Up @@ -420,5 +418,3 @@ let print_add_nobase conf mod_p =
with
| Update.ModErr s -> Api_update_util.UpdateError s
| Api_update_util.ModErrApiConflict c -> Api_update_util.UpdateErrorConflict c

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_update_util.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -1676,5 +1674,3 @@ let reconstitute_somebody base person =
else (fn, sn)
in
(fn, sn, occ, create, var, force_create)

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_util.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -1643,5 +1641,3 @@ let chop_base_prefix base_prefix =
then
String.sub base_prefix 0 (len - 2)
else base_prefix

#endif
4 changes: 0 additions & 4 deletions plugins/api/api_warnings.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

module M = Api_piqi
module Mext = Api_piqi_ext

Expand Down Expand Up @@ -255,5 +253,3 @@ let add_warning_to_piqi_warning_list conf base =
(* Not included in api *)
| ChangedOrderOfFamilyEvents (_, _, _) -> w
| ChangedOrderOfPersonEvents (_, _, _) -> w

#endif
4 changes: 0 additions & 4 deletions plugins/api/dune.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#ifdef API

(rule
(deps api.piqi)
(targets api_piqi.ml api_piqi_ext.ml)
Expand Down Expand Up @@ -73,5 +71,3 @@
)

(alias (name plugin) (deps (source_tree assets) plugin_api.cmxs))

#endif
Loading

0 comments on commit 1fd33d5

Please sign in to comment.