]> git.tdb.fi Git - builder.git/commitdiff
Refactor logger to do message formatting internally
authorMikko Rasa <tdb@tdb.fi>
Wed, 21 Dec 2022 10:26:15 +0000 (12:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 21 Dec 2022 11:59:40 +0000 (13:59 +0200)
This shortens the syntax of using it and may also provide a minor
performance improvement since formatting doesn't need to be done for
disabled channels.

22 files changed:
source/androidcompiler.cpp
source/androidtools.cpp
source/binarypackage.cpp
source/builder.cpp
source/buildercli.cpp
source/cache.cpp
source/component.cpp
source/conditionalloader.cpp
source/config.cpp
source/csourcefile.cpp
source/datatransform.cpp
source/gnucompiler.cpp
source/gnulinker.cpp
source/logger.cpp
source/logger.h
source/microsofttools.cpp
source/msvccompiler.cpp
source/msvclinker.cpp
source/packagemanager.cpp
source/target.cpp
source/tool.cpp
source/virtualfilesystem.cpp

index 68c4e56d2ad675a4ac64f72a492f4ff38305e78c..9ae31ac1b0d6d7fd732b188f65a4625c491ab36f 100644 (file)
@@ -68,7 +68,7 @@ void AndroidCompiler::do_prepare()
                build_info.incpath.push_back(public_dir);
 
                FS::Path arch_path = libstdcxx_path/"libs";
-               builder.get_logger().log("files", format("Traversing %s", arch_path.str()));
+               builder.get_logger().log("files", "Traversing %s", arch_path.str());
                string arch_dir = architecture->best_match(list_files(arch_path));
                if(!arch_dir.empty())
                {
index 1633b8b6465dd575acd0676536969a7b9d027af1..c5aab653c51fe3eec613412e1328daead5a2c3a8 100644 (file)
@@ -44,7 +44,7 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def
                        root = default_path;
                else
                {
-                       builder.get_logger().log("problems", format("Android %s not found", type));
+                       builder.get_logger().log("problems", "Android %s not found", type);
                        return;
                }
        }
@@ -53,13 +53,13 @@ AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &def
        if(!FS::exists(platforms_dir))
                return;
 
-       builder.get_logger().log("files", format("Traversing %s", platforms_dir.str()));
+       builder.get_logger().log("files", "Traversing %s", platforms_dir.str());
        supported_api_levels = 0;
        for(const string &p: list_filtered(platforms_dir, "^android-[1-9][0-9]*$"))
        {
                unsigned api = lexical_cast<unsigned>(p.substr(8));
                if(api>63)
-                       builder.get_logger().log("problems", format("API level %d is too high", api));
+                       builder.get_logger().log("problems", "API level %d is too high", api);
                else
                        supported_api_levels |= 1<<api;
        }
@@ -89,7 +89,7 @@ void AndroidSdk::find_build_tools_dir()
                return;
        }
 
-       builder.get_logger().log("files", format("Traversing %s", bt_dir.str()));
+       builder.get_logger().log("files", "Traversing %s", bt_dir.str());
        string use_tools;
        unsigned latest_version = 0;
        for(const string &v: list_files(bt_dir))
@@ -109,7 +109,7 @@ void AndroidSdk::find_build_tools_dir()
        }
 
        build_tools_dir = bt_dir/use_tools;
-       builder.get_logger().log("tools", format("Android build-tools found in %s", build_tools_dir.str()));
+       builder.get_logger().log("tools", "Android build-tools found in %s", build_tools_dir.str());
 }
 
 void AndroidSdk::init_api_level(unsigned api)
@@ -128,7 +128,7 @@ AndroidNdk::AndroidNdk(Builder &b, const Architecture &a, const AndroidSdk &sdk)
                if(FS::exists(csr))
                {
                        common_sysroot = csr;
-                       builder.get_logger().log("tools", format("Android NDK common sysroot is %s", common_sysroot));
+                       builder.get_logger().log("tools", "Android NDK common sysroot is %s", common_sysroot);
                }
        }
 
@@ -154,7 +154,7 @@ void AndroidNdk::find_toolchain_dir()
                return;
        }
 
-       builder.get_logger().log("files", format("Traversing %s", toolchains_dir.str()));
+       builder.get_logger().log("files", "Traversing %s", toolchains_dir.str());
        string prefix = architecture.get_cross_prefix()+"-";
        string use_toolchain;
        unsigned latest_version = 0;
@@ -190,7 +190,7 @@ void AndroidNdk::find_toolchain_dir()
        const Architecture &native_arch = builder.get_native_arch();
 
        FS::Path tc_archs_dir = toolchains_dir/use_toolchain/"prebuilt";
