1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Additionnal annotations to gather metadata on Android projects
18 module android_annotations
20 intrude import app_annotations
22 # Metadata associated to an Android project
26 # Custom lines to add to the AndroidManifest.xml in the <manifest> node
27 var manifest_lines
= new Array[String]
29 # Custom lines to add to the AndroidManifest.xml in the <application> node
30 var manifest_application_lines
= new Array[String]
32 # Custom lines to add to AndroidManifest.xml as attributes inside the <activity> node
33 var manifest_activity_attributes
= new Array[String]
35 # Minimum API level required for the application to run
36 var min_api
: nullable Int = null
38 # Build target API level
39 var target_api
: nullable Int = null
41 # Maximum API level on which the application will be allowed to run
42 var max_api
: nullable Int = null
44 # Activities to declare in the manifest
45 var activities
= new Array[String]
49 var annots
= modelbuilder
.collect_annotations_on_modules
("android_api_min", mainmodule
)
50 if not annots
.is_empty
then
51 var i
= annots
.pop
.arg_as_int
(modelbuilder
)
52 if i
== null then i
= 0
55 i
= an
.arg_as_int
(modelbuilder
)
56 if i
== null then continue
57 min_api
= min_api
.max
(i
)
61 annots
= modelbuilder
.collect_annotations_on_modules
("android_api_max", mainmodule
)
62 if not annots
.is_empty
then
63 var i
= annots
.pop
.arg_as_int
(modelbuilder
)
64 if i
== null then i
= 0
67 i
= an
.arg_as_int
(modelbuilder
)
68 if i
== null then continue
69 max_api
= max_api
.min
(i
)
73 var annot
= modelbuilder
.lookup_annotation_on_modules
("android_api_target", mainmodule
)
74 if annot
!= null then target_api
= annot
.arg_as_int
(modelbuilder
) or else 0
76 annots
= modelbuilder
.collect_annotations_on_modules
("android_manifest", mainmodule
)
77 for an
in annots
do manifest_lines
.add an
.arg_as_string
(modelbuilder
) or else ""
79 annots
= modelbuilder
.collect_annotations_on_modules
("android_manifest_application", mainmodule
)
80 for an
in annots
do manifest_application_lines
.add an
.arg_as_string
(modelbuilder
) or else ""
82 annots
= modelbuilder
.collect_annotations_on_modules
("android_manifest_activity", mainmodule
)
83 for an
in annots
do manifest_activity_attributes
.add an
.arg_as_string
(modelbuilder
) or else ""
85 annots
= modelbuilder
.collect_annotations_on_modules
("android_activity", mainmodule
)
87 var activity
= an
.arg_as_string
(modelbuilder
)
88 if activity
!= null then activities
.add activity