]> git.tdb.fi Git - builder.git/commitdiff
Variables in Build files weren't such a hot idea. KISS.
authorMikko Rasa <tdb@tdb.fi>
Mon, 16 Jul 2012 17:32:05 +0000 (20:32 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 16 Jul 2012 19:27:35 +0000 (22:27 +0300)
source/component.cpp
source/config.cpp
source/config.h
source/sourcepackage.cpp
source/sourcepackage.h

index 93d450b4a47372297e6da6c797006837b4c4e277..3ce6b14297a40bfb774846d4133e4bac389edeb5 100644 (file)
@@ -32,9 +32,6 @@ Component::Component(SourcePackage &p, Type t, const string &n):
 
 void Component::configure(const StringMap &opts, unsigned flag)
 {
-       for(StringList::iterator i=sources.begin(); i!=sources.end(); ++i)
-               *i = (pkg.get_source()/pkg.expand_string(*i)).str();
-
        for(PackageList::const_iterator i=requires.begin(); i!=requires.end(); ++i)
                (*i)->configure(opts, flag&2);
 }
@@ -249,7 +246,7 @@ Component::Loader::Loader(Component &c):
 
 void Component::Loader::source(const string &s)
 {
-       obj.sources.push_back(s);
+       obj.sources.push_back((obj.pkg.get_source()/s).str());
 }
 
 void Component::Loader::require(const string &n)
index 489026329ec4338390badffe13be7b5b6ef08435..c6dcb70b25ee9a31f90fa0ffce557592ce36c850 100644 (file)
@@ -52,12 +52,6 @@ bool Config::update(const StringMap &opts)
        return changed_now;
 }
 
-void Config::finish()
-{
-       for(OptionMap::iterator i=options.begin(); i!=options.end(); ++i)
-               i->second.value = package.expand_string(i->second.value);
-}
-
 void Config::save() const
 {
        if(!changed)
index 64e42259defb93454237f316a817155218ea31d7..9043208364b554e518feb8a74ff1a18e37df730e 100644 (file)
@@ -67,9 +67,6 @@ public:
        were changed. */
        bool update(const StringMap &);
 
-       /** Expands any variable references in options. */
-       void finish();
-
        void save() const;
        bool set_option(const std::string &, const std::string &);
        void load();
index 44faa071512280cec93c9ee8e8348e51c63333a0..ca49976a9c95cddefe6b1e9d0e8fa54618c3e9ef 100644 (file)
@@ -63,50 +63,6 @@ FS::Path SourcePackage::get_out_dir() const
                return source/arch.get_name()/detail;
 }
 
-string SourcePackage::expand_string(const string &str) const
-{
-       string result = str;
-       string::size_type dollar = 0;
-       unsigned n = 0;
-       while((dollar = result.find('$'))!=string::npos)
-       {
-               if(n>1000)
-                       throw bad_expansion("nested too deep");
-
-               string::size_type end;
-               string var;
-               if(dollar+1<result.size() && result[dollar+1]=='{')
-               {
-                       end = result.find('}', dollar+2);
-                       if(end==string::npos)
-                               throw bad_expansion("unterminated variable reference");
-                       var = result.substr(dollar+2, end-dollar-2);
-                       ++end;
-               }
-               else
-               {
-                       for(end=dollar+1; (isalnum(result[end]) || result[end]=='_'); ++end) ;
-                       var = result.substr(dollar+1, end-dollar-1);
-               }
-
-               string value;
-               if(config.is_option(var))
-                       value = config.get_option(var).value;
-               else if(var=="arch")
-                       value = builder.get_current_arch().get_name();
-               else if(var=="system")
-                       value = builder.get_current_arch().get_system();
-               else if(const char *ptr = getenv(var.c_str()))
-                       value = ptr;
-
-               result.replace(dollar, end-dollar, value);
-
-               ++n;
-       }
-
-       return result;
-}
-
 void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
 {
        init_config();
@@ -116,8 +72,6 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag)
        if(flag && config.update(opts))
                builder.get_logger().log("configure", format("Configuration of %s changed", name));
 
-       config.finish();
-
        deps_cache.load();
 
        for(ComponentList::iterator i=components.begin(); i!=components.end(); ++i)
index 9327f17c4eccc619cfa9e1b2dd5226d93c8ed701..23e376eb89393d12c51ac05840910490c68b054a 100644 (file)
@@ -77,7 +77,6 @@ public:
        Builder &get_builder() const { return builder; }
 
        DependencyCache &get_deps_cache() const { return deps_cache; }
-       std::string expand_string(const std::string &) const;
 private:
        virtual void do_configure(const StringMap &, unsigned);