-       builder.get_logger().log("files", format("Traversing %s", tc_archs_dir.str()));
+       builder.get_logger().log("files", "Traversing %s", tc_archs_dir.str());
        string use_arch = native_arch.best_match(list_files(tc_archs_dir));
 
        if(use_arch.empty())
@@ -200,13 +200,13 @@ void AndroidNdk::find_toolchain_dir()
        }
 
        bin_dir = toolchains_dir/use_toolchain/"prebuilt"/use_arch/"bin";
-       builder.get_logger().log("tools", format("Android NDK toolchain binaries found in %s", bin_dir.str()));
+       builder.get_logger().log("tools", "Android NDK toolchain binaries found in %s", bin_dir.str());
 }
 
 void AndroidNdk::init_api_level(unsigned api)
 {
        FS::Path platform_archs_dir = root/"platforms"/format("android-%d", api);
-       builder.get_logger().log("files", format("Traversing %s", platform_archs_dir.str()));
+       builder.get_logger().log("files", "Traversing %s", platform_archs_dir.str());
        vector<string> platform_archs = list_filtered(platform_archs_dir, "^arch-");
        for(string &a: platform_archs)
                a.erase(0, 5);
@@ -219,7 +219,7 @@ void AndroidNdk::init_api_level(unsigned api)
        }
 
        platform_sysroot = platform_archs_dir/("arch-"+use_arch);
-       builder.get_logger().log("tools", format("Android NDK platform sysroot is %s", platform_sysroot));
+       builder.get_logger().log("tools", "Android NDK platform sysroot is %s", platform_sysroot);
 }
 
 
@@ -232,7 +232,7 @@ AndroidTools::AndroidTools(Builder &builder, const Architecture &arch):
                unsigned api = 0;
                for(unsigned i=32; i>0; i>>=1)
                        api += i*!!(common_api_levels>>(api+i));
-               builder.get_logger().log("tools", format("Using Android API level %d", api));
+               builder.get_logger().log("tools", "Using Android API level %d", api);
                sdk.select_api_level(api);
                ndk.select_api_level(api);
        }
