X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fapkbuilder.cpp;h=9cd1a16b5b45e878bf194509438e9a06dd26d52b;hb=HEAD;hp=d232a6f927ee23827db9eaafacf7a5997e3f999d;hpb=d1f9551e05c9d341149eb490e05b1465d3d6b711;p=builder.git diff --git a/source/apkbuilder.cpp b/source/apkbuilder.cpp deleted file mode 100644 index d232a6f..0000000 --- a/source/apkbuilder.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include -#include "androidpackagefile.h" -#include "androidresourcebundle.h" -#include "apkbuilder.h" -#include "builder.h" -#include "chainedtask.h" -#include "component.h" -#include "externaltask.h" -#include "filetarget.h" -#include "sourcepackage.h" - -using namespace std; -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") -{ - set_command("jar"); -} - -Target *ApkBuilder::create_target(const vector &sources, const string &) -{ - AndroidResourceBundle *resource_bundle = 0; - vector other_files; - other_files.reserve(sources.size()); - for(Target *s: sources) - { - if(AndroidResourceBundle *r = dynamic_cast(s)) - resource_bundle = r; - 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); - apk->set_tool(*this); - return apk; -} - -void ApkBuilder::do_prepare() -{ - jarsigner = &builder.get_toolchain().get_tool("JSGN"); - jarsigner->prepare(); -} - -Task *ApkBuilder::run(const Target &tgt) const -{ - const AndroidPackageFile &apk = dynamic_cast(tgt); - - ExternalTask::Arguments argv; - argv.push_back(executable->get_path().str()); - argv.push_back("u"); - - FS::Path input_path; - vector files; - files.reserve(apk.get_dependencies().size()); - for(Target *d: apk.get_dependencies()) - { - FileTarget *file = dynamic_cast(d); - Target *real = d->get_real_target(); - - if(dynamic_cast(real)) - input_path = file->get_path(); - else if(real->get_package()==apk.get_package()) - files.push_back(file->get_path()); - } - - FS::Path work_dir = FS::dirname(input_path); - - 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)); - return chain; -}