X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fapkbuilder.cpp;h=e487784f4eeebf2df37d974a01432fb70e00d85a;hb=1ed833343bc83b83c5f61cbfd74423bbba677a04;hp=9cd1a16b5b45e878bf194509438e9a06dd26d52b;hpb=68f084e4ed817da0c25cefa1772cadf97b8cfe5e;p=builder.git diff --git a/source/apkbuilder.cpp b/source/apkbuilder.cpp index 9cd1a16..e487784 100644 --- a/source/apkbuilder.cpp +++ b/source/apkbuilder.cpp @@ -15,21 +15,22 @@ using namespace Msp; // TODO Separate jar into its own tool and have this one just chain the two ApkBuilder::ApkBuilder(Builder &b): - Tool(b, "APK"), - jarsigner(0) + Tool(b, "APK") { set_command("jar"); + set_run(_run); } -Target *ApkBuilder::create_target(const list &sources, const string &) +Target *ApkBuilder::create_target(const vector &sources, const string &) { AndroidResourceBundle *resource_bundle = 0; - list other_files; - for(list::const_iterator i=sources.begin(); i!=sources.end(); ++i) + vector other_files; + other_files.reserve(sources.size()); + for(Target *s: sources) { - if(AndroidResourceBundle *r = dynamic_cast(*i)) + if(AndroidResourceBundle *r = dynamic_cast(s)) resource_bundle = r; - else if(FileTarget *f = dynamic_cast(*i)) + else if(FileTarget *f = dynamic_cast(s)) other_files.push_back(f); } AndroidPackageFile *apk = new AndroidPackageFile(builder, *resource_bundle->get_component(), *resource_bundle, other_files); @@ -43,21 +44,21 @@ void ApkBuilder::do_prepare() jarsigner->prepare(); } -Task *ApkBuilder::run(const Target &tgt) const +Task *ApkBuilder::_run(const AndroidPackageFile &apk) { - const AndroidPackageFile &apk = dynamic_cast(tgt); + const ApkBuilder &tool = dynamic_cast(*apk.get_tool()); ExternalTask::Arguments argv; - argv.push_back(executable->get_path().str()); + argv.push_back(tool.get_executable()->get_path().str()); argv.push_back("u"); - const Target::Dependencies &depends = apk.get_dependencies(); FS::Path input_path; - list files; - for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) + vector files; + files.reserve(apk.get_dependencies().size()); + for(Target *d: apk.get_dependencies()) { - FileTarget *file = dynamic_cast(*i); - Target *real = (*i)->get_real_target(); + FileTarget *file = dynamic_cast(d); + Target *real = d->get_real_target(); if(dynamic_cast(real)) input_path = file->get_path(); @@ -67,13 +68,13 @@ Task *ApkBuilder::run(const Target &tgt) const FS::Path work_dir = FS::dirname(input_path); - for(list::const_iterator i=files.begin(); i!=files.end(); ++i) - argv.push_back(FS::relative(*i, work_dir).str()); + for(const FS::Path &f: files) + argv.push_back(FS::relative(f, work_dir).str()); ExternalTask *task = new ExternalTask(argv, work_dir); task->set_stdin(FS::basename(input_path)); task->set_stdout(FS::relative(apk.get_path(), work_dir)); ChainedTask *chain = new ChainedTask(task); - chain->add_task(jarsigner->run(tgt)); + chain->add_task(tool.jarsigner->run(apk)); return chain; }