From 7d15b53a7ada69ec47eb1cbabcde88c1e4f92214 Mon Sep 17 00:00:00 2001 From: Romain Chanoir Date: Tue, 1 Jul 2014 15:18:00 -0400 Subject: [PATCH] Adding the support of the res folder for android applications Signed-off-by: Romain Chanoir --- src/android_platform.nit | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/android_platform.nit b/src/android_platform.nit index ff8ca4c..d5498d6 100644 --- a/src/android_platform.nit +++ b/src/android_platform.nit @@ -161,17 +161,6 @@ $(call import-module,android/native_app_glue) """.write_to_file("{dir}/AndroidManifest.xml") - ### generate res/values/strings.xml - dir = "{android_project_root}/res/" - if not dir.file_exists then dir.mkdir - dir = "{dir}/values/" - if not dir.file_exists then dir.mkdir - """ - - {{{app_name}}} - - """.write_to_file("{dir}/strings.xml") - ### Link to png sources # libpng is not available on Android NDK # FIXME make obtionnal when we have alternatives to mnit @@ -204,6 +193,26 @@ $(call import-module,android/native_app_glue) toolcontext.exec_and_check(["ln", "-s", assets_dir, target_assets_dir], "Android project error") end end + + ### copy resources (for android) + # This will be accessed from `android_project_root` + var res_dir + if compiler.mainmodule.location.file != null then + # it is a real file, use "{file}/../res" + res_dir = "{compiler.mainmodule.location.file.filename.dirname}/../res" + else + # probably used -m, use "." + res_dir = "res" + end + if res_dir.file_exists then + res_dir = res_dir.realpath + var target_res_dir = "{android_project_root}" + if target_res_dir.file_exists then + # copy the res folder to .nit_compile + toolcontext.exec_and_check(["cp", "-R", res_dir, target_res_dir], "Android project error") + end + end + end redef fun write_makefile(compiler, compile_dir, cfiles) -- 1.7.9.5