import platform
import abstract_compiler
-import common_ffi
-intrude import common_ffi::extra_java_files
+import ffi
+intrude import ffi::extra_java_files
import android_annotations
redef class ToolContext
# Also copy over the java files
dir = "{android_project_root}/src/"
- var extra_java_files = compiler.mainmodule.extra_java_files
- if extra_java_files != null then for file in extra_java_files do
- var path = file.filename
- path.file_copy_to("{dir}/{path.basename("")}")
+ for mmodule in compiler.mainmodule.in_importation.greaters do
+ var extra_java_files = mmodule.extra_java_files
+ if extra_java_files != null then for file in extra_java_files do
+ var path = file.filename
+ path.file_copy_to(dir/path.basename(""))
+ end
end
## Generate delagating makefile
<application
android:label="@string/app_name"
android:hasCode="true"
- android:debuggable="{{{not release}}}">
+ android:debuggable="{{{not release}}}"
+ {{{icon_declaration}}}>
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="android.app.NativeActivity"
android:label="@string/app_name"
- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
- android:configChanges="orientation|keyboardHidden"
- android:screenOrientation="portrait"
+ {{{project.manifest_activity_attributes.join("\n")}}}
{{{icon_declaration}}}>
- <!-- Tell NativeActivity the name of or .so -->
- <meta-data android:name=\"{{{app_package}}}\"
- android:value=\"{{{app_name}}}\" />
+ <!-- Tell NativeActivity the name of our .so -->
+ <meta-data android:name=\"android.app.lib_name\"
+ android:value=\"main\" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
# libpng is not available on Android NDK
# FIXME make obtionnal when we have alternatives to mnit
var nit_dir = toolcontext.nit_dir
- var share_dir = "{nit_dir or else ""}/share/"
- if nit_dir == null or not share_dir.file_exists then
+ var share_dir = nit_dir/"share/"
+ if not share_dir.file_exists then
print "Android project error: Nit share directory not found, please use the environment variable NIT_DIR"
exit 1
end
end
end
- ### copy resources (for android)
- # This will be accessed from `android_project_root`
- var res_dir
+ ### Copy resources and libs where expected by the SDK
+ var project_root
if compiler.mainmodule.location.file != null then
# it is a real file, use "{file}/../res"
- res_dir = "{compiler.mainmodule.location.file.filename.dirname}/../res"
+ project_root = "{compiler.mainmodule.location.file.filename.dirname}/.."
else
# probably used -m, use "."
- res_dir = "res"
+ project_root = "."
end
+
+ # Android resources folder
+ var res_dir = project_root / "res"
if res_dir.file_exists then
# copy the res folder to .nit_compile
res_dir = res_dir.realpath
- var target_res_dir = "{android_project_root}"
- toolcontext.exec_and_check(["cp", "-R", res_dir, target_res_dir], "Android project error")
+ toolcontext.exec_and_check(["cp", "-R", res_dir, android_project_root], "Android project error")
end
if not res_dir.file_exists or not "{res_dir}/values/strings.xml".file_exists then
<string name="app_name">{{{app_name}}}</string>
</resources>""".write_to_file "{dir}/res/values/strings.xml"
end
+
+ # Android libs folder
+ var libs_dir = project_root / "libs"
+ if libs_dir.file_exists then
+ toolcontext.exec_and_check(["cp", "-r", libs_dir, android_project_root], "Android project error")
+ end
end
redef fun write_makefile(compiler, compile_dir, cfiles)