From eadb72197ef2fde2a44914067277054c59b67161 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 19 Dec 2022 20:01:03 +0200 Subject: [PATCH] Combine the processing of configuration and tool overrides --- source/buildercli.cpp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/source/buildercli.cpp b/source/buildercli.cpp index 1952f59..2e588ad 100644 --- a/source/buildercli.cpp +++ b/source/buildercli.cpp @@ -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; -- 2.45.2