index 66d1225f81b0643cea6eb4dd384c53366aa90690..adfca1a273bd4ae86b1296e23225918000f0c6cd 100644 (file)
@@ -105,7 +105,7 @@ void BinaryPackage::do_prepare()
                if(all_found)
                {
                        base_path = prefix;
-                       builder.get_logger().log("configure", format("%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str())));
+                       builder.get_logger().log("configure", "%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str()));
                        break;
                }
        }
@@ -113,7 +113,7 @@ void BinaryPackage::do_prepare()
        if(base_path.empty())
        {
                // TODO report which files were not found
-               builder.get_logger().log("problems", format("Cannot locate files for %s", name));
+               builder.get_logger().log("problems", "Cannot locate files for %s", name);
                problems.push_back("Cannot locate files");
                return;
        }
index 1b8ed3c16eb538d17afbc3933089f750bd12e4be..239258196632ca82d8928c0aeceb9d64700b2af0 100644 (file)
@@ -160,7 +160,7 @@ void Builder::load_build_file(const FS::Path &fn, const Config::InputOptions *op
 {
        IO::BufferedFile in(fn.str());
 
-       get_logger().log("files", format("Reading %s", fn));
+       get_logger().log("files", "Reading %s", fn);
 
        DataFile::Parser parser(in, fn.str());
        Loader loader(*this, opts, all);
@@ -182,7 +182,7 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
                get_logger().log("summary", "Already up to date");
                return 0;
        }
-       get_logger().log("summary", format("Will build %d target%s", total, (total!=1 ? "s" : "")));
+       get_logger().log("summary", "Will build %d target%s", total, (total!=1 ? "s" : ""));
 
        vector<Task *> tasks;
 
@@ -200,11 +200,11 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
                        if(tgt)
                        {
                                if(tgt->get_tool())
-                                       get_logger().log("tasks", format("%-4s  %s", tgt->get_tool()->get_tag(), tgt->get_name()));
+                                       get_logger().log("tasks", "%-4s  %s", tgt->get_tool()->get_tag(), tgt->get_name());
                                Task *task = tgt->build();
                                if(task)
                                {
-                                       get_logger().log("commands", format("%s", task->get_command()));
+                                       get_logger().log("commands", "%s", task->get_command());
                                        if(dry_run)
                                        {
                                                task->signal_finished.emit(true);
@@ -286,7 +286,7 @@ int Builder::clean(bool all, bool dry_run)
 
        for(Target *t: clean_tgts)
        {
-               get_logger().log("tasks", format("RM    %s", t->get_name()));
+               get_logger().log("tasks", "RM    %s", t->get_name());
                if(!dry_run)
                        t->clean();
        }
index 2469f5162862faf199f0931105cede9e0f0b72fa..41a2429a48aba8307c00553bb45583c183134e7c 100644 (file)
@@ -205,16 +205,16 @@ int BuilderCLI::main()
 
        const Architecture &native_arch = builder.get_native_arch();
        const Architecture &current_arch = builder.get_current_arch();
-       logger.log("environment", format("Building on %s, for %s%s", native_arch.get_name(),
-               current_arch.get_name(), (current_arch.is_native() ? " (native)" : "")));
-       logger.log("environment", format("Prefix is %s", builder.get_prefix()));
+       logger.log("environment", "Building on %s, for %s%s", native_arch.get_name(),
+               current_arch.get_name(), (current_arch.is_native() ? " (native)" : ""));
+       logger.log("environment", "Prefix is %s", builder.get_prefix());
        const FS::Path &tempdir = builder.get_temp_directory();
        if(tempdir.is_absolute())
-               logger.log("environment", format("Temporary directory is %s", tempdir));
+               logger.log("environment", "Temporary directory is %s", tempdir);
        else
-               logger.log("environment", format("Using per-package temporary directory %s", tempdir));
+               logger.log("environment", "Using per-package temporary directory %s", tempdir);
        const BuildType &build_type = builder.get_build_type();
-       logger.log("environment", format("Build type is %s", build_type.get_name()));
+       logger.log("environment", "Build type is %s", build_type.get_name());
 
        if(!prepare_build())
                return 1;
@@ -256,7 +256,7 @@ int BuilderCLI::main()
                package_details.push_back(line);
        }
 
-       logger.log("summary", format("%d active packages, %d targets", package_details.size(), build_graph.get_targets().size()));
+       logger.log("summary", "%d active packages, %d targets", package_details.size(), build_graph.get_targets().size());
        for(const string &d: package_details)
                logger.log("packages", d);
 
index 229783a002b92cf9b966e0459f010b028a1df490..30f3fc33a67141fe996874865828a76dd5ca39eb 100644 (file)
@@ -78,14 +78,14 @@ void Cache::append_value(const Target *tgt, const string &k, const string &v)
                i = data.insert({ key, Values() }).first;
        i->second.push_back(v);
        changed = true;
-       package.get_builder().get_logger().log("cache", format("Updated key %s %s+ %s", tgt->get_name(), k, v));
+       package.get_builder().get_logger().log("cache", "Updated key %s %s+ %s", tgt->get_name(), k, v);
 }
 
 void Cache::set_values(const Target *tgt, const string &k, const Values &v)
 {
        data[Key(tgt->get_name(), k)] = v;
        changed = true;
-       package.get_builder().get_logger().log("cache", format("Updated key %s %s: %s", tgt->get_name(), k, join(v.begin(), v.end())));
+       package.get_builder().get_logger().log("cache", "Updated key %s %s: %s", tgt->get_name(), k, join(v.begin(), v.end()));
 }
 
 const string &Cache::get_value(const Target *tgt, const string &k)
@@ -110,7 +110,7 @@ void Cache::load()
 {
        if(FS::Stat st = FS::stat(filename))
        {
-               package.get_builder().get_logger().log("files", format("Reading %s", filename));
+               package.get_builder().get_logger().log("files", "Reading %s", filename);
                IO::BufferedFile in(filename.str());
 
                while(!in.eof())
@@ -123,7 +123,7 @@ void Cache::load()
                        Values &values = data[key];
                        for(unsigned count = read_count(in); count; --count)
                                values.push_back(read_string(in));
-                       package.get_builder().get_logger().log("cache", format("Loaded key %s %s: %s", key.first, key.second, join(values.begin(), values.end())));
+                       package.get_builder().get_logger().log("cache", "Loaded key %s %s: %s", key.first, key.second, join(values.begin(), values.end()));
                }
 
                mtime = st.get_modify_time();
@@ -138,7 +138,7 @@ void Cache::save() const
        FS::Path dir = FS::dirname(filename);
        if(!FS::exists(dir))
                FS::mkpath(dir, 0755);
-       package.get_builder().get_logger().log("files", format("Writing %s", filename));
+       package.get_builder().get_logger().log("files", "Writing %s", filename);
        IO::BufferedFile out(filename.str(), IO::M_WRITE);
 
        for(const auto &kvp: data)
index a571933bd04eb4d299d4bcac1e09b303390322c3..e3f80fbc95b9becfd93c89ec9968784783d90dbf 100644 (file)
@@ -113,7 +113,7 @@ vector<FS::Path> Component::collect_source_files() const
                        set<string> overlay_files;
                        for(auto j=dirs.begin(); j!=dirs.end(); ++j)
                        {
-                               package.get_builder().get_logger().log("files", format("Traversing %s", *j));
+                               package.get_builder().get_logger().log("files", "Traversing %s", *j);
                                for(const string &f: list_files(*j))
                                {
                                        if(j!=dirs.begin())
index 623343549f842100df978091b65f711ddc87aac5..b9d9d25cbbd39bd1dbd6ac039c4228fdb8460c2e 100644 (file)
@@ -1,4 +1,3 @@
-#include <msp/strings/format.h>
 #include "booleanevaluator.h"
 #include "builder.h"
 #include "conditionalloader.h"
@@ -19,7 +18,7 @@ void ArchitectureConditional::if_arch(const string &cond)
        const Architecture &arch = builder.get_current_arch();
        BooleanEvaluator eval([&arch](const string &value){ return arch.match_name(value); });
        bool match = eval.evaluate(cond);
-       builder.get_logger().log("configure", format("%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not ")));
+       builder.get_logger().log("configure", "%s: arch %s %smatched", log_prefix, cond, (match ? "" : "not "));
        if(match)
                load_sub_with(*this);
 }
@@ -36,7 +35,7 @@ void FeatureConditional::if_feature(const string &cond)
 {
        BooleanEvaluator eval([this](const string &feat, const string *value){ return package.match_feature(feat, value); });
        bool match = eval.evaluate(cond);
-       package.get_builder().get_logger().log("configure", format("%s: feature %s %smatched", log_prefix, cond, (match ? "" : "not ")));
+       package.get_builder().get_logger().log("configure", "%s: feature %s %smatched", log_prefix, cond, (match ? "" : "not "));
        if(match)
                load_sub_with(*this);
 }
index 4e57fdfbbc70e6f8afbbef45f866f2ac94b5b3bb..74d582e7017ddd62bd7189b10c89faabe96f5d6f 100644 (file)
@@ -62,7 +62,7 @@ void Config::load()
        FS::Stat stat = FS::stat(fn);
        if(stat)
        {
-               package.get_builder().get_logger().log("files", format("Reading %s", fn));
+               package.get_builder().get_logger().log("files", "Reading %s", fn);
                IO::BufferedFile in(fn.str());
 
                mtime = stat.get_modify_time();
@@ -80,7 +80,7 @@ void Config::save() const
 
        FS::Path fn = package.get_source_directory()/".config";
 
-       package.get_builder().get_logger().log("files", format("Writing %s", fn));
+       package.get_builder().get_logger().log("files", "Writing %s", fn);
        IO::BufferedFile out(fn.str(), IO::M_WRITE);
        DataFile::Writer writer(out);
 
index e9b0bc8dca7d9c67a7e10d251120de4ac9e593b9..6429d4fe287504948480bd2e740f02c392a46c36 100644 (file)
@@ -47,7 +47,7 @@ void CSourceFile::find_dependencies()
        {
                IO::BufferedFile in(path.str());
 
-               builder.get_logger().log("files", format("Reading includes from %s", path.str()));
+               builder.get_logger().log("files", "Reading includes from %s", path.str());
 
                parse_includes(in);
                cache.set_values(this, "includes", includes);
index 055587a71bc7d290343f4674173dc625f087a3f8..01d237b93daf028fb8e2f5c7b68c3e380eddc275 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/fs/dir.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
-#include <msp/strings/format.h>
 #include <msp/strings/regex.h>
 #include "builder.h"
 #include "cache.h"
@@ -31,7 +30,7 @@ void DataTransform::find_dependencies()
                files = cache.get_values(this, "files");
        else
        {
-               builder.get_logger().log("files", format("Reading imports from %s", path.str()));
+               builder.get_logger().log("files", "Reading imports from %s", path.str());
                IO::File in(path.str());
                DataFile::Parser parser(in, path.str());
 
@@ -45,7 +44,7 @@ void DataTransform::find_dependencies()
                                if(dir_files.empty())
                                {
                                        FS::Path dir = FS::dirname(path);
-                                       builder.get_logger().log("files", format("Traversing %s", dir.str()));
+                                       builder.get_logger().log("files", "Traversing %s", dir.str());
                                        dir_files = list_files(dir);
                                }
 
index 9e7eb390220d451dabac88c0a971ba698c095e97..b8b25152e70acfce73e0c9f9e313daf8460f3979 100644 (file)
@@ -126,7 +126,7 @@ void GnuCompiler::prepare_syspath()
                        argv.push_back("--sysroot="+sysroot.str());
                argv.push_back("-");
 
-               builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+               builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
                try
                {
                        string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
@@ -145,7 +145,7 @@ void GnuCompiler::prepare_syspath()
                                else if(record_path)
                                {
                                        FS::Path path = strip(output.substr(start, newline-start));
-                                       builder.get_logger().log("tools", format("Got %s system path: %s", tag, path));
+                                       builder.get_logger().log("tools", "Got %s system path: %s", tag, path);
                                        system_path.push_back(path);
                                }
                                start = newline+1;
@@ -157,7 +157,7 @@ void GnuCompiler::prepare_syspath()
 
        if(!path_found)
        {
-               builder.get_logger().log("tools", format("No %s system path found, using defaults", tag));
+               builder.get_logger().log("tools", "No %s system path found, using defaults", tag);
                if(!sysroot.empty())
                        system_path.push_back(sysroot/"usr/include");
                else if(architecture->is_native())
@@ -175,7 +175,7 @@ void GnuCompiler::prepare_version()
        prepare_version("-dumpversion");
        if(version>=0x70000)
                prepare_version("-dumpfullversion");
-       builder.get_logger().log("tools", format("%s version is %d.%d.%d", FS::basename(executable->get_path()), version>>16, (version>>8)&0xFF, version&0xFF));
+       builder.get_logger().log("tools", "%s version is %d.%d.%d", FS::basename(executable->get_path()), version>>16, (version>>8)&0xFF, version&0xFF);
 }
 
 void GnuCompiler::prepare_version(const string &arg)
@@ -184,7 +184,7 @@ void GnuCompiler::prepare_version(const string &arg)
        argv.push_back(executable->get_path().str());
        argv.push_back(arg);
 
-       builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+       builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
        try
        {
                string version_str = strip(ExternalTask::run_and_capture_output(argv));
index 72c8b07a423a08bacc1e2238fc9354ba70a10230..56becc2c42ef0f6f9f32f30f7ba910213a077212 100644 (file)
@@ -111,7 +111,7 @@ void GnuLinker::do_prepare()
                        if(!sysroot.empty())
                                argv.push_back("--sysroot="+sysroot.str());
 
-                       builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+                       builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
                        try
                        {
                                string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
@@ -138,7 +138,7 @@ void GnuLinker::do_prepare()
                                        }
 
                                        path /= output.substr(search_dir, end-search_dir);
-                                       builder.get_logger().log("tools", format("Got %s system path: %s", tag, path));
+                                       builder.get_logger().log("tools", "Got %s system path: %s", tag, path);
                                        system_path.push_back(path);
                                        path_found = true;
 
@@ -152,7 +152,7 @@ void GnuLinker::do_prepare()
 
        if(!path_found)
        {
-               builder.get_logger().log("tools", format("No %s system path found, using defaults", tag));
+               builder.get_logger().log("tools", "No %s system path found, using defaults", tag);
                if(!sysroot.empty())
                        system_path.push_back(sysroot/"usr/lib");
                else if(architecture->is_native())
index dfb5fd4d6ced799be4a3f4aad4aaf43d60631c5e..35d45079e98e8b05dc5b44413c5cd094fdb802e1 100644 (file)
@@ -19,9 +19,19 @@ void Logger::disable_channel(const string &chan)
                enabled_channels.erase(i);
 }
 
-void Logger::log(const string &chan, const string &message) const
+bool Logger::is_channel_enabled(const string &chan) const
 {
        auto i = lower_bound(enabled_channels, chan);
-       if(i!=enabled_channels.end() && *i==chan)
-               IO::print("%s\n", message);
+       return (i!=enabled_channels.end() && *i==chan);
+}
+
+void Logger::log(const string &chan, const string &message) const
+{
+       if(is_channel_enabled(chan))
+               print(message);
+}
+
+void Logger::print(const string &message) const
+{
+       IO::print("%s\n", message);
 }
index 64c131544c4cef1995ec8c8b3786b7355f90ee36..3a10f0e89177e10c071b97cd389c79e4d46a1404 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <string>
 #include <vector>
+#include <msp/strings/format.h>
 
 class Logger
 {
@@ -12,8 +13,22 @@ private:
 public:
        void enable_channel(const std::string &);
        void disable_channel(const std::string &);
+       bool is_channel_enabled(const std::string &) const;
 
        void log(const std::string &, const std::string &) const;
+
+       template<typename... Args>
+       void log(const std::string &, const std::string &, Args &&...) const;
+
+private:
+       void print(const std::string &) const;
 };
 
+template<typename... Args>
+void Logger::log(const std::string &chan, const std::string &fmt, Args &&... args) const
+{
+       if(is_channel_enabled(chan))
+               print(Msp::format(fmt, std::forward<Args>(args)...));
+}
+
 #endif
index 9d3f1da92ee8f47fc2b854c0c6d66da80f7a9eaf..d6ed9e4babdcc91133335a4051accc6b7008eda3 100644 (file)
@@ -1,6 +1,5 @@
 #include <msp/core/algorithm.h>
 #include <msp/fs/dir.h>
-#include <msp/strings/format.h>
 #include <msp/strings/utils.h>
 #include "builder.h"
 #include "externaltask.h"
@@ -35,15 +34,15 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch)
        argv.push_back("-property");
        argv.push_back("installationPath");
 
-       builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+       builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
 
        string output = ExternalTask::run_and_capture_output(argv, FS::Path(), true);
        FS::Path vs_path = strip(output);
 
-       builder.get_logger().log("tools", format("Visual Studio found in %s", vs_path));
+       builder.get_logger().log("tools", "Visual Studio found in %s", vs_path);
 
        FS::Path vc_aux_build_dir = vs_path/"VC"/"Auxiliary"/"Build";
-       builder.get_logger().log("files", format("Traversing %s", vc_aux_build_dir));
+       builder.get_logger().log("files", "Traversing %s", vc_aux_build_dir);
        vector<string> vc_version_files = FS::list_filtered(vc_aux_build_dir, "^Microsoft\\.VCToolsVersion\\.");
        if(vc_version_files.empty())
        {
@@ -53,12 +52,12 @@ void MicrosoftTools::find_vc_bin_dir(Builder &builder, const Architecture &arch)
 
        sort(vc_version_files);
        FS::Path vc_version_fn = vc_aux_build_dir/vc_version_files.back();
-       builder.get_logger().log("files", format("Reading %s", vc_version_fn));
+       builder.get_logger().log("files", "Reading %s", vc_version_fn);
        char buffer[256];
        unsigned len = IO::File(vc_version_fn.str()).read(buffer, sizeof(buffer));
        string vc_version = strip(string(buffer, len));
 
-       builder.get_logger().log("tools", format("Detected MSVC version %s", vc_version));
+       builder.get_logger().log("tools", "Detected MSVC version %s", vc_version);
 
        const Architecture &native_arch = builder.get_native_arch();
        string host = (native_arch.get_bits()==64 ? "Hostx64" : "Hostx86");
@@ -74,7 +73,7 @@ void MicrosoftTools::find_windows_sdk_dir(Builder &builder)
        if(win_sdk_dir.empty())
                win_sdk_dir = get_program_files_x86_dir()/"Windows Kits"/"10";
 
-       builder.get_logger().log("files", format("Traversing %s", win_sdk_dir/"include"));
+       builder.get_logger().log("files", "Traversing %s", win_sdk_dir/"include");
        vector<string> sdk_versions = FS::list_filtered(win_sdk_dir/"include", "^10\\.");
        if(sdk_versions.empty())
        {
@@ -85,5 +84,5 @@ void MicrosoftTools::find_windows_sdk_dir(Builder &builder)
        sort(sdk_versions);
        win_sdk_version = sdk_versions.back();
 
-       builder.get_logger().log("tools", format("Windows SDK version %s found in %s", win_sdk_version, win_sdk_dir));
+       builder.get_logger().log("tools", "Windows SDK version %s found in %s", win_sdk_version, win_sdk_dir);
 }
index c4066273b6905e2e8754973b1cb73a10f6b57b43..dbbc64d41895baea735e41d2e7f8f5c19ec8dd59 100644 (file)
@@ -87,7 +87,7 @@ void MsvcCompiler::do_prepare()
        for(const FS::Path &p: system_path)
        {
                append(path, ";", p.str());
-               builder.get_logger().log("tools", format("Got %s system path: %s", tag, p));
+               builder.get_logger().log("tools", "Got %s system path: %s", tag, p);
        }
 
        setenv("INCLUDE", path);
index f6d514ba8bbd99a664f7fdb4f8ca753805288e96..78cf0b25b0d9fd5b395528c641111d877a7bb8df 100644 (file)
@@ -1,6 +1,5 @@
 #include <msp/core/environ.h>
 #include <msp/fs/utils.h>
-#include <msp/strings/format.h>
 #include <msp/strings/utils.h>
 #include "builder.h"
 #include "component.h"
@@ -79,7 +78,7 @@ void MsvcLinker::do_prepare()
        for(const FS::Path &p: system_path)
        {
                append(path, ";", p.str());
-               builder.get_logger().log("tools", format("Got %s system path: %s", tag, p));
+               builder.get_logger().log("tools", "Got %s system path: %s", tag, p);
        }
 
        setenv("LIB", path);
index af672d9710fd175db235bf9be11d2ba730ef20b8..31b24613b6f4c468957208ae412c68fa9775d656 100644 (file)
@@ -4,7 +4,6 @@
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/io/print.h>
-#include <msp/strings/format.h>
 #include <msp/strings/utils.h>
 #include <msp/time/timedelta.h>
 #include <msp/time/utils.h>
@@ -162,7 +161,7 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what)
                argv.push_back("--variable="+what);
        argv.push_back(pkg);
 
-       builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
+       builder.get_logger().log("auxcommands", "Running %s", join(argv.begin(), argv.end()));
 
        return ExternalTask::run_and_capture_output(argv);
 #else
@@ -174,7 +173,7 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what)
 
 FS::Path PackageManager::get_package_location(const string &name)
 {
-       builder.get_logger().log("packagemgr", format("Looking for source package %s", name));
+       builder.get_logger().log("packagemgr", "Looking for source package %s", name);
 
        try
        {
@@ -190,7 +189,7 @@ FS::Path PackageManager::get_package_location(const string &name)
        {
                for(const FS::Path &p: pkg_path)
                {
-                       builder.get_logger().log("files", format("Traversing %s", p));
+                       builder.get_logger().log("files", "Traversing %s", p);
                        unsigned count = 0;
                        for(const string &f: list_files(p))
                        {
@@ -202,10 +201,10 @@ FS::Path PackageManager::get_package_location(const string &name)
                                }
                        }
 
-                       builder.get_logger().log("packagemgr", format("%d source packages found in %s", count, p));
+                       builder.get_logger().log("packagemgr", "%d source packages found in %s", count, p);
                }
 
-               builder.get_logger().log("packagemgr", format("%d source packages found", pkg_dirs.size()));
+               builder.get_logger().log("packagemgr", "%d source packages found", pkg_dirs.size());
        }
 
        bool msp = !name.compare(0, 3, "msp");
@@ -225,20 +224,20 @@ FS::Path PackageManager::get_package_location(const string &name)
 
 FS::Path PackageManager::get_binary_package_file(const string &name)
 {
-       builder.get_logger().log("packagemgr", format("Looking for binary package %s", name));
+       builder.get_logger().log("packagemgr", "Looking for binary package %s", name);
 
        if(binpkg_files.empty())
        {
                for(const FS::Path &p: binpkg_path)
                {
-                       builder.get_logger().log("files", format("Traversing %s", p));
+                       builder.get_logger().log("files", "Traversing %s", p);
                        vector<string> files = list_filtered(p, "\\.bpk$");
                        for(const string &f: files)
                                binpkg_files.push_back(p/f);
-                       builder.get_logger().log("packagemgr", format("%d binary packages found in %s", files.size(), p));
+                       builder.get_logger().log("packagemgr", "%d binary packages found in %s", files.size(), p);
                }
 
-               builder.get_logger().log("packagemgr", format("%d binary packages found", binpkg_files.size()));
+               builder.get_logger().log("packagemgr", "%d binary packages found", binpkg_files.size());
        }
 
        auto i = find_if(binpkg_files, [&name](const FS::Path &p){ return FS::basepart(FS::basename(p))==name; });
index d21bda8f255da200ed9660df546fd235224f1498..055abb56982203e6645873d10b428dae8e3e488f 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/core/algorithm.h>
 #include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
-#include <msp/strings/format.h>
 #include "builder.h"
 #include "filetarget.h"
 #include "sourcepackage.h"
@@ -110,7 +109,7 @@ void Target::mark_rebuild(const string &reason)
        state = REBUILD;
        rebuild_reason = reason;
 
-       builder.get_logger().log("rebuild", format("Rebuilding %s: %s", name, reason));
+       builder.get_logger().log("rebuild", "Rebuilding %s: %s", name, reason);
 
        signal_bubble_rebuild.emit();
 }
@@ -121,7 +120,7 @@ void Target::prepare()
                return;
        if(state==PREPARING)
        {
-               builder.get_logger().log("problems", format("Dependency cycle detected at %s", name));
+               builder.get_logger().log("problems", "Dependency cycle detected at %s", name);
                problems.push_back("Dependency cycle detected");
                state = BROKEN;
                return;
index 54138215e5f0ca25d368fb32bc801592f3413c2d..da7054abf3fdb5959b880e5772e55cde08863d2b 100644 (file)
@@ -62,7 +62,7 @@ void Tool::prepare()
                executable = builder.get_vfs().find_binary(command);
                if(!executable)
                {
-                       builder.get_logger().log("problems", format("Can't find executable %s for %s", command, tag));
+                       builder.get_logger().log("problems", "Can't find executable %s for %s", command, tag);
                        problems.push_back(format("Can't find executable %s", command));
                }
        }
index 2fecdf0fc50c9427fd1d06c194b597b7b41ff864..d3bc708faf99cbf25944d764f7054d40c643be00 100644 (file)
@@ -32,7 +32,7 @@ void VirtualFileSystem::register_path(const FS::Path &path, FileTarget *t)
 {
        targets.insert({ path, t });
        nonexistent.erase(path);
-       builder.get_logger().log("vfs", format("Path %s registered to %s", path, t->get_name()));
+       builder.get_logger().log("vfs", "Path %s registered to %s", path, t->get_name());
 }
 
 FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const SearchPath &path, bool use_syspath)
@@ -56,16 +56,16 @@ FileTarget *VirtualFileSystem::find_header(const string &name, Tool *tool, const
                FS::Path filename = p/name;
                if(FileTarget *tgt = get_target(filename))
                {
-                       builder.get_logger().log("vfs", format("Header %s found in %s as existing %s", name, p.str(), tgt->get_type()));
+                       builder.get_logger().log("vfs", "Header %s found in %s as existing %s", name, p.str(), tgt->get_type());
                        return tgt;
                }
                else if(file_exists(filename))
                {
-                       builder.get_logger().log("vfs", format("Header %s found in %s", name, p.str()));
+                       builder.get_logger().log("vfs", "Header %s found in %s", name, p.str());
                        return dynamic_cast<FileTarget *>(tool->create_source(filename));
                }
 
-               builder.get_logger().log("vfs", format("Header %s not found in %s", name, p.str()));
+               builder.get_logger().log("vfs", "Header %s not found in %s", name, p.str());
        }
 
        return 0;
@@ -105,12 +105,12 @@ FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath
                        FS::Path filename = p / *j;
                        if(FileTarget *tgt = get_target(filename))
                        {
-                               builder.get_logger().log("vfs", format("Library %s (%s) found in %s as existing %s", lib, *j, p.str(), tgt->get_type()));
+                               builder.get_logger().log("vfs", "Library %s (%s) found in %s as existing %s", lib, *j, p.str(), tgt->get_type());
                                return tgt;
                        }
                        else if(file_exists(filename))
                        {
-                               builder.get_logger().log("vfs", format("Library %s (%s) found in %s", lib, *j, p.str()));
+                               builder.get_logger().log("vfs", "Library %s (%s) found in %s", lib, *j, p.str());
                                if(cur_names==&shared_names)
                                {
                                        if(use_import_lib)
@@ -133,7 +133,7 @@ FileTarget *VirtualFileSystem::find_library(const string &lib, const SearchPath
                        }
                }
 
-               builder.get_logger().log("vfs", format("Library %s not found in %s", lib, p.str()));
+               builder.get_logger().log("vfs", "Library %s not found in %s", lib, p.str());
        }
 
        return 0;
@@ -168,16 +168,16 @@ FileTarget *VirtualFileSystem::find_binary(const string &name)
                FS::Path filename = p/name;
                if(FileTarget *tgt = get_target(filename))
                {
-                       builder.get_logger().log("vfs", format("Binary %s found in %s as existing %s", name, p, tgt->get_type()));
+                       builder.get_logger().log("vfs", "Binary %s found in %s as existing %s", name, p, tgt->get_type());
                        return tgt;
                }
                else if(file_exists(filename))
                {
-                       builder.get_logger().log("vfs", format("Binary %s found in %s", name, p));
+                       builder.get_logger().log("vfs", "Binary %s found in %s", name, p);
                        return new Executable(builder, filename);
                }
 
-               builder.get_logger().log("vfs", format("Binary %s not found in %s", name, p));
+               builder.get_logger().log("vfs", "Binary %s not found in %s", name, p);
        }
 
        return 0;