#include "androidmanifestfile.h"
#include "androidmanifestgenerator.h"
#include "component.h"
+#include "internaltask.h"
#include "sharedlibrary.h"
#include "sourcepackage.h"
AndroidManifestGenerator::AndroidManifestGenerator(Builder &b):
Tool(b, "AMG")
-{ }
-
-Target *AndroidManifestGenerator::create_target(const list<Target *> &, const string &)
{
- throw logic_error("not implemented");
+ set_run_internal(_run);
}
-Task *AndroidManifestGenerator::run(const Target &target) const
+Target *AndroidManifestGenerator::create_target(const vector<Target *> &, const string &)
{
- const AndroidManifestFile &manifest = dynamic_cast<const AndroidManifestFile &>(target);
- Worker *worker = new Worker(manifest);
- return new InternalTask(worker);
+ throw logic_error("not implemented");
}
-
-AndroidManifestGenerator::Worker::Worker(const AndroidManifestFile &m):
- manifest(m)
-{ }
-
-void AndroidManifestGenerator::Worker::main()
+bool AndroidManifestGenerator::_run(const AndroidManifestFile &manifest)
{
const Component &comp = *manifest.get_component();
const SourcePackage &pkg = comp.get_package();
+ BuildInfo binfo;
+ manifest.collect_build_info(binfo);
+
IO::BufferedFile out(manifest.get_path().str(), IO::M_WRITE);
out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
IO::print(out, "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"%s\">\n", comp.get_name());
out.write("\t<uses-sdk android:minSdkVersion=\"9\" />\n");
// TODO Make the icon name configurable
- IO::print(out, "\t<application android:icon=\"@drawable/icon\" android:label=\"%s\" android:hasCode=\"false\">\n", pkg.get_label());
+ bool debuggable = binfo.debug;
+ IO::print(out, "\t<application android:icon=\"@drawable/icon\" android:label=\"%s\" android:hasCode=\"false\" android:debuggable=\"%s\">\n", pkg.get_label(), debuggable);
if(SharedLibrary *native_lib = manifest.get_native_library())
{
- out.write("\t\t<activity android:name=\"android.app.NativeActivity\">\n");
+ out.write("\t\t<activity android:name=\"android.app.NativeActivity\"");
+ const string &orientation = manifest.get_orientation();
+ if(!orientation.empty())
+ IO::print(out, " android:screenOrientation=\"%s\"", orientation);
+ out.write(">\n");
IO::print(out, "\t\t\t<meta-data android:name=\"android.app.lib_name\" android:value=\"%s\" />\n", native_lib->get_libname());
out.write("\t\t\t<intent-filter>\n");
out.write("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />\n");
out.write("\t\t</activity>\n");
}
out.write("\t</application>\n");
+ for(const string &p: manifest.get_permissions())
+ IO::print(out, "\t<uses-permission android:name=\"%s\" />\n", p);
out.write("</manifest>\n");
- status = Task::SUCCESS;
+ return true;
}