]> git.tdb.fi Git - builder.git/blobdiff - source/packagemanager.cpp
Basic support for running builder on Windows
[builder.git] / source / packagemanager.cpp
index f840ea22d4edb929624097f3c47fad0a896bf1ae..2ee3c30de63f67bca4f649d27326d9b97e05d4f1 100644 (file)
@@ -5,7 +5,7 @@
 #include <msp/io/print.h>
 #include <msp/strings/format.h>
 #include <msp/strings/utils.h>
-#include <msp/time/units.h>
+#include <msp/time/timedelta.h>
 #include <msp/time/utils.h>
 #include "binarypackage.h"
 #include "builder.h"
@@ -109,14 +109,15 @@ Package *PackageManager::find_package(const string &name)
        {
                // Package source not found - create a binary package
                string flags_str = run_pkgconfig(name, "flags");
-               vector<string> flags = split(flags_str);
-               Package *pkg = BinaryPackage::from_flags(builder, name, flags);
+               BinaryPackage::Flags flags = split(flags_str);
+               flags_str = run_pkgconfig(name, "staticflags");
+               BinaryPackage::Flags static_flags = split(flags_str);
+               Package *pkg = BinaryPackage::from_flags(builder, name, flags, static_flags);
                packages.insert(PackageMap::value_type(name, pkg));
                return pkg;
        }
        catch(...)
        {
-               builder.problem(name, "not found");
                not_found.insert(name);
                return 0;
        }
@@ -124,6 +125,7 @@ Package *PackageManager::find_package(const string &name)
 
 string PackageManager::run_pkgconfig(const string &pkg, const string &what)
 {
+#ifndef _WIN32
        if(!env_set)
        {
                const FS::Path &prefix = builder.get_prefix();
@@ -151,10 +153,12 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what)
        argv.push_back("pkg-config");
        if(what=="cflags" || what=="libs")
                argv.push_back("--"+what);
-       else if(what=="flags")
+       else if(what=="flags" || what=="staticflags")
        {
                argv.push_back("--cflags");
                argv.push_back("--libs");
+               if(what=="staticflags")
+                       argv.push_back("--static");
        }
        else
                argv.push_back("--variable="+what);
@@ -163,6 +167,11 @@ string PackageManager::run_pkgconfig(const string &pkg, const string &what)
        builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end())));
 
        return ExternalTask::run_and_capture_output(argv);
+#else
+       (void)pkg;
+       (void)what;
+       return string();
+#endif
 }
 
 FS::Path PackageManager::get_package_location(const string &name)
@@ -244,3 +253,9 @@ FS::Path PackageManager::get_binary_package_file(const string &name)
 
        return FS::Path();
 }
+
+void PackageManager::save_all_caches() const
+{
+       for(PackageMap::const_iterator i=packages.begin(); i!=packages.end(); ++i)
+               i->second->save_caches();
+}