From: Mikko Rasa Date: Sun, 15 Jul 2012 21:09:37 +0000 (+0300) Subject: Make tempdir a global option X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=398983749391592988daca0c9b62b3d38f86e4e6;p=builder.git Make tempdir a global option --- diff --git a/source/builder.cpp b/source/builder.cpp index c0574e9..03429cf 100644 --- a/source/builder.cpp +++ b/source/builder.cpp @@ -50,7 +50,8 @@ Builder::Builder(int argc, char **argv): conf_all(false), conf_only(false), build_all(false), - create_makefile(false) + create_makefile(false), + tempdir("temp") { string analyze_mode; string work_dir; @@ -58,6 +59,7 @@ Builder::Builder(int argc, char **argv): unsigned max_depth = 5; StringList cmdline_warn; string prfx; + string temp_str; string arch; bool no_externals = false; unsigned verbose = 1; @@ -88,6 +90,7 @@ Builder::Builder(int argc, char **argv): getopt.add_option( "full-paths", full_paths, GetOpt::NO_ARG).set_help("Output full paths in analysis."); getopt.add_option( "max-depth", max_depth, GetOpt::REQUIRED_ARG).set_help("Maximum depth to show in analysis.", "NUM"); getopt.add_option( "prefix", prfx, GetOpt::REQUIRED_ARG).set_help("Directory to install things to.", "DIR"); + getopt.add_option( "tempdir", temp_str, GetOpt::REQUIRED_ARG).set_help("Store temporary files in DIR.", "DIR"); getopt.add_option( "warnings", cmdline_warn, GetOpt::REQUIRED_ARG).set_help("Compiler warnings to use.", "LIST"); usagemsg = getopt.generate_usage(argv[0])+" [ ...]"; helpmsg = getopt.generate_help(); @@ -187,6 +190,9 @@ Builder::Builder(int argc, char **argv): else prefix = FS::getcwd()/prfx; + if(!temp_str.empty()) + tempdir = temp_str; + if(!build_type_name.empty()) { BuildTypeMap::iterator i = build_types.find(build_type_name); @@ -276,6 +282,10 @@ int Builder::main() 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", prefix)); + if(tempdir.is_absolute()) + logger.log("environment", format("Temporary directory is %s", tempdir)); + else + logger.log("environment", format("Using per-package temporary directory %s", tempdir)); if(build_type) logger.log("environment", format("Build type is %s", build_type->get_name())); diff --git a/source/builder.h b/source/builder.h index cd6bf16..cdf615d 100644 --- a/source/builder.h +++ b/source/builder.h @@ -84,6 +84,7 @@ private: bool build_all; bool create_makefile; Msp::FS::Path prefix; + Msp::FS::Path tempdir; StringList warnings; static std::string usagemsg; @@ -108,6 +109,7 @@ public: const Architecture &get_current_arch() const { return *current_arch; } const Architecture &get_native_arch() const { return native_arch; } const Msp::FS::Path &get_prefix() const { return prefix; } + const Msp::FS::Path &get_temp_directory() const { return tempdir; } const StringList &get_warnings() const { return warnings; } const Toolchain &get_toolchain() const { return toolchain; } diff --git a/source/sourcepackage.cpp b/source/sourcepackage.cpp index 85f64a6..029d524 100644 --- a/source/sourcepackage.cpp +++ b/source/sourcepackage.cpp @@ -43,7 +43,12 @@ FS::Path SourcePackage::get_temp_dir() const subdir += '.'; subdir += build_type->get_name(); } - return source/config.get_option("tempdir").value/subdir; + + const FS::Path &temp = builder.get_temp_directory(); + if(temp.is_absolute()) + return temp/name/subdir; + else + return source/temp/subdir; } FS::Path SourcePackage::get_out_dir() const @@ -135,8 +140,6 @@ void SourcePackage::do_configure(const StringMap &opts, unsigned flag) void SourcePackage::init_config() { - config.add_option("tempdir", "temp", "Directory for storing temporary files"); - for(FeatureList::iterator i=features.begin(); i!=features.end(); ++i) config.add_option("with_"+i->name, i->def_value, i->descr);