mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +08:00
Drop old compat (#2786)
* [ocaml] drop of compat for Ocaml < 4.05 this is linked to Ubuntu 16.04 that have reached end of life * [pprzlink] update pprzlink for removed old compat
This commit is contained in:
committed by
GitHub
parent
da5b527795
commit
83a74e412f
+4
-27
@@ -49,26 +49,12 @@ ifeq ($(LABLGTK2GNOMECANVAS),)
|
||||
LABLGTK2GNOMECANVAS = $(shell ocamlfind query -p-format lablgtk2.gnomecanvas 2>/dev/null)
|
||||
endif
|
||||
|
||||
CAMLP4_DEFS ?=
|
||||
OCAMLC_VER := $(shell ocamlc -version)
|
||||
OCAMLC_MAJOR := $(shell echo $(OCAMLC_VER) | cut -f1 -d.)
|
||||
OCAMLC_MINOR := $(shell echo $(OCAMLC_VER) | cut -f2 -d.)
|
||||
ifeq ($(shell test $(OCAMLC_MAJOR) -ge 4; echo $$?),0)
|
||||
ifeq ($(shell test $(OCAMLC_MINOR) -ge 4; echo $$?),0)
|
||||
CAMLP4_DEFS += -DOCAML_V404
|
||||
endif
|
||||
endif
|
||||
PP_OPTS = -pp "camlp4o pa_macro.cmo $(CAMLP4_DEFS)"
|
||||
|
||||
# which source files to run through caml4p
|
||||
PP_SRC = compat.ml
|
||||
|
||||
INCLUDES=
|
||||
PKGCOMMON=pprzlink,xml-light,netclient,nettls-gnutls,glibivy,lablgtk2
|
||||
XINCLUDES=
|
||||
XPKGCOMMON=pprzlink,xml-light,glibivy,$(LABLGTK2GNOMECANVAS),lablgtk2.glade
|
||||
|
||||
SRC = compat.ml fig.ml debug.ml base64.ml serial.ml ocaml_tools.ml expr_syntax.ml expr_parser.ml expr_lexer.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o ubx.ml xmlCom.ml os_calls.ml editAirframe.ml defivybus.ml fp_proc.ml quaternion.ml
|
||||
SRC = fig.ml debug.ml base64.ml serial.ml ocaml_tools.ml expr_syntax.ml expr_parser.ml expr_lexer.ml extXml.ml env.ml xml2h.ml latlong.ml egm96.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o ubx.ml xmlCom.ml os_calls.ml editAirframe.ml defivybus.ml fp_proc.ml quaternion.ml
|
||||
SRC += gen_common.ml radio.ml settings.ml module.ml flight_plan.ml autopilot.ml airframe.ml telemetry.ml aircraft.ml
|
||||
CMO = $(SRC:.ml=.cmo)
|
||||
CMX = $(SRC:.ml=.cmx)
|
||||
@@ -139,19 +125,11 @@ ml_gtk_drag.o : ml_gtk_drag.c
|
||||
|
||||
%.cmo : %.ml
|
||||
@echo OC $<
|
||||
@if test $(findstring $<,$(PP_SRC)); then \
|
||||
$(OCAMLC) $(INCLUDES) $(PP_OPTS) -package $(PKGCOMMON) -c $<; \
|
||||
else \
|
||||
$(OCAMLC) $(INCLUDES) -package $(PKGCOMMON) -c $<; \
|
||||
fi;
|
||||
$(Q)$(OCAMLC) $(INCLUDES) -package $(PKGCOMMON) -c $<
|
||||
|
||||
%.cmx : %.ml
|
||||
@echo OOC $<
|
||||
@if test $(findstring $<,$(PP_SRC)); then \
|
||||
$(OCAMLOPT) $(INCLUDES) $(PP_OPTS) -package $(PKGCOMMON) -c $<; \
|
||||
else \
|
||||
$(OCAMLOPT) $(INCLUDES) -package $(PKGCOMMON) -c $<; \
|
||||
fi;
|
||||
$(Q)$(OCAMLOPT) $(INCLUDES) -package $(PKGCOMMON) -c $<
|
||||
|
||||
%.cmi : %.mli
|
||||
@echo OC $<
|
||||
@@ -208,8 +186,7 @@ clean :
|
||||
|
||||
.depend: Makefile $(GEN_DEP)
|
||||
@echo DEPEND $@
|
||||
$(Q)$(OCAMLDEP) $(PP_OPTS) $(PP_SRC) > .depend
|
||||
$(Q)$(OCAMLDEP) $(filter-out $(PP_SRC), $(SRC) $(XSRC)) *.mli >> .depend
|
||||
$(Q)$(OCAMLDEP) $(SRC) $(XSRC) *.mli >> .depend
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include .depend
|
||||
|
||||
@@ -55,7 +55,7 @@ let get_sys_ap_settings = fun autopilots ->
|
||||
let dl_settings = List.fold_left (fun sl (_, autopilot) ->
|
||||
(* Filter state machines that need to be displayed *)
|
||||
let sm_filtered = List.filter (fun sm ->
|
||||
try (Compat.lowercase_ascii (Xml.attrib sm "settings_mode")) = "true" with _ -> false
|
||||
try (String.lowercase_ascii (Xml.attrib sm "settings_mode")) = "true" with _ -> false
|
||||
) (Xml.children autopilot.xml) in
|
||||
if List.length sm_filtered = 0 then sl
|
||||
else
|
||||
@@ -65,7 +65,7 @@ let get_sys_ap_settings = fun autopilots ->
|
||||
let name = Xml.attrib sm "name" in
|
||||
(* Iter on modes and store min, max and values *)
|
||||
let (_, min, max, values) = List.fold_left (fun (current, min, max, values) m ->
|
||||
let print = try Compat.lowercase_ascii (Xml.attrib m "settings") <> "hide" with _ -> true in
|
||||
let print = try String.lowercase_ascii (Xml.attrib m "settings") <> "hide" with _ -> true in
|
||||
let name = Xml.attrib m "name" in
|
||||
if print then begin
|
||||
let min = match min with
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
(*
|
||||
* Abstract some String/Byte functions for compatibility between OCaml 3.x and 4.x
|
||||
*
|
||||
* Copyright (C) 2016 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*)
|
||||
|
||||
IFDEF OCAML_V404 THEN
|
||||
let lowercase_ascii = String.lowercase_ascii
|
||||
|
||||
let uppercase_ascii = String.uppercase_ascii
|
||||
|
||||
let capitalize_ascii = String.capitalize_ascii
|
||||
|
||||
ELSE
|
||||
let lowercase_ascii = String.lowercase
|
||||
|
||||
let uppercase_ascii = String.uppercase
|
||||
|
||||
let capitalize_ascii = String.capitalize
|
||||
|
||||
END
|
||||
@@ -1,27 +0,0 @@
|
||||
(*
|
||||
* Abstract some String/Byte functions for compatibility between OCaml 3.x and 4.x
|
||||
*
|
||||
* Copyright (C) 2016 Felix Ruess <felix.ruess@gmail.com>
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
* paparazzi is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* paparazzi is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with paparazzi; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*)
|
||||
|
||||
val lowercase_ascii : string -> string
|
||||
val uppercase_ascii : string -> string
|
||||
val capitalize_ascii : string -> string
|
||||
@@ -82,7 +82,7 @@ let attrib_opt_map = fun xml attr f ->
|
||||
let attrib_opt_int = fun xml attr -> attrib_opt_map xml attr int_of_string
|
||||
let attrib_opt_float = fun xml attr -> attrib_opt_map xml attr float_of_string
|
||||
|
||||
let tag_is = fun x v -> Compat.lowercase_ascii (Xml.tag x) = Compat.lowercase_ascii v
|
||||
let tag_is = fun x v -> String.lowercase_ascii (Xml.tag x) = String.lowercase_ascii v
|
||||
|
||||
let attrib_or_default = fun x a default ->
|
||||
try Xml.attrib x a
|
||||
@@ -153,7 +153,7 @@ let my_to_string_fmt = fun tab_attribs x ->
|
||||
s
|
||||
|
||||
let to_string_fmt = fun ?(tab_attribs = false) xml ->
|
||||
let l = Compat.lowercase_ascii in
|
||||
let l = String.lowercase_ascii in
|
||||
let rec lower = function
|
||||
| Xml.PCData _ as x -> x
|
||||
| Xml.Element (t, ats, cs) ->
|
||||
@@ -164,7 +164,7 @@ let to_string_fmt = fun ?(tab_attribs = false) xml ->
|
||||
|
||||
|
||||
let subst_attrib = fun attrib value xml ->
|
||||
let u = Compat.uppercase_ascii in
|
||||
let u = String.uppercase_ascii in
|
||||
let uattrib = u attrib in
|
||||
match xml with
|
||||
| Xml.Element (tag, attrs, children) ->
|
||||
|
||||
@@ -72,7 +72,7 @@ let transform_values = fun attribs_not_modified env attribs ->
|
||||
List.map
|
||||
(fun (a, v) ->
|
||||
let v' =
|
||||
if List.mem (Compat.lowercase_ascii a) attribs_not_modified
|
||||
if List.mem (String.lowercase_ascii a) attribs_not_modified
|
||||
then v
|
||||
else transform_expression env (parse_expression v) in
|
||||
(a, v'))
|
||||
@@ -83,7 +83,7 @@ let prefix_or_deroute = fun prefix reroutes name attribs ->
|
||||
List.map
|
||||
(fun (a, v) ->
|
||||
let v' =
|
||||
if Compat.lowercase_ascii a = name then
|
||||
if String.lowercase_ascii a = name then
|
||||
try List.assoc v reroutes with
|
||||
Not_found -> prefix v
|
||||
else v in
|
||||
@@ -105,7 +105,7 @@ let transform_stage = fun prefix reroutes env xml ->
|
||||
let rec tr = fun xml ->
|
||||
match xml with
|
||||
Xml.Element (tag, attribs, children) -> begin
|
||||
match Compat.lowercase_ascii tag with
|
||||
match String.lowercase_ascii tag with
|
||||
"exception" ->
|
||||
transform_exception prefix reroutes env xml
|
||||
| "while" ->
|
||||
@@ -276,7 +276,7 @@ let process_includes = fun dir xml ->
|
||||
|
||||
|
||||
let remove_attribs = fun xml names ->
|
||||
List.filter (fun (x,_) -> not (List.mem (Compat.lowercase_ascii x) names)) (Xml.attribs xml)
|
||||
List.filter (fun (x,_) -> not (List.mem (String.lowercase_ascii x) names)) (Xml.attribs xml)
|
||||
|
||||
let xml_assoc_attrib = fun a v xmls ->
|
||||
List.find (fun x -> ExtXml.attrib x a = v) xmls
|
||||
@@ -327,7 +327,7 @@ let replace_from = fun stage waypoints ->
|
||||
|
||||
let process_stage = fun stage waypoints ->
|
||||
let rec do_it = fun stage ->
|
||||
match Compat.lowercase_ascii (Xml.tag stage) with
|
||||
match String.lowercase_ascii (Xml.tag stage) with
|
||||
"go" | "stay" | "circle" ->
|
||||
replace_from (replace_wp stage waypoints) waypoints
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ let float_attr = fun xml a -> float_of_string (ExtXml.attrib xml a)
|
||||
let rec assoc_nocase at = function
|
||||
[] -> raise Not_found
|
||||
| (a, v)::avs ->
|
||||
if Compat.uppercase_ascii at = Compat.uppercase_ascii a then v else assoc_nocase at avs
|
||||
if String.uppercase_ascii at = String.uppercase_ascii a then v else assoc_nocase at avs
|
||||
|
||||
(** Returns the WGS84 coordinates of a waypoint, either from its relative x and
|
||||
y coordinates or from its lat and long *)
|
||||
@@ -203,7 +203,7 @@ let display_kml = fun ?group color geomap xml ->
|
||||
try
|
||||
let document = ExtXml.child xml "Document" in
|
||||
let rec loop = fun child ->
|
||||
let tag = Compat.lowercase_ascii (Xml.tag child) in
|
||||
let tag = String.lowercase_ascii (Xml.tag child) in
|
||||
match tag with
|
||||
| "linestring" | "linearring" ->
|
||||
let coordinates = ExtXml.child child "coordinates" in
|
||||
@@ -266,7 +266,7 @@ class flight_plan = fun ?format_attribs ?editable ~show_moved geomap color fp_dt
|
||||
let waypoints = ExtXml.child xml "waypoints" in
|
||||
try
|
||||
List.fold_left (fun l x ->
|
||||
match Compat.lowercase_ascii (Xml.tag x) with
|
||||
match String.lowercase_ascii (Xml.tag x) with
|
||||
"kml" ->
|
||||
let file = ExtXml.attrib x "file" in
|
||||
display_kml ~group:wpts_group#group color geomap (ExtXml.parse_file (Env.flight_plans_path // file));
|
||||
|
||||
@@ -151,7 +151,7 @@ type periodic = {
|
||||
let parse_periodic = fun xml ->
|
||||
let get = fun x -> ExtXml.attrib_opt xml x in
|
||||
let getf = fun x -> ExtXml.attrib_opt_float xml x in
|
||||
let call = snd (List.find (fun (a, _) -> Compat.lowercase_ascii a = "fun")
|
||||
let call = snd (List.find (fun (a, _) -> String.lowercase_ascii a = "fun")
|
||||
(Xml.attribs xml)) in
|
||||
let call_regexp = Str.regexp "\\([a-zA-Z_][a-zA-Z0-9_]*\\)\\(.*\\)" in
|
||||
let fname =
|
||||
|
||||
@@ -368,7 +368,7 @@ object (self)
|
||||
let (x, y) = item#xy in
|
||||
let attrs =
|
||||
[ "type", msg_obj#type_;
|
||||
"display", Compat.lowercase_ascii item#renderer#tag;
|
||||
"display", String.lowercase_ascii item#renderer#tag;
|
||||
"x", sprintf "%.0f" x; "y", sprintf "%.0f" y ] in
|
||||
Xml.Element ("papget", attrs, scale_prop::val_props@renderer_props)
|
||||
end
|
||||
@@ -387,7 +387,7 @@ object
|
||||
let (x, y) = item#xy in
|
||||
let attrs =
|
||||
[ "type", type_;
|
||||
"display", Compat.lowercase_ascii item#renderer#tag;
|
||||
"display", String.lowercase_ascii item#renderer#tag;
|
||||
"x", sprintf "%.0f" x; "y", sprintf "%.0f" y ] in
|
||||
Xml.Element ("papget", attrs, properties@props)
|
||||
end
|
||||
@@ -416,7 +416,7 @@ object (self)
|
||||
let (x, y) = item#xy in
|
||||
let attrs =
|
||||
[ "type", "video_plugin";
|
||||
"display", Compat.lowercase_ascii item#renderer#tag;
|
||||
"display", String.lowercase_ascii item#renderer#tag;
|
||||
"x", sprintf "%.0f" x; "y", sprintf "%.0f" y ] in
|
||||
Xml.Element ("papget", attrs, properties@props)
|
||||
initializer ignore(adj#connect#value_changed (fun () -> self#update_zoom (string_of_float adj#value)))
|
||||
|
||||
@@ -352,21 +352,21 @@ let set_attribs = fun ((model, path):node) attribs ->
|
||||
let rec replace_assoc a v = function
|
||||
[] -> [(a, v)]
|
||||
| (a', v')::l ->
|
||||
if a = Compat.uppercase_ascii a'
|
||||
if a = String.uppercase_ascii a'
|
||||
then (a, v)::l
|
||||
else (a', v')::replace_assoc a v l
|
||||
|
||||
let set_attrib = fun node (a, v) ->
|
||||
let atbs = attribs node in
|
||||
set_attribs node (replace_assoc (Compat.uppercase_ascii a) v atbs)
|
||||
set_attribs node (replace_assoc (String.uppercase_ascii a) v atbs)
|
||||
|
||||
let attrib = fun node at ->
|
||||
let at = Compat.uppercase_ascii at in
|
||||
let at = String.uppercase_ascii at in
|
||||
let ats = attribs node in
|
||||
let rec loop = function
|
||||
[] -> raise Not_found
|
||||
| (a,v)::avs ->
|
||||
if Compat.uppercase_ascii a = at then v else loop avs in
|
||||
if String.uppercase_ascii a = at then v else loop avs in
|
||||
loop ats
|
||||
|
||||
let tag = fun ((model, path):node) ->
|
||||
|
||||
Reference in New Issue
Block a user