From 683301f94f4a3c5b7e2a7f21087f4185b07c4858 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 18 Sep 2006 22:08:52 +0000 Subject: [PATCH] Support custom build info Support single source files --- source/builder.cpp | 25 ++++++++++--------------- source/buildinfo.cpp | 13 +++++++++++++ source/buildinfo.h | 16 ++++++++++++++++ source/component.cpp | 6 +++--- source/component.h | 2 +- source/package.cpp | 6 ++++++ source/package.h | 1 + 7 files changed, 50 insertions(+), 19 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index 2c137ca..7ba6be8 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -312,9 +312,16 @@ int Builder::create_targets() const PathList &sources=j->get_sources(); for(PathList::const_iterator k=sources.begin(); k!=sources.end(); ++k) { - list sfiles=list_files(*k); - for(list::iterator l=sfiles.begin(); l!=sfiles.end(); ++l) - files.push_back(*k / *l); + struct stat st; + stat(*k, st); + if(S_ISDIR(st.st_mode)) + { + list sfiles=list_files(*k); + for(list::iterator l=sfiles.begin(); l!=sfiles.end(); ++l) + files.push_back(*k / *l); + } + else + files.push_back(*k); } bool build_exe=j->get_type()!=Component::HEADERS; @@ -444,12 +451,8 @@ int Builder::build() vector actions; - //ProgressBar *progress=0; if(chrome) - { - //progress=new ProgressBar(cout, total); cout<<"0 targets built\n"; - } unsigned count=0; bool fail=false; @@ -462,12 +465,6 @@ int Builder::build() Target *tgt=cmdline->get_buildable_target(); if(tgt) { - /*if(chrome) - { - cout<<"\e["<set(count); - cout<<"\e["<build(); if(action) actions.push_back(action); @@ -507,8 +504,6 @@ int Builder::build() } } - //delete progress; - return fail?-1:0; } diff --git a/source/buildinfo.cpp b/source/buildinfo.cpp index 7669546..340fd96 100644 --- a/source/buildinfo.cpp +++ b/source/buildinfo.cpp @@ -31,3 +31,16 @@ void BuildInfo::unique(InfoList &l) l2.push_back(*i); swap(l, l2); } + +BuildInfo::Loader::Loader(BuildInfo &bi): + binfo(bi) +{ + add("cflag", &Loader::cflag); + add("incpath", &Loader::incpath); + add("define", &Loader::define); + add("ldflag", &Loader::ldflag); + add("libpath", &Loader::libpath); + add("library", &Loader::library); +} + + diff --git a/source/buildinfo.h b/source/buildinfo.h index a4035b1..2e98906 100644 --- a/source/buildinfo.h +++ b/source/buildinfo.h @@ -3,10 +3,26 @@ #include #include +#include class BuildInfo { public: + class Loader: public Msp::Parser::Loader + { + public: + Loader(BuildInfo &); + private: + BuildInfo &binfo; + + void cflag(const std::string &s) { binfo.cflags.push_back(s); } + void incpath(const std::string &s) { binfo.incpath.push_back(s); } + void define(const std::string &s) { binfo.defines.push_back(s); } + void ldflag(const std::string &s) { binfo.ldflags.push_back(s); } + void libpath(const std::string &s) { binfo.libpath.push_back(s); } + void library(const std::string &s) { binfo.libs.push_back(s); } + }; + typedef std::list InfoList; InfoList cflags; diff --git a/source/component.cpp b/source/component.cpp index 1fd6b24..e0630e6 100644 --- a/source/component.cpp +++ b/source/component.cpp @@ -22,7 +22,7 @@ Component::Loader::Loader(Component &c): add("source", &Loader::source); add("install", &Component::install); add("install_headers", &Component::install_headers); - add("cflag", &Loader::cflag); + add("build_info", &Loader::build_info); } void Component::Loader::source(const string &s) @@ -30,7 +30,7 @@ void Component::Loader::source(const string &s) comp.sources.push_back(comp.pkg.get_source()/s); } -void Component::Loader::cflag(const string &f) +void Component::Loader::build_info() { - comp.build_info.cflags.push_back(f); + load_sub(comp.build_info); } diff --git a/source/component.h b/source/component.h index d0b3cc2..b1ce222 100644 --- a/source/component.h +++ b/source/component.h @@ -21,7 +21,7 @@ public: Component ∁ void source(const std::string &); - void cflag(const std::string &); + void build_info(); }; enum Type diff --git a/source/package.cpp b/source/package.cpp index 121213f..5861180 100644 --- a/source/package.cpp +++ b/source/package.cpp @@ -191,6 +191,7 @@ Package::Loader::Loader(Package &p): add("program", &Loader::program); add("library", &Loader::library); add("headers", &Loader::headers); + add("build_info", &Loader::build_info); } Package::Loader::~Loader() @@ -223,3 +224,8 @@ void Package::Loader::headers(const string &n) load_sub(prog); pkg.components.push_back(prog); } + +void Package::Loader::build_info() +{ + load_sub(pkg.build_info); +} diff --git a/source/package.h b/source/package.h index 06a68ba..eee1572 100644 --- a/source/package.h +++ b/source/package.h @@ -40,6 +40,7 @@ public: void program(const std::string &); void library(const std::string &); void headers(const std::string &); + void build_info(); }; Package(Builder &, const std::string &, const Msp::Path::Path &); -- 2.45.2