+++ /dev/null
-#include <msp/fs/utils.h>
-#include "androidapplicationcomponent.h"
-#include "androidmanifestfile.h"
-#include "androidresourcefile.h"
-#include "builder.h"
-#include "installedfile.h"
-#include "sharedlibrary.h"
-#include "sourcepackage.h"
-#include "tool.h"
-#include "toolchain.h"
-
-using namespace std;
-using namespace Msp;
-
-AndroidApplicationComponent::AndroidApplicationComponent(SourcePackage &p, const string &n):
- Component(p, n)
-{ }
-
-void AndroidApplicationComponent::create_targets() const
-{
- Builder &builder = package.get_builder();
- BuildGraph &build_graph = builder.get_build_graph();
-
- const BuildGraph::TargetMap &targets = build_graph.get_targets();
- list<Target *> contents;
- for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i)
- if(i->second->get_package()==&package)
- if(InstalledFile *inst = dynamic_cast<InstalledFile *>(i->second))
- contents.push_back(inst->get_real_target());
-
- AndroidManifestFile *manifest = new AndroidManifestFile(builder, *this);
-
- list<Target *> resource_sources;
- resource_sources.push_back(manifest);
-
- const Toolchain &toolchain = builder.get_toolchain();
- Tool © = toolchain.get_tool("CP");
- SourceList source_filenames = collect_source_files();
- for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i)
- {
- Target *tgt = new AndroidResourceFile(builder, *this, *i);
- resource_sources.push_back(copy.create_target(*tgt, "//"));
- }
-
- Tool &aapt = toolchain.get_tool("AAPT");
- Target *resource_bundle = aapt.create_target(resource_sources);
-
- list<Target *> apk_sources;
- apk_sources.push_back(resource_bundle);
-
- const Architecture &arch = package.get_builder().get_current_arch();
- string lib_dir = "//"+name+"/lib/";
- if(arch.get_type()=="arm")
- {
- lib_dir += "armeabi";
- if(arch.get_cpu()=="armv7a")
- lib_dir += "-v7a";
- }
- else
- lib_dir += arch.get_type();
-
- string assets_dir = "//"+name+"/assets";
- for(list<Target *>::const_iterator i=contents.begin(); i!=contents.end(); ++i)
- {
- Target *staged = 0;
- if(SharedLibrary *shlib = dynamic_cast<SharedLibrary *>(*i))
- {
- manifest->set_native_library(shlib);
- staged = copy.create_target(**i, lib_dir);
- }
- else
- staged = copy.create_target(**i, assets_dir);
- apk_sources.push_back(staged);
- }
-
- Tool &apk_builder = toolchain.get_tool("APK");
- Target *apk = apk_builder.create_target(apk_sources);
- builder.get_build_graph().add_primary_target(*apk);
-}