]> git.tdb.fi Git - builder.git/commitdiff
Combine the processing of configuration and tool overrides
authorMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:01:03 +0000 (20:01 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 19 Dec 2022 18:01:03 +0000 (20:01 +0200)
source/buildercli.cpp

index 1952f594bd7daece578b4d7e65e1608ba5044097..2e588aded12e2a2158432b83bbfb0d289ca8c534 100644 (file)
@@ -121,18 +121,6 @@ BuilderCLI::BuilderCLI(int argc, char **argv):
        else if(!clean && !create_makefile)
                build = true;
 
-       for(auto i=cmdline_targets.begin(); i!=cmdline_targets.end(); )
-       {
-               string::size_type equal = i->find('=');
-               if(equal!=string::npos)
-               {
-                       cmdline_options.insert({ i->substr(0, equal), i->substr(equal+1) });
-                       cmdline_targets.erase(i++);
-               }
-               else
-                       ++i;
-       }
-
        if(!work_dir.empty())
                FS::chdir(work_dir);
 
@@ -167,12 +155,18 @@ BuilderCLI::BuilderCLI(int argc, char **argv):
        builder.add_default_tools();
 
        const Toolchain &toolchain = builder.get_toolchain();
-       for(auto i=cmdline_options.begin(); i!=cmdline_options.end(); )
+       for(auto i=cmdline_targets.begin(); i!=cmdline_targets.end(); )
        {
-               if(toolchain.has_tool(i->first))
+               string::size_type equal = i->find('=');
+               if(equal!=string::npos)
                {
-                       toolchain.get_tool(i->first).set_command(i->second);
-                       cmdline_options.erase(i++);
+                       string key = i->substr(0, equal);
+                       string value = i->substr(equal+1);
+                       if(toolchain.has_tool(key))
+                               toolchain.get_tool(key).set_command(value);
+                       else
+                               cmdline_options.insert({ key, value });
+                       i = cmdline_targets.erase(i);
                }
                else
                        ++i;