--- /dev/null
+#include <msp/io/file.h>
+#include <msp/io/print.h>
+#include "androidmanifestfile.h"
+#include "androidmanifestgenerator.h"
+#include "component.h"
+#include "sharedlibrary.h"
+#include "sourcepackage.h"
+
+using namespace std;
+using namespace Msp;
+
+AndroidManifestGenerator::AndroidManifestGenerator(Builder &b):
+ Tool(b, "AMG")
+{ }
+
+Target *AndroidManifestGenerator::create_target(const list<Target *> &, const string &)
+{
+ throw logic_error("not implemented");
+}
+
+Task *AndroidManifestGenerator::run(const Target &target) const
+{
+ const AndroidManifestFile &manifest = dynamic_cast<const AndroidManifestFile &>(target);
+ Worker *worker = new Worker(manifest);
+ return new InternalTask(worker);
+}
+
+
+AndroidManifestGenerator::Worker::Worker(const AndroidManifestFile &m):
+ manifest(m)
+{ }
+
+void AndroidManifestGenerator::Worker::main()
+{
+ const Component &comp = *manifest.get_component();
+ const SourcePackage &pkg = comp.get_package();
+
+ 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());
+ if(SharedLibrary *native_lib = manifest.get_native_library())
+ {
+ out.write("\t\t<activity android:name=\"android.app.NativeActivity\">\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\t\t<category android:name=\"android.intent.category.LAUNCHER\" />\n");
+ out.write("\t\t\t</intent-filter>\n");
+ out.write("\t\t</activity>\n");
+ }
+ out.write("\t</application>\n");
+ out.write("</manifest>\n");
+
+ status = Task::SUCCESS;
+}