1 #include <msp/builder/component.h>
2 #include <msp/builder/sharedlibrary.h>
3 #include <msp/builder/sourcepackage.h>
4 #include <msp/io/file.h>
5 #include <msp/io/print.h>
6 #include "androidmanifestfile.h"
7 #include "androidmanifestgenerator.h"
12 AndroidManifestGenerator::AndroidManifestGenerator(Builder &b):
15 set_run_internal(_run);
18 Target *AndroidManifestGenerator::create_target(const vector<Target *> &, const string &)
20 throw logic_error("not implemented");
23 bool AndroidManifestGenerator::_run(const AndroidManifestFile &manifest)
25 const Component &comp = *manifest.get_component();
26 const SourcePackage &pkg = comp.get_package();
29 manifest.collect_build_info(binfo);
31 IO::BufferedFile out(manifest.get_path().str(), IO::M_WRITE);
32 out.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
33 IO::print(out, "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\" package=\"%s\">\n", comp.get_name());
34 out.write("\t<uses-sdk android:minSdkVersion=\"9\" />\n");
35 // TODO Make the icon name configurable
36 bool debuggable = binfo.debug;
37 IO::print(out, "\t<application android:icon=\"@drawable/icon\" android:label=\"%s\" android:hasCode=\"false\" android:debuggable=\"%s\">\n", pkg.get_label(), debuggable);
38 if(SharedLibrary *native_lib = manifest.get_native_library())
40 out.write("\t\t<activity android:name=\"android.app.NativeActivity\"");
41 const string &orientation = manifest.get_orientation();
42 if(!orientation.empty())
43 IO::print(out, " android:screenOrientation=\"%s\"", orientation);
45 IO::print(out, "\t\t\t<meta-data android:name=\"android.app.lib_name\" android:value=\"%s\" />\n", native_lib->get_libname());
46 out.write("\t\t\t<intent-filter>\n");
47 out.write("\t\t\t\t<action android:name=\"android.intent.action.MAIN\" />\n");
48 out.write("\t\t\t\t<category android:name=\"android.intent.category.LAUNCHER\" />\n");
49 out.write("\t\t\t</intent-filter>\n");
50 out.write("\t\t</activity>\n");
52 out.write("\t</application>\n");
53 for(const string &p: manifest.get_permissions())
54 IO::print(out, "\t<uses-permission android:name=\"%s\" />\n", p);
55 out.write("</manifest>\n");