From 11b4732f81396aa3d8b0fc8928b8e1981032e743 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 6 Oct 2014 23:43:34 +0300 Subject: [PATCH] Drop support for generic tarball components I originally envisioned using them for creating binary release tarballs, but that turns out to be a less than spectacular idea. Tarballs only really work as a distribution format on Linux. Other platforms either use a different archive format or require more complicated preparations. --- Build | 2 +- source/buildgraph.cpp | 2 +- source/component.h | 2 +- source/sourcearchivecomponent.cpp | 41 +++++++++++++++++ ...llcomponent.h => sourcearchivecomponent.h} | 4 +- source/sourcepackage.cpp | 22 ++++----- source/sourcepackage.h | 6 +-- source/tarballcomponent.cpp | 46 ------------------- 8 files changed, 60 insertions(+), 65 deletions(-) create mode 100644 source/sourcearchivecomponent.cpp rename source/{tarballcomponent.h => sourcearchivecomponent.h} (58%) delete mode 100644 source/tarballcomponent.cpp diff --git a/Build b/Build index 9e7ee86..fff39a9 100644 --- a/Build +++ b/Build @@ -15,7 +15,7 @@ package "builder" install true; }; - source_tarball + source_archive { source "bootstrap.sh"; source "Readme.txt"; diff --git a/source/buildgraph.cpp b/source/buildgraph.cpp index 94b5ed6..6ae13dc 100644 --- a/source/buildgraph.cpp +++ b/source/buildgraph.cpp @@ -14,7 +14,7 @@ BuildGraph::BuildGraph(Builder &b): Target *world = new VirtualTarget(builder, "world"); world->add_dependency(*new VirtualTarget(builder, "default")); world->add_dependency(*new VirtualTarget(builder, "install")); - world->add_dependency(*new VirtualTarget(builder, "tarballs")); + world->add_dependency(*new VirtualTarget(builder, "archives")); } BuildGraph::~BuildGraph() diff --git a/source/component.h b/source/component.h index d33ca25..1fbe3de 100644 --- a/source/component.h +++ b/source/component.h @@ -48,8 +48,8 @@ protected: InstallMap install_map; std::list problems; -public: Component(SourcePackage &, const std::string &); +public: virtual ~Component() { } const SourcePackage &get_package() const { return package; } diff --git a/source/sourcearchivecomponent.cpp b/source/sourcearchivecomponent.cpp new file mode 100644 index 0000000..6dc5fe6 --- /dev/null +++ b/source/sourcearchivecomponent.cpp @@ -0,0 +1,41 @@ +#include +#include "builder.h" +#include "file.h" +#include "sourcearchivecomponent.h" +#include "sourcepackage.h" +#include "tool.h" + +using namespace std; + +SourceArchiveComponent::SourceArchiveComponent(SourcePackage &p): + Component(p, p.get_name()+"-source") +{ } + +void SourceArchiveComponent::create_targets() const +{ + Builder &builder = package.get_builder(); + + list files; + files.insert(files.begin(), &package.get_build_file()); + + SourceList source_filenames = collect_source_files(); + for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) + { + FileTarget *file = builder.get_vfs().get_target(*i); + if(!file) + file = new File(builder, package, *i); + files.push_back(file); + } + + BuildGraph &build_graph = builder.get_build_graph(); + const BuildGraph::TargetMap &targets = build_graph.get_targets(); + for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) + if(i->second->get_package()==&package && !i->second->is_buildable()) + if(find(files.begin(), files.end(), i->second)==files.end()) + files.push_back(i->second); + + const Toolchain &toolchain = builder.get_toolchain(); + string archive_name = package.get_name()+"-"+package.get_version()+"-source"; + Target *result = toolchain.get_tool("TAR").create_target(files, archive_name); + build_graph.get_target("archives")->add_dependency(*result); +} diff --git a/source/tarballcomponent.h b/source/sourcearchivecomponent.h similarity index 58% rename from source/tarballcomponent.h rename to source/sourcearchivecomponent.h index d54f95e..cfef56e 100644 --- a/source/tarballcomponent.h +++ b/source/sourcearchivecomponent.h @@ -3,10 +3,10 @@ #include "component.h" -class TarballComponent: public Component +class SourceArchiveComponent: public Component { public: - TarballComponent(SourcePackage &, const std::string &); + SourceArchiveComponent(SourcePackage &); virtual void create_targets() const; }; diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 1dd7dbd..9738146 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -13,10 +13,10 @@ #include "file.h" #include "installcomponent.h" #include "pkgconfigfile.h" -#include "tarballcomponent.h" -#include "tool.h" +#include "sourcearchivecomponent.h" #include "sourcegenerator.h" #include "sourcepackage.h" +#include "tool.h" using namespace std; using namespace Msp; @@ -33,8 +33,8 @@ SourcePackage::SourcePackage(Builder &b, const string &n, const FS::Path &f): build_file = builder.get_vfs().get_target(f); if(!build_file) build_file = new File(builder, *this, f); - source_tarball = new TarballComponent(*this, "@src"); - components.push_back(source_tarball); + source_archive = new SourceArchiveComponent(*this); + components.push_back(source_archive); } SourcePackage::~SourcePackage() @@ -169,7 +169,8 @@ void SourcePackage::Loader::init(const Config::InputOptions *o) add("install", &Loader::component); add("interface_version", &Loader::interface_version); add("datapack", &Loader::component); - add("source_tarball", &Loader::source_tarball); + add("source_archive", &Loader::source_archive); + add("source_tarball", &Loader::source_archive); add("tarball", &Loader::tarball); add("version", &Loader::version); } @@ -178,7 +179,7 @@ void SourcePackage::Loader::finish() { /* Make sure the source tarball is last in the list so targets from all other components wil be created first */ - ComponentList::iterator i = find(obj.components.begin(), obj.components.end(), obj.source_tarball); + ComponentList::iterator i = find(obj.components.begin(), obj.components.end(), obj.source_archive); if(i!=obj.components.end()) obj.components.splice(obj.components.end(), obj.components, i); } @@ -243,15 +244,14 @@ void SourcePackage::Loader::interface_version(const string &v) obj.version = v; } -void SourcePackage::Loader::source_tarball() +void SourcePackage::Loader::source_archive() { - load_sub(*obj.source_tarball); + load_sub(*obj.source_archive); } -void SourcePackage::Loader::tarball(const string &n) +void SourcePackage::Loader::tarball(const string &) { - TarballComponent trbl(obj, n); - load_sub(trbl); + IO::print("%s: Deprecated tarball component ignored\n", get_source()); } void SourcePackage::Loader::version(const string &v) diff --git a/source/sourcepackage.h b/source/sourcepackage.h index 6629600..ed8ad40 100644 --- a/source/sourcepackage.h +++ b/source/sourcepackage.h @@ -14,7 +14,7 @@ class Builder; class BuildType; class FileTarget; -class TarballComponent; +class SourceArchiveComponent; /** A package that can be built by Builder. @@ -42,7 +42,7 @@ public: void generate(const std::string &); void if_feature(const std::string &); void interface_version(const std::string &); - void source_tarball(); + void source_archive(); void tarball(const std::string &); void version(const std::string &); }; @@ -63,7 +63,7 @@ private: FeatureList features; BuildInfo build_info; ComponentList components; - TarballComponent *source_tarball; + SourceArchiveComponent *source_archive; Config config; mutable Cache cache; diff --git a/source/tarballcomponent.cpp b/source/tarballcomponent.cpp deleted file mode 100644 index c94103c..0000000 --- a/source/tarballcomponent.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include "builder.h" -#include "file.h" -#include "sourcepackage.h" -#include "tarballcomponent.h" -#include "tool.h" - -using namespace std; - -TarballComponent::TarballComponent(SourcePackage &p, const string &n): - Component(p, n) -{ } - -void TarballComponent::create_targets() const -{ - Builder &builder = package.get_builder(); - - list files; - SourceList source_filenames = collect_source_files(); - for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) - { - FileTarget *file = builder.get_vfs().get_target(*i); - if(!file) - file = new File(builder, package, *i); - files.push_back(file); - } - - BuildGraph &build_graph = builder.get_build_graph(); - - string tarname = name; - if(name=="@src") - { - tarname = package.get_name()+"-"+package.get_version(); - files.insert(files.begin(), &package.get_build_file()); - - const BuildGraph::TargetMap &targets = build_graph.get_targets(); - for(BuildGraph::TargetMap::const_iterator i=targets.begin(); i!=targets.end(); ++i) - if(i->second->get_package()==&package && !i->second->is_buildable()) - if(find(files.begin(), files.end(), i->second)==files.end()) - files.push_back(i->second); - } - - const Toolchain &toolchain = builder.get_toolchain(); - Target *result = toolchain.get_tool("TAR").create_target(files, tarname); - build_graph.get_target("tarballs")->add_dependency(*result); -} -- 2.45.2