]> git.tdb.fi Git - builder.git/blobdiff - source/apkbuilder.cpp
Refactor transitive dependencies to work on all targets
[builder.git] / source / apkbuilder.cpp
diff --git a/source/apkbuilder.cpp b/source/apkbuilder.cpp
deleted file mode 100644 (file)
index e426c89..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#include <msp/fs/utils.h>
-#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");
-       set_run(_run);
-}
-
-Target *ApkBuilder::create_target(const vector<Target *> &sources, const string &)
-{
-       AndroidResourceBundle *resource_bundle = 0;
-       vector<FileTarget *> other_files;
-       other_files.reserve(sources.size());
-       for(Target *s: sources)
-       {
-               if(AndroidResourceBundle *r = dynamic_cast<AndroidResourceBundle *>(s))
-                       resource_bundle = r;
-               else if(FileTarget *f = dynamic_cast<FileTarget *>(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(ToolData &tool) const
-{
-       Tool *jarsigner = &builder.get_toolchain().get_tool("JSGN");
-       jarsigner->prepare();
-       tool.extra_data = jarsigner;
-}
-
-Task *ApkBuilder::_run(const AndroidPackageFile &apk)
-{
-       const ApkBuilder &tool = dynamic_cast<const ApkBuilder &>(*apk.get_tool());
-
-       ExternalTask::Arguments argv;
-       argv.push_back(tool.get_executable()->get_path().str());
-       argv.push_back("u");
-
-       FS::Path input_path;
-       vector<FS::Path> files;
-       files.reserve(apk.get_dependencies().size());
-       for(Target *d: apk.get_dependencies())
-       {
-               FileTarget *file = dynamic_cast<FileTarget *>(d);
-               Target *real = d->get_real_target();
-
-               if(dynamic_cast<AndroidResourceBundle *>(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(tool.extra_data.value<Tool *>()->run(apk));
-       return chain;
-}