From 7d126d2fc1a00b073acbb5a2e42485f969ef93ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Mon, 26 Jan 2015 21:41:22 -0500 Subject: [PATCH] nitc & lib: intro the @android annotation and use it in nitc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- lib/android/aware.nit | 20 ++++++++++++++++++++ lib/android/platform.nit | 1 + src/platform/android.nit | 13 +++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 lib/android/aware.nit diff --git a/lib/android/aware.nit b/lib/android/aware.nit new file mode 100644 index 0000000..92a3a80 --- /dev/null +++ b/lib/android/aware.nit @@ -0,0 +1,20 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2014 Alexis Laferrière +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Android compatibility module +# +# Defines the `@android` annotation used to tag `ldflags` annotations. +module aware is new_annotation(android) diff --git a/lib/android/platform.nit b/lib/android/platform.nit index fca03e0..7c15af5 100644 --- a/lib/android/platform.nit +++ b/lib/android/platform.nit @@ -27,3 +27,4 @@ end import java import app +import aware diff --git a/src/platform/android.nit b/src/platform/android.nit index 98a017e..fb13044 100644 --- a/src/platform/android.nit +++ b/src/platform/android.nit @@ -138,12 +138,21 @@ class AndroidToolchain end end - ## Generate delagating makefile + ## Generate delegating makefile dir = "{android_project_root}/jni/" """ include $(call all-subdir-makefiles) """.write_to_file("{dir}/Android.mk") + # Gather ldflags for Android + var ldflags = new Array[String] + var platform_name = "android" + for mmodule in compiler.mainmodule.in_importation.greaters do + if mmodule.ldflags.keys.has(platform_name) then + ldflags.add_all mmodule.ldflags[platform_name] + end + end + ### generate makefile into "{compile_dir}/Android.mk" dir = compile_dir """ @@ -154,7 +163,7 @@ LOCAL_CFLAGS := -D ANDROID -D WITH_LIBGC LOCAL_MODULE := main LOCAL_SRC_FILES := \\ {{{cfiles.join(" \\\n")}}} -LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM -lz libgc.a +LOCAL_LDLIBS := {{{ldflags.join(" ")}}} libgc.a LOCAL_STATIC_LIBRARIES := android_native_app_glue png include $(BUILD_SHARED_LIBRARY) -- 1.7.9.5