X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbuilder.cpp;h=e8f8927d580ea0e2739aadf1bd32b055f420e1a5;hb=4facd021514ab372c23b1b132d6b4b62baa4efbf;hp=9dfa2e693fdeb8ff27afcb0cd7383f381b3da1ec;hpb=b5ccba555f4985233532041c34e28d71dd58933f;p=builder.git diff --git a/source/builder.cpp b/source/builder.cpp index 9dfa2e6..e8f8927 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -17,14 +17,14 @@ #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 "pkgconfig.h" +#include "pkgconfigfile.h" #include "pkgconfiggenerator.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -125,14 +125,6 @@ Builder::Builder(int argc, char **argv): cwd = FS::getcwd(); - toolchain.add_tool(new GnuCCompiler(*this)); - toolchain.add_tool(new GnuCxxCompiler(*this)); - toolchain.add_tool(new GnuLinker(*this)); - toolchain.add_tool(new GnuArchiver(*this)); - toolchain.add_tool(new Copy(*this)); - toolchain.add_tool(new Tar(*this)); - toolchain.add_tool(new PkgConfigGenerator(*this)); - load_build_file((FS::get_sys_data_dir(argv[0], "builder")/"builderrc").str()); load_build_file((FS::get_user_data_dir("builder")/"rc").str()); @@ -151,6 +143,14 @@ Builder::Builder(int argc, char **argv): } } + toolchain.add_tool(new GnuCCompiler(*this)); + toolchain.add_tool(new GnuCxxCompiler(*this)); + toolchain.add_tool(new GnuLinker(*this)); + toolchain.add_tool(new GnuArchiver(*this)); + toolchain.add_tool(new Copy(*this)); + toolchain.add_tool(new Tar(*this)); + toolchain.add_tool(new PkgConfigGenerator(*this)); + if(prfx.empty()) { if(current_arch->is_native()) @@ -305,7 +305,7 @@ int Builder::main() string Builder::run_pkgconfig(const string &pkg, const string &what) { - list argv; + ExternalTask::Arguments 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); + 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) @@ -504,8 +509,8 @@ int Builder::create_targets() if(spkg->get_install_flags()&(SourcePackage::LIB|SourcePackage::INCLUDE)) { - PkgConfig *pc = new PkgConfig(*this, *spkg); - install->add_depend(new InstalledFile(*this, *spkg, *pc)); + PkgConfigFile *pc = new PkgConfigFile(*this, *spkg); + install->add_depend(toolchain.get_tool("CP").create_target(*pc)); } } @@ -585,8 +590,18 @@ int Builder::do_build() Task *task = tgt->build(); if(task) { - task->start(); - tasks.push_back(task); + if(verbose>=2) + IO::print("%s\n", task->get_command()); + if(dry_run) + { + task->signal_finished.emit(true); + delete task; + } + else + { + task->start(); + tasks.push_back(task); + } } if(show_progress)