From 276a7c7c046a8f1b692cecbd53f17595ed23264d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 9 Oct 2014 01:42:04 +0300 Subject: [PATCH] A bunch of minor cleanups --- Build | 2 -- source/androidtools.cpp | 8 +------- source/file.h | 2 +- source/gnucompiler.cpp | 3 +-- source/gnulinker.cpp | 4 +--- source/installcomponent.cpp | 10 ++++------ source/pkgconfigfile.h | 2 +- source/sourcegenerator.cpp | 10 +--------- source/sourcegenerator.h | 4 ---- source/sourcepackage.cpp | 10 +++++----- 10 files changed, 15 insertions(+), 40 deletions(-) diff --git a/Build b/Build index 5e50e8f..1abaa6c 100644 --- a/Build +++ b/Build @@ -1,5 +1,3 @@ -/* $Id$ */ - package "builder" { version "2.0"; diff --git a/source/androidtools.cpp b/source/androidtools.cpp index b89af6e..c0fe6d1 100644 --- a/source/androidtools.cpp +++ b/source/androidtools.cpp @@ -78,17 +78,11 @@ void AndroidNdk::find_toolchain_dir() list tc_archs = list_files(toolchains_dir/use_toolchain/"prebuilt"); string use_arch; for(list::const_iterator i=tc_archs.begin(); i!=tc_archs.end(); ++i) - { - string tca = *i; - for(string::iterator j=tca.begin(); j!=tca.end(); ++j) - if(*j=='_') - *j = '-'; - if(native_arch.match_name(tca)) + if(native_arch.match_name(*i)) { use_arch = *i; break; } - } if(use_arch.empty()) throw runtime_error("No matching toolchain found"); diff --git a/source/file.h b/source/file.h index aa0035f..5a216a9 100644 --- a/source/file.h +++ b/source/file.h @@ -4,7 +4,7 @@ #include "filetarget.h" /** -Just an arbitary file. No special meaning attached. +Just an arbitrary file. No special meaning attached. */ class File: public FileTarget { diff --git a/source/gnucompiler.cpp b/source/gnucompiler.cpp index 6daa99d..2f6393e 100644 --- a/source/gnucompiler.cpp +++ b/source/gnucompiler.cpp @@ -92,7 +92,6 @@ void GnuCompiler::do_prepare() Task *GnuCompiler::run(const Target &target) const { const ObjectFile &object = dynamic_cast(target); - const Component &comp = *object.get_component(); ExternalTask::Arguments argv; argv.push_back(executable->get_path().str()); @@ -190,7 +189,7 @@ Task *GnuCompiler::run(const Target &target) const FS::Path obj_path = object.get_path(); FS::Path src_path = object.get_source().get_path(); - FS::Path work_dir = comp.get_package().get_source_directory(); + FS::Path work_dir = object.get_component()->get_package().get_source_directory(); argv.push_back("-o"); argv.push_back(relative(obj_path, work_dir).str()); diff --git a/source/gnulinker.cpp b/source/gnulinker.cpp index e266a8e..2ec4c04 100644 --- a/source/gnulinker.cpp +++ b/source/gnulinker.cpp @@ -174,9 +174,7 @@ Task *GnuLinker::Linker::run(const Target &target) const vector argv; argv.push_back(executable->get_path().str()); - const Component &comp = *bin.get_component(); - - FS::Path work_dir = comp.get_package().get_source_directory(); + FS::Path work_dir = bin.get_component()->get_package().get_source_directory(); if(const SharedLibrary *shlib = dynamic_cast(&bin)) { diff --git a/source/installcomponent.cpp b/source/installcomponent.cpp index 9584a51..ed3c191 100644 --- a/source/installcomponent.cpp +++ b/source/installcomponent.cpp @@ -19,11 +19,9 @@ void InstallComponent::create_targets() const SourceList source_filenames = collect_source_files(); for(SourceList::const_iterator i=source_filenames.begin(); i!=source_filenames.end(); ++i) { - FileTarget *ft; - if(Target *tgt = builder.get_vfs().get_target(*i)) - ft = dynamic_cast(tgt); - else - ft = new File(builder, package, *i); - inst->add_dependency(*copy.create_target(*ft, name)); + Target *tgt = builder.get_vfs().get_target(*i); + if(!tgt) + tgt = new File(builder, package, *i); + inst->add_dependency(*copy.create_target(*tgt, name)); } } diff --git a/source/pkgconfigfile.h b/source/pkgconfigfile.h index 1a31c38..5ec1aa4 100644 --- a/source/pkgconfigfile.h +++ b/source/pkgconfigfile.h @@ -12,7 +12,7 @@ class PkgConfigFile: public FileTarget public: PkgConfigFile(Builder &, const SourcePackage &); - virtual const char *get_type() const { return "PkgConfig"; } + virtual const char *get_type() const { return "PkgConfigFile"; } }; #endif diff --git a/source/sourcegenerator.cpp b/source/sourcegenerator.cpp index c09e5c7..4f75721 100644 --- a/source/sourcegenerator.cpp +++ b/source/sourcegenerator.cpp @@ -49,14 +49,6 @@ Target *SourceGenerator::create_target(const list &sources, const stri return primary; } -void SourceGenerator::do_prepare() -{ - FS::Path exe_fn = package.get_source_directory()/command; - executable = builder.get_vfs().get_target(exe_fn); - if(!executable) - executable = new Executable(builder, exe_fn); -} - Task *SourceGenerator::run(const Target &target) const { const SourceFile &out_src = dynamic_cast(target); @@ -86,7 +78,7 @@ SourceGenerator::Loader::Loader(SourceGenerator &sg): void SourceGenerator::Loader::command(const string &c) { - obj.set_command(c); + obj.set_command((obj.package.get_source_directory()/c).str()); } void SourceGenerator::Loader::in_suffix(const string &s) diff --git a/source/sourcegenerator.h b/source/sourcegenerator.h index b3c00e4..28456ad 100644 --- a/source/sourcegenerator.h +++ b/source/sourcegenerator.h @@ -29,10 +29,6 @@ public: virtual Target *create_source(const Component &, const Msp::FS::Path &) const; virtual Target *create_target(const std::list &, const std::string &); -private: - virtual void do_prepare(); - -public: virtual Task *run(const Target &) const; }; diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 9738146..2742300 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -158,17 +158,17 @@ SourcePackage::Loader::Loader(SourcePackage &p, const Config::InputOptions &o): void SourcePackage::Loader::init(const Config::InputOptions *o) { options = o; - add("description", &SourcePackage::description); add("build_info", &Loader::build_info); + add("datapack", &Loader::component); + add("description", &SourcePackage::description); add("feature", &Loader::feature); add("generate", &Loader::generate); add("if_feature", &Loader::if_feature); - add("program", &Loader::component_arg); - add("library", &Loader::component_arg); - add("module", &Loader::component_arg); add("install", &Loader::component); add("interface_version", &Loader::interface_version); - add("datapack", &Loader::component); + add("library", &Loader::component_arg); + add("module", &Loader::component_arg); + add("program", &Loader::component_arg); add("source_archive", &Loader::source_archive); add("source_tarball", &Loader::source_archive); add("tarball", &Loader::tarball); -- 2.43.0