[modules] split define and include

also reuse 'type' attribute for string flags
This commit is contained in:
Gautier Hattenberger
2016-03-30 23:41:16 +02:00
committed by Felix Ruess
parent d14135246e
commit 1fdea9387b
8 changed files with 34 additions and 18 deletions
+1 -1
View File
@@ -32,7 +32,7 @@
<file name="bebop_front_camera.c"/> <file name="bebop_front_camera.c"/>
<!-- Include the needed Computer Vision files --> <!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/> <include name="modules/computer_vision"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/> <file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/> <file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/> <file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>
+1 -1
View File
@@ -78,7 +78,7 @@
<makefile target="ap"> <makefile target="ap">
<!-- Include the needed Computer Vision files --> <!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/> <include name="modules/computer_vision"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/> <file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/> <file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>
<file name="rtp.c" dir="modules/computer_vision/lib/encoding"/> <file name="rtp.c" dir="modules/computer_vision/lib/encoding"/>
+2 -2
View File
@@ -43,8 +43,8 @@
<file name="img_scanner.c" dir="$(LIBZBAR)/zbar"/> <file name="img_scanner.c" dir="$(LIBZBAR)/zbar"/>
<!-- libexif flags --> <!-- libexif flags -->
<define name="$(LIBZBAR)/zbar" type="include"/> <include name="$(LIBZBAR)/zbar"/>
<define name="$(LIBZBAR)/include" type="include"/> <include name="$(LIBZBAR)/include"/>
<!--define name="DEBUG_QR_FINDER" value="1"/--> <!--define name="DEBUG_QR_FINDER" value="1"/-->
+6 -1
View File
@@ -12,11 +12,12 @@
<!ELEMENT event (handler*)> <!ELEMENT event (handler*)>
<!ELEMENT handler EMPTY> <!ELEMENT handler EMPTY>
<!ELEMENT datalink EMPTY> <!ELEMENT datalink EMPTY>
<!ELEMENT makefile (configure|define|flag|file|file_arch|raw)*> <!ELEMENT makefile (configure|define|include|flag|file|file_arch|raw)*>
<!ELEMENT section (define|configure)*> <!ELEMENT section (define|configure)*>
<!ELEMENT description (#PCDATA)> <!ELEMENT description (#PCDATA)>
<!ELEMENT configure EMPTY> <!ELEMENT configure EMPTY>
<!ELEMENT define EMPTY> <!ELEMENT define EMPTY>
<!ELEMENT include EMPTY>
<!ELEMENT flag EMPTY> <!ELEMENT flag EMPTY>
<!ELEMENT file EMPTY> <!ELEMENT file EMPTY>
<!ELEMENT file_arch EMPTY> <!ELEMENT file_arch EMPTY>
@@ -77,6 +78,10 @@ type CDATA #IMPLIED
description CDATA #IMPLIED description CDATA #IMPLIED
cond CDATA #IMPLIED> cond CDATA #IMPLIED>
<!ATTLIST include
name CDATA #REQUIRED
cond CDATA #IMPLIED>
<!ATTLIST flag <!ATTLIST flag
name CDATA #REQUIRED name CDATA #REQUIRED
value CDATA #REQUIRED> value CDATA #REQUIRED>
+1 -1
View File
@@ -17,7 +17,7 @@
</header> </header>
<periodic fun="push_gps_to_vision()" freq="8"/> <periodic fun="push_gps_to_vision()" freq="8"/>
<makefile target="ap"> <makefile target="ap">
<define name="modules/computer_vision" type="include"/> <include name="modules/computer_vision"/>
<file name="exif_module.c" dir="modules/computer_vision/lib/exif"/> <file name="exif_module.c" dir="modules/computer_vision/lib/exif"/>
<!-- libexif --> <!-- libexif -->
+1 -1
View File
@@ -36,7 +36,7 @@
<file name="viewvideo.c"/> <file name="viewvideo.c"/>
<!-- Include the needed Computer Vision files --> <!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/> <include name="modules/computer_vision"/>
<file name="rtp.c" dir="modules/computer_vision/lib/encoding"/> <file name="rtp.c" dir="modules/computer_vision/lib/encoding"/>
<!-- Define the network connection to send images over --> <!-- Define the network connection to send images over -->
+1 -1
View File
@@ -41,7 +41,7 @@
<file name="cv.c"/> <file name="cv.c"/>
<!-- Include the needed Computer Vision files --> <!-- Include the needed Computer Vision files -->
<define name="modules/computer_vision" type="include"/> <include name="modules/computer_vision"/>
<file name="image.c" dir="modules/computer_vision/lib/vision"/> <file name="image.c" dir="modules/computer_vision/lib/vision"/>
<file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/> <file name="v4l2.c" dir="modules/computer_vision/lib/v4l"/>
<file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/> <file name="jpeg.c" dir="modules/computer_vision/lib/encoding"/>
+21 -10
View File
@@ -71,17 +71,27 @@ let configure_xml2mk = fun f xml ->
fprintf f "%s_LOWER = $(shell echo $(%s) | tr A-Z a-z)\n" name name; fprintf f "%s_LOWER = $(shell echo $(%s) | tr A-Z a-z)\n" name name;
if Str.string_match (Str.regexp ".*upper.*") case 0 then if Str.string_match (Str.regexp ".*upper.*") case 0 then
fprintf f "%s_UPPER = $(shell echo $(%s) | tr a-z A-Z)\n" name name fprintf f "%s_UPPER = $(shell echo $(%s) | tr a-z A-Z)\n" name name
let define_xml2mk = fun f ?(target="$(TARGET)") ?(vpath=None) xml -> let include_xml2mk = fun f ?(target="$(TARGET)") ?(vpath=None) xml ->
let name = Xml.attrib xml "name" let name = Xml.attrib xml "name"
and value = try "=" ^ Xml.attrib xml "value" with _ -> "" in and path = match vpath with Some vp -> vp ^ "/" | None -> "" in
let flag_type = match ExtXml.attrib_or_default xml "type" "define" with let flag = sprintf "%s.CFLAGS += -I%s%s" target path name in
| "define" | "D" -> "D" try
| "include" | "I" -> "I" ^ (match vpath with Some vp -> vp ^ "/" | None -> "") (* TODO: add condition in xml syntax ? *)
| "raw" -> "" let cond = Xml.attrib xml "cond" in
| _ -> "D" in fprintf f "%s\n%s\nendif\n" cond flag
let flag = sprintf "%s.CFLAGS += -%s%s%s" target flag_type name value in with Xml.No_attribute _ -> fprintf f "%s\n" flag
let define_xml2mk = fun f ?(target="$(TARGET)") xml ->
let name = Xml.attrib xml "name"
and value = try Some (Xml.attrib xml "value") with _ -> None in
let flag_type = fun s ->
match ExtXml.attrib_or_default xml "type" "raw", value with
| "string", Some v -> "=\\\""^v^"\\\""
| _, Some v -> "="^v
| _, _ -> ""
in
let flag = sprintf "%s.CFLAGS += -D%s%s" target name (flag_type value) in
try try
(* TODO: add condition in xml syntax ? *) (* TODO: add condition in xml syntax ? *)
let cond = Xml.attrib xml "cond" in let cond = Xml.attrib xml "cond" in
@@ -132,7 +142,8 @@ let module_xml2mk = fun f target firmware m ->
(fun field -> (fun field ->
match String.lowercase (Xml.tag field) with match String.lowercase (Xml.tag field) with
| "configure" -> configure_xml2mk f field | "configure" -> configure_xml2mk f field
| "define" -> define_xml2mk f ~target ~vpath:m.vpath field | "define" -> define_xml2mk f ~target field
| "include" -> include_xml2mk f ~target ~vpath:m.vpath field
| "flag" -> | "flag" ->
let value = Xml.attrib field "value" let value = Xml.attrib field "value"
and name = Xml.attrib field "name" in and name = Xml.attrib field "name" in