From 2ea79c8f3ca8c12907a6c121ec564f5a4d643f52 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 30 May 2012 19:29:33 +0000 Subject: [PATCH] Use ExternalTask rather than run_command for running pkg-config --- source/builder.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/source/builder.cpp b/source/builder.cpp index b3e0968..ed749f8 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -17,12 +17,12 @@ #include "binarypackage.h" #include "builder.h" #include "copy.h" +#include "externaltask.h" #include "gnuarchiver.h" #include "gnuccompiler.h" #include "gnucxxcompiler.h" #include "gnulinker.h" #include "installedfile.h" -#include "misc.h" #include "package.h" #include "pkgconfigfile.h" #include "pkgconfiggenerator.h" @@ -305,7 +305,7 @@ int Builder::main() string Builder::run_pkgconfig(const string &pkg, const string &what) { - list argv; + vector argv; argv.push_back("pkg-config"); if(what=="cflags" || what=="libs") argv.push_back("--"+what); @@ -321,12 +321,17 @@ string Builder::run_pkgconfig(const string &pkg, const string &what) if(verbose>=4) IO::print("Running %s\n", join(argv.begin(), argv.end())); - int status; - string res = run_command(argv, &status); - if(status) + ExternalTask task(argv, FS::Path()); + task.set_stdout(ExternalTask::CAPTURE); + task.set_stderr(ExternalTask::IGNORE); + task.start(); + Task::Status status; + while((status=task.check())==Task::RUNNING) + Time::sleep(10*Time::msec); + if(status==Task::ERROR) throw runtime_error(format("pkg-config for package %s failed", pkg)); - return res; + return task.get_output(); } Package *Builder::get_package(const string &name) -- 2.43.0