redef fun compile_c_code(compiler, compile_dir)
do
+ var android_project_root = android_project_root.as(not null)
+ var release = toolcontext.opt_release.value
+
# Compile C code (and thus Nit)
- toolcontext.exec_and_check(["ndk-build", "-s", "-j", "4", "-C", android_project_root])
+ toolcontext.exec_and_check(["ndk-build", "-s", "-j", "4", "-C", android_project_root], "Android project error")
# Generate the apk
- toolcontext.exec_and_check(["ant", "-q", "debug", "-f", android_project_root+"/build.xml"], "Android project error")
+ var args = ["ant", "-q", "-f", android_project_root+"/build.xml"]
+ if release then
+ args.add "release"
+ else args.add "debug"
- toolcontext.exec_and_check(args)
++ toolcontext.exec_and_check(args, "Android project error")
# Move the apk to the target
var outname = toolcontext.opt_output.value
if outname == null then outname = "{compiler.mainmodule.name}.apk"
- toolcontext.exec_and_check(["mv", "{android_project_root}/bin/{compiler.mainmodule.name}-debug.apk", outname], "Android project error")
+
+ var src_apk_suffix
+ if release then
+ src_apk_suffix = "release-unsigned"
+ else src_apk_suffix = "debug"
+
- toolcontext.exec_and_check(["mv", "{android_project_root}/bin/{compiler.mainmodule.name}-{src_apk_suffix}.apk", outname])
++ toolcontext.exec_and_check(["mv", "{android_project_root}/bin/{compiler.mainmodule.name}-{src_apk_suffix}.apk", outname], "Android project error")
end
end