From 59a8a590a7ad327d18f15fab32adee94cb8c8843 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 31 Oct 2021 18:24:36 +0200 Subject: [PATCH] Reorder functions to match the header --- source/binarypackage.cpp | 78 ++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/source/binarypackage.cpp b/source/binarypackage.cpp index aa1aed3..e48f17c 100644 --- a/source/binarypackage.cpp +++ b/source/binarypackage.cpp @@ -15,6 +15,45 @@ BinaryPackage::BinaryPackage(Builder &b, const string &n): use_pkgconfig = false; } +BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const Flags &flags, const Flags &static_flags) +{ + BinaryPackage *pkg = new BinaryPackage(builder, name); + pkg->use_pkgconfig = true; + + process_flags(flags, pkg->export_binfo); + + Flags exclusive_static_flags; + for(Flags::const_iterator i=static_flags.begin(); i!=static_flags.end(); ++i) + if(find(flags.begin(), flags.end(), *i)==flags.end()) + exclusive_static_flags.push_back(*i); + process_flags(exclusive_static_flags, pkg->static_binfo); + + return pkg; +} + +void BinaryPackage::process_flags(const Flags &flags, BuildInfo &binfo) +{ + for(Flags::const_iterator i=flags.begin(); i!=flags.end(); ++i) + { + if(!i->compare(0, 2, "-I")) + binfo.incpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-D")) + { + string::size_type equals = i->find('='); + if(equals!=string::npos) + binfo.defines[i->substr(2, equals-2)] = i->substr(equals+1); + else + binfo.defines[i->substr(2)] = string(); + } + else if(!i->compare(0, 2, "-L")) + binfo.libpath.push_back(i->substr(2)); + else if(!i->compare(0, 2, "-l")) + binfo.libs.push_back(i->substr(2)); + else if(*i=="-pthread") + binfo.threads = true; + } +} + void BinaryPackage::do_prepare() { bool has_relative_paths = false; @@ -113,45 +152,6 @@ void BinaryPackage::do_prepare() } } -BinaryPackage *BinaryPackage::from_flags(Builder &builder, const string &name, const Flags &flags, const Flags &static_flags) -{ - BinaryPackage *pkg = new BinaryPackage(builder, name); - pkg->use_pkgconfig = true; - - process_flags(flags, pkg->export_binfo); - - Flags exclusive_static_flags; - for(Flags::const_iterator i=static_flags.begin(); i!=static_flags.end(); ++i) - if(find(flags.begin(), flags.end(), *i)==flags.end()) - exclusive_static_flags.push_back(*i); - process_flags(exclusive_static_flags, pkg->static_binfo); - - return pkg; -} - -void BinaryPackage::process_flags(const Flags &flags, BuildInfo &binfo) -{ - for(Flags::const_iterator i=flags.begin(); i!=flags.end(); ++i) - { - if(!i->compare(0, 2, "-I")) - binfo.incpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-D")) - { - string::size_type equals = i->find('='); - if(equals!=string::npos) - binfo.defines[i->substr(2, equals-2)] = i->substr(equals+1); - else - binfo.defines[i->substr(2)] = string(); - } - else if(!i->compare(0, 2, "-L")) - binfo.libpath.push_back(i->substr(2)); - else if(!i->compare(0, 2, "-l")) - binfo.libs.push_back(i->substr(2)); - else if(*i=="-pthread") - binfo.threads = true; - } -} - BinaryPackage::Loader::Loader(BinaryPackage &p): DataFile::DerivedObjectLoader(p) -- 2.43.0