+#include <msp/core/algorithm.h>
#include <msp/fs/utils.h>
#include "androidassetpackagingtool.h"
#include "androidmanifestfile.h"
Tool(b, "AAPT"),
sdk(s)
{
- set_command((sdk.get_build_tools_dir()/"aapt").str());
+ if(sdk.get_root_dir().empty())
+ problems.push_back("Android SDK not found");
+ else if(sdk.get_build_tools_dir().empty())
+ problems.push_back("Android build-tools not found");
+ else
+ set_command((sdk.get_build_tools_dir()/"aapt").str());
+
+ if(sdk.get_platform_jar().empty())
+ problems.push_back("Android platform not found");
}
-Target *AndroidAssetPackagingTool::create_target(const list<Target *> &sources, const string &)
+Target *AndroidAssetPackagingTool::create_target(const vector<Target *> &sources, const string &)
{
AndroidManifestFile *manifest = 0;
- list<FileTarget *> resources;
- for(list<Target *>::const_iterator i=sources.begin(); i!=sources.end(); ++i)
+ vector<FileTarget *> resources;
+ resources.reserve(sources.size());
+ for(Target *s: sources)
{
- if(AndroidManifestFile *m = dynamic_cast<AndroidManifestFile *>(*i))
+ if(AndroidManifestFile *m = dynamic_cast<AndroidManifestFile *>(s))
manifest = m;
- else if(FileTarget *f = dynamic_cast<FileTarget *>(*i))
+ else if(FileTarget *f = dynamic_cast<FileTarget *>(s))
resources.push_back(f);
}
argv.push_back("-F");
argv.push_back(FS::relative(res.get_path(), work_dir).str());
- const Target::Dependencies &depends = res.get_dependencies();
- list<FS::Path> resource_dirs;
- for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i)
+ vector<FS::Path> resource_dirs;
+ resource_dirs.reserve(res.get_dependencies().size());
+ for(Target *d: res.get_dependencies())
{
- FileTarget *file = dynamic_cast<FileTarget *>(*i);
- Target *real = (*i)->get_real_target();
+ FileTarget *file = dynamic_cast<FileTarget *>(d);
+ Target *real = d->get_real_target();
if(dynamic_cast<AndroidManifestFile *>(real))
{
else if(real->get_package()==res.get_package())
{
const FS::Path &path = file->get_path();
- resource_dirs.push_back(path.subpath(0, path.size()-2));
+ FS::Path res_dir = path.subpath(0, path.size()-2);
+ if(!any_equals(resource_dirs, res_dir))
+ resource_dirs.push_back(res_dir);
}
}
- set<string> seen_dirs;
- for(list<FS::Path>::const_iterator i=resource_dirs.begin(); i!=resource_dirs.end(); ++i)
- if(seen_dirs.insert(i->str()).second)
- {
- argv.push_back("-S");
- argv.push_back(FS::relative(*i, work_dir).str());
- }
+ for(const FS::Path &d: resource_dirs)
+ {
+ argv.push_back("-S");
+ argv.push_back(FS::relative(d, work_dir).str());
+ }
return new ExternalTask(argv, work_dir);
}